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,
uint32_t toStringStart, Directives directives,
bool extraWarnings, GeneratorKind generatorKind,
FunctionAsyncKind asyncKind, bool isArrow,
bool isNamedLambda, bool isGetter, bool isSetter,
bool isMethod, bool isInterpreted,
bool isInterpretedLazy,
FunctionFlags::FunctionKind kind, JSAtom* explicitName)
FunctionAsyncKind asyncKind, JSAtom* explicitName,
FunctionFlags flags)
: ObjectBox(nullptr, traceListHead, TraceListNode::NodeType::Function),
SharedContext(cx, Kind::FunctionBox, directives, extraWarnings),
enclosingScope_(nullptr),
@ -159,16 +156,9 @@ FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
isDerivedClassConstructor_(false),
hasThisBinding_(false),
hasInnerFunctions_(false),
isArrow_(isArrow),
isNamedLambda_(isNamedLambda),
isGetter_(isGetter),
isSetter_(isSetter),
isMethod_(isMethod),
isInterpreted_(isInterpreted),
isInterpretedLazy_(isInterpretedLazy),
kind_(kind),
nargs_(0),
explicitName_(explicitName),
nargs_(0) {}
flags_(flags) {}
FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
JSFunction* fun, uint32_t toStringStart,
@ -176,10 +166,7 @@ FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
GeneratorKind generatorKind,
FunctionAsyncKind asyncKind)
: FunctionBox(cx, traceListHead, toStringStart, directives, extraWarnings,
generatorKind, asyncKind, fun->isArrow(),
fun->isNamedLambda(), fun->isGetter(), fun->isSetter(),
fun->isMethod(), fun->isInterpreted(),
fun->isInterpretedLazy(), fun->kind(), fun->explicitName()) {
generatorKind, asyncKind, fun->explicitName(), fun->flags()) {
gcThing = fun;
// 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
@ -193,12 +180,7 @@ FunctionBox::FunctionBox(JSContext* cx, TraceListNode* traceListHead,
bool extraWarnings, GeneratorKind generatorKind,
FunctionAsyncKind asyncKind)
: FunctionBox(cx, traceListHead, toStringStart, directives, extraWarnings,
generatorKind, asyncKind, data.get().flags.isArrow(),
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) {
generatorKind, asyncKind, data.get().atom, data.get().flags) {
functionCreationData_.emplace(data);
}

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

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

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

@ -147,6 +147,13 @@ class FunctionFlags {
bool hasFlags(uint16_t flags) const { return flags_ & flags; }
void setFlags(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 {
return static_cast<FunctionKind>((flags_ & FUNCTION_KIND_MASK) >>