Commit c3504034 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[parser] Only use write barriers conditionally in ScopeInfo::Create

Change-Id: Ia082e676e2cabab07c99b424f80b91e9459f1d3d
Reviewed-on: https://chromium-review.googlesource.com/c/1430070Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59112}
parent 1bc801a1
......@@ -477,15 +477,10 @@ void ObjectLiteral::BuildBoilerplateDescription(Isolate* isolate) {
has_seen_proto = true;
continue;
}
if (property->is_computed_name()) {
continue;
}
if (property->is_computed_name()) continue;
Literal* key = property->key()->AsLiteral();
if (!key->IsPropertyName()) {
index_keys++;
}
if (!key->IsPropertyName()) index_keys++;
}
Handle<ObjectBoilerplateDescription> boilerplate_description =
......
......@@ -148,8 +148,13 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
? 2 + kModuleVariableEntryLength * module_vars_count
: 0);
Factory* factory = isolate->factory();
Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length);
Handle<ScopeInfo> scope_info_handle =
isolate->factory()->NewScopeInfo(length);
int index = kVariablePartIndex;
{
DisallowHeapAllocation no_gc;
ScopeInfo scope_info = *scope_info_handle;
WriteBarrierMode mode = scope_info->GetWriteBarrierMode(no_gc);
bool has_simple_parameters = false;
bool is_asm_module = false;
......@@ -180,14 +185,13 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
FunctionKindField::encode(function_kind) |
HasOuterScopeInfoField::encode(has_outer_scope_info) |
IsDebugEvaluateScopeField::encode(scope->is_debug_evaluate_scope()) |
ForceContextAllocationField::encode(scope->ForceContextForLanguageMode());
ForceContextAllocationField::encode(
scope->ForceContextForLanguageMode());
scope_info->SetFlags(flags);
scope_info->SetParameterCount(parameter_count);
scope_info->SetContextLocalCount(context_local_count);
int index = kVariablePartIndex;
// Add context locals' names and info, module variables' names and info.
// Context locals are added using their index.
int context_local_base = index;
......@@ -197,8 +201,8 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
for (Variable* var : *scope->locals()) {
switch (var->location()) {
case VariableLocation::CONTEXT: {
// Due to duplicate parameters, context locals aren't guaranteed to come
// in order.
// Due to duplicate parameters, context locals aren't guaranteed to
// come in order.
int local_index = var->index() - Context::MIN_CONTEXT_SLOTS;
DCHECK_LE(0, local_index);
DCHECK_LT(local_index, context_local_count);
......@@ -207,23 +211,23 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
InitFlagField::encode(var->initialization_flag()) |
MaybeAssignedFlagField::encode(var->maybe_assigned()) |
ParameterNumberField::encode(ParameterNumberField::kMax);
scope_info->set(context_local_base + local_index, *var->name());
scope_info->set(context_local_base + local_index, *var->name(), mode);
scope_info->set(context_local_info_base + local_index,
Smi::FromInt(info));
Smi::FromInt(info), mode);
break;
}
case VariableLocation::MODULE: {
scope_info->set(module_var_entry + kModuleVariableNameOffset,
*var->name());
*var->name(), mode);
scope_info->set(module_var_entry + kModuleVariableIndexOffset,
Smi::FromInt(var->index()));
Smi::FromInt(var->index()), mode);
uint32_t properties =
VariableModeField::encode(var->mode()) |
InitFlagField::encode(var->initialization_flag()) |
MaybeAssignedFlagField::encode(var->maybe_assigned()) |
ParameterNumberField::encode(ParameterNumberField::kMax);
scope_info->set(module_var_entry + kModuleVariablePropertiesOffset,
Smi::FromInt(properties));
Smi::FromInt(properties), mode);
module_var_entry += kModuleVariableEntryLength;
break;
}
......@@ -233,13 +237,13 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
}
if (scope->is_declaration_scope()) {
// Mark contexts slots with the parameter number they represent. We walk the
// list of parameters. That can include duplicate entries if a parameter
// name is repeated. By walking upwards, we'll automatically mark the
// context slot with the highest parameter number that uses this variable.
// That will be the parameter number that is represented by the context
// slot. All lower parameters will only be available on the stack through
// the arguments object.
// Mark contexts slots with the parameter number they represent. We walk
// the list of parameters. That can include duplicate entries if a
// parameter name is repeated. By walking upwards, we'll automatically
// mark the context slot with the highest parameter number that uses this
// variable. That will be the parameter number that is represented by the
// context slot. All lower parameters will only be available on the stack
// through the arguments object.
for (int i = 0; i < parameter_count; i++) {
Variable* parameter = scope->AsDeclarationScope()->parameter(i);
if (parameter->location() != VariableLocation::CONTEXT) continue;
......@@ -247,7 +251,7 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
int info_index = context_local_info_base + index;
int info = Smi::ToInt(scope_info->get(info_index));
info = ParameterNumberField::update(info, i);
scope_info->set(info_index, Smi::FromInt(info));
scope_info->set(info_index, Smi::FromInt(info), mode);
}
}
......@@ -257,7 +261,7 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
DCHECK_EQ(index, scope_info->ReceiverInfoIndex());
if (has_receiver) {
int var_index = scope->AsDeclarationScope()->receiver()->index();
scope_info->set(index++, Smi::FromInt(var_index));
scope_info->set(index++, Smi::FromInt(var_index), mode);
// ?? DCHECK(receiver_info != CONTEXT || var_index ==
// scope_info->ContextLength() - 1);
}
......@@ -265,7 +269,6 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
// If present, add the function variable name and its index.
DCHECK_EQ(index, scope_info->FunctionNameInfoIndex());
if (has_function_name) {
DisallowHeapAllocation no_gc;
Variable* var = scope->AsDeclarationScope()->function_var();
int var_index = -1;
Object name = Smi::kZero;
......@@ -273,8 +276,8 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
var_index = var->index();
name = *var->name();
}
scope_info->set(index++, name);
scope_info->set(index++, Smi::FromInt(var_index));
scope_info->set(index++, name, mode);
scope_info->set(index++, Smi::FromInt(var_index), mode);
DCHECK(function_name_info != CONTEXT ||
var_index == scope_info->ContextLength() - 1);
}
......@@ -287,33 +290,34 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
DCHECK_EQ(index, scope_info->PositionInfoIndex());
if (has_position_info) {
scope_info->set(index++, Smi::FromInt(scope->start_position()));
scope_info->set(index++, Smi::FromInt(scope->end_position()));
scope_info->set(index++, Smi::FromInt(scope->start_position()), mode);
scope_info->set(index++, Smi::FromInt(scope->end_position()), mode);
}
// If present, add the outer scope info.
DCHECK(index == scope_info->OuterScopeInfoIndex());
if (has_outer_scope_info) {
scope_info->set(index++, *outer_scope.ToHandleChecked());
scope_info->set(index++, *outer_scope.ToHandleChecked(), mode);
}
}
// Module-specific information (only for module scopes).
if (scope->is_module_scope()) {
Handle<ModuleInfo> module_info =
ModuleInfo::New(isolate, zone, scope->AsModuleScope()->module());
DCHECK_EQ(index, scope_info->ModuleInfoIndex());
scope_info->set(index++, *module_info);
DCHECK_EQ(index, scope_info->ModuleVariableCountIndex());
scope_info->set(index++, Smi::FromInt(module_vars_count));
DCHECK_EQ(index, scope_info->ModuleVariablesIndex());
DCHECK_EQ(index, scope_info_handle->ModuleInfoIndex());
scope_info_handle->set(index++, *module_info);
DCHECK_EQ(index, scope_info_handle->ModuleVariableCountIndex());
scope_info_handle->set(index++, Smi::FromInt(module_vars_count));
DCHECK_EQ(index, scope_info_handle->ModuleVariablesIndex());
// The variable entries themselves have already been written above.
index += kModuleVariableEntryLength * module_vars_count;
}
DCHECK_EQ(index, scope_info->length());
DCHECK_EQ(scope->num_parameters(), scope_info->ParameterCount());
DCHECK_EQ(scope->num_heap_slots(), scope_info->ContextLength());
return scope_info;
DCHECK_EQ(index, scope_info_handle->length());
DCHECK_EQ(scope->num_parameters(), scope_info_handle->ParameterCount());
DCHECK_EQ(scope->num_heap_slots(), scope_info_handle->ContextLength());
return scope_info_handle;
}
// static
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment