| 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 <stack> | 7 #include <stack> |
| 8 | 8 |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 BytecodeGenerator::~BytecodeGenerator() {} | 147 BytecodeGenerator::~BytecodeGenerator() {} |
| 148 | 148 |
| 149 | 149 |
| 150 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { | 150 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { |
| 151 set_info(info); | 151 set_info(info); |
| 152 set_scope(info->scope()); | 152 set_scope(info->scope()); |
| 153 | 153 |
| 154 builder()->set_parameter_count(info->num_parameters_including_this()); | 154 builder()->set_parameter_count(info->num_parameters_including_this()); |
| 155 builder()->set_locals_count(scope()->num_stack_slots()); | 155 builder()->set_locals_count(scope()->num_stack_slots()); |
| 156 // TODO(rmcilroy): Set correct context count. | 156 builder()->set_context_count(scope()->MaxNestedContextChainLength()); |
| 157 builder()->set_context_count(info->num_heap_slots() > 0 ? 1 : 0); | |
| 158 | 157 |
| 159 // Build function context only if there are context allocated variables. | 158 // Build function context only if there are context allocated variables. |
| 160 if (info->num_heap_slots() > 0) { | 159 if (scope()->NeedsContext()) { |
| 161 // Push a new inner context scope for the function. | 160 // Push a new inner context scope for the function. |
| 162 VisitNewLocalFunctionContext(); | 161 VisitNewLocalFunctionContext(); |
| 163 ContextScope top_context(this, true); | 162 ContextScope top_context(this, true); |
| 164 MakeBytecodeBody(); | 163 MakeBytecodeBody(); |
| 165 } else { | 164 } else { |
| 166 MakeBytecodeBody(); | 165 MakeBytecodeBody(); |
| 167 } | 166 } |
| 168 | 167 |
| 169 set_scope(nullptr); | 168 set_scope(nullptr); |
| 170 set_info(nullptr); | 169 set_info(nullptr); |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 } | 1264 } |
| 1266 | 1265 |
| 1267 | 1266 |
| 1268 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 1267 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 1269 return info()->feedback_vector()->GetIndex(slot); | 1268 return info()->feedback_vector()->GetIndex(slot); |
| 1270 } | 1269 } |
| 1271 | 1270 |
| 1272 } // namespace interpreter | 1271 } // namespace interpreter |
| 1273 } // namespace internal | 1272 } // namespace internal |
| 1274 } // namespace v8 | 1273 } // namespace v8 |
| OLD | NEW |