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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 // | 1090 // |
1091 // Cast the object referenced by the accumulator to a number. | 1091 // Cast the object referenced by the accumulator to a number. |
1092 void Interpreter::DoToNumber(compiler::InterpreterAssembler* assembler) { | 1092 void Interpreter::DoToNumber(compiler::InterpreterAssembler* assembler) { |
1093 Node* accumulator = __ GetAccumulator(); | 1093 Node* accumulator = __ GetAccumulator(); |
1094 Node* result = __ CallRuntime(Runtime::kToNumber, accumulator); | 1094 Node* result = __ CallRuntime(Runtime::kToNumber, accumulator); |
1095 __ SetAccumulator(result); | 1095 __ SetAccumulator(result); |
1096 __ Dispatch(); | 1096 __ Dispatch(); |
1097 } | 1097 } |
1098 | 1098 |
1099 | 1099 |
1100 // ToObject | |
1101 // | |
1102 // Cast the object referenced by the accumulator to a JSObject. | |
1103 void Interpreter::DoToObject(compiler::InterpreterAssembler* assembler) { | |
1104 Node* accumulator = __ GetAccumulator(); | |
1105 Node* result = __ CallRuntime(Runtime::kToObject, accumulator); | |
1106 __ SetAccumulator(result); | |
1107 __ Dispatch(); | |
1108 } | |
1109 | |
1110 | |
1111 // Jump <imm8> | 1100 // Jump <imm8> |
1112 // | 1101 // |
1113 // Jump by number of bytes represented by the immediate operand |imm8|. | 1102 // Jump by number of bytes represented by the immediate operand |imm8|. |
1114 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { | 1103 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { |
1115 Node* relative_jump = __ BytecodeOperandImm(0); | 1104 Node* relative_jump = __ BytecodeOperandImm(0); |
1116 __ Jump(relative_jump); | 1105 __ Jump(relative_jump); |
1117 } | 1106 } |
1118 | 1107 |
1119 | 1108 |
1120 // JumpConstant <idx> | 1109 // JumpConstant <idx> |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1444 | 1433 |
1445 | 1434 |
1446 // Return | 1435 // Return |
1447 // | 1436 // |
1448 // Return the value in the accumulator. | 1437 // Return the value in the accumulator. |
1449 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 1438 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
1450 __ Return(); | 1439 __ Return(); |
1451 } | 1440 } |
1452 | 1441 |
1453 | 1442 |
1454 // ForInPrepare <receiver> | 1443 // ForInPrepare <receiver> <cache_type> <cache_array> <cache_length> |
1455 // | 1444 // |
1456 // Returns state for for..in loop execution based on the |receiver| and | 1445 // Returns state for for..in loop execution based on the object in the |
1457 // the property names in the accumulator. | 1446 // accumulator. |
1447 // The |receiver|, |cache_type|, |cache_array|, and |cache_length| are all | |
1448 // output | |
1449 // parameters. | |
1458 void Interpreter::DoForInPrepare(compiler::InterpreterAssembler* assembler) { | 1450 void Interpreter::DoForInPrepare(compiler::InterpreterAssembler* assembler) { |
1459 Node* receiver_reg = __ BytecodeOperandReg(0); | 1451 // Call runtime to set-up ForInPrepareState |
1460 Node* receiver = __ LoadRegister(receiver_reg); | 1452 Node* object = __ GetAccumulator(); |
1461 Node* property_names = __ GetAccumulator(); | 1453 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, object); |
1462 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, receiver, | 1454 |
1463 property_names); | 1455 for (int i = 0; i < 4; i++) { |
1456 // 0 == receiver, 1 == cache_type, 2 == cache_array, 3 == cache_length | |
1457 Node* cache_info = __ LoadFixedArrayElement(result, i); | |
1458 Node* cache_info_reg = __ BytecodeOperandReg(i); | |
1459 __ StoreRegister(cache_info, cache_info_reg); | |
1460 } | |
1464 __ SetAccumulator(result); | 1461 __ SetAccumulator(result); |
1465 __ Dispatch(); | 1462 __ Dispatch(); |
1466 } | 1463 } |
1467 | 1464 |
1468 | 1465 |
1469 // ForInNext <for_in_state> <index> | 1466 // ForInNext <receiver> <cache_type> <cache_array> <index> |
1470 // | 1467 // |
1471 // Returns the next key in a for..in loop. The state associated with the | 1468 // Returns the next key in a for..in loop. |
1472 // iteration is contained in |for_in_state| and |index| is the current | |
1473 // zero-based iteration count. | |
1474 void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) { | 1469 void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) { |
1475 Node* for_in_state_reg = __ BytecodeOperandReg(0); | 1470 Node* receiver_reg = __ BytecodeOperandReg(0); |
1476 Node* for_in_state = __ LoadRegister(for_in_state_reg); | 1471 Node* receiver = __ LoadRegister(receiver_reg); |
1477 Node* receiver = __ LoadFixedArrayElement(for_in_state, 0); | 1472 Node* cache_type_reg = __ BytecodeOperandReg(1); |
1478 Node* cache_array = __ LoadFixedArrayElement(for_in_state, 1); | 1473 Node* cache_type = __ LoadRegister(cache_type_reg); |
1479 Node* cache_type = __ LoadFixedArrayElement(for_in_state, 2); | 1474 Node* cache_array_reg = __ BytecodeOperandReg(2); |
1480 Node* index_reg = __ BytecodeOperandReg(1); | 1475 Node* cache_array = __ LoadRegister(cache_array_reg); |
1476 Node* index_reg = __ BytecodeOperandReg(3); | |
1481 Node* index = __ LoadRegister(index_reg); | 1477 Node* index = __ LoadRegister(index_reg); |
1482 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array, | 1478 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array, |
1483 cache_type, index); | 1479 cache_type, index); |
1484 __ SetAccumulator(result); | 1480 __ SetAccumulator(result); |
1485 __ Dispatch(); | 1481 __ Dispatch(); |
1486 } | 1482 } |
1487 | 1483 |
1488 | 1484 |
1489 // ForInDone <for_in_state> | 1485 // ForInDone <index> <cache_length> |
1490 // | 1486 // |
1491 // Returns the next key in a for..in loop. The accumulator contains the current | 1487 // Returns the next key in a for..in loop. |
1492 // zero-based iteration count and |for_in_state| is the state returned by an | |
1493 // earlier invocation of ForInPrepare. | |
1494 void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) { | 1488 void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) { |
1495 Node* index = __ GetAccumulator(); | 1489 // TODO(oth): Implement in interpreter assembler. |
rmcilroy
2015/12/17 15:43:26
Not sure what this TODO means? What do you want to
oth
2015/12/17 19:28:23
There are among the easiest bytecodes to write in
| |
1496 Node* for_in_state_reg = __ BytecodeOperandReg(0); | 1490 Node* index_reg = __ BytecodeOperandReg(0); |
1497 Node* for_in_state = __ LoadRegister(for_in_state_reg); | 1491 Node* index = __ LoadRegister(index_reg); |
1498 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); | 1492 Node* cache_length_reg = __ BytecodeOperandReg(1); |
1493 Node* cache_length = __ LoadRegister(cache_length_reg); | |
1499 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); | 1494 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); |
1500 __ SetAccumulator(result); | 1495 __ SetAccumulator(result); |
1501 __ Dispatch(); | 1496 __ Dispatch(); |
1502 } | 1497 } |
1503 | 1498 |
1504 | 1499 |
1500 // ForInStep <index> | |
1501 // | |
1502 // Increments the loop counter |index|. | |
1503 void Interpreter::DoForInStep(compiler::InterpreterAssembler* assembler) { | |
1504 // TODO(oth): Implement in interpreter assembler. | |
rmcilroy
2015/12/17 15:43:27
ditto
oth
2015/12/17 19:28:23
ditto.
| |
1505 Node* index_reg = __ BytecodeOperandReg(0); | |
1506 Node* index = __ LoadRegister(index_reg); | |
1507 Node* result = __ CallRuntime(Runtime::kForInStep, index); | |
1508 __ StoreRegister(result, index_reg); | |
1509 __ Dispatch(); | |
1510 } | |
1511 | |
1512 | |
1505 } // namespace interpreter | 1513 } // namespace interpreter |
1506 } // namespace internal | 1514 } // namespace internal |
1507 } // namespace v8 | 1515 } // namespace v8 |
OLD | NEW |