Bug 1534840 part 0 - Clarify table case generation in CodeGenerator::visitOutOfLineSwitch. r=sstangl
authorNicolas B. Pierron <nicolas.b.pierron@nbp.name>
Tue, 16 Apr 2019 13:56:46 +0000
changeset 469669 639d0d388b96
parent 469668 00f2ad0a202a
child 469670 4f54d68ba18e
push id35879
push usernerli@mozilla.com
push dateTue, 16 Apr 2019 22:01:48 +0000
treeherdermozilla-central@12a60898fdc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs1534840
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1534840 part 0 - Clarify table case generation in CodeGenerator::visitOutOfLineSwitch. r=sstangl Differential Revision: https://phabricator.services.mozilla.com/D26520
js/src/jit/CodeGenerator.cpp
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -12062,30 +12062,31 @@ void CodeGenerator::visitOutOfLineSwitch
 
   if (tableType == SwitchTableType::OutOfLine) {
 #if defined(JS_CODEGEN_ARM)
     MOZ_CRASH("NYI: SwitchTableType::OutOfLine");
 #elif defined(JS_CODEGEN_NONE)
     MOZ_CRASH();
 #else
     masm.haltingAlign(sizeof(void*));
+    // Bind the address of the jump table and reserve the space for code
+    // pointers to jump in the newly generated code.
     masm.bind(jumpTable->start());
     masm.addCodeLabel(*jumpTable->start());
-#endif
-  }
-
-  // Add table entries if the table is inlined.
-  for (size_t i = 0, e = labels.length(); i < e; i++) {
-    jumpTable->addTableEntry(masm);
-  }
-
+    for (size_t i = 0, e = labels.length(); i < e; i++) {
+      jumpTable->addTableEntry(masm);
+    }
+#endif
+  }
+
+  // Register all reserved pointers of the jump table to target labels. The
+  // entries of the jump table need to be absolute addresses and thus must be
+  // patched after codegen is finished.
   auto& codeLabels = jumpTable->codeLabels();
   for (size_t i = 0, e = codeLabels.length(); i < e; i++) {
-    // The entries of the jump table need to be absolute addresses and thus
-    // must be patched after codegen is finished.
     auto& cl = codeLabels[i];
     cl.target()->bind(labels[i].offset());
     masm.addCodeLabel(cl);
   }
 }
 
 template void CodeGenerator::visitOutOfLineSwitch(
     OutOfLineSwitch<SwitchTableType::Inline>* jumpTable);