summaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/scope-info.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/objects/scope-info.h')
-rw-r--r--deps/v8/src/objects/scope-info.h43
1 files changed, 35 insertions, 8 deletions
diff --git a/deps/v8/src/objects/scope-info.h b/deps/v8/src/objects/scope-info.h
index 123b9b1797..aa63cf2998 100644
--- a/deps/v8/src/objects/scope-info.h
+++ b/deps/v8/src/objects/scope-info.h
@@ -72,6 +72,10 @@ class ScopeInfo : public FixedArray {
// Does this scope has class brand (for private methods)?
bool HasClassBrand() const;
+ // Does this scope contains a saved class variable context local slot index
+ // for checking receivers of static private methods?
+ bool HasSavedClassVariableIndex() const;
+
// Does this scope declare a "new.target" binding?
bool HasNewTarget() const;
@@ -121,6 +125,9 @@ class ScopeInfo : public FixedArray {
// Return the mode of the given context local.
VariableMode ContextLocalMode(int var) const;
+ // Return whether the given context local variable is static.
+ IsStaticFlag ContextLocalIsStaticFlag(int var) const;
+
// Return the initialization flag of the given context local.
InitializationFlag ContextLocalInitFlag(int var) const;
@@ -141,7 +148,8 @@ class ScopeInfo : public FixedArray {
// mode for that variable.
static int ContextSlotIndex(ScopeInfo scope_info, String name,
VariableMode* mode, InitializationFlag* init_flag,
- MaybeAssignedFlag* maybe_assigned_flag);
+ MaybeAssignedFlag* maybe_assigned_flag,
+ IsStaticFlag* is_static_flag);
// Lookup metadata of a MODULE-allocated variable. Return 0 if there is no
// module variable with the given name (the index value of a MODULE variable
@@ -161,6 +169,12 @@ class ScopeInfo : public FixedArray {
// context-allocated. Otherwise returns a value < 0.
int ReceiverContextSlotIndex() const;
+ // Lookup support for serialized scope info. Returns the index of the
+ // saved class variable in context local slots if scope is a class scope
+ // and it contains static private methods that may be accessed.
+ // Otherwise returns a value < 0.
+ int SavedClassVariableContextLocalIndex() const;
+
FunctionKind function_kind() const;
// Returns true if this ScopeInfo is linked to a outer ScopeInfo.
@@ -176,6 +190,10 @@ class ScopeInfo : public FixedArray {
// Return the outer ScopeInfo if present.
ScopeInfo OuterScopeInfo() const;
+ // Returns true if this ScopeInfo was created for a scope that skips the
+ // closest outer class when resolving private names.
+ bool PrivateNameLookupSkipsOuterClass() const;
+
#ifdef DEBUG
bool Equals(ScopeInfo other) const;
#endif
@@ -228,7 +246,8 @@ class ScopeInfo : public FixedArray {
using ReceiverVariableField =
DeclarationScopeField::Next<VariableAllocationInfo, 2>;
using HasClassBrandField = ReceiverVariableField::Next<bool, 1>;
- using HasNewTargetField = HasClassBrandField::Next<bool, 1>;
+ using HasSavedClassVariableIndexField = HasClassBrandField::Next<bool, 1>;
+ using HasNewTargetField = HasSavedClassVariableIndexField::Next<bool, 1>;
using FunctionVariableField =
HasNewTargetField::Next<VariableAllocationInfo, 2>;
// TODO(cbruni): Combine with function variable field when only storing the
@@ -240,6 +259,8 @@ class ScopeInfo : public FixedArray {
using HasOuterScopeInfoField = FunctionKindField::Next<bool, 1>;
using IsDebugEvaluateScopeField = HasOuterScopeInfoField::Next<bool, 1>;
using ForceContextAllocationField = IsDebugEvaluateScopeField::Next<bool, 1>;
+ using PrivateNameLookupSkipsOuterClassField =
+ ForceContextAllocationField::Next<bool, 1>;
STATIC_ASSERT(kLastFunctionKind <= FunctionKindField::kMax);
@@ -256,27 +277,32 @@ class ScopeInfo : public FixedArray {
// the context locals in ContextLocalNames. One slot is used per
// context local, so in total this part occupies ContextLocalCount()
// slots in the array.
- // 3. ReceiverInfo:
+ // 3. SavedClassVariableInfo:
+ // If the scope is a class scope and it has static private methods that
+ // may be accessed directly or through eval, one slot is reserved to hold
+ // the context slot index for the class variable.
+ // 4. ReceiverInfo:
// If the scope binds a "this" value, one slot is reserved to hold the
// context or stack slot index for the variable.
- // 4. FunctionNameInfo:
+ // 5. FunctionNameInfo:
// If the scope belongs to a named function expression this part contains
// information about the function variable. It always occupies two array
// slots: a. The name of the function variable.
// b. The context or stack slot index for the variable.
- // 5. InferredFunctionName:
+ // 6. InferredFunctionName:
// Contains the function's inferred name.
- // 6. SourcePosition:
+ // 7. SourcePosition:
// Contains two slots with a) the startPosition and b) the endPosition if
// the scope belongs to a function or script.
- // 7. OuterScopeInfoIndex:
+ // 8. OuterScopeInfoIndex:
// The outer scope's ScopeInfo or the hole if there's none.
- // 8. SourceTextModuleInfo, ModuleVariableCount, and ModuleVariables:
+ // 9. SourceTextModuleInfo, ModuleVariableCount, and ModuleVariables:
// For a module scope, this part contains the SourceTextModuleInfo, the
// number of MODULE-allocated variables, and the metadata of those
// variables. For non-module scopes it is empty.
int ContextLocalNamesIndex() const;
int ContextLocalInfosIndex() const;
+ int SavedClassVariableInfoIndex() const;
int ReceiverInfoIndex() const;
int FunctionNameInfoIndex() const;
int InferredFunctionNameIndex() const;
@@ -310,6 +336,7 @@ class ScopeInfo : public FixedArray {
using InitFlagField = VariableModeField::Next<InitializationFlag, 1>;
using MaybeAssignedFlagField = InitFlagField::Next<MaybeAssignedFlag, 1>;
using ParameterNumberField = MaybeAssignedFlagField::Next<uint32_t, 16>;
+ using IsStaticFlagField = ParameterNumberField::Next<IsStaticFlag, 1>;
friend class ScopeIterator;
friend std::ostream& operator<<(std::ostream& os,