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/compiler/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 Node* index = | 1412 Node* index = |
1413 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1413 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1414 index = NewNode(javascript()->ForInStep(), index); | 1414 index = NewNode(javascript()->ForInStep(), index); |
1415 environment()->BindAccumulator(index, &states); | 1415 environment()->BindAccumulator(index, &states); |
1416 } | 1416 } |
1417 | 1417 |
1418 void BytecodeGraphBuilder::VisitSuspendGenerator() { | 1418 void BytecodeGraphBuilder::VisitSuspendGenerator() { |
1419 Node* state = environment()->LookupAccumulator(); | 1419 Node* state = environment()->LookupAccumulator(); |
1420 Node* generator = environment()->LookupRegister( | 1420 Node* generator = environment()->LookupRegister( |
1421 bytecode_iterator().GetRegisterOperand(0)); | 1421 bytecode_iterator().GetRegisterOperand(0)); |
| 1422 // The offsets used by the bytecode iterator are relative to a different base |
| 1423 // than what is used in the interpreter, hence the addition. |
| 1424 Node* offset = |
| 1425 jsgraph()->Constant(bytecode_iterator().current_offset() + |
| 1426 (BytecodeArray::kHeaderSize - kHeapObjectTag)); |
1422 | 1427 |
1423 int register_count = environment()->register_count(); | 1428 int register_count = environment()->register_count(); |
1424 int value_input_count = 2 + register_count; | 1429 int value_input_count = 3 + register_count; |
1425 | 1430 |
1426 Node** value_inputs = local_zone()->NewArray<Node*>(value_input_count); | 1431 Node** value_inputs = local_zone()->NewArray<Node*>(value_input_count); |
1427 value_inputs[0] = generator; | 1432 value_inputs[0] = generator; |
1428 value_inputs[1] = state; | 1433 value_inputs[1] = state; |
| 1434 value_inputs[2] = offset; |
1429 for (int i = 0; i < register_count; ++i) { | 1435 for (int i = 0; i < register_count; ++i) { |
1430 value_inputs[2 + i] = | 1436 value_inputs[3 + i] = |
1431 environment()->LookupRegister(interpreter::Register(i)); | 1437 environment()->LookupRegister(interpreter::Register(i)); |
1432 } | 1438 } |
1433 | 1439 |
1434 MakeNode(javascript()->GeneratorStore(register_count), value_input_count, | 1440 MakeNode(javascript()->GeneratorStore(register_count), value_input_count, |
1435 value_inputs, false); | 1441 value_inputs, false); |
1436 } | 1442 } |
1437 | 1443 |
1438 void BytecodeGraphBuilder::VisitResumeGenerator() { | 1444 void BytecodeGraphBuilder::VisitResumeGenerator() { |
1439 FrameStateBeforeAndAfter states(this); | 1445 FrameStateBeforeAndAfter states(this); |
1440 | 1446 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 // Phi does not exist yet, introduce one. | 1746 // Phi does not exist yet, introduce one. |
1741 value = NewPhi(inputs, value, control); | 1747 value = NewPhi(inputs, value, control); |
1742 value->ReplaceInput(inputs - 1, other); | 1748 value->ReplaceInput(inputs - 1, other); |
1743 } | 1749 } |
1744 return value; | 1750 return value; |
1745 } | 1751 } |
1746 | 1752 |
1747 } // namespace compiler | 1753 } // namespace compiler |
1748 } // namespace internal | 1754 } // namespace internal |
1749 } // namespace v8 | 1755 } // namespace v8 |
OLD | NEW |