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/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/ast/variables.h" | 9 #include "src/ast/variables.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 FunctionKind function_kind = kNormalFunction; | 148 FunctionKind function_kind = kNormalFunction; |
149 if (scope->is_function_scope()) { | 149 if (scope->is_function_scope()) { |
150 DeclarationScope* function_scope = scope->AsDeclarationScope(); | 150 DeclarationScope* function_scope = scope->AsDeclarationScope(); |
151 has_simple_parameters = function_scope->has_simple_parameters(); | 151 has_simple_parameters = function_scope->has_simple_parameters(); |
152 asm_module = function_scope->asm_module(); | 152 asm_module = function_scope->asm_module(); |
153 asm_function = function_scope->asm_function(); | 153 asm_function = function_scope->asm_function(); |
154 function_kind = function_scope->function_kind(); | 154 function_kind = function_scope->function_kind(); |
155 } | 155 } |
156 | 156 |
157 // Encode the flags. | 157 // Encode the flags. |
158 int flags = ScopeTypeField::encode(scope->scope_type()) | | 158 int flags = |
159 CallsEvalField::encode(scope->calls_eval()) | | 159 ScopeTypeField::encode(scope->scope_type()) | |
160 LanguageModeField::encode(scope->language_mode()) | | 160 CallsEvalField::encode(scope->calls_eval()) | |
161 DeclarationScopeField::encode(scope->is_declaration_scope()) | | 161 LanguageModeField::encode(scope->language_mode()) | |
162 ReceiverVariableField::encode(receiver_info) | | 162 DeclarationScopeField::encode(scope->is_declaration_scope()) | |
163 HasNewTargetField::encode(has_new_target) | | 163 ReceiverVariableField::encode(receiver_info) | |
164 FunctionVariableField::encode(function_name_info) | | 164 HasNewTargetField::encode(has_new_target) | |
165 AsmModuleField::encode(asm_module) | | 165 FunctionVariableField::encode(function_name_info) | |
166 AsmFunctionField::encode(asm_function) | | 166 AsmModuleField::encode(asm_module) | |
167 HasSimpleParametersField::encode(has_simple_parameters) | | 167 AsmFunctionField::encode(asm_function) | |
168 FunctionKindField::encode(function_kind) | | 168 HasSimpleParametersField::encode(has_simple_parameters) | |
169 HasOuterScopeInfoField::encode(has_outer_scope_info); | 169 FunctionKindField::encode(function_kind) | |
| 170 HasOuterScopeInfoField::encode(has_outer_scope_info) | |
| 171 IsDebugEvaluateScopeField::encode(scope->is_debug_evaluate_scope()); |
170 scope_info->SetFlags(flags); | 172 scope_info->SetFlags(flags); |
171 | 173 |
172 scope_info->SetParameterCount(parameter_count); | 174 scope_info->SetParameterCount(parameter_count); |
173 scope_info->SetStackLocalCount(stack_local_count); | 175 scope_info->SetStackLocalCount(stack_local_count); |
174 scope_info->SetContextLocalCount(context_local_count); | 176 scope_info->SetContextLocalCount(context_local_count); |
175 | 177 |
176 int index = kVariablePartIndex; | 178 int index = kVariablePartIndex; |
177 // Add parameters. | 179 // Add parameters. |
178 DCHECK_EQ(index, scope_info->ParameterNamesIndex()); | 180 DCHECK_EQ(index, scope_info->ParameterNamesIndex()); |
179 if (scope->is_declaration_scope()) { | 181 if (scope->is_declaration_scope()) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); | 297 Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length); |
296 | 298 |
297 // Encode the flags. | 299 // Encode the flags. |
298 int flags = | 300 int flags = |
299 ScopeTypeField::encode(WITH_SCOPE) | CallsEvalField::encode(false) | | 301 ScopeTypeField::encode(WITH_SCOPE) | CallsEvalField::encode(false) | |
300 LanguageModeField::encode(SLOPPY) | DeclarationScopeField::encode(false) | | 302 LanguageModeField::encode(SLOPPY) | DeclarationScopeField::encode(false) | |
301 ReceiverVariableField::encode(NONE) | HasNewTargetField::encode(false) | | 303 ReceiverVariableField::encode(NONE) | HasNewTargetField::encode(false) | |
302 FunctionVariableField::encode(NONE) | AsmModuleField::encode(false) | | 304 FunctionVariableField::encode(NONE) | AsmModuleField::encode(false) | |
303 AsmFunctionField::encode(false) | HasSimpleParametersField::encode(true) | | 305 AsmFunctionField::encode(false) | HasSimpleParametersField::encode(true) | |
304 FunctionKindField::encode(kNormalFunction) | | 306 FunctionKindField::encode(kNormalFunction) | |
305 HasOuterScopeInfoField::encode(has_outer_scope_info); | 307 HasOuterScopeInfoField::encode(has_outer_scope_info) | |
| 308 IsDebugEvaluateScopeField::encode(false); |
306 scope_info->SetFlags(flags); | 309 scope_info->SetFlags(flags); |
307 | 310 |
308 scope_info->SetParameterCount(0); | 311 scope_info->SetParameterCount(0); |
309 scope_info->SetStackLocalCount(0); | 312 scope_info->SetStackLocalCount(0); |
310 scope_info->SetContextLocalCount(0); | 313 scope_info->SetContextLocalCount(0); |
311 | 314 |
312 int index = kVariablePartIndex; | 315 int index = kVariablePartIndex; |
313 DCHECK_EQ(index, scope_info->ParameterNamesIndex()); | 316 DCHECK_EQ(index, scope_info->ParameterNamesIndex()); |
314 DCHECK_EQ(index, scope_info->StackLocalFirstSlotIndex()); | 317 DCHECK_EQ(index, scope_info->StackLocalFirstSlotIndex()); |
315 scope_info->set(index++, Smi::FromInt(0)); | 318 scope_info->set(index++, Smi::FromInt(0)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 351 |
349 // Encode the flags. | 352 // Encode the flags. |
350 int flags = | 353 int flags = |
351 ScopeTypeField::encode(SCRIPT_SCOPE) | CallsEvalField::encode(false) | | 354 ScopeTypeField::encode(SCRIPT_SCOPE) | CallsEvalField::encode(false) | |
352 LanguageModeField::encode(SLOPPY) | DeclarationScopeField::encode(true) | | 355 LanguageModeField::encode(SLOPPY) | DeclarationScopeField::encode(true) | |
353 ReceiverVariableField::encode(receiver_info) | | 356 ReceiverVariableField::encode(receiver_info) | |
354 FunctionVariableField::encode(function_name_info) | | 357 FunctionVariableField::encode(function_name_info) | |
355 AsmModuleField::encode(false) | AsmFunctionField::encode(false) | | 358 AsmModuleField::encode(false) | AsmFunctionField::encode(false) | |
356 HasSimpleParametersField::encode(has_simple_parameters) | | 359 HasSimpleParametersField::encode(has_simple_parameters) | |
357 FunctionKindField::encode(FunctionKind::kNormalFunction) | | 360 FunctionKindField::encode(FunctionKind::kNormalFunction) | |
358 HasOuterScopeInfoField::encode(has_outer_scope_info); | 361 HasOuterScopeInfoField::encode(has_outer_scope_info) | |
| 362 IsDebugEvaluateScopeField::encode(false); |
359 scope_info->SetFlags(flags); | 363 scope_info->SetFlags(flags); |
360 scope_info->SetParameterCount(parameter_count); | 364 scope_info->SetParameterCount(parameter_count); |
361 scope_info->SetStackLocalCount(stack_local_count); | 365 scope_info->SetStackLocalCount(stack_local_count); |
362 scope_info->SetContextLocalCount(context_local_count); | 366 scope_info->SetContextLocalCount(context_local_count); |
363 | 367 |
364 int index = kVariablePartIndex; | 368 int index = kVariablePartIndex; |
365 const int first_slot_index = 0; | 369 const int first_slot_index = 0; |
366 DCHECK_EQ(index, scope_info->StackLocalFirstSlotIndex()); | 370 DCHECK_EQ(index, scope_info->StackLocalFirstSlotIndex()); |
367 scope_info->set(index++, Smi::FromInt(first_slot_index)); | 371 scope_info->set(index++, Smi::FromInt(first_slot_index)); |
368 DCHECK_EQ(index, scope_info->StackLocalNamesIndex()); | 372 DCHECK_EQ(index, scope_info->StackLocalNamesIndex()); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 } | 488 } |
485 | 489 |
486 bool ScopeInfo::HasOuterScopeInfo() { | 490 bool ScopeInfo::HasOuterScopeInfo() { |
487 if (length() > 0) { | 491 if (length() > 0) { |
488 return HasOuterScopeInfoField::decode(Flags()); | 492 return HasOuterScopeInfoField::decode(Flags()); |
489 } else { | 493 } else { |
490 return false; | 494 return false; |
491 } | 495 } |
492 } | 496 } |
493 | 497 |
| 498 bool ScopeInfo::IsDebugEvaluateScope() { |
| 499 if (length() > 0) { |
| 500 return IsDebugEvaluateScopeField::decode(Flags()); |
| 501 } else { |
| 502 return false; |
| 503 } |
| 504 } |
| 505 |
| 506 void ScopeInfo::SetIsDebugEvaluateScope() { |
| 507 if (length() > 0) { |
| 508 DCHECK_EQ(scope_type(), WITH_SCOPE); |
| 509 SetFlags(Flags() | IsDebugEvaluateScopeField::encode(true)); |
| 510 } else { |
| 511 UNREACHABLE(); |
| 512 } |
| 513 } |
| 514 |
494 bool ScopeInfo::HasHeapAllocatedLocals() { | 515 bool ScopeInfo::HasHeapAllocatedLocals() { |
495 if (length() > 0) { | 516 if (length() > 0) { |
496 return ContextLocalCount() > 0; | 517 return ContextLocalCount() > 0; |
497 } else { | 518 } else { |
498 return false; | 519 return false; |
499 } | 520 } |
500 } | 521 } |
501 | 522 |
502 | 523 |
503 bool ScopeInfo::HasContext() { | 524 bool ScopeInfo::HasContext() { |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 } | 874 } |
854 | 875 |
855 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); | 876 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); |
856 result->set(kSpecialExportsIndex, *special_exports); | 877 result->set(kSpecialExportsIndex, *special_exports); |
857 result->set(kRegularExportsIndex, *regular_exports); | 878 result->set(kRegularExportsIndex, *regular_exports); |
858 return result; | 879 return result; |
859 } | 880 } |
860 | 881 |
861 } // namespace internal | 882 } // namespace internal |
862 } // namespace v8 | 883 } // namespace v8 |
OLD | NEW |