Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: src/scopes.cc

Issue 1335633002: Do not look for the slot in the ScopeInfo's global range when it's not necessary. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Cleanup Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/scopeinfo.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/scopes.h" 5 #include "src/scopes.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 Handle<String> name_handle = name->string(); 387 Handle<String> name_handle = name->string();
388 // The Scope is backed up by ScopeInfo. This means it cannot operate in a 388 // The Scope is backed up by ScopeInfo. This means it cannot operate in a
389 // heap-independent mode, and all strings must be internalized immediately. So 389 // heap-independent mode, and all strings must be internalized immediately. So
390 // it's ok to get the Handle<String> here. 390 // it's ok to get the Handle<String> here.
391 // If we have a serialized scope info, we might find the variable there. 391 // If we have a serialized scope info, we might find the variable there.
392 // There should be no local slot with the given name. 392 // There should be no local slot with the given name.
393 DCHECK(scope_info_->StackSlotIndex(*name_handle) < 0 || is_block_scope()); 393 DCHECK(scope_info_->StackSlotIndex(*name_handle) < 0 || is_block_scope());
394 394
395 // Check context slot lookup. 395 // Check context slot lookup.
396 VariableMode mode; 396 VariableMode mode;
397 VariableLocation location; 397 VariableLocation location = VariableLocation::CONTEXT;
398 InitializationFlag init_flag; 398 InitializationFlag init_flag;
399 MaybeAssignedFlag maybe_assigned_flag; 399 MaybeAssignedFlag maybe_assigned_flag;
400 int index = 400 int index = ScopeInfo::ContextSlotIndex(scope_info_, name_handle, &mode,
401 ScopeInfo::ContextSlotIndex(scope_info_, name_handle, &mode, &location, 401 &init_flag, &maybe_assigned_flag);
402 &init_flag, &maybe_assigned_flag); 402 if (index < 0) {
403 location = VariableLocation::GLOBAL;
404 index = ScopeInfo::ContextGlobalSlotIndex(scope_info_, name_handle, &mode,
405 &init_flag, &maybe_assigned_flag);
406 }
403 if (index < 0) { 407 if (index < 0) {
404 // Check parameters. 408 // Check parameters.
405 index = scope_info_->ParameterIndex(*name_handle); 409 index = scope_info_->ParameterIndex(*name_handle);
406 if (index < 0) return NULL; 410 if (index < 0) return NULL;
407 411
408 mode = DYNAMIC; 412 mode = DYNAMIC;
409 location = VariableLocation::LOOKUP; 413 location = VariableLocation::LOOKUP;
410 init_flag = kCreatedInitialized; 414 init_flag = kCreatedInitialized;
411 // Be conservative and flag parameters as maybe assigned. Better information 415 // Be conservative and flag parameters as maybe assigned. Better information
412 // would require ScopeInfo to serialize the maybe_assigned bit also for 416 // would require ScopeInfo to serialize the maybe_assigned bit also for
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1625 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1622 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1626 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1623 (is_function_var_in_context ? 1 : 0); 1627 (is_function_var_in_context ? 1 : 0);
1624 } 1628 }
1625 1629
1626 1630
1627 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1631 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1628 1632
1629 } // namespace internal 1633 } // namespace internal
1630 } // namespace v8 1634 } // namespace v8
OLDNEW
« no previous file with comments | « src/scopeinfo.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698