OLD | NEW |
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/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/scopeinfo.h" | 9 #include "src/scopeinfo.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 | 15 |
16 Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, | 16 Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, |
17 Scope* scope) { | 17 Scope* scope) { |
18 // Collect stack and context locals. | 18 // Collect stack and context locals. |
19 ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone); | 19 ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone); |
20 ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone); | 20 ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone); |
21 scope->CollectStackAndContextLocals(&stack_locals, &context_locals); | 21 scope->CollectStackAndContextLocals(&stack_locals, &context_locals); |
22 const int stack_local_count = stack_locals.length(); | 22 const int stack_local_count = stack_locals.length(); |
23 const int context_local_count = context_locals.length(); | 23 const int context_local_count = context_locals.length(); |
24 // Make sure we allocate the correct amount. | 24 // Make sure we allocate the correct amount. |
25 DCHECK(scope->StackLocalCount() == stack_local_count); | 25 DCHECK(scope->StackLocalCount() == stack_local_count); |
26 DCHECK(scope->ContextLocalCount() == context_local_count); | 26 DCHECK(scope->ContextLocalCount() == context_local_count); |
27 | 27 |
| 28 bool simple_parameter_list = |
| 29 scope->is_function_scope() ? scope->is_simple_parameter_list() : true; |
| 30 |
28 // Determine use and location of the function variable if it is present. | 31 // Determine use and location of the function variable if it is present. |
29 FunctionVariableInfo function_name_info; | 32 FunctionVariableInfo function_name_info; |
30 VariableMode function_variable_mode; | 33 VariableMode function_variable_mode; |
31 if (scope->is_function_scope() && scope->function() != NULL) { | 34 if (scope->is_function_scope() && scope->function() != NULL) { |
32 Variable* var = scope->function()->proxy()->var(); | 35 Variable* var = scope->function()->proxy()->var(); |
33 if (!var->is_used()) { | 36 if (!var->is_used()) { |
34 function_name_info = UNUSED; | 37 function_name_info = UNUSED; |
35 } else if (var->IsContextSlot()) { | 38 } else if (var->IsContextSlot()) { |
36 function_name_info = CONTEXT; | 39 function_name_info = CONTEXT; |
37 } else { | 40 } else { |
(...skipping 15 matching lines...) Expand all Loading... |
53 Factory* factory = isolate->factory(); | 56 Factory* factory = isolate->factory(); |
54 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); | 57 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); |
55 | 58 |
56 // Encode the flags. | 59 // Encode the flags. |
57 int flags = ScopeTypeField::encode(scope->scope_type()) | | 60 int flags = ScopeTypeField::encode(scope->scope_type()) | |
58 CallsEvalField::encode(scope->calls_eval()) | | 61 CallsEvalField::encode(scope->calls_eval()) | |
59 LanguageModeField::encode(scope->language_mode()) | | 62 LanguageModeField::encode(scope->language_mode()) | |
60 FunctionVariableField::encode(function_name_info) | | 63 FunctionVariableField::encode(function_name_info) | |
61 FunctionVariableMode::encode(function_variable_mode) | | 64 FunctionVariableMode::encode(function_variable_mode) | |
62 AsmModuleField::encode(scope->asm_module()) | | 65 AsmModuleField::encode(scope->asm_module()) | |
63 AsmFunctionField::encode(scope->asm_function()); | 66 AsmFunctionField::encode(scope->asm_function()) | |
| 67 IsSimpleParameterListField::encode(simple_parameter_list); |
64 scope_info->SetFlags(flags); | 68 scope_info->SetFlags(flags); |
65 scope_info->SetParameterCount(parameter_count); | 69 scope_info->SetParameterCount(parameter_count); |
66 scope_info->SetStackLocalCount(stack_local_count); | 70 scope_info->SetStackLocalCount(stack_local_count); |
67 scope_info->SetContextLocalCount(context_local_count); | 71 scope_info->SetContextLocalCount(context_local_count); |
68 | 72 |
69 int index = kVariablePartIndex; | 73 int index = kVariablePartIndex; |
70 // Add parameters. | 74 // Add parameters. |
71 DCHECK(index == scope_info->ParameterEntriesIndex()); | 75 DCHECK(index == scope_info->ParameterEntriesIndex()); |
72 for (int i = 0; i < parameter_count; ++i) { | 76 for (int i = 0; i < parameter_count; ++i) { |
73 scope_info->set(index++, *scope->parameter(i)->name()); | 77 scope_info->set(index++, *scope->parameter(i)->name()); |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 } else { | 570 } else { |
567 DCHECK(var->index() >= 0); | 571 DCHECK(var->index() >= 0); |
568 info->set_index(i, var->index()); | 572 info->set_index(i, var->index()); |
569 } | 573 } |
570 } | 574 } |
571 DCHECK(i == info->length()); | 575 DCHECK(i == info->length()); |
572 return info; | 576 return info; |
573 } | 577 } |
574 | 578 |
575 } } // namespace v8::internal | 579 } } // namespace v8::internal |
OLD | NEW |