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/interpreter.h" | 5 #include "src/interpreter/interpreter.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/compiler/interpreter-assembler.h" | 9 #include "src/compiler/interpreter-assembler.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 | 1509 |
1510 | 1510 |
1511 // Return | 1511 // Return |
1512 // | 1512 // |
1513 // Return the value in the accumulator. | 1513 // Return the value in the accumulator. |
1514 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 1514 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
1515 __ Return(); | 1515 __ Return(); |
1516 } | 1516 } |
1517 | 1517 |
1518 | 1518 |
1519 // ForInPrepare <receiver> | 1519 // ForInPrepare <cache_type> <cache_array> <cache_length> |
1520 // | 1520 // |
1521 // Returns state for for..in loop execution based on the |receiver| and | 1521 // Returns state for for..in loop execution based on the object in the |
1522 // the property names in the accumulator. | 1522 // accumulator. The registers |cache_type|, |cache_array|, and |
| 1523 // |cache_length| represent output parameters. |
1523 void Interpreter::DoForInPrepare(compiler::InterpreterAssembler* assembler) { | 1524 void Interpreter::DoForInPrepare(compiler::InterpreterAssembler* assembler) { |
1524 Node* receiver_reg = __ BytecodeOperandReg(0); | 1525 Node* object = __ GetAccumulator(); |
1525 Node* receiver = __ LoadRegister(receiver_reg); | 1526 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, object); |
1526 Node* property_names = __ GetAccumulator(); | 1527 for (int i = 0; i < 3; i++) { |
1527 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, receiver, | 1528 // 0 == cache_type, 1 == cache_array, 2 == cache_length |
1528 property_names); | 1529 Node* cache_info = __ LoadFixedArrayElement(result, i); |
| 1530 Node* cache_info_reg = __ BytecodeOperandReg(i); |
| 1531 __ StoreRegister(cache_info, cache_info_reg); |
| 1532 } |
1529 __ SetAccumulator(result); | 1533 __ SetAccumulator(result); |
1530 __ Dispatch(); | 1534 __ Dispatch(); |
1531 } | 1535 } |
1532 | 1536 |
1533 | 1537 |
1534 // ForInNext <for_in_state> <index> | 1538 // ForInNext <receiver> <cache_type> <cache_array> <index> |
1535 // | 1539 // |
1536 // Returns the next key in a for..in loop. The state associated with the | 1540 // Returns the next enumerable property in the the accumulator. |
1537 // iteration is contained in |for_in_state| and |index| is the current | |
1538 // zero-based iteration count. | |
1539 void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) { | 1541 void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) { |
1540 Node* for_in_state_reg = __ BytecodeOperandReg(0); | 1542 Node* receiver_reg = __ BytecodeOperandReg(0); |
1541 Node* for_in_state = __ LoadRegister(for_in_state_reg); | 1543 Node* receiver = __ LoadRegister(receiver_reg); |
1542 Node* receiver = __ LoadFixedArrayElement(for_in_state, 0); | 1544 Node* cache_type_reg = __ BytecodeOperandReg(1); |
1543 Node* cache_array = __ LoadFixedArrayElement(for_in_state, 1); | 1545 Node* cache_type = __ LoadRegister(cache_type_reg); |
1544 Node* cache_type = __ LoadFixedArrayElement(for_in_state, 2); | 1546 Node* cache_array_reg = __ BytecodeOperandReg(2); |
1545 Node* index_reg = __ BytecodeOperandReg(1); | 1547 Node* cache_array = __ LoadRegister(cache_array_reg); |
| 1548 Node* index_reg = __ BytecodeOperandReg(3); |
1546 Node* index = __ LoadRegister(index_reg); | 1549 Node* index = __ LoadRegister(index_reg); |
1547 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array, | 1550 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array, |
1548 cache_type, index); | 1551 cache_type, index); |
1549 __ SetAccumulator(result); | 1552 __ SetAccumulator(result); |
1550 __ Dispatch(); | 1553 __ Dispatch(); |
1551 } | 1554 } |
1552 | 1555 |
1553 | 1556 |
1554 // ForInDone <for_in_state> | 1557 // ForInDone <index> <cache_length> |
1555 // | 1558 // |
1556 // Returns the next key in a for..in loop. The accumulator contains the current | 1559 // Returns true if the end of the enumerable properties has been reached. |
1557 // zero-based iteration count and |for_in_state| is the state returned by an | |
1558 // earlier invocation of ForInPrepare. | |
1559 void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) { | 1560 void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) { |
1560 Node* index = __ GetAccumulator(); | 1561 // TODO(oth): Implement directly rather than making a runtime call. |
1561 Node* for_in_state_reg = __ BytecodeOperandReg(0); | 1562 Node* index_reg = __ BytecodeOperandReg(0); |
1562 Node* for_in_state = __ LoadRegister(for_in_state_reg); | 1563 Node* index = __ LoadRegister(index_reg); |
1563 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); | 1564 Node* cache_length_reg = __ BytecodeOperandReg(1); |
| 1565 Node* cache_length = __ LoadRegister(cache_length_reg); |
1564 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); | 1566 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); |
1565 __ SetAccumulator(result); | 1567 __ SetAccumulator(result); |
1566 __ Dispatch(); | 1568 __ Dispatch(); |
1567 } | 1569 } |
1568 | 1570 |
1569 | 1571 |
| 1572 // ForInStep <index> |
| 1573 // |
| 1574 // Increments the loop counter in register |index| and stores the result |
| 1575 // in the accumulator. |
| 1576 void Interpreter::DoForInStep(compiler::InterpreterAssembler* assembler) { |
| 1577 // TODO(oth): Implement directly rather than making a runtime call. |
| 1578 Node* index_reg = __ BytecodeOperandReg(0); |
| 1579 Node* index = __ LoadRegister(index_reg); |
| 1580 Node* result = __ CallRuntime(Runtime::kForInStep, index); |
| 1581 __ SetAccumulator(result); |
| 1582 __ Dispatch(); |
| 1583 } |
| 1584 |
1570 } // namespace interpreter | 1585 } // namespace interpreter |
1571 } // namespace internal | 1586 } // namespace internal |
1572 } // namespace v8 | 1587 } // namespace v8 |
OLD | NEW |