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

Side by Side Diff: src/contexts.cc

Issue 1281883002: Group lexical context variables for faster look up. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: added comments and TODOs Created 5 years, 4 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/contexts.h ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/scopeinfo.h" 9 #include "src/scopeinfo.h"
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 if (slot_index >= 0 && result->location == VariableLocation::CONTEXT) { 49 if (slot_index >= 0 && result->location == VariableLocation::CONTEXT) {
50 result->context_index = i; 50 result->context_index = i;
51 result->slot_index = slot_index; 51 result->slot_index = slot_index;
52 return true; 52 return true;
53 } 53 }
54 } 54 }
55 return false; 55 return false;
56 } 56 }
57 57
58 58
59 bool ScriptContextTable::LookupLexical(Handle<ScriptContextTable> table,
60 Handle<String> name) {
61 for (int i = 0; i < table->used(); i++) {
62 Handle<Context> context = GetContext(table, i);
63 DCHECK(context->IsScriptContext());
64 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension()));
65 int slot_index = ScopeInfo::LexicalContextSlotIndex(scope_info, name);
66 if (slot_index >= 0) return true;
67 }
68 return false;
69 }
70
71
59 Context* Context::declaration_context() { 72 Context* Context::declaration_context() {
60 Context* current = this; 73 Context* current = this;
61 while (!current->IsFunctionContext() && !current->IsNativeContext() && 74 while (!current->IsFunctionContext() && !current->IsNativeContext() &&
62 !current->IsScriptContext()) { 75 !current->IsScriptContext()) {
63 current = current->previous(); 76 current = current->previous();
64 DCHECK(current->closure() == closure()); 77 DCHECK(current->closure() == closure());
65 } 78 }
66 return current; 79 return current;
67 } 80 }
68 81
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // During bootstrapping we allow all objects to pass as global 524 // During bootstrapping we allow all objects to pass as global
512 // objects. This is necessary to fix circular dependencies. 525 // objects. This is necessary to fix circular dependencies.
513 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || 526 return isolate->heap()->gc_state() != Heap::NOT_IN_GC ||
514 isolate->bootstrapper()->IsActive() || 527 isolate->bootstrapper()->IsActive() ||
515 object->IsGlobalObject(); 528 object->IsGlobalObject();
516 } 529 }
517 #endif 530 #endif
518 531
519 } // namespace internal 532 } // namespace internal
520 } // namespace v8 533 } // namespace v8
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698