| 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 "src/ast/scopeinfo.h" | 5 #include "src/ast/scopeinfo.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } else if (var->IsContextSlot()) { | 42 } else if (var->IsContextSlot()) { |
| 43 receiver_info = CONTEXT; | 43 receiver_info = CONTEXT; |
| 44 } else { | 44 } else { |
| 45 DCHECK(var->IsParameter()); | 45 DCHECK(var->IsParameter()); |
| 46 receiver_info = STACK; | 46 receiver_info = STACK; |
| 47 } | 47 } |
| 48 } else { | 48 } else { |
| 49 receiver_info = NONE; | 49 receiver_info = NONE; |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool has_new_target = scope->new_target_var() != nullptr; |
| 53 |
| 52 // Determine use and location of the function variable if it is present. | 54 // Determine use and location of the function variable if it is present. |
| 53 VariableAllocationInfo function_name_info; | 55 VariableAllocationInfo function_name_info; |
| 54 VariableMode function_variable_mode; | 56 VariableMode function_variable_mode; |
| 55 if (scope->is_function_scope() && scope->function() != NULL) { | 57 if (scope->is_function_scope() && scope->function() != NULL) { |
| 56 Variable* var = scope->function()->proxy()->var(); | 58 Variable* var = scope->function()->proxy()->var(); |
| 57 if (!var->is_used()) { | 59 if (!var->is_used()) { |
| 58 function_name_info = UNUSED; | 60 function_name_info = UNUSED; |
| 59 } else if (var->IsContextSlot()) { | 61 } else if (var->IsContextSlot()) { |
| 60 function_name_info = CONTEXT; | 62 function_name_info = CONTEXT; |
| 61 } else { | 63 } else { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 83 | 85 |
| 84 bool has_simple_parameters = | 86 bool has_simple_parameters = |
| 85 scope->is_function_scope() && scope->has_simple_parameters(); | 87 scope->is_function_scope() && scope->has_simple_parameters(); |
| 86 | 88 |
| 87 // Encode the flags. | 89 // Encode the flags. |
| 88 int flags = ScopeTypeField::encode(scope->scope_type()) | | 90 int flags = ScopeTypeField::encode(scope->scope_type()) | |
| 89 CallsEvalField::encode(scope->calls_eval()) | | 91 CallsEvalField::encode(scope->calls_eval()) | |
| 90 LanguageModeField::encode(scope->language_mode()) | | 92 LanguageModeField::encode(scope->language_mode()) | |
| 91 DeclarationScopeField::encode(scope->is_declaration_scope()) | | 93 DeclarationScopeField::encode(scope->is_declaration_scope()) | |
| 92 ReceiverVariableField::encode(receiver_info) | | 94 ReceiverVariableField::encode(receiver_info) | |
| 95 HasNewTargetField::encode(has_new_target) | |
| 93 FunctionVariableField::encode(function_name_info) | | 96 FunctionVariableField::encode(function_name_info) | |
| 94 FunctionVariableMode::encode(function_variable_mode) | | 97 FunctionVariableMode::encode(function_variable_mode) | |
| 95 AsmModuleField::encode(scope->asm_module()) | | 98 AsmModuleField::encode(scope->asm_module()) | |
| 96 AsmFunctionField::encode(scope->asm_function()) | | 99 AsmFunctionField::encode(scope->asm_function()) | |
| 97 HasSimpleParametersField::encode(has_simple_parameters) | | 100 HasSimpleParametersField::encode(has_simple_parameters) | |
| 98 FunctionKindField::encode(scope->function_kind()); | 101 FunctionKindField::encode(scope->function_kind()); |
| 99 scope_info->SetFlags(flags); | 102 scope_info->SetFlags(flags); |
| 100 scope_info->SetParameterCount(parameter_count); | 103 scope_info->SetParameterCount(parameter_count); |
| 101 scope_info->SetStackLocalCount(stack_local_count); | 104 scope_info->SetStackLocalCount(stack_local_count); |
| 102 scope_info->SetContextLocalCount(context_local_count); | 105 scope_info->SetContextLocalCount(context_local_count); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 bool ScopeInfo::HasAllocatedReceiver() { | 370 bool ScopeInfo::HasAllocatedReceiver() { |
| 368 if (length() > 0) { | 371 if (length() > 0) { |
| 369 VariableAllocationInfo allocation = ReceiverVariableField::decode(Flags()); | 372 VariableAllocationInfo allocation = ReceiverVariableField::decode(Flags()); |
| 370 return allocation == STACK || allocation == CONTEXT; | 373 return allocation == STACK || allocation == CONTEXT; |
| 371 } else { | 374 } else { |
| 372 return false; | 375 return false; |
| 373 } | 376 } |
| 374 } | 377 } |
| 375 | 378 |
| 376 | 379 |
| 380 bool ScopeInfo::HasNewTarget() { return HasNewTargetField::decode(Flags()); } |
| 381 |
| 382 |
| 377 bool ScopeInfo::HasFunctionName() { | 383 bool ScopeInfo::HasFunctionName() { |
| 378 if (length() > 0) { | 384 if (length() > 0) { |
| 379 return NONE != FunctionVariableField::decode(Flags()); | 385 return NONE != FunctionVariableField::decode(Flags()); |
| 380 } else { | 386 } else { |
| 381 return false; | 387 return false; |
| 382 } | 388 } |
| 383 } | 389 } |
| 384 | 390 |
| 385 | 391 |
| 386 bool ScopeInfo::HasHeapAllocatedLocals() { | 392 bool ScopeInfo::HasHeapAllocatedLocals() { |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 info->set_mode(i, var->mode()); | 849 info->set_mode(i, var->mode()); |
| 844 DCHECK(var->index() >= 0); | 850 DCHECK(var->index() >= 0); |
| 845 info->set_index(i, var->index()); | 851 info->set_index(i, var->index()); |
| 846 } | 852 } |
| 847 DCHECK(i == info->length()); | 853 DCHECK(i == info->length()); |
| 848 return info; | 854 return info; |
| 849 } | 855 } |
| 850 | 856 |
| 851 } // namespace internal | 857 } // namespace internal |
| 852 } // namespace v8 | 858 } // namespace v8 |
| OLD | NEW |