Skip to content

Instantly share code, notes, and snippets.

@jimblandy
Created February 12, 2018 21:34
Show Gist options
  • Save jimblandy/42e190cc3cd51d28f26d33ae67978d52 to your computer and use it in GitHub Desktop.
Save jimblandy/42e190cc3cd51d28f26d33ae67978d52 to your computer and use it in GitHub Desktop.
Remove `wasm` member from `JSFunction`
diff --git a/js/src/jsfun.h b/js/src/jsfun.h
--- a/js/src/jsfun.h
+++ b/js/src/jsfun.h
@@ -123,31 +123,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** jitEntry_;
} 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());
@@ -608,57 +605,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.jitEntry_ = 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.jitEntry_);
+ u.native.extra.jitEntry_ = entry;
}
void** wasmJitEntry() const {
MOZ_ASSERT(isNativeWithJitEntry());
- MOZ_ASSERT(u.wasm.jitEntry_);
- return u.wasm.jitEntry_;
+ MOZ_ASSERT(u.native.extra.jitEntry_);
+ return u.native.extra.jitEntry_;
}
// 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.jitEntry_),
+ "scripted.s.script_ must be at the same offset as native.extra.jitEntry_");
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() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment