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

Unified Diff: src/scopes.cc

Issue 6646017: Rebuild scope chain from serialized scope info before parsing lazily. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index a03dbdde9691c7129e9cc1622528b2b3d06c453d..cffbef6d1f8455bd89eb1caabde85d669f8d5331 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -148,13 +148,14 @@ Scope::Scope(Scope* inner_scope, SerializedScopeInfo* scope_info)
unresolved_(16),
decls_(4) {
ASSERT(scope_info != NULL);
- SetDefaults(FUNCTION_SCOPE, inner_scope->outer_scope(), scope_info);
+ SetDefaults(FUNCTION_SCOPE, NULL, scope_info);
ASSERT(resolved());
- InsertAfterScope(inner_scope);
if (scope_info->HasHeapAllocatedLocals()) {
num_heap_slots_ = scope_info_->NumberOfContextSlots();
}
+ AddInnerScope(inner_scope);
+
// This scope's arguments shadow (if present) is context-allocated if an inner
// scope accesses this one's parameters. Allocate the arguments_shadow_
// variable if necessary.
@@ -175,29 +176,39 @@ Scope::Scope(Scope* inner_scope, SerializedScopeInfo* scope_info)
}
+Scope* Scope::DeserializeScopeChain(CompilationInfo* info,
+ Scope* global_scope) {
+ ASSERT(!info->closure().is_null());
+ // If we have a serialized scope info, reuse it.
+ Scope* innermost_scope = NULL;
+ Scope* scope = NULL;
+
+ SerializedScopeInfo* scope_info = info->closure()->shared()->scope_info();
+ if (scope_info != SerializedScopeInfo::Empty()) {
+ JSFunction* current = *info->closure();
+ do {
+ current = current->context()->closure();
+ SerializedScopeInfo* scope_info = current->shared()->scope_info();
+ if (scope_info != SerializedScopeInfo::Empty()) {
+ scope = new Scope(scope, scope_info);
+ if (innermost_scope == NULL) innermost_scope = scope;
+ } else {
+ ASSERT(current->context()->IsGlobalContext());
+ }
+ } while (!current->context()->IsGlobalContext());
+ }
+
+ global_scope->AddInnerScope(scope);
+ if (innermost_scope == NULL) innermost_scope = global_scope;
+
+ return innermost_scope;
+}
+
bool Scope::Analyze(CompilationInfo* info) {
ASSERT(info->function() != NULL);
Scope* top = info->function()->scope();
- // If we have a serialized scope info, reuse it.
- if (!info->closure().is_null()) {
- SerializedScopeInfo* scope_info = info->closure()->shared()->scope_info();
- if (scope_info != SerializedScopeInfo::Empty()) {
- Scope* scope = top;
- JSFunction* current = *info->closure();
- do {
- current = current->context()->closure();
- SerializedScopeInfo* scope_info = current->shared()->scope_info();
- if (scope_info != SerializedScopeInfo::Empty()) {
- scope = new Scope(scope, scope_info);
- } else {
- ASSERT(current->context()->IsGlobalContext());
- }
- } while (!current->context()->IsGlobalContext());
- }
- }
-
while (top->outer_scope() != NULL) top = top->outer_scope();
top->AllocateVariables(info->calling_context());
« no previous file with comments | « src/scopes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698