Bug 1629741 - Move FunctionFlags, GeneratorKind, FunctionAsyncKind, FunctionSyntaxKind to their own headers. r=jorendorff

Differential Revision: https://phabricator.services.mozilla.com/D71155
This commit is contained in:
Tooru Fujisawa 2020-04-23 21:44:07 +00:00
Родитель b1ad9498a5
Коммит feac3e9061
44 изменённых файлов: 474 добавлений и 352 удалений

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

@ -23,6 +23,7 @@
#include "js/CharacterEncoding.h"
#include "js/StableStringChars.h"
#include "vm/BigIntType.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/JSAtom.h"
#include "vm/JSObject.h"
#include "vm/ModuleBuilder.h" // js::ModuleBuilder

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

@ -43,10 +43,18 @@ cpp:
#include "frontend/BinASTTokenReaderContext.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ParseNode.h"
#include "frontend/Parser.h"
#include "frontend/SharedContext.h"
#ifndef ENABLE_NEW_REGEXP
# include "irregexp/RegExpParser.h"
#endif
#include "js/RegExpFlags.h" // JS::RegExpFlag, JS::RegExpFlags
#ifdef ENABLE_NEW_REGEXP
# include "new-regexp/RegExpAPI.h"
#endif
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
#include "vm/RegExpObject.h"
#include "frontend/ParseContext-inl.h"

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

@ -24,6 +24,7 @@
#include "frontend/BinASTTokenReaderContext.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ParseNode.h"
#include "frontend/Parser.h"
#include "frontend/SharedContext.h"
@ -34,6 +35,7 @@
#ifdef ENABLE_NEW_REGEXP
# include "new-regexp/RegExpAPI.h"
#endif
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
#include "vm/RegExpObject.h"
#include "frontend/ParseContext-inl.h"

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

@ -20,10 +20,13 @@
#include "frontend/BinASTTokenReaderContext.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ParseNode.h"
#include "frontend/Parser.h"
#include "frontend/SharedContext.h"
#include "js/Result.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
#include "vm/RegExpObject.h"
#include "frontend/ParseContext-inl.h"

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

@ -25,16 +25,16 @@
#include "frontend/BinASTTokenReaderContext.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ParseContext.h"
#include "frontend/ParseNode.h"
#include "frontend/SharedContext.h"
#include "js/CompileOptions.h"
#include "js/GCHashTable.h"
#include "js/GCVector.h"
#include "js/Result.h"
#include "vm/ErrorReporting.h"
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
namespace js {
namespace frontend {

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

@ -26,6 +26,7 @@
#include "frontend/ModuleSharedContext.h"
#include "frontend/Parser.h"
#include "js/SourceText.h"
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
#include "vm/GlobalObject.h"
#include "vm/JSContext.h"
#include "vm/JSScript.h"

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

@ -13,6 +13,7 @@
#include <cstddef> // std::nullptr_t
#include <string.h>
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ParseNode.h"
#include "frontend/SharedContext.h"
#include "frontend/Stencil.h"

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

@ -11,6 +11,7 @@
#include "builtin/ModuleObject.h" // ModuleObject
#include "frontend/BCEScriptStencil.h" // BCEScriptStencil
#include "frontend/BytecodeEmitter.h" // BytecodeEmitter
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ModuleSharedContext.h" // ModuleSharedContext
#include "frontend/NameAnalysisTypes.h" // NameLocation
#include "frontend/NameOpEmitter.h" // NameOpEmitter

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

@ -11,15 +11,16 @@
#include <stdint.h> // uint16_t, uint32_t
#include "frontend/DefaultEmitter.h" // DefaultEmitter
#include "frontend/EmitterScope.h" // EmitterScope
#include "frontend/SharedContext.h" // FunctionBox
#include "frontend/TDZCheckCache.h" // TDZCheckCache
#include "frontend/TryEmitter.h" // TryEmitter
#include "gc/Rooting.h" // JS::Rooted, JS::Handle
#include "vm/BytecodeUtil.h" // JSOp
#include "vm/JSAtom.h" // JSAtom
#include "vm/JSFunction.h" // JSFunction
#include "frontend/DefaultEmitter.h" // DefaultEmitter
#include "frontend/EmitterScope.h" // EmitterScope
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/SharedContext.h" // FunctionBox
#include "frontend/TDZCheckCache.h" // TDZCheckCache
#include "frontend/TryEmitter.h" // TryEmitter
#include "gc/Rooting.h" // JS::Rooted, JS::Handle
#include "vm/BytecodeUtil.h" // JSOp
#include "vm/JSAtom.h" // JSAtom
#include "vm/JSFunction.h" // JSFunction
namespace js {
namespace frontend {

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

@ -0,0 +1,36 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef frontend_FunctionSyntaxKind_h
#define frontend_FunctionSyntaxKind_h
#include <stdint.h> // uint8_t
namespace js {
namespace frontend {
enum class FunctionSyntaxKind : uint8_t {
// A non-arrow function expression.
Expression,
// A named function appearing as a Statement.
Statement,
Arrow,
// Method of a class or object. Field initializers also desugar to methods.
Method,
ClassConstructor,
DerivedClassConstructor,
Getter,
Setter,
};
} /* namespace frontend */
} /* namespace js */
#endif /* frontend_FunctionSyntaxKind_h */

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

@ -15,6 +15,7 @@
#include "frontend/NameCollections.h"
#include "frontend/SharedContext.h"
#include "frontend/UsedNameTracker.h"
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
namespace js {

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

@ -14,6 +14,7 @@
#include <stddef.h>
#include <stdint.h>
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/Stencil.h"
#include "frontend/Token.h"
#include "js/RootingAPI.h"
@ -629,24 +630,6 @@ inline bool IsTypeofKind(ParseNodeKind kind) {
FOR_EACH_PARSENODE_SUBCLASS(DECLARE_CLASS)
#undef DECLARE_CLASS
enum class FunctionSyntaxKind : uint8_t {
// A non-arrow function expression.
Expression,
// A named function appearing as a Statement.
Statement,
Arrow,
// Method of a class or object. Field initializers also desugar to methods.
Method,
ClassConstructor,
DerivedClassConstructor,
Getter,
Setter,
};
enum class AccessorType { None, Getter, Setter };
static inline bool IsConstructorKind(FunctionSyntaxKind kind) {

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

@ -40,6 +40,7 @@
#include "frontend/BytecodeCompiler.h"
#include "frontend/BytecodeSection.h"
#include "frontend/FoldConstants.h"
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ModuleSharedContext.h"
#include "frontend/ParseNode.h"
#include "frontend/ParseNodeVerify.h"
@ -53,6 +54,8 @@
#endif
#include "vm/BigIntType.h"
#include "vm/BytecodeUtil.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
#include "vm/JSAtom.h"
#include "vm/JSContext.h"
#include "vm/JSFunction.h"

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

@ -184,6 +184,7 @@
#include "frontend/CompilationInfo.h"
#include "frontend/ErrorReporter.h"
#include "frontend/FullParseHandler.h"
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/FunctionTree.h"
#include "frontend/NameAnalysisTypes.h"
#include "frontend/NameCollections.h"
@ -193,6 +194,7 @@
#include "frontend/TokenStream.h"
#include "js/Vector.h"
#include "vm/ErrorReporting.h"
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
namespace js {

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

@ -7,7 +7,10 @@
#include "frontend/SharedContext.h"
#include "frontend/AbstractScopePtr.h"
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ModuleSharedContext.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
#include "wasm/AsmJS.h"
#include "frontend/ParseContext-inl.h"

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

@ -14,8 +14,11 @@
#include "jstypes.h"
#include "frontend/AbstractScopePtr.h"
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ParseNode.h"
#include "frontend/Stencil.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
#include "vm/JSFunction.h"
#include "vm/JSScript.h"
#include "vm/Scope.h"

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

@ -16,22 +16,25 @@
#include <stdint.h> // char16_t, uint8_t, uint32_t
#include <stdlib.h> // size_t
#include "frontend/AbstractScopePtr.h" // AbstractScopePtr, ScopeIndex
#include "frontend/NameAnalysisTypes.h" // AtomVector
#include "frontend/ObjLiteral.h" // ObjLiteralCreationData
#include "frontend/TypedIndex.h" // TypedIndex
#include "gc/Barrier.h" // HeapPtr, GCPtrAtom
#include "frontend/AbstractScopePtr.h" // AbstractScopePtr, ScopeIndex
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/NameAnalysisTypes.h" // AtomVector
#include "frontend/ObjLiteral.h" // ObjLiteralCreationData
#include "frontend/TypedIndex.h" // TypedIndex
#include "gc/Barrier.h" // HeapPtr, GCPtrAtom
#include "gc/Rooting.h" // HandleAtom, HandleModuleObject, HandleScriptSourceObject, MutableHandleScope
#include "js/GCVariant.h" // GC Support for mozilla::Variant
#include "js/RegExpFlags.h" // JS::RegExpFlags
#include "js/RootingAPI.h" // Handle
#include "js/TypeDecls.h" // JSContext,JSAtom,JSFunction
#include "js/UniquePtr.h" // js::UniquePtr
#include "js/Utility.h" // JS::FreePolicy, UniqueTwoByteChars
#include "js/Vector.h" // js::Vector
#include "util/Text.h" // DuplicateString
#include "vm/BigIntType.h" // ParseBigIntLiteral
#include "vm/JSFunction.h" // FunctionFlags
#include "js/GCVariant.h" // GC Support for mozilla::Variant
#include "js/RegExpFlags.h" // JS::RegExpFlags
#include "js/RootingAPI.h" // Handle
#include "js/TypeDecls.h" // JSContext,JSAtom,JSFunction
#include "js/UniquePtr.h" // js::UniquePtr
#include "js/Utility.h" // JS::FreePolicy, UniqueTwoByteChars
#include "js/Vector.h" // js::Vector
#include "util/Text.h" // DuplicateString
#include "vm/BigIntType.h" // ParseBigIntLiteral
#include "vm/FunctionFlags.h" // FunctionFlags
#include "vm/GeneratorAndAsyncKind.h" // GeneratorKind, FunctionAsyncKind
#include "vm/JSFunction.h" // FunctionFlags
#include "vm/JSScript.h" // GeneratorKind, FunctionAsyncKind, FieldInitializers
#include "vm/Runtime.h" // ReportOutOfMemory
#include "vm/Scope.h" // BaseScopeData, FunctionScope, LexicalScope, VarScope, GlobalScope, EvalScope, ModuleScope
@ -54,8 +57,6 @@ class FunctionBox;
//
// Renaming to use the term stencil more broadly is still in progress.
enum class FunctionSyntaxKind : uint8_t;
// Arbitrary typename to disambiguate TypedIndexes;
class FunctionIndexType;

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

@ -12,6 +12,7 @@
#include <string.h>
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ParseNode.h"
#include "frontend/TokenStream.h"
#include "js/GCAnnotations.h"

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

@ -24,6 +24,7 @@
#include "vm/AsyncFunction.h"
#include "vm/AsyncIteration.h"
#include "vm/EnvironmentObject.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/Interpreter.h"
#include "vm/JSFunction.h"
#include "vm/TraceLogging.h"

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

@ -23,6 +23,7 @@
#include "proxy/Proxy.h"
#include "vm/ArrayBufferObject.h"
#include "vm/BigIntType.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorObject.h"
#include "builtin/Boolean-inl.h"

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

@ -57,6 +57,7 @@
#include "vm/AsyncFunction.h"
#include "vm/AsyncIteration.h"
#include "vm/EqualityOperations.h" // js::SameValue
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/MatchPairs.h"
#include "vm/PlainObject.h" // js::PlainObject
#include "vm/RegExpObject.h"

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

@ -31,6 +31,7 @@
#include "js/HeapAPI.h"
#include "vm/ArrayObject.h"
#include "vm/EnvironmentObject.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/RegExpObject.h"
#include "vm/SharedMem.h"
#include "vm/TypedArrayObject.h"

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

@ -27,6 +27,7 @@
#include "jit/Simulator.h"
#include "js/Conversions.h"
#include "js/Printf.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/TraceLogging.h"
#include "gc/Nursery-inl.h"

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

@ -13,6 +13,7 @@
#include "gc/Policy.h"
#include "jit/JitAllocPolicy.h"
#include "jit/JitContext.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/Printer.h"
namespace js {

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

@ -2168,7 +2168,7 @@ static MOZ_ALWAYS_INLINE shadow::Function* FunctionObjectToShadowFunction(
return reinterpret_cast<shadow::Function*>(fun);
}
/* Statically asserted in JSFunction.h. */
/* Statically asserted in FunctionFlags.cpp. */
static const unsigned JS_FUNCTION_INTERPRETED_BITS = 0x0060;
// Return whether the given function object is native.

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

@ -310,6 +310,7 @@ UNIFIED_SOURCES += [
'vm/Exception.cpp',
'vm/ForOfIterator.cpp',
'vm/FrameIter.cpp',
'vm/FunctionFlags.cpp',
'vm/GeckoProfiler.cpp',
'vm/GeneratorObject.cpp',
'vm/GlobalObject.cpp',

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

@ -9,6 +9,7 @@
#include "mozilla/Maybe.h"
#include "builtin/Promise.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorObject.h"
#include "vm/GlobalObject.h"
#include "vm/Interpreter.h"

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

@ -10,6 +10,7 @@
#include "builtin/Promise.h" // js::AsyncFromSyncIteratorMethod, js::AsyncGeneratorEnqueue
#include "js/PropertySpec.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorObject.h"
#include "vm/GlobalObject.h"
#include "vm/Interpreter.h"

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

@ -31,6 +31,7 @@
#include "util/CompleteFile.h" // js::FileContents, js::ReadCompleteFile
#include "util/StringBuffer.h" // js::StringBuffer
#include "vm/EnvironmentObject.h" // js::CreateNonSyntacticEnvironmentChain
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/Interpreter.h" // js::Execute
#include "vm/JSContext.h" // JSContext

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

@ -22,6 +22,7 @@
#include "js/TypeDecls.h"
#include "js/UniquePtr.h"
#include "js/Value.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/JSObject.h"
#include "vm/NativeObject.h"
#include "vm/Shape.h"

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

@ -22,7 +22,7 @@
#include "vm/EnvironmentObject.h" // js::CallObject
#include "vm/JitActivation.h" // js::jit::JitActivation
#include "vm/JSContext.h" // JSContext
#include "vm/JSFunction.h" // js::CanReuseScriptForClone, js::FunctionFlags, JSFunction
#include "vm/JSFunction.h" // js::CanReuseScriptForClone, JSFunction
#include "vm/JSScript.h" // js::PCToLineNumber, JSScript, js::ScriptSource
#include "vm/Runtime.h" // JSRuntime
#include "vm/Stack.h" // js::{AbstractFramePtr,InterpreterFrame,MaybeCheckAliasing}

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

@ -0,0 +1,13 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "vm/FunctionFlags.h" // js::FunctionFlags::Flags
#include "jsfriendapi.h" // js::JS_FUNCTION_INTERPRETED_BITS
static_assert((js::FunctionFlags::Flags::BASESCRIPT |
js::FunctionFlags::Flags::SELFHOSTLAZY) ==
js::JS_FUNCTION_INTERPRETED_BITS,
"jsfriendapi.h's FunctionFlags::INTERPRETED-alike is wrong");

317
js/src/vm/FunctionFlags.h Normal file
Просмотреть файл

@ -0,0 +1,317 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef vm_FunctionFlags_h
#define vm_FunctionFlags_h
#include "mozilla/Assertions.h" // MOZ_ASSERT, MOZ_ASSERT_IF
#include "mozilla/Attributes.h" // MOZ_IMPLICIT
#include <stdint.h> // uint8_t, uint16_t
class JSAtom;
namespace js {
class FunctionFlags {
public:
enum FunctionKind : uint8_t {
NormalFunction = 0,
Arrow, // ES6 '(args) => body' syntax
Method, // ES6 MethodDefinition
ClassConstructor,
Getter,
Setter,
AsmJS, // An asm.js module or exported function
Wasm, // An exported WebAssembly function
FunctionKindLimit
};
enum Flags : uint16_t {
// The general kind of a function. This is used to describe characteristics
// of functions that do not merit a dedicated flag bit below.
FUNCTION_KIND_SHIFT = 0,
FUNCTION_KIND_MASK = 0x0007,
// The AllocKind used was FunctionExtended and extra slots were allocated.
// These slots may be used by the engine or the embedding so care must be
// taken to avoid conflicts.
EXTENDED = 1 << 3,
// Set if function is a self-hosted builtin or intrinsic. An 'intrinsic'
// here means a native function used inside self-hosted code. In general, a
// self-hosted function should appear to script as though it were a native
// builtin.
SELF_HOSTED = 1 << 4,
// An interpreted function has or may-have bytecode and an environment. Only
// one of these flags may be used at a time. As a memory optimization, the
// SELFHOSTLAZY flag indicates there is no js::BaseScript at all and we must
// clone from the self-hosted realm in order to get bytecode.
BASESCRIPT = 1 << 5,
SELFHOSTLAZY = 1 << 6,
// Function may be called as a constructor. This corresponds in the spec as
// having a [[Construct]] internal method.
CONSTRUCTOR = 1 << 7,
// A 'Bound Function Exotic Object' created by Function.prototype.bind.
BOUND_FUN = 1 << 8,
// Function comes from a FunctionExpression, ArrowFunction, or Function()
// call (not a FunctionDeclaration or nonstandard function-statement).
LAMBDA = 1 << 9,
// The WASM function has a JIT entry which emulates the
// js::BaseScript::jitCodeRaw mechanism.
WASM_JIT_ENTRY = 1 << 10,
// Function had no explicit name, but a name was set by SetFunctionName at
// compile time or SetFunctionName at runtime.
HAS_INFERRED_NAME = 1 << 11,
// Function had no explicit name, but a name was guessed for it anyway. For
// a Bound function, tracks if atom_ already contains the "bound " prefix.
ATOM_EXTRA_FLAG = 1 << 12,
HAS_GUESSED_ATOM = ATOM_EXTRA_FLAG,
HAS_BOUND_FUNCTION_NAME_PREFIX = ATOM_EXTRA_FLAG,
// The 'length' or 'name property has been resolved. See fun_resolve.
RESOLVED_NAME = 1 << 13,
RESOLVED_LENGTH = 1 << 14,
// For a function used as an interpreted constructor, whether a 'new' type
// had constructor information cleared.
NEW_SCRIPT_CLEARED = 1 << 15,
// Shifted form of FunctionKinds.
NORMAL_KIND = NormalFunction << FUNCTION_KIND_SHIFT,
ASMJS_KIND = AsmJS << FUNCTION_KIND_SHIFT,
WASM_KIND = Wasm << FUNCTION_KIND_SHIFT,
ARROW_KIND = Arrow << FUNCTION_KIND_SHIFT,
METHOD_KIND = Method << FUNCTION_KIND_SHIFT,
CLASSCONSTRUCTOR_KIND = ClassConstructor << FUNCTION_KIND_SHIFT,
GETTER_KIND = Getter << FUNCTION_KIND_SHIFT,
SETTER_KIND = Setter << FUNCTION_KIND_SHIFT,
// Derived Flags combinations to use when creating functions.
NATIVE_FUN = NORMAL_KIND,
NATIVE_CTOR = CONSTRUCTOR | NORMAL_KIND,
ASMJS_CTOR = CONSTRUCTOR | ASMJS_KIND,
ASMJS_LAMBDA_CTOR = CONSTRUCTOR | LAMBDA | ASMJS_KIND,
WASM = WASM_KIND,
INTERPRETED_NORMAL = BASESCRIPT | CONSTRUCTOR | NORMAL_KIND,
INTERPRETED_CLASS_CTOR = BASESCRIPT | CONSTRUCTOR | CLASSCONSTRUCTOR_KIND,
INTERPRETED_GENERATOR_OR_ASYNC = BASESCRIPT | NORMAL_KIND,
INTERPRETED_LAMBDA = BASESCRIPT | LAMBDA | CONSTRUCTOR | NORMAL_KIND,
INTERPRETED_LAMBDA_ARROW = BASESCRIPT | LAMBDA | ARROW_KIND,
INTERPRETED_LAMBDA_GENERATOR_OR_ASYNC = BASESCRIPT | LAMBDA | NORMAL_KIND,
INTERPRETED_GETTER = BASESCRIPT | GETTER_KIND,
INTERPRETED_SETTER = BASESCRIPT | SETTER_KIND,
INTERPRETED_METHOD = BASESCRIPT | METHOD_KIND,
// Flags that XDR ignores. See also: js::BaseScript::MutableFlags.
MUTABLE_FLAGS = RESOLVED_NAME | RESOLVED_LENGTH | NEW_SCRIPT_CLEARED,
// Flags preserved when cloning a function. (Exception:
// js::MakeDefaultConstructor produces default constructors for ECMAScript
// classes by cloning self-hosted functions, and then clearing their
// SELF_HOSTED bit, setting their CONSTRUCTOR bit, and otherwise munging
// them to look like they originated with the class definition.) */
STABLE_ACROSS_CLONES =
CONSTRUCTOR | LAMBDA | SELF_HOSTED | FUNCTION_KIND_MASK
};
uint16_t flags_;
public:
FunctionFlags() : flags_() {
static_assert(sizeof(FunctionFlags) == sizeof(flags_),
"No extra members allowed is it'll grow JSFunction");
static_assert(offsetof(FunctionFlags, flags_) == 0,
"Required for JIT flag access");
}
explicit FunctionFlags(uint16_t flags) : flags_(flags) {}
MOZ_IMPLICIT FunctionFlags(Flags f) : flags_(f) {}
static_assert(((FunctionKindLimit - 1) << FUNCTION_KIND_SHIFT) <=
FUNCTION_KIND_MASK,
"FunctionKind doesn't fit into flags_");
uint16_t toRaw() const { return flags_; }
uint16_t stableAcrossClones() const { return flags_ & STABLE_ACROSS_CLONES; }
// For flag combinations the type is int.
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) >>
FUNCTION_KIND_SHIFT);
}
/* A function can be classified as either native (C++) or interpreted (JS): */
bool isInterpreted() const {
return hasFlags(BASESCRIPT) || hasFlags(SELFHOSTLAZY);
}
bool isNative() const { return !isInterpreted(); }
bool isConstructor() const { return hasFlags(CONSTRUCTOR); }
/* Possible attributes of a native function: */
bool isAsmJSNative() const {
MOZ_ASSERT_IF(kind() == AsmJS, isNative());
return kind() == AsmJS;
}
bool isWasm() const {
MOZ_ASSERT_IF(kind() == Wasm, isNative());
return kind() == Wasm;
}
bool isWasmWithJitEntry() const {
MOZ_ASSERT_IF(hasFlags(WASM_JIT_ENTRY), isWasm());
return hasFlags(WASM_JIT_ENTRY);
}
bool isNativeWithJitEntry() const {
MOZ_ASSERT_IF(isWasmWithJitEntry(), isNative());
return isWasmWithJitEntry();
}
bool isBuiltinNative() const {
return isNative() && !isAsmJSNative() && !isWasm();
}
/* Possible attributes of an interpreted function: */
bool isBoundFunction() const { return hasFlags(BOUND_FUN); }
bool hasInferredName() const { return hasFlags(HAS_INFERRED_NAME); }
bool hasGuessedAtom() const {
static_assert(HAS_GUESSED_ATOM == HAS_BOUND_FUNCTION_NAME_PREFIX,
"HAS_GUESSED_ATOM is unused for bound functions");
bool hasGuessedAtom = hasFlags(HAS_GUESSED_ATOM);
bool boundFun = hasFlags(BOUND_FUN);
return hasGuessedAtom && !boundFun;
}
bool hasBoundFunctionNamePrefix() const {
static_assert(
HAS_BOUND_FUNCTION_NAME_PREFIX == HAS_GUESSED_ATOM,
"HAS_BOUND_FUNCTION_NAME_PREFIX is only used for bound functions");
MOZ_ASSERT(isBoundFunction());
return hasFlags(HAS_BOUND_FUNCTION_NAME_PREFIX);
}
bool isLambda() const { return hasFlags(LAMBDA); }
bool isNamedLambda(JSAtom* atom) const {
return isLambda() && atom && !hasInferredName() && !hasGuessedAtom();
}
// These methods determine which of the u.scripted.s union arms are active.
// For live JSFunctions the pointer values will always be non-null, but due
// to partial initialization the GC (and other features that scan the heap
// directly) may still return a null pointer.
bool hasBaseScript() const { return hasFlags(BASESCRIPT); }
bool hasSelfHostedLazyScript() const { return hasFlags(SELFHOSTLAZY); }
// Arrow functions store their lexical new.target in the first extended slot.
bool isArrow() const { return kind() == Arrow; }
// Every class-constructor is also a method.
bool isMethod() const {
return kind() == Method || kind() == ClassConstructor;
}
bool isClassConstructor() const { return kind() == ClassConstructor; }
bool isGetter() const { return kind() == Getter; }
bool isSetter() const { return kind() == Setter; }
bool allowSuperProperty() const {
return isMethod() || isGetter() || isSetter();
}
bool hasResolvedLength() const { return hasFlags(RESOLVED_LENGTH); }
bool hasResolvedName() const { return hasFlags(RESOLVED_NAME); }
bool isSelfHostedOrIntrinsic() const { return hasFlags(SELF_HOSTED); }
bool isSelfHostedBuiltin() const {
return isSelfHostedOrIntrinsic() && !isNative();
}
bool isIntrinsic() const { return isSelfHostedOrIntrinsic() && isNative(); }
void setKind(FunctionKind kind) {
this->flags_ &= ~FUNCTION_KIND_MASK;
this->flags_ |= static_cast<uint16_t>(kind) << FUNCTION_KIND_SHIFT;
}
// Make the function constructible.
void setIsConstructor() {
MOZ_ASSERT(!isConstructor());
MOZ_ASSERT(isSelfHostedBuiltin());
setFlags(CONSTRUCTOR);
}
void setIsClassConstructor() {
MOZ_ASSERT(!isClassConstructor());
MOZ_ASSERT(isConstructor());
setKind(ClassConstructor);
}
void setIsBoundFunction() {
MOZ_ASSERT(!isBoundFunction());
setFlags(BOUND_FUN);
}
void setIsSelfHostedBuiltin() {
MOZ_ASSERT(isInterpreted());
MOZ_ASSERT(!isSelfHostedBuiltin());
setFlags(SELF_HOSTED);
// Self-hosted functions should not be constructable.
clearFlags(CONSTRUCTOR);
}
void setIsIntrinsic() {
MOZ_ASSERT(isNative());
MOZ_ASSERT(!isIntrinsic());
setFlags(SELF_HOSTED);
}
void setResolvedLength() { setFlags(RESOLVED_LENGTH); }
void setResolvedName() { setFlags(RESOLVED_NAME); }
// Mark a function as having its 'new' script information cleared.
bool wasNewScriptCleared() const { return hasFlags(NEW_SCRIPT_CLEARED); }
void setNewScriptCleared() { setFlags(NEW_SCRIPT_CLEARED); }
void setInferredName() { setFlags(HAS_INFERRED_NAME); }
void clearInferredName() { clearFlags(HAS_INFERRED_NAME); }
void setGuessedAtom() { setFlags(HAS_GUESSED_ATOM); }
void setPrefixedBoundFunctionName() {
setFlags(HAS_BOUND_FUNCTION_NAME_PREFIX);
}
void setSelfHostedLazy() { setFlags(SELFHOSTLAZY); }
void clearSelfHostedLazy() { clearFlags(SELFHOSTLAZY); }
void setBaseScript() { setFlags(BASESCRIPT); }
void clearBaseScript() { clearFlags(BASESCRIPT); }
void setWasmJitEntry() { setFlags(WASM_JIT_ENTRY); }
bool isExtended() const { return hasFlags(EXTENDED); }
void setIsExtended() { setFlags(EXTENDED); }
bool isNativeConstructor() const { return hasFlags(NATIVE_CTOR); }
};
} /* namespace js */
#endif /* vm_FunctionFlags_h */

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

@ -0,0 +1,17 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef vm_GeneratorAndAsyncKind_h
#define vm_GeneratorAndAsyncKind_h
namespace js {
enum class GeneratorKind : bool { NotGenerator, Generator };
enum class FunctionAsyncKind : bool { SyncFunction, AsyncFunction };
} /* namespace js */
#endif /* vm_GeneratorAndAsyncKind_h */

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

@ -9,6 +9,7 @@
#include "js/PropertySpec.h"
#include "vm/AsyncFunction.h"
#include "vm/AsyncIteration.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GlobalObject.h"
#include "vm/JSObject.h"
#include "vm/PlainObject.h" // js::PlainObject

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

@ -39,6 +39,7 @@
#include "vm/BigIntType.h"
#include "vm/BytecodeUtil.h" // JSDVG_SEARCH_STACK
#include "vm/EqualityOperations.h" // js::StrictlyEqual
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorObject.h"
#include "vm/Instrumentation.h"
#include "vm/Iteration.h"
@ -1912,7 +1913,7 @@ class ReservedRooted : public RootedBase<T, ReservedRooted<T>> {
void set(const T& p) const { *savedRoot = p; }
operator Handle<T>() { return *savedRoot; }
operator Rooted<T>&() { return *savedRoot; }
operator Rooted<T> &() { return *savedRoot; }
MutableHandle<T> operator&() { return &*savedRoot; }
DECLARE_NONPOINTER_ACCESSOR_METHODS(savedRoot->get())

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

@ -44,6 +44,8 @@
#include "util/StringBuffer.h"
#include "vm/AsyncFunction.h"
#include "vm/AsyncIteration.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
#include "vm/GlobalObject.h"
#include "vm/Interpreter.h"
#include "vm/JSAtom.h"

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

@ -13,7 +13,9 @@
#include "jstypes.h"
#include "vm/FunctionPrefixKind.h" // FunctionPrefixKind
#include "vm/FunctionFlags.h" // FunctionFlags
#include "vm/FunctionPrefixKind.h" // FunctionPrefixKind
#include "vm/GeneratorAndAsyncKind.h" // GeneratorKind, FunctionAsyncKind
#include "vm/JSObject.h"
#include "vm/JSScript.h"
@ -31,304 +33,6 @@ static constexpr uint32_t BoundFunctionEnvArgsSlot = 4;
static const char FunctionConstructorMedialSigils[] = ") {\n";
static const char FunctionConstructorFinalBrace[] = "\n}";
class FunctionFlags {
public:
enum FunctionKind {
NormalFunction = 0,
Arrow, // ES6 '(args) => body' syntax
Method, // ES6 MethodDefinition
ClassConstructor,
Getter,
Setter,
AsmJS, // An asm.js module or exported function
Wasm, // An exported WebAssembly function
FunctionKindLimit
};
enum Flags : uint16_t {
// The general kind of a function. This is used to describe characteristics
// of functions that do not merit a dedicated flag bit below.
FUNCTION_KIND_SHIFT = 0,
FUNCTION_KIND_MASK = 0x0007,
// The AllocKind used was FunctionExtended and extra slots were allocated.
// These slots may be used by the engine or the embedding so care must be
// taken to avoid conflicts.
EXTENDED = 1 << 3,
// Set if function is a self-hosted builtin or intrinsic. An 'intrinsic'
// here means a native function used inside self-hosted code. In general, a
// self-hosted function should appear to script as though it were a native
// builtin.
SELF_HOSTED = 1 << 4,
// An interpreted function has or may-have bytecode and an environment. Only
// one of these flags may be used at a time. As a memory optimization, the
// SELFHOSTLAZY flag indicates there is no js::BaseScript at all and we must
// clone from the self-hosted realm in order to get bytecode.
BASESCRIPT = 1 << 5,
SELFHOSTLAZY = 1 << 6,
// Function may be called as a constructor. This corresponds in the spec as
// having a [[Construct]] internal method.
CONSTRUCTOR = 1 << 7,
// A 'Bound Function Exotic Object' created by Function.prototype.bind.
BOUND_FUN = 1 << 8,
// Function comes from a FunctionExpression, ArrowFunction, or Function()
// call (not a FunctionDeclaration or nonstandard function-statement).
LAMBDA = 1 << 9,
// The WASM function has a JIT entry which emulates the
// js::BaseScript::jitCodeRaw mechanism.
WASM_JIT_ENTRY = 1 << 10,
// Function had no explicit name, but a name was set by SetFunctionName at
// compile time or SetFunctionName at runtime.
HAS_INFERRED_NAME = 1 << 11,
// Function had no explicit name, but a name was guessed for it anyway. For
// a Bound function, tracks if atom_ already contains the "bound " prefix.
ATOM_EXTRA_FLAG = 1 << 12,
HAS_GUESSED_ATOM = ATOM_EXTRA_FLAG,
HAS_BOUND_FUNCTION_NAME_PREFIX = ATOM_EXTRA_FLAG,
// The 'length' or 'name property has been resolved. See fun_resolve.
RESOLVED_NAME = 1 << 13,
RESOLVED_LENGTH = 1 << 14,
// For a function used as an interpreted constructor, whether a 'new' type
// had constructor information cleared.
NEW_SCRIPT_CLEARED = 1 << 15,
// Shifted form of FunctionKinds.
NORMAL_KIND = NormalFunction << FUNCTION_KIND_SHIFT,
ASMJS_KIND = AsmJS << FUNCTION_KIND_SHIFT,
WASM_KIND = Wasm << FUNCTION_KIND_SHIFT,
ARROW_KIND = Arrow << FUNCTION_KIND_SHIFT,
METHOD_KIND = Method << FUNCTION_KIND_SHIFT,
CLASSCONSTRUCTOR_KIND = ClassConstructor << FUNCTION_KIND_SHIFT,
GETTER_KIND = Getter << FUNCTION_KIND_SHIFT,
SETTER_KIND = Setter << FUNCTION_KIND_SHIFT,
// Derived Flags combinations to use when creating functions.
NATIVE_FUN = NORMAL_KIND,
NATIVE_CTOR = CONSTRUCTOR | NORMAL_KIND,
ASMJS_CTOR = CONSTRUCTOR | ASMJS_KIND,
ASMJS_LAMBDA_CTOR = CONSTRUCTOR | LAMBDA | ASMJS_KIND,
WASM = WASM_KIND,
INTERPRETED_NORMAL = BASESCRIPT | CONSTRUCTOR | NORMAL_KIND,
INTERPRETED_CLASS_CTOR = BASESCRIPT | CONSTRUCTOR | CLASSCONSTRUCTOR_KIND,
INTERPRETED_GENERATOR_OR_ASYNC = BASESCRIPT | NORMAL_KIND,
INTERPRETED_LAMBDA = BASESCRIPT | LAMBDA | CONSTRUCTOR | NORMAL_KIND,
INTERPRETED_LAMBDA_ARROW = BASESCRIPT | LAMBDA | ARROW_KIND,
INTERPRETED_LAMBDA_GENERATOR_OR_ASYNC = BASESCRIPT | LAMBDA | NORMAL_KIND,
INTERPRETED_GETTER = BASESCRIPT | GETTER_KIND,
INTERPRETED_SETTER = BASESCRIPT | SETTER_KIND,
INTERPRETED_METHOD = BASESCRIPT | METHOD_KIND,
// Flags that XDR ignores. See also: js::BaseScript::MutableFlags.
MUTABLE_FLAGS = RESOLVED_NAME | RESOLVED_LENGTH | NEW_SCRIPT_CLEARED,
// Flags preserved when cloning a function. (Exception:
// js::MakeDefaultConstructor produces default constructors for ECMAScript
// classes by cloning self-hosted functions, and then clearing their
// SELF_HOSTED bit, setting their CONSTRUCTOR bit, and otherwise munging
// them to look like they originated with the class definition.) */
STABLE_ACROSS_CLONES =
CONSTRUCTOR | LAMBDA | SELF_HOSTED | FUNCTION_KIND_MASK
};
uint16_t flags_;
public:
FunctionFlags() : flags_() {
static_assert(sizeof(FunctionFlags) == sizeof(flags_),
"No extra members allowed is it'll grow JSFunction");
static_assert(offsetof(FunctionFlags, flags_) == 0,
"Required for JIT flag access");
}
explicit FunctionFlags(uint16_t flags) : flags_(flags) {}
MOZ_IMPLICIT FunctionFlags(Flags f) : flags_(f) {}
static_assert((BASESCRIPT | SELFHOSTLAZY) == js::JS_FUNCTION_INTERPRETED_BITS,
"jsfriendapi.h's FunctionFlags::INTERPRETED-alike is wrong");
static_assert(((FunctionKindLimit - 1) << FUNCTION_KIND_SHIFT) <=
FUNCTION_KIND_MASK,
"FunctionKind doesn't fit into flags_");
uint16_t toRaw() const { return flags_; }
uint16_t stableAcrossClones() const { return flags_ & STABLE_ACROSS_CLONES; }
// For flag combinations the type is int.
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) >>
FUNCTION_KIND_SHIFT);
}
/* A function can be classified as either native (C++) or interpreted (JS): */
bool isInterpreted() const {
return hasFlags(BASESCRIPT) || hasFlags(SELFHOSTLAZY);
}
bool isNative() const { return !isInterpreted(); }
bool isConstructor() const { return hasFlags(CONSTRUCTOR); }
/* Possible attributes of a native function: */
bool isAsmJSNative() const {
MOZ_ASSERT_IF(kind() == AsmJS, isNative());
return kind() == AsmJS;
}
bool isWasm() const {
MOZ_ASSERT_IF(kind() == Wasm, isNative());
return kind() == Wasm;
}
bool isWasmWithJitEntry() const {
MOZ_ASSERT_IF(hasFlags(WASM_JIT_ENTRY), isWasm());
return hasFlags(WASM_JIT_ENTRY);
}
bool isNativeWithJitEntry() const {
MOZ_ASSERT_IF(isWasmWithJitEntry(), isNative());
return isWasmWithJitEntry();
}
bool isBuiltinNative() const {
return isNative() && !isAsmJSNative() && !isWasm();
}
/* Possible attributes of an interpreted function: */
bool isBoundFunction() const { return hasFlags(BOUND_FUN); }
bool hasInferredName() const { return hasFlags(HAS_INFERRED_NAME); }
bool hasGuessedAtom() const {
static_assert(HAS_GUESSED_ATOM == HAS_BOUND_FUNCTION_NAME_PREFIX,
"HAS_GUESSED_ATOM is unused for bound functions");
bool hasGuessedAtom = hasFlags(HAS_GUESSED_ATOM);
bool boundFun = hasFlags(BOUND_FUN);
return hasGuessedAtom && !boundFun;
}
bool hasBoundFunctionNamePrefix() const {
static_assert(
HAS_BOUND_FUNCTION_NAME_PREFIX == HAS_GUESSED_ATOM,
"HAS_BOUND_FUNCTION_NAME_PREFIX is only used for bound functions");
MOZ_ASSERT(isBoundFunction());
return hasFlags(HAS_BOUND_FUNCTION_NAME_PREFIX);
}
bool isLambda() const { return hasFlags(LAMBDA); }
bool isNamedLambda(JSAtom* atom) const {
return isLambda() && atom && !hasInferredName() && !hasGuessedAtom();
}
// These methods determine which of the u.scripted.s union arms are active.
// For live JSFunctions the pointer values will always be non-null, but due
// to partial initialization the GC (and other features that scan the heap
// directly) may still return a null pointer.
bool hasBaseScript() const { return hasFlags(BASESCRIPT); }
bool hasSelfHostedLazyScript() const { return hasFlags(SELFHOSTLAZY); }
// Arrow functions store their lexical new.target in the first extended slot.
bool isArrow() const { return kind() == Arrow; }
// Every class-constructor is also a method.
bool isMethod() const {
return kind() == Method || kind() == ClassConstructor;
}
bool isClassConstructor() const { return kind() == ClassConstructor; }
bool isGetter() const { return kind() == Getter; }
bool isSetter() const { return kind() == Setter; }
bool allowSuperProperty() const {
return isMethod() || isGetter() || isSetter();
}
bool hasResolvedLength() const { return hasFlags(RESOLVED_LENGTH); }
bool hasResolvedName() const { return hasFlags(RESOLVED_NAME); }
bool isSelfHostedOrIntrinsic() const { return hasFlags(SELF_HOSTED); }
bool isSelfHostedBuiltin() const {
return isSelfHostedOrIntrinsic() && !isNative();
}
bool isIntrinsic() const { return isSelfHostedOrIntrinsic() && isNative(); }
void setKind(FunctionKind kind) {
this->flags_ &= ~FUNCTION_KIND_MASK;
this->flags_ |= static_cast<uint16_t>(kind) << FUNCTION_KIND_SHIFT;
}
// Make the function constructible.
void setIsConstructor() {
MOZ_ASSERT(!isConstructor());
MOZ_ASSERT(isSelfHostedBuiltin());
setFlags(CONSTRUCTOR);
}
void setIsClassConstructor() {
MOZ_ASSERT(!isClassConstructor());
MOZ_ASSERT(isConstructor());
setKind(ClassConstructor);
}
void setIsBoundFunction() {
MOZ_ASSERT(!isBoundFunction());
setFlags(BOUND_FUN);
}
void setIsSelfHostedBuiltin() {
MOZ_ASSERT(isInterpreted());
MOZ_ASSERT(!isSelfHostedBuiltin());
setFlags(SELF_HOSTED);
// Self-hosted functions should not be constructable.
clearFlags(CONSTRUCTOR);
}
void setIsIntrinsic() {
MOZ_ASSERT(isNative());
MOZ_ASSERT(!isIntrinsic());
setFlags(SELF_HOSTED);
}
void setResolvedLength() { setFlags(RESOLVED_LENGTH); }
void setResolvedName() { setFlags(RESOLVED_NAME); }
// Mark a function as having its 'new' script information cleared.
bool wasNewScriptCleared() const { return hasFlags(NEW_SCRIPT_CLEARED); }
void setNewScriptCleared() { setFlags(NEW_SCRIPT_CLEARED); }
void setInferredName() { setFlags(HAS_INFERRED_NAME); }
void clearInferredName() { clearFlags(HAS_INFERRED_NAME); }
void setGuessedAtom() { setFlags(HAS_GUESSED_ATOM); }
void setPrefixedBoundFunctionName() {
setFlags(HAS_BOUND_FUNCTION_NAME_PREFIX);
}
void setSelfHostedLazy() { setFlags(SELFHOSTLAZY); }
void clearSelfHostedLazy() { clearFlags(SELFHOSTLAZY); }
void setBaseScript() { setFlags(BASESCRIPT); }
void clearBaseScript() { clearFlags(BASESCRIPT); }
void setWasmJitEntry() { setFlags(WASM_JIT_ENTRY); }
bool isExtended() const { return hasFlags(EXTENDED); }
void setIsExtended() { setFlags(EXTENDED); }
bool isNativeConstructor() const { return hasFlags(NATIVE_CTOR); }
};
} // namespace js
class JSFunction : public js::NativeObject {

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

@ -58,6 +58,7 @@
#include "vm/BytecodeLocation.h"
#include "vm/BytecodeUtil.h"
#include "vm/Compression.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/HelperThreads.h" // js::RunPendingSourceCompressions
#include "vm/JSAtom.h"
#include "vm/JSContext.h"

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

@ -41,6 +41,7 @@
#include "vm/BytecodeIterator.h"
#include "vm/BytecodeLocation.h"
#include "vm/BytecodeUtil.h"
#include "vm/GeneratorAndAsyncKind.h" // GeneratorKind, FunctionAsyncKind
#include "vm/JSAtom.h"
#include "vm/NativeObject.h"
#include "vm/Scope.h"
@ -1266,9 +1267,6 @@ class ScriptSourceObject : public NativeObject {
};
};
enum class GeneratorKind : bool { NotGenerator, Generator };
enum class FunctionAsyncKind : bool { SyncFunction, AsyncFunction };
// ScriptWarmUpData represents a pointer-sized field in BaseScript that stores
// one of the following using low-bit tags:
//

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

@ -65,7 +65,8 @@
#include "vm/BytecodeLocation.h"
#include "vm/Compression.h"
#include "vm/DateObject.h"
#include "vm/FrameIter.h" // js::ScriptFrameIter
#include "vm/FrameIter.h" // js::ScriptFrameIter
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorObject.h"
#include "vm/Interpreter.h"
#include "vm/Iteration.h"

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

@ -37,6 +37,7 @@
#include "util/Text.h"
#include "util/Windows.h"
#include "vm/ArrayBufferObject.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GlobalObject.h"
#include "vm/Interpreter.h"
#include "vm/JSContext.h"

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

@ -33,6 +33,7 @@
#include "jsmath.h"
#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
#include "frontend/ParseNode.h"
#include "frontend/Parser.h"
#include "gc/Policy.h"
@ -45,6 +46,8 @@
#include "util/StringBuffer.h"
#include "util/Text.h"
#include "vm/ErrorReporting.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
#include "vm/SelfHosting.h"
#include "vm/Time.h"
#include "vm/TypedArrayObject.h"

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

@ -35,6 +35,7 @@
#include "util/StringBuffer.h"
#include "util/Text.h"
#include "vm/ErrorObject.h"
#include "vm/FunctionFlags.h" // js::FunctionFlags
#include "vm/Interpreter.h"
#include "vm/PlainObject.h" // js::PlainObject
#include "vm/PromiseObject.h" // js::PromiseObject