summaryrefslogtreecommitdiffstats
path: root/js/src/jsfun.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jsfun.h')
-rw-r--r--js/src/jsfun.h51
1 files changed, 28 insertions, 23 deletions
diff --git a/js/src/jsfun.h b/js/src/jsfun.h
index 7da831aa2..234169507 100644
--- a/js/src/jsfun.h
+++ b/js/src/jsfun.h
@@ -58,8 +58,6 @@ class JSFunction : public js::NativeObject
CONSTRUCTOR = 0x0002, /* function that can be called as a constructor */
EXTENDED = 0x0004, /* structure is FunctionExtended */
BOUND_FUN = 0x0008, /* function was created with Function.prototype.bind. */
- EXPR_BODY = 0x0010, /* arrow function with expression body or
- * expression closure: function(x) x*x */
HAS_GUESSED_ATOM = 0x0020, /* function had no explicit name, but a
name was guessed for it anyway */
LAMBDA = 0x0040, /* function comes from a FunctionExpression, ArrowFunction, or
@@ -102,7 +100,7 @@ class JSFunction : public js::NativeObject
INTERPRETED_GENERATOR = INTERPRETED,
NO_XDR_FLAGS = RESOLVED_LENGTH | RESOLVED_NAME,
- STABLE_ACROSS_CLONES = CONSTRUCTOR | EXPR_BODY | HAS_GUESSED_ATOM | LAMBDA |
+ STABLE_ACROSS_CLONES = CONSTRUCTOR | HAS_GUESSED_ATOM | LAMBDA |
SELF_HOSTED | HAS_COMPILE_TIME_NAME | FUNCTION_KIND_MASK
};
@@ -187,7 +185,6 @@ class JSFunction : public js::NativeObject
bool isAsmJSNative() const { return kind() == AsmJS; }
/* Possible attributes of an interpreted function: */
- bool isExprBody() const { return flags() & EXPR_BODY; }
bool hasCompileTimeName() const { return flags() & HAS_COMPILE_TIME_NAME; }
bool hasGuessedAtom() const { return flags() & HAS_GUESSED_ATOM; }
bool isLambda() const { return flags() & LAMBDA; }
@@ -290,11 +287,6 @@ class JSFunction : public js::NativeObject
flags_ |= SELF_HOSTED;
}
- // Can be called multiple times by the parser.
- void setIsExprBody() {
- flags_ |= EXPR_BODY;
- }
-
void setArrow() {
setKind(Arrow);
}
@@ -314,7 +306,8 @@ class JSFunction : public js::NativeObject
nonLazyScript()->setAsyncKind(asyncKind);
}
- bool getUnresolvedLength(JSContext* cx, js::MutableHandleValue v);
+ static bool getUnresolvedLength(JSContext* cx, js::HandleFunction fun,
+ js::MutableHandleValue v);
JSAtom* getUnresolvedName(JSContext* cx);
@@ -419,16 +412,15 @@ class JSFunction : public js::NativeObject
//
// - For functions known to have a JSScript, nonLazyScript() will get it.
- JSScript* getOrCreateScript(JSContext* cx) {
- MOZ_ASSERT(isInterpreted());
+ static JSScript* getOrCreateScript(JSContext* cx, js::HandleFunction fun) {
+ MOZ_ASSERT(fun->isInterpreted());
MOZ_ASSERT(cx);
- if (isInterpretedLazy()) {
- JS::RootedFunction self(cx, this);
- if (!createScriptForLazilyInterpretedFunction(cx, self))
+ if (fun->isInterpretedLazy()) {
+ if (!createScriptForLazilyInterpretedFunction(cx, fun))
return nullptr;
- return self->nonLazyScript();
+ return fun->nonLazyScript();
}
- return nonLazyScript();
+ return fun->nonLazyScript();
}
JSScript* existingScriptNonDelazifying() const {
@@ -460,6 +452,19 @@ class JSFunction : public js::NativeObject
return nonLazyScript();
}
+ // If this is a scripted function, returns its canonical function (the
+ // original function allocated by the frontend). Note that lazy self-hosted
+ // builtins don't have a lazy script so in that case we also return nullptr.
+ JSFunction* maybeCanonicalFunction() const {
+ if (hasScript()) {
+ return nonLazyScript()->functionNonDelazifying();
+ }
+ if (isInterpretedLazy() && !isSelfHostedBuiltin()) {
+ return lazyScript()->functionNonDelazifying();
+ }
+ return nullptr;
+ }
+
// The state of a JSFunction whose script errored out during bytecode
// compilation. Such JSFunctions are only reachable via GC iteration and
// not from script.
@@ -473,7 +478,7 @@ class JSFunction : public js::NativeObject
return u.i.s.script_;
}
- bool getLength(JSContext* cx, uint16_t* length);
+ static bool getLength(JSContext* cx, js::HandleFunction fun, uint16_t* length);
js::LazyScript* lazyScript() const {
MOZ_ASSERT(isInterpretedLazy() && u.i.s.lazy_);
@@ -580,13 +585,17 @@ class JSFunction : public js::NativeObject
return offsetof(JSFunction, u.nativeOrScript);
}
+ static unsigned offsetOfJitInfo() {
+ return offsetof(JSFunction, u.n.jitinfo);
+ }
+
inline void trace(JSTracer* trc);
/* Bound function accessors. */
JSObject* getBoundFunctionTarget() const;
const js::Value& getBoundFunctionThis() const;
- const js::Value& getBoundFunctionArgument(JSContext* cx, unsigned which) const;
+ const js::Value& getBoundFunctionArgument(unsigned which) const;
size_t getBoundFunctionArgumentCount() const;
private:
@@ -789,10 +798,6 @@ CloneFunctionAndScript(JSContext* cx, HandleFunction fun, HandleObject parent,
gc::AllocKind kind = gc::AllocKind::FUNCTION,
HandleObject proto = nullptr);
-extern bool
-FindBody(JSContext* cx, HandleFunction fun, HandleLinearString src, size_t* bodyStart,
- size_t* bodyEnd);
-
} // namespace js
inline js::FunctionExtended*