| 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 | 8 |
| 9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 DoUnaryOp<IncStub>(assembler); | 1045 DoUnaryOp<IncStub>(assembler); |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 // Dec | 1048 // Dec |
| 1049 // | 1049 // |
| 1050 // Decrements value in the accumulator by one. | 1050 // Decrements value in the accumulator by one. |
| 1051 void Interpreter::DoDec(InterpreterAssembler* assembler) { | 1051 void Interpreter::DoDec(InterpreterAssembler* assembler) { |
| 1052 DoUnaryOp<DecStub>(assembler); | 1052 DoUnaryOp<DecStub>(assembler); |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 Node* Interpreter::BuildToBoolean(Node* value, | 1055 // LogicalNot |
| 1056 InterpreterAssembler* assembler) { | 1056 // |
| 1057 Node* context = __ GetContext(); | 1057 // Perform logical-not on the accumulator, first casting the |
| 1058 return ToBooleanStub::Generate(assembler, value, context); | 1058 // accumulator to a boolean value if required. |
| 1059 } | 1059 // ToBooleanLogicalNot |
| 1060 | 1060 void Interpreter::DoToBooleanLogicalNot(InterpreterAssembler* assembler) { |
| 1061 Node* Interpreter::BuildLogicalNot(Node* value, | 1061 Node* value = __ GetAccumulator(); |
| 1062 InterpreterAssembler* assembler) { | |
| 1063 Variable result(assembler, MachineRepresentation::kTagged); | 1062 Variable result(assembler, MachineRepresentation::kTagged); |
| 1064 Label if_true(assembler), if_false(assembler), end(assembler); | 1063 Label if_true(assembler), if_false(assembler), end(assembler); |
| 1065 Node* true_value = __ BooleanConstant(true); | 1064 Node* true_value = __ BooleanConstant(true); |
| 1066 Node* false_value = __ BooleanConstant(false); | 1065 Node* false_value = __ BooleanConstant(false); |
| 1067 __ BranchIfWordEqual(value, true_value, &if_true, &if_false); | 1066 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); |
| 1068 __ Bind(&if_true); | 1067 __ Bind(&if_true); |
| 1069 { | 1068 { |
| 1070 result.Bind(false_value); | 1069 result.Bind(false_value); |
| 1071 __ Goto(&end); | 1070 __ Goto(&end); |
| 1072 } | 1071 } |
| 1073 __ Bind(&if_false); | 1072 __ Bind(&if_false); |
| 1074 { | 1073 { |
| 1075 if (FLAG_debug_code) { | |
| 1076 __ AbortIfWordNotEqual(value, false_value, | |
| 1077 BailoutReason::kExpectedBooleanValue); | |
| 1078 } | |
| 1079 result.Bind(true_value); | 1074 result.Bind(true_value); |
| 1080 __ Goto(&end); | 1075 __ Goto(&end); |
| 1081 } | 1076 } |
| 1082 __ Bind(&end); | 1077 __ Bind(&end); |
| 1083 return result.value(); | 1078 __ SetAccumulator(result.value()); |
| 1084 } | |
| 1085 | |
| 1086 // LogicalNot | |
| 1087 // | |
| 1088 // Perform logical-not on the accumulator, first casting the | |
| 1089 // accumulator to a boolean value if required. | |
| 1090 // ToBooleanLogicalNot | |
| 1091 void Interpreter::DoToBooleanLogicalNot(InterpreterAssembler* assembler) { | |
| 1092 Node* value = __ GetAccumulator(); | |
| 1093 Node* to_boolean_value = BuildToBoolean(value, assembler); | |
| 1094 Node* result = BuildLogicalNot(to_boolean_value, assembler); | |
| 1095 __ SetAccumulator(result); | |
| 1096 __ Dispatch(); | 1079 __ Dispatch(); |
| 1097 } | 1080 } |
| 1098 | 1081 |
| 1099 // LogicalNot | 1082 // LogicalNot |
| 1100 // | 1083 // |
| 1101 // Perform logical-not on the accumulator, which must already be a boolean | 1084 // Perform logical-not on the accumulator, which must already be a boolean |
| 1102 // value. | 1085 // value. |
| 1103 void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) { | 1086 void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) { |
| 1104 Node* value = __ GetAccumulator(); | 1087 Node* value = __ GetAccumulator(); |
| 1105 Node* result = BuildLogicalNot(value, assembler); | 1088 Variable result(assembler, MachineRepresentation::kTagged); |
| 1106 __ SetAccumulator(result); | 1089 Label if_true(assembler), if_false(assembler), end(assembler); |
| 1090 Node* true_value = __ BooleanConstant(true); |
| 1091 Node* false_value = __ BooleanConstant(false); |
| 1092 __ BranchIfWordEqual(value, true_value, &if_true, &if_false); |
| 1093 __ Bind(&if_true); |
| 1094 { |
| 1095 result.Bind(false_value); |
| 1096 __ Goto(&end); |
| 1097 } |
| 1098 __ Bind(&if_false); |
| 1099 { |
| 1100 if (FLAG_debug_code) { |
| 1101 __ AbortIfWordNotEqual(value, false_value, |
| 1102 BailoutReason::kExpectedBooleanValue); |
| 1103 } |
| 1104 result.Bind(true_value); |
| 1105 __ Goto(&end); |
| 1106 } |
| 1107 __ Bind(&end); |
| 1108 __ SetAccumulator(result.value()); |
| 1107 __ Dispatch(); | 1109 __ Dispatch(); |
| 1108 } | 1110 } |
| 1109 | 1111 |
| 1110 // TypeOf | 1112 // TypeOf |
| 1111 // | 1113 // |
| 1112 // Load the accumulator with the string representating type of the | 1114 // Load the accumulator with the string representating type of the |
| 1113 // object in the accumulator. | 1115 // object in the accumulator. |
| 1114 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { | 1116 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { |
| 1115 DoUnaryOp(CodeFactory::Typeof(isolate_), assembler); | 1117 DoUnaryOp(CodeFactory::Typeof(isolate_), assembler); |
| 1116 } | 1118 } |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 Node* relative_jump = __ SmiUntag(constant); | 1433 Node* relative_jump = __ SmiUntag(constant); |
| 1432 Node* false_value = __ BooleanConstant(false); | 1434 Node* false_value = __ BooleanConstant(false); |
| 1433 __ JumpIfWordEqual(accumulator, false_value, relative_jump); | 1435 __ JumpIfWordEqual(accumulator, false_value, relative_jump); |
| 1434 } | 1436 } |
| 1435 | 1437 |
| 1436 // JumpIfToBooleanTrue <imm> | 1438 // JumpIfToBooleanTrue <imm> |
| 1437 // | 1439 // |
| 1438 // Jump by number of bytes represented by an immediate operand if the object | 1440 // Jump by number of bytes represented by an immediate operand if the object |
| 1439 // referenced by the accumulator is true when the object is cast to boolean. | 1441 // referenced by the accumulator is true when the object is cast to boolean. |
| 1440 void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) { | 1442 void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) { |
| 1441 Node* accumulator = __ GetAccumulator(); | 1443 Node* value = __ GetAccumulator(); |
| 1442 Node* to_boolean_value = BuildToBoolean(accumulator, assembler); | |
| 1443 Node* relative_jump = __ BytecodeOperandImm(0); | 1444 Node* relative_jump = __ BytecodeOperandImm(0); |
| 1444 Node* true_value = __ BooleanConstant(true); | 1445 Label if_true(assembler), if_false(assembler); |
| 1445 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | 1446 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); |
| 1447 __ Bind(&if_true); |
| 1448 __ Jump(relative_jump); |
| 1449 __ Bind(&if_false); |
| 1450 __ Dispatch(); |
| 1446 } | 1451 } |
| 1447 | 1452 |
| 1448 // JumpIfToBooleanTrueConstant <idx> | 1453 // JumpIfToBooleanTrueConstant <idx> |
| 1449 // | 1454 // |
| 1450 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1455 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 1451 // if the object referenced by the accumulator is true when the object is cast | 1456 // if the object referenced by the accumulator is true when the object is cast |
| 1452 // to boolean. | 1457 // to boolean. |
| 1453 void Interpreter::DoJumpIfToBooleanTrueConstant( | 1458 void Interpreter::DoJumpIfToBooleanTrueConstant( |
| 1454 InterpreterAssembler* assembler) { | 1459 InterpreterAssembler* assembler) { |
| 1455 Node* accumulator = __ GetAccumulator(); | 1460 Node* value = __ GetAccumulator(); |
| 1456 Node* to_boolean_value = BuildToBoolean(accumulator, assembler); | |
| 1457 Node* index = __ BytecodeOperandIdx(0); | 1461 Node* index = __ BytecodeOperandIdx(0); |
| 1458 Node* constant = __ LoadConstantPoolEntry(index); | 1462 Node* constant = __ LoadConstantPoolEntry(index); |
| 1459 Node* relative_jump = __ SmiUntag(constant); | 1463 Node* relative_jump = __ SmiUntag(constant); |
| 1460 Node* true_value = __ BooleanConstant(true); | 1464 Label if_true(assembler), if_false(assembler); |
| 1461 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | 1465 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); |
| 1466 __ Bind(&if_true); |
| 1467 __ Jump(relative_jump); |
| 1468 __ Bind(&if_false); |
| 1469 __ Dispatch(); |
| 1462 } | 1470 } |
| 1463 | 1471 |
| 1464 // JumpIfToBooleanFalse <imm> | 1472 // JumpIfToBooleanFalse <imm> |
| 1465 // | 1473 // |
| 1466 // Jump by number of bytes represented by an immediate operand if the object | 1474 // Jump by number of bytes represented by an immediate operand if the object |
| 1467 // referenced by the accumulator is false when the object is cast to boolean. | 1475 // referenced by the accumulator is false when the object is cast to boolean. |
| 1468 void Interpreter::DoJumpIfToBooleanFalse(InterpreterAssembler* assembler) { | 1476 void Interpreter::DoJumpIfToBooleanFalse(InterpreterAssembler* assembler) { |
| 1469 Node* accumulator = __ GetAccumulator(); | 1477 Node* value = __ GetAccumulator(); |
| 1470 Node* to_boolean_value = BuildToBoolean(accumulator, assembler); | |
| 1471 Node* relative_jump = __ BytecodeOperandImm(0); | 1478 Node* relative_jump = __ BytecodeOperandImm(0); |
| 1472 Node* false_value = __ BooleanConstant(false); | 1479 Label if_true(assembler), if_false(assembler); |
| 1473 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | 1480 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); |
| 1481 __ Bind(&if_true); |
| 1482 __ Dispatch(); |
| 1483 __ Bind(&if_false); |
| 1484 __ Jump(relative_jump); |
| 1474 } | 1485 } |
| 1475 | 1486 |
| 1476 // JumpIfToBooleanFalseConstant <idx> | 1487 // JumpIfToBooleanFalseConstant <idx> |
| 1477 // | 1488 // |
| 1478 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1489 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 1479 // if the object referenced by the accumulator is false when the object is cast | 1490 // if the object referenced by the accumulator is false when the object is cast |
| 1480 // to boolean. | 1491 // to boolean. |
| 1481 void Interpreter::DoJumpIfToBooleanFalseConstant( | 1492 void Interpreter::DoJumpIfToBooleanFalseConstant( |
| 1482 InterpreterAssembler* assembler) { | 1493 InterpreterAssembler* assembler) { |
| 1483 Node* accumulator = __ GetAccumulator(); | 1494 Node* value = __ GetAccumulator(); |
| 1484 Node* to_boolean_value = BuildToBoolean(accumulator, assembler); | |
| 1485 Node* index = __ BytecodeOperandIdx(0); | 1495 Node* index = __ BytecodeOperandIdx(0); |
| 1486 Node* constant = __ LoadConstantPoolEntry(index); | 1496 Node* constant = __ LoadConstantPoolEntry(index); |
| 1487 Node* relative_jump = __ SmiUntag(constant); | 1497 Node* relative_jump = __ SmiUntag(constant); |
| 1488 Node* false_value = __ BooleanConstant(false); | 1498 Label if_true(assembler), if_false(assembler); |
| 1489 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | 1499 __ BranchIfToBooleanIsTrue(value, &if_true, &if_false); |
| 1500 __ Bind(&if_true); |
| 1501 __ Dispatch(); |
| 1502 __ Bind(&if_false); |
| 1503 __ Jump(relative_jump); |
| 1490 } | 1504 } |
| 1491 | 1505 |
| 1492 // JumpIfNull <imm> | 1506 // JumpIfNull <imm> |
| 1493 // | 1507 // |
| 1494 // Jump by number of bytes represented by an immediate operand if the object | 1508 // Jump by number of bytes represented by an immediate operand if the object |
| 1495 // referenced by the accumulator is the null constant. | 1509 // referenced by the accumulator is the null constant. |
| 1496 void Interpreter::DoJumpIfNull(InterpreterAssembler* assembler) { | 1510 void Interpreter::DoJumpIfNull(InterpreterAssembler* assembler) { |
| 1497 Node* accumulator = __ GetAccumulator(); | 1511 Node* accumulator = __ GetAccumulator(); |
| 1498 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); | 1512 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
| 1499 Node* relative_jump = __ BytecodeOperandImm(0); | 1513 Node* relative_jump = __ BytecodeOperandImm(0); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2035 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
| 2022 __ SmiTag(new_state)); | 2036 __ SmiTag(new_state)); |
| 2023 __ SetAccumulator(old_state); | 2037 __ SetAccumulator(old_state); |
| 2024 | 2038 |
| 2025 __ Dispatch(); | 2039 __ Dispatch(); |
| 2026 } | 2040 } |
| 2027 | 2041 |
| 2028 } // namespace interpreter | 2042 } // namespace interpreter |
| 2029 } // namespace internal | 2043 } // namespace internal |
| 2030 } // namespace v8 | 2044 } // namespace v8 |
| OLD | NEW |