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 <fstream> | 7 #include <fstream> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 void Interpreter::DoJump(InterpreterAssembler* assembler) { | 1395 void Interpreter::DoJump(InterpreterAssembler* assembler) { |
1396 Node* relative_jump = __ BytecodeOperandImm(0); | 1396 Node* relative_jump = __ BytecodeOperandImm(0); |
1397 __ Jump(relative_jump); | 1397 __ Jump(relative_jump); |
1398 } | 1398 } |
1399 | 1399 |
1400 // JumpConstant <idx> | 1400 // JumpConstant <idx> |
1401 // | 1401 // |
1402 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool. | 1402 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool. |
1403 void Interpreter::DoJumpConstant(InterpreterAssembler* assembler) { | 1403 void Interpreter::DoJumpConstant(InterpreterAssembler* assembler) { |
1404 Node* index = __ BytecodeOperandIdx(0); | 1404 Node* index = __ BytecodeOperandIdx(0); |
1405 Node* constant = __ LoadConstantPoolEntry(index); | 1405 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
1406 Node* relative_jump = __ SmiUntag(constant); | |
1407 __ Jump(relative_jump); | 1406 __ Jump(relative_jump); |
1408 } | 1407 } |
1409 | 1408 |
1410 // JumpIfTrue <imm> | 1409 // JumpIfTrue <imm> |
1411 // | 1410 // |
1412 // Jump by number of bytes represented by an immediate operand if the | 1411 // Jump by number of bytes represented by an immediate operand if the |
1413 // accumulator contains true. | 1412 // accumulator contains true. |
1414 void Interpreter::DoJumpIfTrue(InterpreterAssembler* assembler) { | 1413 void Interpreter::DoJumpIfTrue(InterpreterAssembler* assembler) { |
1415 Node* accumulator = __ GetAccumulator(); | 1414 Node* accumulator = __ GetAccumulator(); |
1416 Node* relative_jump = __ BytecodeOperandImm(0); | 1415 Node* relative_jump = __ BytecodeOperandImm(0); |
1417 Node* true_value = __ BooleanConstant(true); | 1416 Node* true_value = __ BooleanConstant(true); |
1418 __ JumpIfWordEqual(accumulator, true_value, relative_jump); | 1417 __ JumpIfWordEqual(accumulator, true_value, relative_jump); |
1419 } | 1418 } |
1420 | 1419 |
1421 // JumpIfTrueConstant <idx> | 1420 // JumpIfTrueConstant <idx> |
1422 // | 1421 // |
1423 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1422 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
1424 // if the accumulator contains true. | 1423 // if the accumulator contains true. |
1425 void Interpreter::DoJumpIfTrueConstant(InterpreterAssembler* assembler) { | 1424 void Interpreter::DoJumpIfTrueConstant(InterpreterAssembler* assembler) { |
1426 Node* accumulator = __ GetAccumulator(); | 1425 Node* accumulator = __ GetAccumulator(); |
1427 Node* index = __ BytecodeOperandIdx(0); | 1426 Node* index = __ BytecodeOperandIdx(0); |
1428 Node* constant = __ LoadConstantPoolEntry(index); | 1427 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
1429 Node* relative_jump = __ SmiUntag(constant); | |
1430 Node* true_value = __ BooleanConstant(true); | 1428 Node* true_value = __ BooleanConstant(true); |
1431 __ JumpIfWordEqual(accumulator, true_value, relative_jump); | 1429 __ JumpIfWordEqual(accumulator, true_value, relative_jump); |
1432 } | 1430 } |
1433 | 1431 |
1434 // JumpIfFalse <imm> | 1432 // JumpIfFalse <imm> |
1435 // | 1433 // |
1436 // Jump by number of bytes represented by an immediate operand if the | 1434 // Jump by number of bytes represented by an immediate operand if the |
1437 // accumulator contains false. | 1435 // accumulator contains false. |
1438 void Interpreter::DoJumpIfFalse(InterpreterAssembler* assembler) { | 1436 void Interpreter::DoJumpIfFalse(InterpreterAssembler* assembler) { |
1439 Node* accumulator = __ GetAccumulator(); | 1437 Node* accumulator = __ GetAccumulator(); |
1440 Node* relative_jump = __ BytecodeOperandImm(0); | 1438 Node* relative_jump = __ BytecodeOperandImm(0); |
1441 Node* false_value = __ BooleanConstant(false); | 1439 Node* false_value = __ BooleanConstant(false); |
1442 __ JumpIfWordEqual(accumulator, false_value, relative_jump); | 1440 __ JumpIfWordEqual(accumulator, false_value, relative_jump); |
1443 } | 1441 } |
1444 | 1442 |
1445 // JumpIfFalseConstant <idx> | 1443 // JumpIfFalseConstant <idx> |
1446 // | 1444 // |
1447 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1445 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
1448 // if the accumulator contains false. | 1446 // if the accumulator contains false. |
1449 void Interpreter::DoJumpIfFalseConstant(InterpreterAssembler* assembler) { | 1447 void Interpreter::DoJumpIfFalseConstant(InterpreterAssembler* assembler) { |
1450 Node* accumulator = __ GetAccumulator(); | 1448 Node* accumulator = __ GetAccumulator(); |
1451 Node* index = __ BytecodeOperandIdx(0); | 1449 Node* index = __ BytecodeOperandIdx(0); |
1452 Node* constant = __ LoadConstantPoolEntry(index); | 1450 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
1453 Node* relative_jump = __ SmiUntag(constant); | |
1454 Node* false_value = __ BooleanConstant(false); | 1451 Node* false_value = __ BooleanConstant(false); |
1455 __ JumpIfWordEqual(accumulator, false_value, relative_jump); | 1452 __ JumpIfWordEqual(accumulator, false_value, relative_jump); |
1456 } | 1453 } |
1457 | 1454 |
1458 // JumpIfToBooleanTrue <imm> | 1455 // JumpIfToBooleanTrue <imm> |
1459 // | 1456 // |
1460 // Jump by number of bytes represented by an immediate operand if the object | 1457 // Jump by number of bytes represented by an immediate operand if the object |
1461 // referenced by the accumulator is true when the object is cast to boolean. | 1458 // referenced by the accumulator is true when the object is cast to boolean. |
1462 void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) { | 1459 void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) { |
1463 Node* value = __ GetAccumulator(); | 1460 Node* value = __ GetAccumulator(); |
1464 Node* relative_jump = __ BytecodeOperandImm(0); | 1461 Node* relative_jump = __ BytecodeOperandImm(0); |
1465 Label if_true(assembler), if_false(assembler); | 1462 Label if_true(assembler), if_false(assembler); |
1466 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); | 1463 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); |
1467 __ Bind(&if_true); | 1464 __ Bind(&if_true); |
1468 __ Jump(relative_jump); | 1465 __ Jump(relative_jump); |
1469 __ Bind(&if_false); | 1466 __ Bind(&if_false); |
1470 __ Dispatch(); | 1467 __ Dispatch(); |
1471 } | 1468 } |
1472 | 1469 |
1473 // JumpIfToBooleanTrueConstant <idx> | 1470 // JumpIfToBooleanTrueConstant <idx> |
1474 // | 1471 // |
1475 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1472 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
1476 // if the object referenced by the accumulator is true when the object is cast | 1473 // if the object referenced by the accumulator is true when the object is cast |
1477 // to boolean. | 1474 // to boolean. |
1478 void Interpreter::DoJumpIfToBooleanTrueConstant( | 1475 void Interpreter::DoJumpIfToBooleanTrueConstant( |
1479 InterpreterAssembler* assembler) { | 1476 InterpreterAssembler* assembler) { |
1480 Node* value = __ GetAccumulator(); | 1477 Node* value = __ GetAccumulator(); |
1481 Node* index = __ BytecodeOperandIdx(0); | 1478 Node* index = __ BytecodeOperandIdx(0); |
1482 Node* constant = __ LoadConstantPoolEntry(index); | 1479 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
1483 Node* relative_jump = __ SmiUntag(constant); | |
1484 Label if_true(assembler), if_false(assembler); | 1480 Label if_true(assembler), if_false(assembler); |
1485 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); | 1481 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); |
1486 __ Bind(&if_true); | 1482 __ Bind(&if_true); |
1487 __ Jump(relative_jump); | 1483 __ Jump(relative_jump); |
1488 __ Bind(&if_false); | 1484 __ Bind(&if_false); |
1489 __ Dispatch(); | 1485 __ Dispatch(); |
1490 } | 1486 } |
1491 | 1487 |
1492 // JumpIfToBooleanFalse <imm> | 1488 // JumpIfToBooleanFalse <imm> |
1493 // | 1489 // |
(...skipping 12 matching lines...) Expand all Loading... |
1506 | 1502 |
1507 // JumpIfToBooleanFalseConstant <idx> | 1503 // JumpIfToBooleanFalseConstant <idx> |
1508 // | 1504 // |
1509 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1505 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
1510 // if the object referenced by the accumulator is false when the object is cast | 1506 // if the object referenced by the accumulator is false when the object is cast |
1511 // to boolean. | 1507 // to boolean. |
1512 void Interpreter::DoJumpIfToBooleanFalseConstant( | 1508 void Interpreter::DoJumpIfToBooleanFalseConstant( |
1513 InterpreterAssembler* assembler) { | 1509 InterpreterAssembler* assembler) { |
1514 Node* value = __ GetAccumulator(); | 1510 Node* value = __ GetAccumulator(); |
1515 Node* index = __ BytecodeOperandIdx(0); | 1511 Node* index = __ BytecodeOperandIdx(0); |
1516 Node* constant = __ LoadConstantPoolEntry(index); | 1512 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
1517 Node* relative_jump = __ SmiUntag(constant); | |
1518 Label if_true(assembler), if_false(assembler); | 1513 Label if_true(assembler), if_false(assembler); |
1519 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); | 1514 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); |
1520 __ Bind(&if_true); | 1515 __ Bind(&if_true); |
1521 __ Dispatch(); | 1516 __ Dispatch(); |
1522 __ Bind(&if_false); | 1517 __ Bind(&if_false); |
1523 __ Jump(relative_jump); | 1518 __ Jump(relative_jump); |
1524 } | 1519 } |
1525 | 1520 |
1526 // JumpIfNull <imm> | 1521 // JumpIfNull <imm> |
1527 // | 1522 // |
1528 // Jump by number of bytes represented by an immediate operand if the object | 1523 // Jump by number of bytes represented by an immediate operand if the object |
1529 // referenced by the accumulator is the null constant. | 1524 // referenced by the accumulator is the null constant. |
1530 void Interpreter::DoJumpIfNull(InterpreterAssembler* assembler) { | 1525 void Interpreter::DoJumpIfNull(InterpreterAssembler* assembler) { |
1531 Node* accumulator = __ GetAccumulator(); | 1526 Node* accumulator = __ GetAccumulator(); |
1532 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); | 1527 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
1533 Node* relative_jump = __ BytecodeOperandImm(0); | 1528 Node* relative_jump = __ BytecodeOperandImm(0); |
1534 __ JumpIfWordEqual(accumulator, null_value, relative_jump); | 1529 __ JumpIfWordEqual(accumulator, null_value, relative_jump); |
1535 } | 1530 } |
1536 | 1531 |
1537 // JumpIfNullConstant <idx> | 1532 // JumpIfNullConstant <idx> |
1538 // | 1533 // |
1539 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1534 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
1540 // if the object referenced by the accumulator is the null constant. | 1535 // if the object referenced by the accumulator is the null constant. |
1541 void Interpreter::DoJumpIfNullConstant(InterpreterAssembler* assembler) { | 1536 void Interpreter::DoJumpIfNullConstant(InterpreterAssembler* assembler) { |
1542 Node* accumulator = __ GetAccumulator(); | 1537 Node* accumulator = __ GetAccumulator(); |
1543 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); | 1538 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
1544 Node* index = __ BytecodeOperandIdx(0); | 1539 Node* index = __ BytecodeOperandIdx(0); |
1545 Node* constant = __ LoadConstantPoolEntry(index); | 1540 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
1546 Node* relative_jump = __ SmiUntag(constant); | |
1547 __ JumpIfWordEqual(accumulator, null_value, relative_jump); | 1541 __ JumpIfWordEqual(accumulator, null_value, relative_jump); |
1548 } | 1542 } |
1549 | 1543 |
1550 // JumpIfUndefined <imm> | 1544 // JumpIfUndefined <imm> |
1551 // | 1545 // |
1552 // Jump by number of bytes represented by an immediate operand if the object | 1546 // Jump by number of bytes represented by an immediate operand if the object |
1553 // referenced by the accumulator is the undefined constant. | 1547 // referenced by the accumulator is the undefined constant. |
1554 void Interpreter::DoJumpIfUndefined(InterpreterAssembler* assembler) { | 1548 void Interpreter::DoJumpIfUndefined(InterpreterAssembler* assembler) { |
1555 Node* accumulator = __ GetAccumulator(); | 1549 Node* accumulator = __ GetAccumulator(); |
1556 Node* undefined_value = | 1550 Node* undefined_value = |
1557 __ HeapConstant(isolate_->factory()->undefined_value()); | 1551 __ HeapConstant(isolate_->factory()->undefined_value()); |
1558 Node* relative_jump = __ BytecodeOperandImm(0); | 1552 Node* relative_jump = __ BytecodeOperandImm(0); |
1559 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); | 1553 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); |
1560 } | 1554 } |
1561 | 1555 |
1562 // JumpIfUndefinedConstant <idx> | 1556 // JumpIfUndefinedConstant <idx> |
1563 // | 1557 // |
1564 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1558 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
1565 // if the object referenced by the accumulator is the undefined constant. | 1559 // if the object referenced by the accumulator is the undefined constant. |
1566 void Interpreter::DoJumpIfUndefinedConstant(InterpreterAssembler* assembler) { | 1560 void Interpreter::DoJumpIfUndefinedConstant(InterpreterAssembler* assembler) { |
1567 Node* accumulator = __ GetAccumulator(); | 1561 Node* accumulator = __ GetAccumulator(); |
1568 Node* undefined_value = | 1562 Node* undefined_value = |
1569 __ HeapConstant(isolate_->factory()->undefined_value()); | 1563 __ HeapConstant(isolate_->factory()->undefined_value()); |
1570 Node* index = __ BytecodeOperandIdx(0); | 1564 Node* index = __ BytecodeOperandIdx(0); |
1571 Node* constant = __ LoadConstantPoolEntry(index); | 1565 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
1572 Node* relative_jump = __ SmiUntag(constant); | |
1573 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); | 1566 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); |
1574 } | 1567 } |
1575 | 1568 |
1576 // JumpIfNotHole <imm> | 1569 // JumpIfNotHole <imm> |
1577 // | 1570 // |
1578 // Jump by number of bytes represented by an immediate operand if the object | 1571 // Jump by number of bytes represented by an immediate operand if the object |
1579 // referenced by the accumulator is the hole. | 1572 // referenced by the accumulator is the hole. |
1580 void Interpreter::DoJumpIfNotHole(InterpreterAssembler* assembler) { | 1573 void Interpreter::DoJumpIfNotHole(InterpreterAssembler* assembler) { |
1581 Node* accumulator = __ GetAccumulator(); | 1574 Node* accumulator = __ GetAccumulator(); |
1582 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value()); | 1575 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value()); |
1583 Node* relative_jump = __ BytecodeOperandImm(0); | 1576 Node* relative_jump = __ BytecodeOperandImm(0); |
1584 __ JumpIfWordNotEqual(accumulator, the_hole_value, relative_jump); | 1577 __ JumpIfWordNotEqual(accumulator, the_hole_value, relative_jump); |
1585 } | 1578 } |
1586 | 1579 |
1587 // JumpIfNotHoleConstant <idx> | 1580 // JumpIfNotHoleConstant <idx> |
1588 // | 1581 // |
1589 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1582 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
1590 // if the object referenced by the accumulator is the hole constant. | 1583 // if the object referenced by the accumulator is the hole constant. |
1591 void Interpreter::DoJumpIfNotHoleConstant(InterpreterAssembler* assembler) { | 1584 void Interpreter::DoJumpIfNotHoleConstant(InterpreterAssembler* assembler) { |
1592 Node* accumulator = __ GetAccumulator(); | 1585 Node* accumulator = __ GetAccumulator(); |
1593 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value()); | 1586 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value()); |
1594 Node* index = __ BytecodeOperandIdx(0); | 1587 Node* index = __ BytecodeOperandIdx(0); |
1595 Node* constant = __ LoadConstantPoolEntry(index); | 1588 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
1596 Node* relative_jump = __ SmiUntag(constant); | |
1597 __ JumpIfWordNotEqual(accumulator, the_hole_value, relative_jump); | 1589 __ JumpIfWordNotEqual(accumulator, the_hole_value, relative_jump); |
1598 } | 1590 } |
1599 | 1591 |
1600 // CreateRegExpLiteral <pattern_idx> <literal_idx> <flags> | 1592 // CreateRegExpLiteral <pattern_idx> <literal_idx> <flags> |
1601 // | 1593 // |
1602 // Creates a regular expression literal for literal index <literal_idx> with | 1594 // Creates a regular expression literal for literal index <literal_idx> with |
1603 // <flags> and the pattern in <pattern_idx>. | 1595 // <flags> and the pattern in <pattern_idx>. |
1604 void Interpreter::DoCreateRegExpLiteral(InterpreterAssembler* assembler) { | 1596 void Interpreter::DoCreateRegExpLiteral(InterpreterAssembler* assembler) { |
1605 Callable callable = CodeFactory::FastCloneRegExp(isolate_); | 1597 Callable callable = CodeFactory::FastCloneRegExp(isolate_); |
1606 Node* target = __ HeapConstant(callable.code()); | 1598 Node* target = __ HeapConstant(callable.code()); |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2180 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2172 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
2181 __ SmiTag(new_state)); | 2173 __ SmiTag(new_state)); |
2182 __ SetAccumulator(old_state); | 2174 __ SetAccumulator(old_state); |
2183 | 2175 |
2184 __ Dispatch(); | 2176 __ Dispatch(); |
2185 } | 2177 } |
2186 | 2178 |
2187 } // namespace interpreter | 2179 } // namespace interpreter |
2188 } // namespace internal | 2180 } // namespace internal |
2189 } // namespace v8 | 2181 } // namespace v8 |
OLD | NEW |