summaryrefslogtreecommitdiff
path: root/deps/v8/src/objects/scope-info.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2021-02-24 14:47:06 +0100
committerMichaël Zasso <targos@protonmail.com>2021-02-25 00:14:47 +0100
commitc5ff019a4e93891106859cb272ded1197a92c7e5 (patch)
treecaf6b7e50b0ceac09878ac4402d9f725b8685dd7 /deps/v8/src/objects/scope-info.cc
parent67dc2bf2084b125dec43689874d237d125562cdf (diff)
downloadnode-new-c5ff019a4e93891106859cb272ded1197a92c7e5.tar.gz
deps: update V8 to 8.9.255.19
PR-URL: https://github.com/nodejs/node/pull/37330 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'deps/v8/src/objects/scope-info.cc')
-rw-r--r--deps/v8/src/objects/scope-info.cc77
1 files changed, 30 insertions, 47 deletions
diff --git a/deps/v8/src/objects/scope-info.cc b/deps/v8/src/objects/scope-info.cc
index 6f9f944b68..bd6fd3cb0b 100644
--- a/deps/v8/src/objects/scope-info.cc
+++ b/deps/v8/src/objects/scope-info.cc
@@ -172,7 +172,7 @@ Handle<ScopeInfo> ScopeInfo::Create(LocalIsolate* isolate, Zone* zone,
isolate->factory()->NewScopeInfo(length);
int index = kVariablePartIndex;
{
- DisallowHeapAllocation no_gc;
+ DisallowGarbageCollection no_gc;
ScopeInfo scope_info = *scope_info_handle;
WriteBarrierMode mode = scope_info.GetWriteBarrierMode(no_gc);
@@ -588,26 +588,27 @@ ScopeInfo ScopeInfo::Empty(Isolate* isolate) {
return ReadOnlyRoots(isolate).empty_scope_info();
}
+bool ScopeInfo::IsEmpty() const { return IsEmptyBit::decode(Flags()); }
+
ScopeType ScopeInfo::scope_type() const {
- DCHECK_LT(0, length());
+ DCHECK(!IsEmpty());
return ScopeTypeBits::decode(Flags());
}
bool ScopeInfo::is_script_scope() const {
- return length() > 0 && scope_type() == SCRIPT_SCOPE;
+ return !IsEmpty() && scope_type() == SCRIPT_SCOPE;
}
bool ScopeInfo::SloppyEvalCanExtendVars() const {
bool sloppy_eval_can_extend_vars =
- length() > 0 && SloppyEvalCanExtendVarsBit::decode(Flags());
+ SloppyEvalCanExtendVarsBit::decode(Flags());
DCHECK_IMPLIES(sloppy_eval_can_extend_vars, is_sloppy(language_mode()));
DCHECK_IMPLIES(sloppy_eval_can_extend_vars, is_declaration_scope());
return sloppy_eval_can_extend_vars;
}
LanguageMode ScopeInfo::language_mode() const {
- return length() > 0 ? LanguageModeBit::decode(Flags())
- : LanguageMode::kSloppy;
+ return LanguageModeBit::decode(Flags());
}
bool ScopeInfo::is_declaration_scope() const {
@@ -615,7 +616,7 @@ bool ScopeInfo::is_declaration_scope() const {
}
int ScopeInfo::ContextLength() const {
- if (length() > 0) {
+ if (!IsEmpty()) {
int context_locals = ContextLocalCount();
bool function_name_context_slot = FunctionVariableBits::decode(Flags()) ==
VariableAllocationInfo::CONTEXT;
@@ -647,12 +648,10 @@ int ScopeInfo::ContextHeaderLength() const {
}
bool ScopeInfo::HasReceiver() const {
- if (length() == 0) return false;
return VariableAllocationInfo::NONE != ReceiverVariableBits::decode(Flags());
}
bool ScopeInfo::HasAllocatedReceiver() const {
- if (length() == 0) return false;
VariableAllocationInfo allocation = ReceiverVariableBits::decode(Flags());
return allocation == VariableAllocationInfo::STACK ||
allocation == VariableAllocationInfo::CONTEXT;
@@ -671,17 +670,15 @@ bool ScopeInfo::HasNewTarget() const {
}
bool ScopeInfo::HasFunctionName() const {
- if (length() == 0) return false;
return VariableAllocationInfo::NONE != FunctionVariableBits::decode(Flags());
}
bool ScopeInfo::HasInferredFunctionName() const {
- if (length() == 0) return false;
return HasInferredFunctionNameBit::decode(Flags());
}
bool ScopeInfo::HasPositionInfo() const {
- if (length() == 0) return false;
+ if (IsEmpty()) return false;
return NeedsPositionInfo(scope_type());
}
@@ -707,36 +704,28 @@ void ScopeInfo::SetInferredFunctionName(String name) {
}
bool ScopeInfo::HasOuterScopeInfo() const {
- if (length() == 0) return false;
return HasOuterScopeInfoBit::decode(Flags());
}
bool ScopeInfo::IsDebugEvaluateScope() const {
- if (length() == 0) return false;
return IsDebugEvaluateScopeBit::decode(Flags());
}
void ScopeInfo::SetIsDebugEvaluateScope() {
- if (length() > 0) {
- DCHECK_EQ(scope_type(), WITH_SCOPE);
- SetFlags(Flags() | IsDebugEvaluateScopeBit::encode(true));
- } else {
- UNREACHABLE();
- }
+ CHECK(!IsEmpty());
+ DCHECK_EQ(scope_type(), WITH_SCOPE);
+ SetFlags(Flags() | IsDebugEvaluateScopeBit::encode(true));
}
bool ScopeInfo::PrivateNameLookupSkipsOuterClass() const {
- if (length() == 0) return false;
return PrivateNameLookupSkipsOuterClassBit::decode(Flags());
}
bool ScopeInfo::IsReplModeScope() const {
- if (length() == 0) return false;
return IsReplModeScopeBit::decode(Flags());
}
bool ScopeInfo::HasLocalsBlockList() const {
- if (length() == 0) return false;
return HasLocalsBlockListBit::decode(Flags());
}
@@ -864,7 +853,7 @@ bool ScopeInfo::VariableIsSynthetic(String name) {
int ScopeInfo::ModuleIndex(String name, VariableMode* mode,
InitializationFlag* init_flag,
MaybeAssignedFlag* maybe_assigned_flag) {
- DisallowHeapAllocation no_gc;
+ DisallowGarbageCollection no_gc;
DCHECK(name.IsInternalizedString());
DCHECK_EQ(scope_type(), MODULE_SCOPE);
DCHECK_NOT_NULL(mode);
@@ -892,13 +881,13 @@ int ScopeInfo::ContextSlotIndex(ScopeInfo scope_info, String name,
InitializationFlag* init_flag,
MaybeAssignedFlag* maybe_assigned_flag,
IsStaticFlag* is_static_flag) {
- DisallowHeapAllocation no_gc;
+ DisallowGarbageCollection no_gc;
DCHECK(name.IsInternalizedString());
DCHECK_NOT_NULL(mode);
DCHECK_NOT_NULL(init_flag);
DCHECK_NOT_NULL(maybe_assigned_flag);
- if (scope_info.length() == 0) return -1;
+ if (scope_info.IsEmpty()) return -1;
int start = scope_info.ContextLocalNamesIndex();
int end = start + scope_info.ContextLocalCount();
@@ -919,7 +908,7 @@ int ScopeInfo::ContextSlotIndex(ScopeInfo scope_info, String name,
}
int ScopeInfo::SavedClassVariableContextLocalIndex() const {
- if (length() > 0 && HasSavedClassVariableIndexBit::decode(Flags())) {
+ if (HasSavedClassVariableIndexBit::decode(Flags())) {
int index = Smi::ToInt(get(SavedClassVariableInfoIndex()));
return index - Context::MIN_CONTEXT_SLOTS;
}
@@ -927,8 +916,8 @@ int ScopeInfo::SavedClassVariableContextLocalIndex() const {
}
int ScopeInfo::ReceiverContextSlotIndex() const {
- if (length() > 0 && ReceiverVariableBits::decode(Flags()) ==
- VariableAllocationInfo::CONTEXT) {
+ if (ReceiverVariableBits::decode(Flags()) ==
+ VariableAllocationInfo::CONTEXT) {
return Smi::ToInt(get(ReceiverInfoIndex()));
}
return -1;
@@ -936,12 +925,10 @@ int ScopeInfo::ReceiverContextSlotIndex() const {
int ScopeInfo::FunctionContextSlotIndex(String name) const {
DCHECK(name.IsInternalizedString());
- if (length() > 0) {
- if (FunctionVariableBits::decode(Flags()) ==
- VariableAllocationInfo::CONTEXT &&
- FunctionName() == name) {
- return Smi::ToInt(get(FunctionNameInfoIndex() + 1));
- }
+ if (FunctionVariableBits::decode(Flags()) ==
+ VariableAllocationInfo::CONTEXT &&
+ FunctionName() == name) {
+ return Smi::ToInt(get(FunctionNameInfoIndex() + 1));
}
return -1;
}
@@ -951,7 +938,7 @@ FunctionKind ScopeInfo::function_kind() const {
}
int ScopeInfo::ContextLocalNamesIndex() const {
- DCHECK_LT(0, length());
+ DCHECK_LE(kVariablePartIndex, length());
return kVariablePartIndex;
}
@@ -1046,20 +1033,22 @@ std::ostream& operator<<(std::ostream& os, VariableAllocationInfo var_info) {
template <typename LocalIsolate>
Handle<ModuleRequest> ModuleRequest::New(LocalIsolate* isolate,
Handle<String> specifier,
- Handle<FixedArray> import_assertions) {
+ Handle<FixedArray> import_assertions,
+ int position) {
Handle<ModuleRequest> result = Handle<ModuleRequest>::cast(
isolate->factory()->NewStruct(MODULE_REQUEST_TYPE, AllocationType::kOld));
result->set_specifier(*specifier);
result->set_import_assertions(*import_assertions);
+ result->set_position(position);
return result;
}
template Handle<ModuleRequest> ModuleRequest::New(
Isolate* isolate, Handle<String> specifier,
- Handle<FixedArray> import_assertions);
+ Handle<FixedArray> import_assertions, int position);
template Handle<ModuleRequest> ModuleRequest::New(
LocalIsolate* isolate, Handle<String> specifier,
- Handle<FixedArray> import_assertions);
+ Handle<FixedArray> import_assertions, int position);
template <typename LocalIsolate>
Handle<SourceTextModuleInfoEntry> SourceTextModuleInfoEntry::New(
@@ -1097,14 +1086,9 @@ Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
// Serialize module requests.
int size = static_cast<int>(descr->module_requests().size());
Handle<FixedArray> module_requests = isolate->factory()->NewFixedArray(size);
- Handle<FixedArray> module_request_positions =
- isolate->factory()->NewFixedArray(size);
for (const auto& elem : descr->module_requests()) {
- Handle<ModuleRequest> serialized_module_request =
- elem.first->Serialize(isolate);
- module_requests->set(elem.second.index, *serialized_module_request);
- module_request_positions->set(elem.second.index,
- Smi::FromInt(elem.second.position));
+ Handle<ModuleRequest> serialized_module_request = elem->Serialize(isolate);
+ module_requests->set(elem->index(), *serialized_module_request);
}
// Serialize special exports.
@@ -1154,7 +1138,6 @@ Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
result->set(kRegularExportsIndex, *regular_exports);
result->set(kNamespaceImportsIndex, *namespace_imports);
result->set(kRegularImportsIndex, *regular_imports);
- result->set(kModuleRequestPositionsIndex, *module_request_positions);
return result;
}
template Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(