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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2209573002: Separate Scope into DeclarationScope and Scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move has_simple_parameters_ to DeclarationScope Created 4 years, 4 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
OLDNEW
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 3033 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 .StoreAccumulatorInRegister(scope_info) 3044 .StoreAccumulatorInRegister(scope_info)
3045 .CallRuntime(Runtime::kNewScriptContext, closure, 2); 3045 .CallRuntime(Runtime::kNewScriptContext, closure, 2);
3046 } else { 3046 } else {
3047 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; 3047 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
3048 builder()->CreateFunctionContext(slot_count); 3048 builder()->CreateFunctionContext(slot_count);
3049 } 3049 }
3050 execution_result()->SetResultInAccumulator(); 3050 execution_result()->SetResultInAccumulator();
3051 } 3051 }
3052 3052
3053 void BytecodeGenerator::VisitBuildLocalActivationContext() { 3053 void BytecodeGenerator::VisitBuildLocalActivationContext() {
3054 Scope* scope = this->scope(); 3054 DeclarationScope* scope = this->scope();
3055 3055
3056 if (scope->has_this_declaration() && scope->receiver()->IsContextSlot()) { 3056 if (scope->has_this_declaration() && scope->receiver()->IsContextSlot()) {
3057 Variable* variable = scope->receiver(); 3057 Variable* variable = scope->receiver();
3058 Register receiver(builder()->Parameter(0)); 3058 Register receiver(builder()->Parameter(0));
3059 // Context variable (at bottom of the context chain). 3059 // Context variable (at bottom of the context chain).
3060 DCHECK_EQ(0, scope->ContextChainLength(variable->scope())); 3060 DCHECK_EQ(0, scope->ContextChainLength(variable->scope()));
3061 builder()->LoadAccumulatorWithRegister(receiver).StoreContextSlot( 3061 builder()->LoadAccumulatorWithRegister(receiver).StoreContextSlot(
3062 execution_context()->reg(), variable->index()); 3062 execution_context()->reg(), variable->index());
3063 } 3063 }
3064 3064
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 void BytecodeGenerator::VisitNewTargetVariable(Variable* variable) { 3193 void BytecodeGenerator::VisitNewTargetVariable(Variable* variable) {
3194 if (variable == nullptr) return; 3194 if (variable == nullptr) return;
3195 3195
3196 // Store the new target we were called with in the given variable. 3196 // Store the new target we were called with in the given variable.
3197 builder()->LoadAccumulatorWithRegister(Register::new_target()); 3197 builder()->LoadAccumulatorWithRegister(Register::new_target());
3198 VisitVariableAssignment(variable, Token::INIT, FeedbackVectorSlot::Invalid()); 3198 VisitVariableAssignment(variable, Token::INIT, FeedbackVectorSlot::Invalid());
3199 } 3199 }
3200 3200
3201 void BytecodeGenerator::VisitFunctionClosureForContext() { 3201 void BytecodeGenerator::VisitFunctionClosureForContext() {
3202 AccumulatorResultScope accumulator_execution_result(this); 3202 AccumulatorResultScope accumulator_execution_result(this);
3203 Scope* closure_scope = execution_context()->scope()->ClosureScope(); 3203 DeclarationScope* closure_scope =
3204 execution_context()->scope()->GetClosureScope();
3204 if (closure_scope->is_script_scope() || 3205 if (closure_scope->is_script_scope() ||
3205 closure_scope->is_module_scope()) { 3206 closure_scope->is_module_scope()) {
3206 // Contexts nested in the native context have a canonical empty function as 3207 // Contexts nested in the native context have a canonical empty function as
3207 // their closure, not the anonymous closure containing the global code. 3208 // their closure, not the anonymous closure containing the global code.
3208 Register native_context = register_allocator()->NewRegister(); 3209 Register native_context = register_allocator()->NewRegister();
3209 builder() 3210 builder()
3210 ->LoadContextSlot(execution_context()->reg(), 3211 ->LoadContextSlot(execution_context()->reg(),
3211 Context::NATIVE_CONTEXT_INDEX) 3212 Context::NATIVE_CONTEXT_INDEX)
3212 .StoreAccumulatorInRegister(native_context) 3213 .StoreAccumulatorInRegister(native_context)
3213 .LoadContextSlot(native_context, Context::CLOSURE_INDEX); 3214 .LoadContextSlot(native_context, Context::CLOSURE_INDEX);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3271 return execution_context()->scope()->language_mode(); 3272 return execution_context()->scope()->language_mode();
3272 } 3273 }
3273 3274
3274 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3275 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3275 return TypeFeedbackVector::GetIndex(slot); 3276 return TypeFeedbackVector::GetIndex(slot);
3276 } 3277 }
3277 3278
3278 } // namespace interpreter 3279 } // namespace interpreter
3279 } // namespace internal 3280 } // namespace internal
3280 } // namespace v8 3281 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698