Chromium Code Reviews| 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/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 145 |
| 146 BytecodeGenerator::~BytecodeGenerator() {} | 146 BytecodeGenerator::~BytecodeGenerator() {} |
| 147 | 147 |
| 148 | 148 |
| 149 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { | 149 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { |
| 150 set_info(info); | 150 set_info(info); |
| 151 set_scope(info->scope()); | 151 set_scope(info->scope()); |
| 152 | 152 |
| 153 builder()->set_parameter_count(info->num_parameters_including_this()); | 153 builder()->set_parameter_count(info->num_parameters_including_this()); |
| 154 builder()->set_locals_count(scope()->num_stack_slots()); | 154 builder()->set_locals_count(scope()->num_stack_slots()); |
| 155 // TODO(rmcilroy): Set correct context count. | 155 builder()->set_context_count(scope()->MaxNestedContextChainLength()); |
|
adamk
2015/10/15 07:38:44
Is this exercised by any tests (I'm not familiar w
rmcilroy
2015/10/15 09:23:07
This is exercised by test-bytecode-generator.cc::D
adamk
2015/10/15 09:34:32
Capturing a lexical variable from a block will for
rmcilroy
2015/10/15 14:06:16
Great, thanks for the pointer. It turns out this n
| |
| 156 builder()->set_context_count(info->num_heap_slots() > 0 ? 1 : 0); | |
| 157 | 156 |
| 158 // Build function context only if there are context allocated variables. | 157 // Build function context only if there are context allocated variables. |
| 159 if (info->num_heap_slots() > 0) { | 158 if (scope()->NeedsContext()) { |
|
adamk
2015/10/15 07:38:45
I'd leave this as num_heap_slots() > 0 (see other
rmcilroy
2015/10/15 09:23:07
Commented on the other comment.
| |
| 160 // Push a new inner context scope for the function. | 159 // Push a new inner context scope for the function. |
| 161 VisitNewLocalFunctionContext(); | 160 VisitNewLocalFunctionContext(); |
| 162 ContextScope top_context(this, true); | 161 ContextScope top_context(this, true); |
| 163 MakeBytecodeBody(); | 162 MakeBytecodeBody(); |
| 164 } else { | 163 } else { |
| 165 MakeBytecodeBody(); | 164 MakeBytecodeBody(); |
| 166 } | 165 } |
| 167 | 166 |
| 168 set_scope(nullptr); | 167 set_scope(nullptr); |
| 169 set_info(nullptr); | 168 set_info(nullptr); |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1202 } | 1201 } |
| 1203 | 1202 |
| 1204 | 1203 |
| 1205 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 1204 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 1206 return info()->feedback_vector()->GetIndex(slot); | 1205 return info()->feedback_vector()->GetIndex(slot); |
| 1207 } | 1206 } |
| 1208 | 1207 |
| 1209 } // namespace interpreter | 1208 } // namespace interpreter |
| 1210 } // namespace internal | 1209 } // namespace internal |
| 1211 } // namespace v8 | 1210 } // namespace v8 |
| OLD | NEW |