| Index: src/ast/scopeinfo.cc
|
| diff --git a/src/ast/scopeinfo.cc b/src/ast/scopeinfo.cc
|
| index 3dd7c870695cbd78cbf50074ef6dd649b90b6260..9df15598723943eee7f9c0cae9bc84e1cb8fc984 100644
|
| --- a/src/ast/scopeinfo.cc
|
| +++ b/src/ast/scopeinfo.cc
|
| @@ -14,13 +14,11 @@ namespace internal {
|
|
|
| Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone,
|
| Scope* scope) {
|
| - // Collect stack and context locals.
|
| + // Collect variables.
|
| ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone);
|
| ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone);
|
| ZoneList<Variable*> context_globals(scope->ContextGlobalCount(), zone);
|
| -
|
| - scope->CollectStackAndContextLocals(&stack_locals, &context_locals,
|
| - &context_globals);
|
| + scope->CollectVariables(&stack_locals, &context_locals, &context_globals);
|
| const int stack_local_count = stack_locals.length();
|
| const int context_local_count = context_locals.length();
|
| const int context_global_count = context_globals.length();
|
| @@ -163,10 +161,9 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone,
|
| DCHECK(index == scope_info->ContextLocalInfoEntriesIndex());
|
| for (int i = 0; i < context_local_count; ++i) {
|
| Variable* var = context_locals[i];
|
| - uint32_t value =
|
| - ContextLocalMode::encode(var->mode()) |
|
| - ContextLocalInitFlag::encode(var->initialization_flag()) |
|
| - ContextLocalMaybeAssignedFlag::encode(var->maybe_assigned());
|
| + uint32_t value = VariableModeField::encode(var->mode()) |
|
| + InitFlagField::encode(var->initialization_flag()) |
|
| + MaybeAssignedFlagField::encode(var->maybe_assigned());
|
| scope_info->set(index++, Smi::FromInt(value));
|
| }
|
|
|
| @@ -175,10 +172,9 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone,
|
| for (int i = 0; i < context_global_count; ++i) {
|
| Variable* var = context_globals[i];
|
| // TODO(ishell): do we need this kind of info for globals here?
|
| - uint32_t value =
|
| - ContextLocalMode::encode(var->mode()) |
|
| - ContextLocalInitFlag::encode(var->initialization_flag()) |
|
| - ContextLocalMaybeAssignedFlag::encode(var->maybe_assigned());
|
| + uint32_t value = VariableModeField::encode(var->mode()) |
|
| + InitFlagField::encode(var->initialization_flag()) |
|
| + MaybeAssignedFlagField::encode(var->maybe_assigned());
|
| scope_info->set(index++, Smi::FromInt(value));
|
| }
|
|
|
| @@ -259,9 +255,9 @@ Handle<ScopeInfo> ScopeInfo::CreateGlobalThisBinding(Isolate* isolate) {
|
| DCHECK(index == scope_info->ContextLocalNameEntriesIndex());
|
| scope_info->set(index++, *isolate->factory()->this_string());
|
| DCHECK(index == scope_info->ContextLocalInfoEntriesIndex());
|
| - const uint32_t value = ContextLocalMode::encode(CONST) |
|
| - ContextLocalInitFlag::encode(kCreatedInitialized) |
|
| - ContextLocalMaybeAssignedFlag::encode(kNotAssigned);
|
| + const uint32_t value = VariableModeField::encode(CONST) |
|
| + InitFlagField::encode(kCreatedInitialized) |
|
| + MaybeAssignedFlagField::encode(kNotAssigned);
|
| scope_info->set(index++, Smi::FromInt(value));
|
|
|
| // And here we record that this scopeinfo binds a receiver.
|
| @@ -435,7 +431,7 @@ VariableMode ScopeInfo::ContextLocalMode(int var) {
|
| DCHECK(0 <= var && var < ContextLocalCount() + ContextGlobalCount());
|
| int info_index = ContextLocalInfoEntriesIndex() + var;
|
| int value = Smi::cast(get(info_index))->value();
|
| - return ContextLocalMode::decode(value);
|
| + return VariableModeField::decode(value);
|
| }
|
|
|
|
|
| @@ -443,7 +439,7 @@ InitializationFlag ScopeInfo::ContextLocalInitFlag(int var) {
|
| DCHECK(0 <= var && var < ContextLocalCount() + ContextGlobalCount());
|
| int info_index = ContextLocalInfoEntriesIndex() + var;
|
| int value = Smi::cast(get(info_index))->value();
|
| - return ContextLocalInitFlag::decode(value);
|
| + return InitFlagField::decode(value);
|
| }
|
|
|
|
|
| @@ -451,7 +447,7 @@ MaybeAssignedFlag ScopeInfo::ContextLocalMaybeAssignedFlag(int var) {
|
| DCHECK(0 <= var && var < ContextLocalCount() + ContextGlobalCount());
|
| int info_index = ContextLocalInfoEntriesIndex() + var;
|
| int value = Smi::cast(get(info_index))->value();
|
| - return ContextLocalMaybeAssignedFlag::decode(value);
|
| + return MaybeAssignedFlagField::decode(value);
|
| }
|
|
|
| bool ScopeInfo::VariableIsSynthetic(String* name) {
|
| @@ -469,7 +465,7 @@ int ScopeInfo::StackSlotIndex(String* name) {
|
| if (length() > 0) {
|
| int first_slot_index = Smi::cast(get(StackLocalFirstSlotIndex()))->value();
|
| int start = StackLocalEntriesIndex();
|
| - int end = StackLocalEntriesIndex() + StackLocalCount();
|
| + int end = start + StackLocalCount();
|
| for (int i = start; i < end; ++i) {
|
| if (name == get(i)) {
|
| return i - start + first_slot_index;
|
| @@ -485,8 +481,10 @@ int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
|
| InitializationFlag* init_flag,
|
| MaybeAssignedFlag* maybe_assigned_flag) {
|
| DCHECK(name->IsInternalizedString());
|
| - DCHECK(mode != NULL);
|
| - DCHECK(init_flag != NULL);
|
| + DCHECK_NOT_NULL(mode);
|
| + DCHECK_NOT_NULL(init_flag);
|
| + DCHECK_NOT_NULL(maybe_assigned_flag);
|
| +
|
| if (scope_info->length() > 0) {
|
| ContextSlotCache* context_slot_cache =
|
| scope_info->GetIsolate()->context_slot_cache();
|
| @@ -498,8 +496,7 @@ int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
|
| }
|
|
|
| int start = scope_info->ContextLocalNameEntriesIndex();
|
| - int end = scope_info->ContextLocalNameEntriesIndex() +
|
| - scope_info->ContextLocalCount();
|
| + int end = start + scope_info->ContextLocalCount();
|
| for (int i = start; i < end; ++i) {
|
| if (*name == scope_info->get(i)) {
|
| int var = i - start;
|
| @@ -518,17 +515,18 @@ int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
|
| context_slot_cache->Update(scope_info, name, TEMPORARY,
|
| kNeedsInitialization, kNotAssigned, -1);
|
| }
|
| +
|
| return -1;
|
| }
|
|
|
| -
|
| int ScopeInfo::ContextGlobalSlotIndex(Handle<ScopeInfo> scope_info,
|
| Handle<String> name, VariableMode* mode,
|
| InitializationFlag* init_flag,
|
| MaybeAssignedFlag* maybe_assigned_flag) {
|
| DCHECK(name->IsInternalizedString());
|
| - DCHECK(mode != NULL);
|
| - DCHECK(init_flag != NULL);
|
| + DCHECK_NOT_NULL(mode);
|
| + DCHECK_NOT_NULL(init_flag);
|
| + DCHECK_NOT_NULL(maybe_assigned_flag);
|
| if (scope_info->length() > 0) {
|
| // This is to ensure that ContextLocalMode() and co. queries would work.
|
| DCHECK_EQ(scope_info->ContextGlobalNameEntriesIndex(),
|
| @@ -536,8 +534,7 @@ int ScopeInfo::ContextGlobalSlotIndex(Handle<ScopeInfo> scope_info,
|
| scope_info->ContextLocalCount());
|
| int base = scope_info->ContextLocalNameEntriesIndex();
|
| int start = scope_info->ContextGlobalNameEntriesIndex();
|
| - int end = scope_info->ContextGlobalNameEntriesIndex() +
|
| - scope_info->ContextGlobalCount();
|
| + int end = start + scope_info->ContextGlobalCount();
|
| for (int i = start; i < end; ++i) {
|
| if (*name == scope_info->get(i)) {
|
| int var = i - base;
|
| @@ -571,7 +568,7 @@ int ScopeInfo::ParameterIndex(String* name) {
|
| // inside a function (and thus we need to look
|
| // at the last index). Was bug# 1110337.
|
| int start = ParameterEntriesIndex();
|
| - int end = ParameterEntriesIndex() + ParameterCount();
|
| + int end = start + ParameterCount();
|
| for (int i = end - 1; i >= start; --i) {
|
| if (name == get(i)) {
|
| return i - start;
|
|
|