| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/interpreter/bytecode-flags.h" | 10 #include "src/interpreter/bytecode-flags.h" |
| (...skipping 2998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3009 .StoreAccumulatorInRegister(scope_info) | 3009 .StoreAccumulatorInRegister(scope_info) |
| 3010 .CallRuntime(Runtime::kNewScriptContext, closure, 2); | 3010 .CallRuntime(Runtime::kNewScriptContext, closure, 2); |
| 3011 } else { | 3011 } else { |
| 3012 builder()->CallRuntime(Runtime::kNewFunctionContext, | 3012 builder()->CallRuntime(Runtime::kNewFunctionContext, |
| 3013 Register::function_closure(), 1); | 3013 Register::function_closure(), 1); |
| 3014 } | 3014 } |
| 3015 execution_result()->SetResultInAccumulator(); | 3015 execution_result()->SetResultInAccumulator(); |
| 3016 } | 3016 } |
| 3017 | 3017 |
| 3018 void BytecodeGenerator::VisitBuildLocalActivationContext() { | 3018 void BytecodeGenerator::VisitBuildLocalActivationContext() { |
| 3019 Scope* scope = this->scope(); | 3019 DeclarationScope* scope = this->scope(); |
| 3020 | 3020 |
| 3021 if (scope->has_this_declaration() && scope->receiver()->IsContextSlot()) { | 3021 if (scope->has_this_declaration() && scope->receiver()->IsContextSlot()) { |
| 3022 Variable* variable = scope->receiver(); | 3022 Variable* variable = scope->receiver(); |
| 3023 Register receiver(builder()->Parameter(0)); | 3023 Register receiver(builder()->Parameter(0)); |
| 3024 // Context variable (at bottom of the context chain). | 3024 // Context variable (at bottom of the context chain). |
| 3025 DCHECK_EQ(0, scope->ContextChainLength(variable->scope())); | 3025 DCHECK_EQ(0, scope->ContextChainLength(variable->scope())); |
| 3026 builder()->LoadAccumulatorWithRegister(receiver).StoreContextSlot( | 3026 builder()->LoadAccumulatorWithRegister(receiver).StoreContextSlot( |
| 3027 execution_context()->reg(), variable->index()); | 3027 execution_context()->reg(), variable->index()); |
| 3028 } | 3028 } |
| 3029 | 3029 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3158 void BytecodeGenerator::VisitNewTargetVariable(Variable* variable) { | 3158 void BytecodeGenerator::VisitNewTargetVariable(Variable* variable) { |
| 3159 if (variable == nullptr) return; | 3159 if (variable == nullptr) return; |
| 3160 | 3160 |
| 3161 // Store the new target we were called with in the given variable. | 3161 // Store the new target we were called with in the given variable. |
| 3162 builder()->LoadAccumulatorWithRegister(Register::new_target()); | 3162 builder()->LoadAccumulatorWithRegister(Register::new_target()); |
| 3163 VisitVariableAssignment(variable, Token::INIT, FeedbackVectorSlot::Invalid()); | 3163 VisitVariableAssignment(variable, Token::INIT, FeedbackVectorSlot::Invalid()); |
| 3164 } | 3164 } |
| 3165 | 3165 |
| 3166 void BytecodeGenerator::VisitFunctionClosureForContext() { | 3166 void BytecodeGenerator::VisitFunctionClosureForContext() { |
| 3167 AccumulatorResultScope accumulator_execution_result(this); | 3167 AccumulatorResultScope accumulator_execution_result(this); |
| 3168 Scope* closure_scope = execution_context()->scope()->ClosureScope(); | 3168 DeclarationScope* closure_scope = |
| 3169 execution_context()->scope()->GetClosureScope(); |
| 3169 if (closure_scope->is_script_scope() || | 3170 if (closure_scope->is_script_scope() || |
| 3170 closure_scope->is_module_scope()) { | 3171 closure_scope->is_module_scope()) { |
| 3171 // Contexts nested in the native context have a canonical empty function as | 3172 // Contexts nested in the native context have a canonical empty function as |
| 3172 // their closure, not the anonymous closure containing the global code. | 3173 // their closure, not the anonymous closure containing the global code. |
| 3173 Register native_context = register_allocator()->NewRegister(); | 3174 Register native_context = register_allocator()->NewRegister(); |
| 3174 builder() | 3175 builder() |
| 3175 ->LoadContextSlot(execution_context()->reg(), | 3176 ->LoadContextSlot(execution_context()->reg(), |
| 3176 Context::NATIVE_CONTEXT_INDEX) | 3177 Context::NATIVE_CONTEXT_INDEX) |
| 3177 .StoreAccumulatorInRegister(native_context) | 3178 .StoreAccumulatorInRegister(native_context) |
| 3178 .LoadContextSlot(native_context, Context::CLOSURE_INDEX); | 3179 .LoadContextSlot(native_context, Context::CLOSURE_INDEX); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3236 return execution_context()->scope()->language_mode(); | 3237 return execution_context()->scope()->language_mode(); |
| 3237 } | 3238 } |
| 3238 | 3239 |
| 3239 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3240 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3240 return TypeFeedbackVector::GetIndex(slot); | 3241 return TypeFeedbackVector::GetIndex(slot); |
| 3241 } | 3242 } |
| 3242 | 3243 |
| 3243 } // namespace interpreter | 3244 } // namespace interpreter |
| 3244 } // namespace internal | 3245 } // namespace internal |
| 3245 } // namespace v8 | 3246 } // namespace v8 |
| OLD | NEW |