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

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

Issue 2223283002: [Interpreter] Create ScopeInfos in ast-numbering phase. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_varchecks
Patch Set: 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
« src/ast/ast-numbering.cc ('K') | « src/ast/ast-numbering.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3034 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 VisitForAccumulatorValue(right); 3045 VisitForAccumulatorValue(right);
3046 builder()->Bind(&end_label); 3046 builder()->Bind(&end_label);
3047 } 3047 }
3048 execution_result()->SetResultInAccumulator(); 3048 execution_result()->SetResultInAccumulator();
3049 } 3049 }
3050 3050
3051 void BytecodeGenerator::VisitRewritableExpression(RewritableExpression* expr) { 3051 void BytecodeGenerator::VisitRewritableExpression(RewritableExpression* expr) {
3052 Visit(expr->expression()); 3052 Visit(expr->expression());
3053 } 3053 }
3054 3054
3055 namespace {
3056
3057 Handle<ScopeInfo> GetScopeInfo(Scope* scope, Isolate* isolate) {
3058 // TODO(5203): Remove this temporary exception.
3059 AllowHeapAllocation allow_allocation;
3060 AllowHandleAllocation allow_handles;
3061 AllowHandleDereference allow_deref;
3062 return scope->GetScopeInfo(isolate);
3063 }
3064
3065 } // namespace
3066
3067 void BytecodeGenerator::VisitNewLocalFunctionContext() { 3055 void BytecodeGenerator::VisitNewLocalFunctionContext() {
3068 AccumulatorResultScope accumulator_execution_result(this); 3056 AccumulatorResultScope accumulator_execution_result(this);
3069 Scope* scope = this->scope(); 3057 Scope* scope = this->scope();
3070 3058
3071 // Allocate a new local context. 3059 // Allocate a new local context.
3072 if (scope->is_script_scope()) { 3060 if (scope->is_script_scope()) {
3073 RegisterAllocationScope register_scope(this); 3061 RegisterAllocationScope register_scope(this);
3074 Register closure = register_allocator()->NewRegister(); 3062 Register closure = register_allocator()->NewRegister();
3075 Register scope_info = register_allocator()->NewRegister(); 3063 Register scope_info = register_allocator()->NewRegister();
3076 DCHECK(Register::AreContiguous(closure, scope_info)); 3064 DCHECK(Register::AreContiguous(closure, scope_info));
3077 builder() 3065 builder()
3078 ->LoadAccumulatorWithRegister(Register::function_closure()) 3066 ->LoadAccumulatorWithRegister(Register::function_closure())
3079 .StoreAccumulatorInRegister(closure) 3067 .StoreAccumulatorInRegister(closure)
3080 .LoadLiteral(GetScopeInfo(scope, isolate())) 3068 .LoadLiteral(scope->GetScopeInfo(isolate()))
3081 .StoreAccumulatorInRegister(scope_info) 3069 .StoreAccumulatorInRegister(scope_info)
3082 .CallRuntime(Runtime::kNewScriptContext, closure, 2); 3070 .CallRuntime(Runtime::kNewScriptContext, closure, 2);
3083 } else { 3071 } else {
3084 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; 3072 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
3085 builder()->CreateFunctionContext(slot_count); 3073 builder()->CreateFunctionContext(slot_count);
3086 } 3074 }
3087 execution_result()->SetResultInAccumulator(); 3075 execution_result()->SetResultInAccumulator();
3088 } 3076 }
3089 3077
3090 void BytecodeGenerator::VisitBuildLocalActivationContext() { 3078 void BytecodeGenerator::VisitBuildLocalActivationContext() {
(...skipping 27 matching lines...) Expand all
3118 void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) { 3106 void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) {
3119 AccumulatorResultScope accumulator_execution_result(this); 3107 AccumulatorResultScope accumulator_execution_result(this);
3120 DCHECK(scope->is_block_scope()); 3108 DCHECK(scope->is_block_scope());
3121 3109
3122 // Allocate a new local block context. 3110 // Allocate a new local block context.
3123 register_allocator()->PrepareForConsecutiveAllocations(2); 3111 register_allocator()->PrepareForConsecutiveAllocations(2);
3124 Register scope_info = register_allocator()->NextConsecutiveRegister(); 3112 Register scope_info = register_allocator()->NextConsecutiveRegister();
3125 Register closure = register_allocator()->NextConsecutiveRegister(); 3113 Register closure = register_allocator()->NextConsecutiveRegister();
3126 3114
3127 builder() 3115 builder()
3128 ->LoadLiteral(GetScopeInfo(scope, isolate())) 3116 ->LoadLiteral(scope->GetScopeInfo(isolate()))
3129 .StoreAccumulatorInRegister(scope_info); 3117 .StoreAccumulatorInRegister(scope_info);
3130 VisitFunctionClosureForContext(); 3118 VisitFunctionClosureForContext();
3131 builder() 3119 builder()
3132 ->StoreAccumulatorInRegister(closure) 3120 ->StoreAccumulatorInRegister(closure)
3133 .CallRuntime(Runtime::kPushBlockContext, scope_info, 2); 3121 .CallRuntime(Runtime::kPushBlockContext, scope_info, 2);
3134 execution_result()->SetResultInAccumulator(); 3122 execution_result()->SetResultInAccumulator();
3135 } 3123 }
3136 3124
3137 void BytecodeGenerator::VisitNewLocalWithContext() { 3125 void BytecodeGenerator::VisitNewLocalWithContext() {
3138 AccumulatorResultScope accumulator_execution_result(this); 3126 AccumulatorResultScope accumulator_execution_result(this);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 return execution_context()->scope()->language_mode(); 3297 return execution_context()->scope()->language_mode();
3310 } 3298 }
3311 3299
3312 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3300 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3313 return TypeFeedbackVector::GetIndex(slot); 3301 return TypeFeedbackVector::GetIndex(slot);
3314 } 3302 }
3315 3303
3316 } // namespace interpreter 3304 } // namespace interpreter
3317 } // namespace internal 3305 } // namespace internal
3318 } // namespace v8 3306 } // namespace v8
OLDNEW
« src/ast/ast-numbering.cc ('K') | « src/ast/ast-numbering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698