@@ -63,20 +63,14 @@ bool ScopeInfo::Equals(ScopeInfo* other) const {
6363Handle<ScopeInfo> ScopeInfo::Create (Isolate* isolate, Zone* zone, Scope* scope,
6464 MaybeHandle<ScopeInfo> outer_scope) {
6565 // Collect variables.
66- int stack_local_count = 0 ;
6766 int context_local_count = 0 ;
6867 int module_vars_count = 0 ;
6968 // Stack allocated block scope variables are allocated in the parent
7069 // declaration scope, but are recorded in the block scope's scope info. First
7170 // slot index indicates at which offset a particular scope starts in the
7271 // parent declaration scope.
73- int first_slot_index = 0 ;
7472 for (Variable* var : *scope->locals ()) {
7573 switch (var->location ()) {
76- case VariableLocation::LOCAL:
77- if (stack_local_count == 0 ) first_slot_index = var->index ();
78- stack_local_count++;
79- break ;
8074 case VariableLocation::CONTEXT:
8175 context_local_count++;
8276 break ;
@@ -146,8 +140,7 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
146140 const int parameter_count = scope->num_parameters ();
147141 const bool has_outer_scope_info = !outer_scope.is_null ();
148142 const int length = kVariablePartIndex + parameter_count +
149- (1 + stack_local_count) + 2 * context_local_count +
150- (has_receiver ? 1 : 0 ) +
143+ 2 * context_local_count + (has_receiver ? 1 : 0 ) +
151144 (has_function_name ? kFunctionNameEntries : 0 ) +
152145 (has_inferred_function_name ? 1 : 0 ) +
153146 (has_position_info ? kPositionInfoEntries : 0 ) +
@@ -191,7 +184,6 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
191184 scope_info->SetFlags (flags);
192185
193186 scope_info->SetParameterCount (parameter_count);
194- scope_info->SetStackLocalCount (stack_local_count);
195187 scope_info->SetContextLocalCount (context_local_count);
196188
197189 int index = kVariablePartIndex ;
@@ -204,28 +196,14 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
204196 }
205197 }
206198
207- // Add stack locals' names, context locals' names and info, module variables'
208- // names and info. We are assuming that the stack locals' slots are allocated
209- // in increasing order, so we can simply add them to the ScopeInfo object.
199+ // Add context locals' names and info, module variables' names and info.
210200 // Context locals are added using their index.
211- DCHECK_EQ (index, scope_info->StackLocalFirstSlotIndex ());
212- scope_info->set (index++, Smi::FromInt (first_slot_index));
213- DCHECK_EQ (index, scope_info->StackLocalNamesIndex ());
214-
215- int stack_local_base = index;
216- int context_local_base = stack_local_base + stack_local_count;
201+ int context_local_base = index;
217202 int context_local_info_base = context_local_base + context_local_count;
218203 int module_var_entry = scope_info->ModuleVariablesIndex ();
219204
220205 for (Variable* var : *scope->locals ()) {
221206 switch (var->location ()) {
222- case VariableLocation::LOCAL: {
223- int local_index = var->index () - first_slot_index;
224- DCHECK_LE (0 , local_index);
225- DCHECK_LT (local_index, stack_local_count);
226- scope_info->set (stack_local_base + local_index, *var->name ());
227- break ;
228- }
229207 case VariableLocation::CONTEXT: {
230208 // Due to duplicate parameters, context locals aren't guaranteed to come
231209 // in order.
@@ -259,7 +237,7 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
259237 }
260238 }
261239
262- index += stack_local_count + 2 * context_local_count;
240+ index += 2 * context_local_count;
263241
264242 // If the receiver is allocated, add its index.
265243 DCHECK_EQ (index, scope_info->ReceiverInfoIndex ());
@@ -328,7 +306,7 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
328306Handle<ScopeInfo> ScopeInfo::CreateForWithScope (
329307 Isolate* isolate, MaybeHandle<ScopeInfo> outer_scope) {
330308 const bool has_outer_scope_info = !outer_scope.is_null ();
331- const int length = kVariablePartIndex + 1 + (has_outer_scope_info ? 1 : 0 );
309+ const int length = kVariablePartIndex + (has_outer_scope_info ? 1 : 0 );
332310
333311 Factory* factory = isolate->factory ();
334312 Handle<ScopeInfo> scope_info = factory->NewScopeInfo (length);
@@ -347,14 +325,10 @@ Handle<ScopeInfo> ScopeInfo::CreateForWithScope(
347325 scope_info->SetFlags (flags);
348326
349327 scope_info->SetParameterCount (0 );
350- scope_info->SetStackLocalCount (0 );
351328 scope_info->SetContextLocalCount (0 );
352329
353330 int index = kVariablePartIndex ;
354331 DCHECK_EQ (index, scope_info->ParameterNamesIndex ());
355- DCHECK_EQ (index, scope_info->StackLocalFirstSlotIndex ());
356- scope_info->set (index++, Smi::kZero );
357- DCHECK_EQ (index, scope_info->StackLocalNamesIndex ());
358332 DCHECK_EQ (index, scope_info->ReceiverInfoIndex ());
359333 DCHECK_EQ (index, scope_info->FunctionNameInfoIndex ());
360334 DCHECK_EQ (index, scope_info->InferredFunctionNameIndex ());
@@ -386,15 +360,13 @@ Handle<ScopeInfo> ScopeInfo::CreateForBootstrapping(Isolate* isolate,
386360 DCHECK (type == SCRIPT_SCOPE || type == FUNCTION_SCOPE);
387361
388362 const int parameter_count = 0 ;
389- const int stack_local_count = 0 ;
390363 const bool is_empty_function = type == FUNCTION_SCOPE;
391364 const int context_local_count = is_empty_function ? 0 : 1 ;
392365 const bool has_receiver = !is_empty_function;
393366 const bool has_inferred_function_name = is_empty_function;
394367 const bool has_position_info = true ;
395368 const int length = kVariablePartIndex + parameter_count +
396- (1 + stack_local_count) + 2 * context_local_count +
397- (has_receiver ? 1 : 0 ) +
369+ 2 * context_local_count + (has_receiver ? 1 : 0 ) +
398370 (is_empty_function ? kFunctionNameEntries : 0 ) +
399371 (has_inferred_function_name ? 1 : 0 ) +
400372 (has_position_info ? kPositionInfoEntries : 0 );
@@ -417,14 +389,9 @@ Handle<ScopeInfo> ScopeInfo::CreateForBootstrapping(Isolate* isolate,
417389 IsDebugEvaluateScopeField::encode (false );
418390 scope_info->SetFlags (flags);
419391 scope_info->SetParameterCount (parameter_count);
420- scope_info->SetStackLocalCount (stack_local_count);
421392 scope_info->SetContextLocalCount (context_local_count);
422393
423394 int index = kVariablePartIndex ;
424- const int first_slot_index = 0 ;
425- DCHECK_EQ (index, scope_info->StackLocalFirstSlotIndex ());
426- scope_info->set (index++, Smi::FromInt (first_slot_index));
427- DCHECK_EQ (index, scope_info->StackLocalNamesIndex ());
428395
429396 // Here we add info for context-allocated "this".
430397 DCHECK_EQ (index, scope_info->ContextLocalNamesIndex ());
@@ -497,19 +464,6 @@ bool ScopeInfo::is_declaration_scope() const {
497464 return DeclarationScopeField::decode (Flags ());
498465}
499466
500- int ScopeInfo::LocalCount () const {
501- return StackLocalCount () + ContextLocalCount ();
502- }
503-
504- int ScopeInfo::StackSlotCount () const {
505- if (length () > 0 ) {
506- bool function_name_stack_slot =
507- FunctionVariableField::decode (Flags ()) == STACK;
508- return StackLocalCount () + (function_name_stack_slot ? 1 : 0 );
509- }
510- return 0 ;
511- }
512-
513467int ScopeInfo::ContextLength () const {
514468 if (length () > 0 ) {
515469 int context_locals = ContextLocalCount ();
@@ -659,29 +613,6 @@ String* ScopeInfo::ParameterName(int var) const {
659613 return String::cast (get (info_index));
660614}
661615
662- String* ScopeInfo::LocalName (int var) const {
663- DCHECK_LE (0 , var);
664- DCHECK_LT (var, LocalCount ());
665- DCHECK (StackLocalNamesIndex () + StackLocalCount () ==
666- ContextLocalNamesIndex ());
667- int info_index = StackLocalNamesIndex () + var;
668- return String::cast (get (info_index));
669- }
670-
671- String* ScopeInfo::StackLocalName (int var) const {
672- DCHECK_LE (0 , var);
673- DCHECK_LT (var, StackLocalCount ());
674- int info_index = StackLocalNamesIndex () + var;
675- return String::cast (get (info_index));
676- }
677-
678- int ScopeInfo::StackLocalIndex (int var) const {
679- DCHECK_LE (0 , var);
680- DCHECK_LT (var, StackLocalCount ());
681- int first_slot_index = Smi::ToInt (get (StackLocalFirstSlotIndex ()));
682- return first_slot_index + var;
683- }
684-
685616String* ScopeInfo::ContextLocalName (int var) const {
686617 DCHECK_LE (0 , var);
687618 DCHECK_LT (var, ContextLocalCount ());
@@ -723,20 +654,6 @@ bool ScopeInfo::VariableIsSynthetic(String* name) {
723654 name->Equals (name->GetHeap ()->this_string ());
724655}
725656
726- int ScopeInfo::StackSlotIndex (String* name) const {
727- DCHECK (name->IsInternalizedString ());
728- if (length () == 0 ) return -1 ;
729- int first_slot_index = Smi::ToInt (get (StackLocalFirstSlotIndex ()));
730- int start = StackLocalNamesIndex ();
731- int end = start + StackLocalCount ();
732- for (int i = start; i < end; ++i) {
733- if (name == get (i)) {
734- return i - start + first_slot_index;
735- }
736- }
737- return -1 ;
738- }
739-
740657int ScopeInfo::ModuleIndex (Handle<String> name, VariableMode* mode,
741658 InitializationFlag* init_flag,
742659 MaybeAssignedFlag* maybe_assigned_flag) {
@@ -850,16 +767,8 @@ int ScopeInfo::ParameterNamesIndex() const {
850767 return kVariablePartIndex ;
851768}
852769
853- int ScopeInfo::StackLocalFirstSlotIndex () const {
854- return ParameterNamesIndex () + ParameterCount ();
855- }
856-
857- int ScopeInfo::StackLocalNamesIndex () const {
858- return StackLocalFirstSlotIndex () + 1 ;
859- }
860-
861770int ScopeInfo::ContextLocalNamesIndex () const {
862- return StackLocalNamesIndex () + StackLocalCount ();
771+ return ParameterNamesIndex () + ParameterCount ();
863772}
864773
865774int ScopeInfo::ContextLocalInfosIndex () const {
0 commit comments