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

Side by Side Diff: src/scopes.cc

Issue 6664001: [Isolates] Merge (7083,7111] from bleeding_edge. (Closed)
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 unified diff | Download patch
« no previous file with comments | « src/scopes.h ('k') | src/serialize.cc » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 144
145 Scope::Scope(Scope* inner_scope, SerializedScopeInfo* scope_info) 145 Scope::Scope(Scope* inner_scope, SerializedScopeInfo* scope_info)
146 : inner_scopes_(4), 146 : inner_scopes_(4),
147 variables_(), 147 variables_(),
148 temps_(4), 148 temps_(4),
149 params_(4), 149 params_(4),
150 unresolved_(16), 150 unresolved_(16),
151 decls_(4) { 151 decls_(4) {
152 ASSERT(scope_info != NULL); 152 ASSERT(scope_info != NULL);
153 SetDefaults(FUNCTION_SCOPE, inner_scope->outer_scope(), scope_info); 153 SetDefaults(FUNCTION_SCOPE, NULL, scope_info);
154 ASSERT(resolved()); 154 ASSERT(resolved());
155 InsertAfterScope(inner_scope);
156 if (scope_info->HasHeapAllocatedLocals()) { 155 if (scope_info->HasHeapAllocatedLocals()) {
157 num_heap_slots_ = scope_info_->NumberOfContextSlots(); 156 num_heap_slots_ = scope_info_->NumberOfContextSlots();
158 } 157 }
159 158
159 AddInnerScope(inner_scope);
160
160 // This scope's arguments shadow (if present) is context-allocated if an inner 161 // This scope's arguments shadow (if present) is context-allocated if an inner
161 // scope accesses this one's parameters. Allocate the arguments_shadow_ 162 // scope accesses this one's parameters. Allocate the arguments_shadow_
162 // variable if necessary. 163 // variable if necessary.
163 Isolate* isolate = Isolate::Current(); 164 Isolate* isolate = Isolate::Current();
164 Variable::Mode mode; 165 Variable::Mode mode;
165 int arguments_shadow_index = 166 int arguments_shadow_index =
166 scope_info_->ContextSlotIndex( 167 scope_info_->ContextSlotIndex(
167 isolate->heap()->arguments_shadow_symbol(), &mode); 168 isolate->heap()->arguments_shadow_symbol(), &mode);
168 if (arguments_shadow_index >= 0) { 169 if (arguments_shadow_index >= 0) {
169 ASSERT(mode == Variable::INTERNAL); 170 ASSERT(mode == Variable::INTERNAL);
170 arguments_shadow_ = new Variable( 171 arguments_shadow_ = new Variable(
171 this, 172 this,
172 isolate->factory()->arguments_shadow_symbol(), 173 isolate->factory()->arguments_shadow_symbol(),
173 Variable::INTERNAL, 174 Variable::INTERNAL,
174 true, 175 true,
175 Variable::ARGUMENTS); 176 Variable::ARGUMENTS);
176 arguments_shadow_->set_rewrite( 177 arguments_shadow_->set_rewrite(
177 new Slot(arguments_shadow_, Slot::CONTEXT, arguments_shadow_index)); 178 new Slot(arguments_shadow_, Slot::CONTEXT, arguments_shadow_index));
178 arguments_shadow_->set_is_used(true); 179 arguments_shadow_->set_is_used(true);
179 } 180 }
180 } 181 }
181 182
182 183
184 Scope* Scope::DeserializeScopeChain(CompilationInfo* info,
185 Scope* global_scope) {
186 ASSERT(!info->closure().is_null());
187 // If we have a serialized scope info, reuse it.
188 Scope* innermost_scope = NULL;
189 Scope* scope = NULL;
190
191 SerializedScopeInfo* scope_info = info->closure()->shared()->scope_info();
192 if (scope_info != SerializedScopeInfo::Empty()) {
193 JSFunction* current = *info->closure();
194 do {
195 current = current->context()->closure();
196 SerializedScopeInfo* scope_info = current->shared()->scope_info();
197 if (scope_info != SerializedScopeInfo::Empty()) {
198 scope = new Scope(scope, scope_info);
199 if (innermost_scope == NULL) innermost_scope = scope;
200 } else {
201 ASSERT(current->context()->IsGlobalContext());
202 }
203 } while (!current->context()->IsGlobalContext());
204 }
205
206 global_scope->AddInnerScope(scope);
207 if (innermost_scope == NULL) innermost_scope = global_scope;
208
209 return innermost_scope;
210 }
211
183 212
184 bool Scope::Analyze(CompilationInfo* info) { 213 bool Scope::Analyze(CompilationInfo* info) {
185 ASSERT(info->function() != NULL); 214 ASSERT(info->function() != NULL);
186 Scope* top = info->function()->scope(); 215 Scope* top = info->function()->scope();
187 216
188 // If we have a serialized scope info, reuse it.
189 if (!info->closure().is_null()) {
190 SerializedScopeInfo* scope_info = info->closure()->shared()->scope_info();
191 if (scope_info != SerializedScopeInfo::Empty()) {
192 Scope* scope = top;
193 JSFunction* current = *info->closure();
194 do {
195 current = current->context()->closure();
196 SerializedScopeInfo* scope_info = current->shared()->scope_info();
197 if (scope_info != SerializedScopeInfo::Empty()) {
198 scope = new Scope(scope, scope_info);
199 } else {
200 ASSERT(current->context()->IsGlobalContext());
201 }
202 } while (!current->context()->IsGlobalContext());
203 }
204 }
205
206 while (top->outer_scope() != NULL) top = top->outer_scope(); 217 while (top->outer_scope() != NULL) top = top->outer_scope();
207 top->AllocateVariables(info->calling_context()); 218 top->AllocateVariables(info->calling_context());
208 219
209 #ifdef DEBUG 220 #ifdef DEBUG
210 if (info->isolate()->bootstrapper()->IsActive() 221 if (info->isolate()->bootstrapper()->IsActive()
211 ? FLAG_print_builtin_scopes 222 ? FLAG_print_builtin_scopes
212 : FLAG_print_scopes) { 223 : FLAG_print_scopes) {
213 info->function()->scope()->Print(); 224 info->function()->scope()->Print();
214 } 225 }
215 #endif 226 #endif
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 1082 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
1072 !must_have_local_context) { 1083 !must_have_local_context) {
1073 num_heap_slots_ = 0; 1084 num_heap_slots_ = 0;
1074 } 1085 }
1075 1086
1076 // Allocation done. 1087 // Allocation done.
1077 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1088 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
1078 } 1089 }
1079 1090
1080 } } // namespace v8::internal 1091 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698