Bug 1588158 - Add FunctionFlags member to FunctionBox, and delegate relevant queries to it r=tcampbell

Differential Revision: https://phabricator.services.mozilla.com/D55315

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matthew Gaudet 2019-12-02 20:26:39 +00:00
Родитель ae3f8a3171
Коммит d0751bba57
3 изменённых файлов: 29 добавлений и 51 удалений

Просмотреть файл

@ -117,11 +117,8 @@ bool FunctionBox::atomsAreKept() { return cx_->zone()->hasKeptAtoms(); }
FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead, FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
uint32_t toStringStart, Directives directives, uint32_t toStringStart, Directives directives,
bool extraWarnings, GeneratorKind generatorKind, bool extraWarnings, GeneratorKind generatorKind,
FunctionAsyncKind asyncKind, bool isArrow, FunctionAsyncKind asyncKind, JSAtom* explicitName,
bool isNamedLambda, bool isGetter, bool isSetter, FunctionFlags flags)
bool isMethod, bool isInterpreted,
bool isInterpretedLazy,
FunctionFlags::FunctionKind kind, JSAtom* explicitName)
: ObjectBox(nullptr, traceListHead, TraceListNode::NodeType::Function), : ObjectBox(nullptr, traceListHead, TraceListNode::NodeType::Function),
SharedContext(cx, Kind::FunctionBox, directives, extraWarnings), SharedContext(cx, Kind::FunctionBox, directives, extraWarnings),
enclosingScope_(nullptr), enclosingScope_(nullptr),
@ -159,16 +156,9 @@ FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
isDerivedClassConstructor_(false), isDerivedClassConstructor_(false),
hasThisBinding_(false), hasThisBinding_(false),
hasInnerFunctions_(false), hasInnerFunctions_(false),
isArrow_(isArrow), nargs_(0),
isNamedLambda_(isNamedLambda),
isGetter_(isGetter),
isSetter_(isSetter),
isMethod_(isMethod),
isInterpreted_(isInterpreted),
isInterpretedLazy_(isInterpretedLazy),
kind_(kind),
explicitName_(explicitName), explicitName_(explicitName),
nargs_(0) {} flags_(flags) {}
FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead, FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
JSFunction* fun, uint32_t toStringStart, JSFunction* fun, uint32_t toStringStart,
@ -176,10 +166,7 @@ FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
GeneratorKind generatorKind, GeneratorKind generatorKind,
FunctionAsyncKind asyncKind) FunctionAsyncKind asyncKind)
: FunctionBox(cx, traceListHead, toStringStart, directives, extraWarnings, : FunctionBox(cx, traceListHead, toStringStart, directives, extraWarnings,
generatorKind, asyncKind, fun->isArrow(), generatorKind, asyncKind, fun->explicitName(), fun->flags()) {
fun->isNamedLambda(), fun->isGetter(), fun->isSetter(),
fun->isMethod(), fun->isInterpreted(),
fun->isInterpretedLazy(), fun->kind(), fun->explicitName()) {
gcThing = fun; gcThing = fun;
// Functions created at parse time may be set singleton after parsing and // Functions created at parse time may be set singleton after parsing and
// baked into JIT code, so they must be allocated tenured. They are held by // baked into JIT code, so they must be allocated tenured. They are held by
@ -193,12 +180,7 @@ FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
bool extraWarnings, GeneratorKind generatorKind, bool extraWarnings, GeneratorKind generatorKind,
FunctionAsyncKind asyncKind) FunctionAsyncKind asyncKind)
: FunctionBox(cx, traceListHead, toStringStart, directives, extraWarnings, : FunctionBox(cx, traceListHead, toStringStart, directives, extraWarnings,
generatorKind, asyncKind, data.get().flags.isArrow(), generatorKind, asyncKind, data.get().atom, data.get().flags) {
data.get().flags.isNamedLambda(data.get().atom),
data.get().flags.isGetter(), data.get().flags.isSetter(),
data.get().flags.isMethod(), data.get().flags.isInterpreted(),
data.get().flags.isInterpretedLazy(), data.get().flags.kind(),
data.get().atom) {
functionCreationData_.emplace(data); functionCreationData_.emplace(data);
} }

Просмотреть файл

@ -328,9 +328,7 @@ class FunctionBox : public ObjectBox, public SharedContext {
FunctionBox(JSContext* cx, TraceListNode* traceListHead, FunctionBox(JSContext* cx, TraceListNode* traceListHead,
uint32_t toStringStart, Directives directives, bool extraWarnings, uint32_t toStringStart, Directives directives, bool extraWarnings,
GeneratorKind generatorKind, FunctionAsyncKind asyncKind, GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
bool isArrow, bool isNamedLambda, bool isGetter, bool isSetter, JSAtom* explicitName, FunctionFlags flags);
bool isMethod, bool isInterpreted, bool isInterpretedLazy,
FunctionFlags::FunctionKind kind, JSAtom* explicitName);
void initWithEnclosingScope(Scope* enclosingScope, JSFunction* fun); void initWithEnclosingScope(Scope* enclosingScope, JSFunction* fun);
@ -426,22 +424,11 @@ class FunctionBox : public ObjectBox, public SharedContext {
// Whether this function has nested functions. // Whether this function has nested functions.
bool hasInnerFunctions_ : 1; bool hasInnerFunctions_ : 1;
// Whether this function is an arrow function
bool isArrow_ : 1;
bool isNamedLambda_ : 1;
bool isGetter_ : 1;
bool isSetter_ : 1;
bool isMethod_ : 1;
bool isInterpreted_ : 1;
bool isInterpretedLazy_ : 1;
FunctionFlags::FunctionKind kind_;
JSAtom* explicitName_;
uint16_t nargs_; uint16_t nargs_;
JSAtom* explicitName_;
FunctionFlags flags_;
mozilla::Maybe<LazyScriptCreationData> lazyScriptData_; mozilla::Maybe<LazyScriptCreationData> lazyScriptData_;
mozilla::Maybe<LazyScriptCreationData>& lazyScriptData() { mozilla::Maybe<LazyScriptCreationData>& lazyScriptData() {
@ -609,7 +596,7 @@ class FunctionBox : public ObjectBox, public SharedContext {
bool needsIteratorResult() const { return isGenerator() && !isAsync(); } bool needsIteratorResult() const { return isGenerator() && !isAsync(); }
bool needsPromiseResult() const { return isAsync() && !isGenerator(); } bool needsPromiseResult() const { return isAsync() && !isGenerator(); }
bool isArrow() const { return isArrow_; } bool isArrow() const { return flags_.isArrow(); }
bool isLambda() const { bool isLambda() const {
if (hasObject()) { if (hasObject()) {
return function()->isLambda(); return function()->isLambda();
@ -633,16 +620,18 @@ class FunctionBox : public ObjectBox, public SharedContext {
bool needsHomeObject() const { return needsHomeObject_; } bool needsHomeObject() const { return needsHomeObject_; }
bool isDerivedClassConstructor() const { return isDerivedClassConstructor_; } bool isDerivedClassConstructor() const { return isDerivedClassConstructor_; }
bool hasInnerFunctions() const { return hasInnerFunctions_; } bool hasInnerFunctions() const { return hasInnerFunctions_; }
bool isNamedLambda() const { return isNamedLambda_; } bool isNamedLambda() const { return flags_.isNamedLambda(explicitName()); }
bool isGetter() const { return isGetter_; } bool isGetter() const { return flags_.isGetter(); }
bool isSetter() const { return isSetter_; } bool isSetter() const { return flags_.isSetter(); }
bool isMethod() const { return isMethod_; } bool isMethod() const { return flags_.isMethod(); }
bool isInterpreted() const { return isInterpreted_; } bool isInterpreted() const { return flags_.isInterpreted(); }
void setIsInterpreted(bool interpreted) { isInterpreted_ = interpreted; } void setIsInterpreted(bool interpreted) {
bool isInterpretedLazy() const { return isInterpretedLazy_; } flags_.setFlags(FunctionFlags::INTERPRETED, interpreted);
}
bool isInterpretedLazy() const { return flags_.isInterpretedLazy(); }
void setIsInterpretedLazy(bool interpretedLazy) { void setIsInterpretedLazy(bool interpretedLazy) {
isInterpretedLazy_ = interpretedLazy; flags_.setFlags(FunctionFlags::INTERPRETED_LAZY, interpretedLazy);
} }
void initLazyScript(LazyScript* script) { void initLazyScript(LazyScript* script) {
@ -650,7 +639,7 @@ class FunctionBox : public ObjectBox, public SharedContext {
setIsInterpretedLazy(function()->isInterpretedLazy()); setIsInterpretedLazy(function()->isInterpretedLazy());
} }
FunctionFlags::FunctionKind kind() { return kind_; } FunctionFlags::FunctionKind kind() { return flags_.kind(); }
JSAtom* explicitName() const { return explicitName_; } JSAtom* explicitName() const { return explicitName_; }

Просмотреть файл

@ -147,6 +147,13 @@ class FunctionFlags {
bool hasFlags(uint16_t flags) const { return flags_ & flags; } bool hasFlags(uint16_t flags) const { return flags_ & flags; }
void setFlags(uint16_t flags) { flags_ |= flags; } void setFlags(uint16_t flags) { flags_ |= flags; }
void clearFlags(uint16_t flags) { flags_ &= ~flags; } void clearFlags(uint16_t flags) { flags_ &= ~flags; }
void setFlags(uint16_t flags, bool set) {
if (set) {
setFlags(flags);
} else {
clearFlags(flags);
}
}
FunctionKind kind() const { FunctionKind kind() const {
return static_cast<FunctionKind>((flags_ & FUNCTION_KIND_MASK) >> return static_cast<FunctionKind>((flags_ & FUNCTION_KIND_MASK) >>