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/ast/prettyprinter.h" | 7 #include "src/ast/prettyprinter.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 void Interpreter::DoDec(InterpreterAssembler* assembler) { | 879 void Interpreter::DoDec(InterpreterAssembler* assembler) { |
880 DoCountOp(Runtime::kSubtract, assembler); | 880 DoCountOp(Runtime::kSubtract, assembler); |
881 } | 881 } |
882 | 882 |
883 | 883 |
884 // LogicalNot | 884 // LogicalNot |
885 // | 885 // |
886 // Perform logical-not on the accumulator, first casting the | 886 // Perform logical-not on the accumulator, first casting the |
887 // accumulator to a boolean value if required. | 887 // accumulator to a boolean value if required. |
888 void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) { | 888 void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) { |
| 889 Callable callable = CodeFactory::ToBoolean(isolate_); |
| 890 Node* target = __ HeapConstant(callable.code()); |
889 Node* accumulator = __ GetAccumulator(); | 891 Node* accumulator = __ GetAccumulator(); |
890 Node* context = __ GetContext(); | 892 Node* context = __ GetContext(); |
891 Node* result = | 893 Node* to_boolean_value = |
892 __ CallRuntime(Runtime::kInterpreterLogicalNot, context, accumulator); | 894 __ CallStub(callable.descriptor(), target, context, accumulator); |
893 __ SetAccumulator(result); | 895 InterpreterAssembler::Label if_true(assembler), if_false(assembler); |
894 __ Dispatch(); | 896 Node* true_value = __ BooleanConstant(true); |
| 897 Node* false_value = __ BooleanConstant(false); |
| 898 Node* condition = __ WordEqual(to_boolean_value, true_value); |
| 899 __ Branch(condition, &if_true, &if_false); |
| 900 __ Bind(&if_true); |
| 901 { |
| 902 __ SetAccumulator(false_value); |
| 903 __ Dispatch(); |
| 904 } |
| 905 __ Bind(&if_false); |
| 906 { |
| 907 __ SetAccumulator(true_value); |
| 908 __ Dispatch(); |
| 909 } |
895 } | 910 } |
896 | 911 |
897 | |
898 // TypeOf | 912 // TypeOf |
899 // | 913 // |
900 // Load the accumulator with the string representating type of the | 914 // Load the accumulator with the string representating type of the |
901 // object in the accumulator. | 915 // object in the accumulator. |
902 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { | 916 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { |
903 Callable callable = CodeFactory::Typeof(isolate_); | 917 Callable callable = CodeFactory::Typeof(isolate_); |
904 Node* target = __ HeapConstant(callable.code()); | 918 Node* target = __ HeapConstant(callable.code()); |
905 Node* accumulator = __ GetAccumulator(); | 919 Node* accumulator = __ GetAccumulator(); |
906 Node* context = __ GetContext(); | 920 Node* context = __ GetContext(); |
907 Node* result = | 921 Node* result = |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 void Interpreter::DoJumpIfFalseConstantWide(InterpreterAssembler* assembler) { | 1370 void Interpreter::DoJumpIfFalseConstantWide(InterpreterAssembler* assembler) { |
1357 DoJumpIfFalseConstant(assembler); | 1371 DoJumpIfFalseConstant(assembler); |
1358 } | 1372 } |
1359 | 1373 |
1360 | 1374 |
1361 // JumpIfToBooleanTrue <imm8> | 1375 // JumpIfToBooleanTrue <imm8> |
1362 // | 1376 // |
1363 // Jump by number of bytes represented by an immediate operand if the object | 1377 // Jump by number of bytes represented by an immediate operand if the object |
1364 // referenced by the accumulator is true when the object is cast to boolean. | 1378 // referenced by the accumulator is true when the object is cast to boolean. |
1365 void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) { | 1379 void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) { |
| 1380 Callable callable = CodeFactory::ToBoolean(isolate_); |
| 1381 Node* target = __ HeapConstant(callable.code()); |
1366 Node* accumulator = __ GetAccumulator(); | 1382 Node* accumulator = __ GetAccumulator(); |
1367 Node* context = __ GetContext(); | 1383 Node* context = __ GetContext(); |
1368 Node* to_boolean_value = | 1384 Node* to_boolean_value = |
1369 __ CallRuntime(Runtime::kInterpreterToBoolean, context, accumulator); | 1385 __ CallStub(callable.descriptor(), target, context, accumulator); |
1370 Node* relative_jump = __ BytecodeOperandImm(0); | 1386 Node* relative_jump = __ BytecodeOperandImm(0); |
1371 Node* true_value = __ BooleanConstant(true); | 1387 Node* true_value = __ BooleanConstant(true); |
1372 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | 1388 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); |
1373 } | 1389 } |
1374 | 1390 |
1375 | 1391 |
1376 // JumpIfToBooleanTrueConstant <idx8> | 1392 // JumpIfToBooleanTrueConstant <idx8> |
1377 // | 1393 // |
1378 // Jump by number of bytes in the Smi in the |idx8| entry in the constant pool | 1394 // Jump by number of bytes in the Smi in the |idx8| entry in the constant pool |
1379 // if the object referenced by the accumulator is true when the object is cast | 1395 // if the object referenced by the accumulator is true when the object is cast |
1380 // to boolean. | 1396 // to boolean. |
1381 void Interpreter::DoJumpIfToBooleanTrueConstant( | 1397 void Interpreter::DoJumpIfToBooleanTrueConstant( |
1382 InterpreterAssembler* assembler) { | 1398 InterpreterAssembler* assembler) { |
| 1399 Callable callable = CodeFactory::ToBoolean(isolate_); |
| 1400 Node* target = __ HeapConstant(callable.code()); |
1383 Node* accumulator = __ GetAccumulator(); | 1401 Node* accumulator = __ GetAccumulator(); |
1384 Node* context = __ GetContext(); | 1402 Node* context = __ GetContext(); |
1385 Node* to_boolean_value = | 1403 Node* to_boolean_value = |
1386 __ CallRuntime(Runtime::kInterpreterToBoolean, context, accumulator); | 1404 __ CallStub(callable.descriptor(), target, context, accumulator); |
1387 Node* index = __ BytecodeOperandIdx(0); | 1405 Node* index = __ BytecodeOperandIdx(0); |
1388 Node* constant = __ LoadConstantPoolEntry(index); | 1406 Node* constant = __ LoadConstantPoolEntry(index); |
1389 Node* relative_jump = __ SmiUntag(constant); | 1407 Node* relative_jump = __ SmiUntag(constant); |
1390 Node* true_value = __ BooleanConstant(true); | 1408 Node* true_value = __ BooleanConstant(true); |
1391 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | 1409 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); |
1392 } | 1410 } |
1393 | 1411 |
1394 | 1412 |
1395 // JumpIfToBooleanTrueConstantWide <idx16> | 1413 // JumpIfToBooleanTrueConstantWide <idx16> |
1396 // | 1414 // |
1397 // Jump by number of bytes in the Smi in the |idx16| entry in the constant pool | 1415 // Jump by number of bytes in the Smi in the |idx16| entry in the constant pool |
1398 // if the object referenced by the accumulator is true when the object is cast | 1416 // if the object referenced by the accumulator is true when the object is cast |
1399 // to boolean. | 1417 // to boolean. |
1400 void Interpreter::DoJumpIfToBooleanTrueConstantWide( | 1418 void Interpreter::DoJumpIfToBooleanTrueConstantWide( |
1401 InterpreterAssembler* assembler) { | 1419 InterpreterAssembler* assembler) { |
1402 DoJumpIfToBooleanTrueConstant(assembler); | 1420 DoJumpIfToBooleanTrueConstant(assembler); |
1403 } | 1421 } |
1404 | 1422 |
1405 | 1423 |
1406 // JumpIfToBooleanFalse <imm8> | 1424 // JumpIfToBooleanFalse <imm8> |
1407 // | 1425 // |
1408 // Jump by number of bytes represented by an immediate operand if the object | 1426 // Jump by number of bytes represented by an immediate operand if the object |
1409 // referenced by the accumulator is false when the object is cast to boolean. | 1427 // referenced by the accumulator is false when the object is cast to boolean. |
1410 void Interpreter::DoJumpIfToBooleanFalse(InterpreterAssembler* assembler) { | 1428 void Interpreter::DoJumpIfToBooleanFalse(InterpreterAssembler* assembler) { |
| 1429 Callable callable = CodeFactory::ToBoolean(isolate_); |
| 1430 Node* target = __ HeapConstant(callable.code()); |
1411 Node* accumulator = __ GetAccumulator(); | 1431 Node* accumulator = __ GetAccumulator(); |
1412 Node* context = __ GetContext(); | 1432 Node* context = __ GetContext(); |
1413 Node* to_boolean_value = | 1433 Node* to_boolean_value = |
1414 __ CallRuntime(Runtime::kInterpreterToBoolean, context, accumulator); | 1434 __ CallStub(callable.descriptor(), target, context, accumulator); |
1415 Node* relative_jump = __ BytecodeOperandImm(0); | 1435 Node* relative_jump = __ BytecodeOperandImm(0); |
1416 Node* false_value = __ BooleanConstant(false); | 1436 Node* false_value = __ BooleanConstant(false); |
1417 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | 1437 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); |
1418 } | 1438 } |
1419 | 1439 |
1420 | 1440 |
1421 // JumpIfToBooleanFalseConstant <idx8> | 1441 // JumpIfToBooleanFalseConstant <idx8> |
1422 // | 1442 // |
1423 // Jump by number of bytes in the Smi in the |idx8| entry in the constant pool | 1443 // Jump by number of bytes in the Smi in the |idx8| entry in the constant pool |
1424 // if the object referenced by the accumulator is false when the object is cast | 1444 // if the object referenced by the accumulator is false when the object is cast |
1425 // to boolean. | 1445 // to boolean. |
1426 void Interpreter::DoJumpIfToBooleanFalseConstant( | 1446 void Interpreter::DoJumpIfToBooleanFalseConstant( |
1427 InterpreterAssembler* assembler) { | 1447 InterpreterAssembler* assembler) { |
| 1448 Callable callable = CodeFactory::ToBoolean(isolate_); |
| 1449 Node* target = __ HeapConstant(callable.code()); |
1428 Node* accumulator = __ GetAccumulator(); | 1450 Node* accumulator = __ GetAccumulator(); |
1429 Node* context = __ GetContext(); | 1451 Node* context = __ GetContext(); |
1430 Node* to_boolean_value = | 1452 Node* to_boolean_value = |
1431 __ CallRuntime(Runtime::kInterpreterToBoolean, context, accumulator); | 1453 __ CallStub(callable.descriptor(), target, context, accumulator); |
1432 Node* index = __ BytecodeOperandIdx(0); | 1454 Node* index = __ BytecodeOperandIdx(0); |
1433 Node* constant = __ LoadConstantPoolEntry(index); | 1455 Node* constant = __ LoadConstantPoolEntry(index); |
1434 Node* relative_jump = __ SmiUntag(constant); | 1456 Node* relative_jump = __ SmiUntag(constant); |
1435 Node* false_value = __ BooleanConstant(false); | 1457 Node* false_value = __ BooleanConstant(false); |
1436 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | 1458 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); |
1437 } | 1459 } |
1438 | 1460 |
1439 | 1461 |
1440 // JumpIfToBooleanFalseConstantWide <idx16> | 1462 // JumpIfToBooleanFalseConstantWide <idx16> |
1441 // | 1463 // |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 Node* index = __ LoadRegister(index_reg); | 1872 Node* index = __ LoadRegister(index_reg); |
1851 Node* one = __ SmiConstant(Smi::FromInt(1)); | 1873 Node* one = __ SmiConstant(Smi::FromInt(1)); |
1852 Node* result = __ SmiAdd(index, one); | 1874 Node* result = __ SmiAdd(index, one); |
1853 __ SetAccumulator(result); | 1875 __ SetAccumulator(result); |
1854 __ Dispatch(); | 1876 __ Dispatch(); |
1855 } | 1877 } |
1856 | 1878 |
1857 } // namespace interpreter | 1879 } // namespace interpreter |
1858 } // namespace internal | 1880 } // namespace internal |
1859 } // namespace v8 | 1881 } // namespace v8 |
OLD | NEW |