| 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 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1370 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1371 index = NewNode(javascript()->ForInStep(), index); | 1371 index = NewNode(javascript()->ForInStep(), index); |
| 1372 environment()->BindAccumulator(index, &states); | 1372 environment()->BindAccumulator(index, &states); |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 void BytecodeGraphBuilder::VisitSuspendGenerator() { | 1375 void BytecodeGraphBuilder::VisitSuspendGenerator() { |
| 1376 Node* state = environment()->LookupAccumulator(); | 1376 Node* state = environment()->LookupAccumulator(); |
| 1377 Node* generator = environment()->LookupRegister( | 1377 Node* generator = environment()->LookupRegister( |
| 1378 bytecode_iterator().GetRegisterOperand(0)); | 1378 bytecode_iterator().GetRegisterOperand(0)); |
| 1379 | 1379 |
| 1380 for (int i = 0; i < environment()->register_count(); ++i) { | 1380 int register_count = environment()->register_count(); |
| 1381 Node* value = environment()->LookupRegister(interpreter::Register(i)); | 1381 int value_input_count = 2 + register_count; |
| 1382 NewNode(javascript()->CallRuntime(Runtime::kGeneratorStoreRegister), | 1382 |
| 1383 generator, jsgraph()->Constant(i), value); | 1383 Node** value_inputs = local_zone()->NewArray<Node*>(value_input_count); |
| 1384 value_inputs[0] = generator; |
| 1385 value_inputs[1] = state; |
| 1386 for (int i = 0; i < register_count; ++i) { |
| 1387 value_inputs[2 + i] = |
| 1388 environment()->LookupRegister(interpreter::Register(i)); |
| 1384 } | 1389 } |
| 1385 | 1390 |
| 1386 NewNode(javascript()->CallRuntime(Runtime::kGeneratorSetContext), generator); | 1391 MakeNode(javascript()->GeneratorStore(register_count), value_input_count, |
| 1387 NewNode(javascript()->CallRuntime(Runtime::kGeneratorSetContinuation), | 1392 value_inputs, false); |
| 1388 generator, state); | |
| 1389 } | 1393 } |
| 1390 | 1394 |
| 1391 void BytecodeGraphBuilder::VisitResumeGenerator() { | 1395 void BytecodeGraphBuilder::VisitResumeGenerator() { |
| 1392 FrameStateBeforeAndAfter states(this); | 1396 FrameStateBeforeAndAfter states(this); |
| 1393 | 1397 |
| 1394 Node* generator = environment()->LookupRegister( | 1398 Node* generator = environment()->LookupRegister( |
| 1395 bytecode_iterator().GetRegisterOperand(0)); | 1399 bytecode_iterator().GetRegisterOperand(0)); |
| 1396 Node* state = NewNode(javascript()->CallRuntime( | |
| 1397 Runtime::kGeneratorGetContinuation), generator); | |
| 1398 | 1400 |
| 1399 // Bijection between registers and array indices must match that used in | 1401 // Bijection between registers and array indices must match that used in |
| 1400 // InterpreterAssembler::ExportRegisterFile. | 1402 // InterpreterAssembler::ExportRegisterFile. |
| 1401 for (int i = 0; i < environment()->register_count(); ++i) { | 1403 for (int i = 0; i < environment()->register_count(); ++i) { |
| 1402 Node* value = NewNode( | 1404 Node* value = NewNode(javascript()->GeneratorRestoreRegister(i), generator); |
| 1403 javascript()->CallRuntime(Runtime::kGeneratorLoadRegister), | |
| 1404 generator, jsgraph()->Constant(i)); | |
| 1405 environment()->BindRegister(interpreter::Register(i), value); | 1405 environment()->BindRegister(interpreter::Register(i), value); |
| 1406 | |
| 1407 NewNode(javascript()->CallRuntime(Runtime::kGeneratorStoreRegister), | |
| 1408 generator, jsgraph()->Constant(i), jsgraph()->StaleRegisterConstant()); | |
| 1409 } | 1406 } |
| 1410 | 1407 |
| 1411 NewNode(javascript()->CallRuntime(Runtime::kGeneratorSetContinuation), | 1408 Node* state = |
| 1412 generator, jsgraph()->Constant(JSGeneratorObject::kGeneratorExecuting)); | 1409 NewNode(javascript()->GeneratorRestoreContinuation(), generator); |
| 1413 | 1410 |
| 1414 environment()->BindAccumulator(state, &states); | 1411 environment()->BindAccumulator(state, &states); |
| 1415 } | 1412 } |
| 1416 | 1413 |
| 1417 void BytecodeGraphBuilder::VisitWide() { | 1414 void BytecodeGraphBuilder::VisitWide() { |
| 1418 // Consumed by the BytecodeArrayIterator. | 1415 // Consumed by the BytecodeArrayIterator. |
| 1419 UNREACHABLE(); | 1416 UNREACHABLE(); |
| 1420 } | 1417 } |
| 1421 | 1418 |
| 1422 void BytecodeGraphBuilder::VisitExtraWide() { | 1419 void BytecodeGraphBuilder::VisitExtraWide() { |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 // Phi does not exist yet, introduce one. | 1693 // Phi does not exist yet, introduce one. |
| 1697 value = NewPhi(inputs, value, control); | 1694 value = NewPhi(inputs, value, control); |
| 1698 value->ReplaceInput(inputs - 1, other); | 1695 value->ReplaceInput(inputs - 1, other); |
| 1699 } | 1696 } |
| 1700 return value; | 1697 return value; |
| 1701 } | 1698 } |
| 1702 | 1699 |
| 1703 } // namespace compiler | 1700 } // namespace compiler |
| 1704 } // namespace internal | 1701 } // namespace internal |
| 1705 } // namespace v8 | 1702 } // namespace v8 |
| OLD | NEW |