Bug 910782 - SpiderMonkey: Use absolute addresses instead of offsets for the interpreter's jump table. r=luke
authorDan Gohman <sunfish@google.com>
Mon, 28 Oct 2013 10:32:50 -0700
changeset 152537 9540960e67a20ad925c5d8c11d66ec6abb426dcf
parent 152536 9a5e4274378185984fb5c6299684eb695a1fc2e1
child 152538 dd6f10de22b12b09d34d549d330dd93e6e9c8a2b
push id25551
push userphilringnalda@gmail.com
push dateMon, 28 Oct 2013 23:57:55 +0000
treeherdermozilla-central@518f5bff0ae4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs910782
milestone27.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 910782 - SpiderMonkey: Use absolute addresses instead of offsets for the interpreter's jump table. r=luke
js/src/vm/Interpreter.cpp
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -1202,30 +1202,28 @@ Interpret(JSContext *cx, RunState &state
  */
 #if (__GNUC__ >= 3 ||                                                         \
      (__IBMC__ >= 700 && defined __IBM_COMPUTED_GOTO) ||                      \
      __SUNPRO_C >= 0x570)
 // Non-standard but faster indirect-goto-based dispatch.
 # define INTERPRETER_LOOP()
 # define CASE(OP)                 label_##OP:
 # define DEFAULT()                label_default:
-# define DISPATCH_TO(OP)          goto *(LABEL(JSOP_NOP) + offsets[(OP)])
-
-# define LABEL(X)                 ((const char *)&&label_##X)
-# define LABEL_OFFSET(X)          (int32_t((X) - LABEL(JSOP_NOP)))
-
-    // We use offsets instead of absolute addresses to avoid PIC load-time
-    // relocations. See the remark about shared libraries here for more info:
-    // http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
-    static const int32_t offsets[EnableInterruptsPseudoOpcode + 1] = {
-# define OPDEF(op,v,n,t,l,u,d,f)  LABEL_OFFSET(LABEL(op)),
+# define DISPATCH_TO(OP)          goto *addresses[(OP)]
+
+# define LABEL(X)                 (&&label_##X)
+
+    // Use addresses instead of offsets to optimize for runtime speed over
+    // load-time relocation overhead.
+    static const void *const addresses[EnableInterruptsPseudoOpcode + 1] = {
+# define OPDEF(op,v,n,t,l,u,d,f)  LABEL(op),
 # define OPPAD(v)                                                             \
-    LABEL_OFFSET((v) == EnableInterruptsPseudoOpcode ?                        \
-                 LABEL(EnableInterruptsPseudoOpcode) :                        \
-                 LABEL(default)),
+    ((v) == EnableInterruptsPseudoOpcode                                      \
+     ? LABEL(EnableInterruptsPseudoOpcode)                                    \
+     : LABEL(default)),
 # include "jsopcode.tbl"
 # undef OPDEF
 # undef OPPAD
     };
 #else
 // Portable switch-based dispatch.
 # define INTERPRETER_LOOP()       the_switch: switch (switchOp)
 # define CASE(OP)                 case OP: