Bug 1437733: Merge JSFunction::u::wasm with other members. r=bbouvier
authorJim Blandy <jimb@mozilla.com>
Mon, 12 Feb 2018 17:55:22 -0800
changeset 462582 de8d3617e884b75b023ebb2591a141cd11eb5a2d
parent 462581 497aead7d738c85926e1edf6259dde2eef6d368b
child 462583 ef4436b9240e81a770738eb34aa0f4ebc8b43002
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1437733
milestone60.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 1437733: Merge JSFunction::u::wasm with other members. r=bbouvier In JSFunction, u.wasm.native_ member must have the same type and offset as u.native.func_. This is better accomplished by simply using func_ for both. Further, u.wasm.jitEntry_ must alias u.native.extra.asmJSFuncIndex_. This is better accomplished simply by making them both members of the same union. This leaves u.wasm empty, so it can be deleted. Two static assertions about member offsets can be removed. MozReview-Commit-ID: 8ukNaFysWvD
js/src/vm/JSFunction.h
--- a/js/src/vm/JSFunction.h
+++ b/js/src/vm/JSFunction.h
@@ -124,31 +124,28 @@ class JSFunction : public js::NativeObje
             friend class JSFunction;
             js::Native func_;          /* native method pointer or null */
             union {
                 // Information about this function to be used by the JIT, only
                 // used if isBuiltinNative(); use the accessor!
                 const JSJitInfo* jitInfo_;
                 // asm.js function index, only used if isAsmJSNative().
                 size_t asmJSFuncIndex_;
+                // for wasm, a pointer to a fast jit->wasm table entry.
+                void** wasmJitEntry_;
             } extra;
         } native;
         struct {
             JSObject* env_;            /* environment for new activations */
             union {
                 JSScript* script_;     /* interpreted bytecode descriptor or
                                           null; use the accessor! */
                 js::LazyScript* lazy_; /* lazily compiled script, or nullptr */
             } s;
         } scripted;
-        class {
-            friend class JSFunction;
-            js::Native native_; // The native for interpreter wasm calls.
-            void** jitEntry_;   // A pointer to a fast jit->wasm table entry.
-        } wasm;
     } u;
     js::GCPtrAtom atom_; /* name for diagnostics and decompiling */
 
   public:
     /* Call objects must be created for each invocation of this function. */
     bool needsCallObject() const {
         MOZ_ASSERT(!isInterpretedLazy());
 
@@ -196,17 +193,17 @@ class JSFunction : public js::NativeObje
 
     bool isConstructor()            const { return flags() & CONSTRUCTOR; }
 
     /* Possible attributes of a native function: */
     bool isAsmJSNative()            const { return kind() == AsmJS; }
     bool isWasmOptimized()          const { return (flags() & WASM_OPTIMIZED); }
     bool isBuiltinNative()          const { return isNativeWithCppEntry() && !isAsmJSNative(); }
 
-    // May be called from the JIT with the jitEntry_ field.
+    // May be called from the JIT with the wasmJitEntry_ field.
     bool isNativeWithJitEntry()     const { return isNative() && isWasmOptimized(); }
     // Must be called from the JIT with the native_ field.
     bool isNativeWithCppEntry()     const { return isNative() && !isWasmOptimized(); }
 
     /* Possible attributes of an interpreted function: */
     bool isBoundFunction()          const { return flags() & BOUND_FUN; }
     bool hasCompileTimeName()       const { return flags() & HAS_COMPILE_TIME_NAME; }
     bool hasGuessedAtom()           const {
@@ -609,57 +606,53 @@ class JSFunction : public js::NativeObje
         MOZ_ASSERT(isBuiltinNative());
         u.native.extra.jitInfo_ = data;
     }
 
     // Wasm natives are optimized and have a jit entry.
     void initWasmNative(js::Native native) {
         MOZ_ASSERT(isNativeWithJitEntry());
         MOZ_ASSERT(native);
-        u.wasm.native_ = native;
-        u.wasm.jitEntry_ = nullptr;
+        u.native.func_ = native;
+        u.native.extra.wasmJitEntry_ = nullptr;
     }
     void setWasmJitEntry(void** entry) {
         MOZ_ASSERT(isNativeWithJitEntry());
         MOZ_ASSERT(entry);
-        MOZ_ASSERT(!u.wasm.jitEntry_);
-        u.wasm.jitEntry_ = entry;
+        MOZ_ASSERT(!u.native.extra.wasmJitEntry_);
+        u.native.extra.wasmJitEntry_ = entry;
     }
     void** wasmJitEntry() const {
         MOZ_ASSERT(isNativeWithJitEntry());
-        MOZ_ASSERT(u.wasm.jitEntry_);
-        return u.wasm.jitEntry_;
+        MOZ_ASSERT(u.native.extra.wasmJitEntry_);
+        return u.native.extra.wasmJitEntry_;
     }
 
     // AsmJS functions store the func index in the jitinfo slot, since these
     // don't have a jit info associated.
     void setAsmJSIndex(uint32_t funcIndex) {
         MOZ_ASSERT(isAsmJSNative());
         MOZ_ASSERT(!isWasmOptimized());
         MOZ_ASSERT(!u.native.extra.asmJSFuncIndex_);
-        static_assert(offsetof(U, native.extra.asmJSFuncIndex_) == offsetof(U, wasm.jitEntry_),
-                      "asm.js func index and wasm jit entry pointer must be at the same location");
         u.native.extra.asmJSFuncIndex_ = funcIndex;
     }
     uint32_t asmJSFuncIndex() const {
         MOZ_ASSERT(isAsmJSNative());
         MOZ_ASSERT(!isWasmOptimized());
         return u.native.extra.asmJSFuncIndex_;
     }
 
     bool isDerivedClassConstructor();
 
     static unsigned offsetOfNative() {
-        static_assert(offsetof(U, native.func_) == offsetof(U, wasm.native_),
-                      "native.func_ must be at the same offset as wasm.native_");
         return offsetof(JSFunction, u.native.func_);
     }
     static unsigned offsetOfScript() {
-        static_assert(offsetof(U, scripted.s.script_) == offsetof(U, wasm.jitEntry_),
-                      "scripted.s.script_ must be at the same offset as wasm.jitEntry_");
+        static_assert(offsetof(U, scripted.s.script_) == offsetof(U, native.extra.wasmJitEntry_),
+                      "scripted.s.script_ must be at the same offset as native.extra.wasmJitEntry_");
         return offsetof(JSFunction, u.scripted.s.script_);
     }
     static unsigned offsetOfNativeOrEnv() {
         static_assert(offsetof(U, native.func_) == offsetof(U, scripted.env_),
                       "U.native.func_ must be at the same offset as U.scripted.env_");
         return offsetOfNative();
     }
     static unsigned offsetOfScriptOrLazyScript() {