BytecodeDumper should print all switch labels
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 20:58:24 +0000 (20:58 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 20:58:24 +0000 (20:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190596

Reviewed by Saam Barati.

Right now the bytecode dumper only prints the default target not any of the
non-default targets.

* bytecode/BytecodeDumper.cpp:
(JSC::BytecodeDumper<Block>::dumpBytecode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237141 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/BytecodeDumper.cpp

index d0e31a4..6c64364 100644 (file)
@@ -1,3 +1,16 @@
+2018-10-15  Keith Miller  <keith_miller@apple.com>
+
+        BytecodeDumper should print all switch labels
+        https://bugs.webkit.org/show_bug.cgi?id=190596
+
+        Reviewed by Saam Barati.
+
+        Right now the bytecode dumper only prints the default target not any of the
+        non-default targets.
+
+        * bytecode/BytecodeDumper.cpp:
+        (JSC::BytecodeDumper<Block>::dumpBytecode):
+
 2018-10-15  Saam barati  <sbarati@apple.com>
 
         Emit fjcvtzs on ARM64E on Darwin
index 70bf712..5d7c0ad 100644 (file)
@@ -1359,7 +1359,11 @@ void BytecodeDumper<Block>::dumpBytecode(PrintStream& out, const typename Block:
         int defaultTarget = (++it)->u.operand;
         int scrutineeRegister = (++it)->u.operand;
         printLocationAndOp(out, location, it, "switch_imm");
-        out.printf("%d, %d(->%d), %s", tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).data());
+        out.printf("%d, default:%d(->%d)", tableIndex, defaultTarget, location + defaultTarget);
+        const auto& table = block()->switchJumpTable(tableIndex);
+        for (unsigned i = 0; i < table.branchOffsets.size(); ++i)
+            out.printf(", %d:%d(->%d)", i, table.branchOffsets[i], location + table.branchOffsets[i]);
+        out.print(", ", registerName(scrutineeRegister).data());
         break;
     }
     case op_switch_char: {
@@ -1367,7 +1371,11 @@ void BytecodeDumper<Block>::dumpBytecode(PrintStream& out, const typename Block:
         int defaultTarget = (++it)->u.operand;
         int scrutineeRegister = (++it)->u.operand;
         printLocationAndOp(out, location, it, "switch_char");
-        out.printf("%d, %d(->%d), %s", tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).data());
+        out.printf("%d, default:%d(->%d)", tableIndex, defaultTarget, location + defaultTarget);
+        const auto& table = block()->switchJumpTable(tableIndex);
+        for (unsigned i = 0; i < table.branchOffsets.size(); ++i)
+            out.printf(", %c:%d(->%d)", i, table.branchOffsets[i], location + table.branchOffsets[i]);
+        out.print(", ", registerName(scrutineeRegister).data());
         break;
     }
     case op_switch_string: {
@@ -1375,7 +1383,13 @@ void BytecodeDumper<Block>::dumpBytecode(PrintStream& out, const typename Block:
         int defaultTarget = (++it)->u.operand;
         int scrutineeRegister = (++it)->u.operand;
         printLocationAndOp(out, location, it, "switch_string");
-        out.printf("%d, %d(->%d), %s", tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).data());
+        out.printf("%d, default:%d(->%d)", tableIndex, defaultTarget, location + defaultTarget);
+        const auto& table = block()->stringSwitchJumpTable(tableIndex);
+        for (const auto& offset : table.offsetTable) {
+            out.print(", ", Identifier::fromUid(vm(), static_cast<UniquedStringImpl*>(offset.key.get())));
+            out.printf(":%d(%d)", offset.value.branchOffset, location + offset.value.branchOffset);
+        }
+        out.print(", ", registerName(scrutineeRegister).data());
         break;
     }
     case op_new_func: {