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

Side by Side Diff: src/ast/scopeinfo.cc

Issue 2314483002: Store the ScopeInfo in WithContexts (Closed)
Patch Set: updates Created 4 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/api.cc ('k') | src/ast/scopes.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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/ast/context-slot-cache.h" 7 #include "src/ast/context-slot-cache.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 10
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // The variable entries themselves have already been written above. 234 // The variable entries themselves have already been written above.
235 index += kModuleVariableEntryLength * module_vars_count; 235 index += kModuleVariableEntryLength * module_vars_count;
236 } 236 }
237 237
238 DCHECK_EQ(index, scope_info->length()); 238 DCHECK_EQ(index, scope_info->length());
239 DCHECK_EQ(scope->num_parameters(), scope_info->ParameterCount()); 239 DCHECK_EQ(scope->num_parameters(), scope_info->ParameterCount());
240 DCHECK_EQ(scope->num_heap_slots(), scope_info->ContextLength()); 240 DCHECK_EQ(scope->num_heap_slots(), scope_info->ContextLength());
241 return scope_info; 241 return scope_info;
242 } 242 }
243 243
244 Handle<ScopeInfo> ScopeInfo::CreateForWithScope(Isolate* isolate) {
245 const int length = kVariablePartIndex + 1;
246
247 Factory* factory = isolate->factory();
248 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length);
249
250 // Encode the flags.
251 int flags =
252 ScopeTypeField::encode(WITH_SCOPE) | CallsEvalField::encode(false) |
253 LanguageModeField::encode(SLOPPY) | DeclarationScopeField::encode(false) |
254 ReceiverVariableField::encode(NONE) | HasNewTargetField::encode(false) |
255 FunctionVariableField::encode(NONE) | AsmModuleField::encode(false) |
256 AsmFunctionField::encode(false) | HasSimpleParametersField::encode(true) |
257 FunctionKindField::encode(kNormalFunction);
258 scope_info->SetFlags(flags);
259
260 scope_info->SetParameterCount(0);
261 scope_info->SetStackLocalCount(0);
262 scope_info->SetContextLocalCount(0);
263
264 int index = kVariablePartIndex;
265 DCHECK_EQ(index, scope_info->ParameterEntriesIndex());
266 DCHECK_EQ(index, scope_info->StackLocalFirstSlotIndex());
267 scope_info->set(index++, Smi::FromInt(0));
268 DCHECK_EQ(index, scope_info->StackLocalEntriesIndex());
269 DCHECK_EQ(index, scope_info->ReceiverEntryIndex());
270 DCHECK_EQ(index, scope_info->FunctionNameEntryIndex());
271 DCHECK_EQ(index, scope_info->length());
272 DCHECK_EQ(0, scope_info->ParameterCount());
273 DCHECK_EQ(Context::MIN_CONTEXT_SLOTS, scope_info->ContextLength());
274 return scope_info;
275 }
244 276
245 Handle<ScopeInfo> ScopeInfo::CreateGlobalThisBinding(Isolate* isolate) { 277 Handle<ScopeInfo> ScopeInfo::CreateGlobalThisBinding(Isolate* isolate) {
246 DCHECK(isolate->bootstrapper()->IsActive()); 278 DCHECK(isolate->bootstrapper()->IsActive());
247 279
248 const int stack_local_count = 0; 280 const int stack_local_count = 0;
249 const int context_local_count = 1; 281 const int context_local_count = 1;
250 const bool has_simple_parameters = true; 282 const bool has_simple_parameters = true;
251 const VariableAllocationInfo receiver_info = CONTEXT; 283 const VariableAllocationInfo receiver_info = CONTEXT;
252 const VariableAllocationInfo function_name_info = NONE; 284 const VariableAllocationInfo function_name_info = NONE;
253 const bool has_function_name = false; 285 const bool has_function_name = false;
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 } 776 }
745 777
746 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); 778 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo();
747 result->set(kSpecialExportsIndex, *special_exports); 779 result->set(kSpecialExportsIndex, *special_exports);
748 result->set(kRegularExportsIndex, *regular_exports); 780 result->set(kRegularExportsIndex, *regular_exports);
749 return result; 781 return result;
750 } 782 }
751 783
752 } // namespace internal 784 } // namespace internal
753 } // namespace v8 785 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/ast/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698