Index: src/scopeinfo.cc |
diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc |
index d62bc4129588196d3f3faf6d7c1fd035b39bbaa6..4e07e83cf498299579d3e1834d513c6a55c3de21 100644 |
--- a/src/scopeinfo.cc |
+++ b/src/scopeinfo.cc |
@@ -18,9 +18,14 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, |
// Collect stack and context locals. |
ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone); |
ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone); |
- scope->CollectStackAndContextLocals(&stack_locals, &context_locals); |
+ ZoneList<Variable*> strong_mode_free_variables(0, zone); |
+ |
+ scope->CollectStackAndContextLocals(&stack_locals, &context_locals, |
+ &strong_mode_free_variables); |
const int stack_local_count = stack_locals.length(); |
const int context_local_count = context_locals.length(); |
+ const int strong_mode_free_variable_count = |
+ strong_mode_free_variables.length(); |
// Make sure we allocate the correct amount. |
DCHECK(scope->StackLocalCount() == stack_local_count); |
DCHECK(scope->ContextLocalCount() == context_local_count); |
@@ -49,9 +54,10 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, |
const bool has_function_name = function_name_info != NONE; |
const int parameter_count = scope->num_parameters(); |
- const int length = kVariablePartIndex |
- + parameter_count + stack_local_count + 2 * context_local_count |
- + (has_function_name ? 2 : 0); |
+ const int length = kVariablePartIndex + parameter_count + stack_local_count + |
+ 2 * context_local_count + |
+ 3 * strong_mode_free_variable_count + |
+ (has_function_name ? 2 : 0); |
Factory* factory = isolate->factory(); |
Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); |
@@ -71,6 +77,7 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, |
scope_info->SetParameterCount(parameter_count); |
scope_info->SetStackLocalCount(stack_local_count); |
scope_info->SetContextLocalCount(context_local_count); |
+ scope_info->SetStrongModeFreeVariableCount(strong_mode_free_variable_count); |
int index = kVariablePartIndex; |
// Add parameters. |
@@ -113,6 +120,31 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, |
scope_info->set(index++, Smi::FromInt(value)); |
} |
+ DCHECK(index == scope_info->StrongModeFreeVariableNameEntriesIndex()); |
+ for (int i = 0; i < strong_mode_free_variable_count; ++i) { |
+ scope_info->set(index++, *strong_mode_free_variables[i]->name()); |
+ } |
+ |
+ DCHECK(index == scope_info->StrongModeFreeVariablePositionEntriesIndex()); |
+ for (int i = 0; i < strong_mode_free_variable_count; ++i) { |
+ int start_position = |
+ strong_mode_free_variables[i]->strong_mode_reference_start_position(); |
+ if (Smi::IsValid(start_position)) { |
Dmitry Lomov (no reviews)
2015/03/24 14:51:46
Factory::NewNumberFromInt does this.
marja
2015/03/24 16:46:14
Done.
|
+ scope_info->set(index++, Smi::FromInt(start_position)); |
+ } else { |
+ Handle<HeapNumber> number = factory->NewHeapNumber(start_position); |
+ scope_info->set(index++, *number); |
+ } |
+ int end_position = |
+ strong_mode_free_variables[i]->strong_mode_reference_end_position(); |
+ if (Smi::IsValid(end_position)) { |
+ scope_info->set(index++, Smi::FromInt(end_position)); |
+ } else { |
+ Handle<HeapNumber> number = factory->NewHeapNumber(end_position); |
+ scope_info->set(index++, *number); |
+ } |
+ } |
+ |
// If present, add the function variable name and its index. |
DCHECK(index == scope_info->FunctionNameEntryIndex()); |
if (has_function_name) { |
@@ -285,6 +317,38 @@ bool ScopeInfo::LocalIsSynthetic(int var) { |
} |
+String* ScopeInfo::StrongModeFreeVariableName(int var) { |
+ DCHECK(0 <= var && var < StrongModeFreeVariableCount()); |
+ int info_index = StrongModeFreeVariableNameEntriesIndex() + var; |
+ return String::cast(get(info_index)); |
+} |
+ |
+ |
+namespace { |
+ |
+int IntFromSmiOrHeapNumber(Object* value) { |
+ if (value->IsSmi()) return Smi::cast(value)->value(); |
+ DCHECK(value->IsHeapNumber()); |
+ return static_cast<int>(HeapNumber::cast(value)->value()); |
+} |
+ |
+} // namespace |
+ |
+ |
+int ScopeInfo::StrongModeFreeVariableStartPosition(int var) { |
+ DCHECK(0 <= var && var < StrongModeFreeVariableCount()); |
+ int info_index = StrongModeFreeVariablePositionEntriesIndex() + var * 2; |
+ return IntFromSmiOrHeapNumber(get(info_index)); |
+} |
+ |
+ |
+int ScopeInfo::StrongModeFreeVariableEndPosition(int var) { |
+ DCHECK(0 <= var && var < StrongModeFreeVariableCount()); |
+ int info_index = StrongModeFreeVariablePositionEntriesIndex() + var * 2 + 1; |
+ return IntFromSmiOrHeapNumber(get(info_index)); |
+} |
+ |
+ |
int ScopeInfo::StackSlotIndex(String* name) { |
DCHECK(name->IsInternalizedString()); |
if (length() > 0) { |
@@ -432,11 +496,23 @@ int ScopeInfo::ContextLocalInfoEntriesIndex() { |
} |
-int ScopeInfo::FunctionNameEntryIndex() { |
+int ScopeInfo::StrongModeFreeVariableNameEntriesIndex() { |
return ContextLocalInfoEntriesIndex() + ContextLocalCount(); |
} |
+int ScopeInfo::StrongModeFreeVariablePositionEntriesIndex() { |
+ return StrongModeFreeVariableNameEntriesIndex() + |
+ StrongModeFreeVariableCount(); |
+} |
+ |
+ |
+int ScopeInfo::FunctionNameEntryIndex() { |
+ return StrongModeFreeVariablePositionEntriesIndex() + |
+ 2 * StrongModeFreeVariableCount(); |
+} |
+ |
+ |
int ContextSlotCache::Hash(Object* data, String* name) { |
// Uses only lower 32 bits if pointers are larger. |
uintptr_t addr_hash = |