Store whether a with scope is actually a debug-eval scope in the scope info
This is required to be able to deserialize the scope chain from the scope info alone. BUG=v8:5215 R=marja@chromium.org,jgruber@chromium.org Review-Url: https://codereview.chromium.org/2331323006 Cr-Commit-Position: refs/heads/master@{#39412}
This commit is contained in:
parent
cc7926d672
commit
404bc9b672
@ -155,18 +155,20 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
|
||||
}
|
||||
|
||||
// Encode the flags.
|
||||
int flags = ScopeTypeField::encode(scope->scope_type()) |
|
||||
CallsEvalField::encode(scope->calls_eval()) |
|
||||
LanguageModeField::encode(scope->language_mode()) |
|
||||
DeclarationScopeField::encode(scope->is_declaration_scope()) |
|
||||
ReceiverVariableField::encode(receiver_info) |
|
||||
HasNewTargetField::encode(has_new_target) |
|
||||
FunctionVariableField::encode(function_name_info) |
|
||||
AsmModuleField::encode(asm_module) |
|
||||
AsmFunctionField::encode(asm_function) |
|
||||
HasSimpleParametersField::encode(has_simple_parameters) |
|
||||
FunctionKindField::encode(function_kind) |
|
||||
HasOuterScopeInfoField::encode(has_outer_scope_info);
|
||||
int flags =
|
||||
ScopeTypeField::encode(scope->scope_type()) |
|
||||
CallsEvalField::encode(scope->calls_eval()) |
|
||||
LanguageModeField::encode(scope->language_mode()) |
|
||||
DeclarationScopeField::encode(scope->is_declaration_scope()) |
|
||||
ReceiverVariableField::encode(receiver_info) |
|
||||
HasNewTargetField::encode(has_new_target) |
|
||||
FunctionVariableField::encode(function_name_info) |
|
||||
AsmModuleField::encode(asm_module) |
|
||||
AsmFunctionField::encode(asm_function) |
|
||||
HasSimpleParametersField::encode(has_simple_parameters) |
|
||||
FunctionKindField::encode(function_kind) |
|
||||
HasOuterScopeInfoField::encode(has_outer_scope_info) |
|
||||
IsDebugEvaluateScopeField::encode(scope->is_debug_evaluate_scope());
|
||||
scope_info->SetFlags(flags);
|
||||
|
||||
scope_info->SetParameterCount(parameter_count);
|
||||
@ -302,7 +304,8 @@ Handle<ScopeInfo> ScopeInfo::CreateForWithScope(
|
||||
FunctionVariableField::encode(NONE) | AsmModuleField::encode(false) |
|
||||
AsmFunctionField::encode(false) | HasSimpleParametersField::encode(true) |
|
||||
FunctionKindField::encode(kNormalFunction) |
|
||||
HasOuterScopeInfoField::encode(has_outer_scope_info);
|
||||
HasOuterScopeInfoField::encode(has_outer_scope_info) |
|
||||
IsDebugEvaluateScopeField::encode(false);
|
||||
scope_info->SetFlags(flags);
|
||||
|
||||
scope_info->SetParameterCount(0);
|
||||
@ -355,7 +358,8 @@ Handle<ScopeInfo> ScopeInfo::CreateGlobalThisBinding(Isolate* isolate) {
|
||||
AsmModuleField::encode(false) | AsmFunctionField::encode(false) |
|
||||
HasSimpleParametersField::encode(has_simple_parameters) |
|
||||
FunctionKindField::encode(FunctionKind::kNormalFunction) |
|
||||
HasOuterScopeInfoField::encode(has_outer_scope_info);
|
||||
HasOuterScopeInfoField::encode(has_outer_scope_info) |
|
||||
IsDebugEvaluateScopeField::encode(false);
|
||||
scope_info->SetFlags(flags);
|
||||
scope_info->SetParameterCount(parameter_count);
|
||||
scope_info->SetStackLocalCount(stack_local_count);
|
||||
@ -491,6 +495,23 @@ bool ScopeInfo::HasOuterScopeInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
bool ScopeInfo::IsDebugEvaluateScope() {
|
||||
if (length() > 0) {
|
||||
return IsDebugEvaluateScopeField::decode(Flags());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ScopeInfo::SetIsDebugEvaluateScope() {
|
||||
if (length() > 0) {
|
||||
DCHECK_EQ(scope_type(), WITH_SCOPE);
|
||||
SetFlags(Flags() | IsDebugEvaluateScopeField::encode(true));
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
bool ScopeInfo::HasHeapAllocatedLocals() {
|
||||
if (length() > 0) {
|
||||
return ContextLocalCount() > 0;
|
||||
|
@ -409,6 +409,7 @@ class Scope: public ZoneObject {
|
||||
// Retrieve `IsSimpleParameterList` of current or outer function.
|
||||
bool HasSimpleParameters();
|
||||
void set_is_debug_evaluate_scope() { is_debug_evaluate_scope_ = true; }
|
||||
bool is_debug_evaluate_scope() const { return is_debug_evaluate_scope_; }
|
||||
|
||||
protected:
|
||||
explicit Scope(Zone* zone);
|
||||
|
@ -209,14 +209,13 @@ DebugEvaluate::ContextBuilder::ContextBuilder(Isolate* isolate,
|
||||
}
|
||||
|
||||
for (int i = context_chain_.length() - 1; i >= 0; i--) {
|
||||
Handle<ScopeInfo> scope_info(ScopeInfo::CreateForWithScope(
|
||||
isolate, evaluation_context_->IsNativeContext()
|
||||
? Handle<ScopeInfo>::null()
|
||||
: Handle<ScopeInfo>(evaluation_context_->scope_info())));
|
||||
scope_info->SetIsDebugEvaluateScope();
|
||||
evaluation_context_ = factory->NewDebugEvaluateContext(
|
||||
evaluation_context_,
|
||||
ScopeInfo::CreateForWithScope(
|
||||
isolate,
|
||||
evaluation_context_->IsNativeContext()
|
||||
? Handle<ScopeInfo>::null()
|
||||
: Handle<ScopeInfo>(evaluation_context_->scope_info())),
|
||||
context_chain_[i].materialized_object,
|
||||
evaluation_context_, scope_info, context_chain_[i].materialized_object,
|
||||
context_chain_[i].wrapped_context, context_chain_[i].whitelist);
|
||||
}
|
||||
}
|
||||
|
@ -844,6 +844,7 @@ Handle<Context> Factory::NewDebugEvaluateContext(Handle<Context> previous,
|
||||
Handle<Context> wrapped,
|
||||
Handle<StringSet> whitelist) {
|
||||
STATIC_ASSERT(Context::WHITE_LIST_INDEX == Context::MIN_CONTEXT_SLOTS + 1);
|
||||
DCHECK(scope_info->IsDebugEvaluateScope());
|
||||
Handle<ContextExtension> context_extension = NewContextExtension(
|
||||
scope_info, extension.is_null() ? Handle<Object>::cast(undefined_value())
|
||||
: Handle<Object>::cast(extension));
|
||||
|
@ -4394,6 +4394,13 @@ class ScopeInfo : public FixedArray {
|
||||
// Returns true if this ScopeInfo is linked to a outer ScopeInfo.
|
||||
bool HasOuterScopeInfo();
|
||||
|
||||
// Returns true if this ScopeInfo was created for a debug-evaluate scope.
|
||||
bool IsDebugEvaluateScope();
|
||||
|
||||
// Can be used to mark a ScopeInfo that looks like a with-scope as actually
|
||||
// being a debug-evaluate scope.
|
||||
void SetIsDebugEvaluateScope();
|
||||
|
||||
// Return the outer ScopeInfo if present.
|
||||
ScopeInfo* OuterScopeInfo();
|
||||
|
||||
@ -4525,6 +4532,8 @@ class ScopeInfo : public FixedArray {
|
||||
: public BitField<FunctionKind, HasSimpleParametersField::kNext, 9> {};
|
||||
class HasOuterScopeInfoField
|
||||
: public BitField<bool, FunctionKindField::kNext, 1> {};
|
||||
class IsDebugEvaluateScopeField
|
||||
: public BitField<bool, HasOuterScopeInfoField::kNext, 1> {};
|
||||
|
||||
// Properties of variables.
|
||||
class VariableModeField : public BitField<VariableMode, 0, 3> {};
|
||||
|
Loading…
Reference in New Issue
Block a user