OLD | NEW |
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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-generator.h" | 5 #include "src/interpreter/interpreter-generator.h" |
6 | 6 |
7 #include <array> | 7 #include <array> |
8 #include <tuple> | 8 #include <tuple> |
9 | 9 |
10 #include "src/builtins/builtins-arguments-gen.h" | 10 #include "src/builtins/builtins-arguments-gen.h" |
(...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2422 } | 2422 } |
2423 | 2423 |
2424 // TestInstanceOf <src> | 2424 // TestInstanceOf <src> |
2425 // | 2425 // |
2426 // Test if the object referenced by the <src> register is an an instance of type | 2426 // Test if the object referenced by the <src> register is an an instance of type |
2427 // referenced by the accumulator. | 2427 // referenced by the accumulator. |
2428 void InterpreterGenerator::DoTestInstanceOf(InterpreterAssembler* assembler) { | 2428 void InterpreterGenerator::DoTestInstanceOf(InterpreterAssembler* assembler) { |
2429 DoCompareOp(Token::INSTANCEOF, assembler); | 2429 DoCompareOp(Token::INSTANCEOF, assembler); |
2430 } | 2430 } |
2431 | 2431 |
2432 // TestUndetectable <src> | 2432 // TestUndetectable |
2433 // | 2433 // |
2434 // Test if the value in the <src> register equals to null/undefined. This is | 2434 // Test if the value in the accumulator is undetectable (null, undefined or |
2435 // done by checking undetectable bit on the map of the object. | 2435 // document.all). |
2436 void InterpreterGenerator::DoTestUndetectable(InterpreterAssembler* assembler) { | 2436 void InterpreterGenerator::DoTestUndetectable(InterpreterAssembler* assembler) { |
2437 Node* reg_index = __ BytecodeOperandReg(0); | 2437 Label return_false(assembler), end(assembler); |
2438 Node* object = __ LoadRegister(reg_index); | 2438 Node* object = __ GetAccumulator(); |
2439 | 2439 |
2440 Label not_equal(assembler), end(assembler); | |
2441 // If the object is an Smi then return false. | 2440 // If the object is an Smi then return false. |
2442 __ GotoIf(__ TaggedIsSmi(object), ¬_equal); | 2441 __ SetAccumulator(__ BooleanConstant(false)); |
| 2442 __ GotoIf(__ TaggedIsSmi(object), &end); |
2443 | 2443 |
2444 // If it is a HeapObject, load the map and check for undetectable bit. | 2444 // If it is a HeapObject, load the map and check for undetectable bit. |
2445 Node* map = __ LoadMap(object); | 2445 Node* map = __ LoadMap(object); |
2446 Node* map_bitfield = __ LoadMapBitField(map); | 2446 Node* map_bitfield = __ LoadMapBitField(map); |
2447 Node* map_undetectable = | 2447 Node* map_undetectable = |
2448 __ Word32And(map_bitfield, __ Int32Constant(1 << Map::kIsUndetectable)); | 2448 __ Word32And(map_bitfield, __ Int32Constant(1 << Map::kIsUndetectable)); |
2449 __ GotoIf(__ Word32Equal(map_undetectable, __ Int32Constant(0)), ¬_equal); | 2449 Node* result = __ SelectBooleanConstant( |
2450 | 2450 __ Word32NotEqual(map_undetectable, __ Int32Constant(0))); |
2451 __ SetAccumulator(__ BooleanConstant(true)); | 2451 __ SetAccumulator(result); |
2452 __ Goto(&end); | 2452 __ Goto(&end); |
2453 | 2453 |
2454 __ Bind(¬_equal); | |
2455 { | |
2456 __ SetAccumulator(__ BooleanConstant(false)); | |
2457 __ Goto(&end); | |
2458 } | |
2459 | |
2460 __ Bind(&end); | 2454 __ Bind(&end); |
2461 __ Dispatch(); | 2455 __ Dispatch(); |
2462 } | 2456 } |
2463 | 2457 |
2464 // TestNull <src> | 2458 // TestNull |
2465 // | 2459 // |
2466 // Test if the value in the <src> register is strictly equal to null. | 2460 // Test if the value in accumulator is strictly equal to null. |
2467 void InterpreterGenerator::DoTestNull(InterpreterAssembler* assembler) { | 2461 void InterpreterGenerator::DoTestNull(InterpreterAssembler* assembler) { |
2468 Node* reg_index = __ BytecodeOperandReg(0); | 2462 Node* object = __ GetAccumulator(); |
2469 Node* object = __ LoadRegister(reg_index); | |
2470 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); | 2463 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
2471 | 2464 Node* result = __ SelectBooleanConstant(__ WordEqual(object, null_value)); |
2472 Label equal(assembler), end(assembler); | 2465 __ SetAccumulator(result); |
2473 __ GotoIf(__ WordEqual(object, null_value), &equal); | |
2474 __ SetAccumulator(__ BooleanConstant(false)); | |
2475 __ Goto(&end); | |
2476 | |
2477 __ Bind(&equal); | |
2478 { | |
2479 __ SetAccumulator(__ BooleanConstant(true)); | |
2480 __ Goto(&end); | |
2481 } | |
2482 | |
2483 __ Bind(&end); | |
2484 __ Dispatch(); | 2466 __ Dispatch(); |
2485 } | 2467 } |
2486 | 2468 |
2487 // TestUndefined <src> | 2469 // TestUndefined |
2488 // | 2470 // |
2489 // Test if the value in the <src> register is strictly equal to undefined. | 2471 // Test if the value in the accumulator is strictly equal to undefined. |
2490 void InterpreterGenerator::DoTestUndefined(InterpreterAssembler* assembler) { | 2472 void InterpreterGenerator::DoTestUndefined(InterpreterAssembler* assembler) { |
2491 Node* reg_index = __ BytecodeOperandReg(0); | 2473 Node* object = __ GetAccumulator(); |
2492 Node* object = __ LoadRegister(reg_index); | |
2493 Node* undefined_value = | 2474 Node* undefined_value = |
2494 __ HeapConstant(isolate_->factory()->undefined_value()); | 2475 __ HeapConstant(isolate_->factory()->undefined_value()); |
2495 | 2476 Node* result = |
2496 Label equal(assembler), end(assembler); | 2477 __ SelectBooleanConstant(__ WordEqual(object, undefined_value)); |
2497 __ GotoIf(__ WordEqual(object, undefined_value), &equal); | 2478 __ SetAccumulator(result); |
2498 __ SetAccumulator(__ BooleanConstant(false)); | |
2499 __ Goto(&end); | |
2500 | |
2501 __ Bind(&equal); | |
2502 { | |
2503 __ SetAccumulator(__ BooleanConstant(true)); | |
2504 __ Goto(&end); | |
2505 } | |
2506 | |
2507 __ Bind(&end); | |
2508 __ Dispatch(); | 2479 __ Dispatch(); |
2509 } | 2480 } |
2510 | 2481 |
2511 // TestTypeOf <literal_flag> | 2482 // TestTypeOf <literal_flag> |
2512 // | 2483 // |
2513 // Tests if the object in the <accumulator> is typeof the literal represented | 2484 // Tests if the object in the <accumulator> is typeof the literal represented |
2514 // by |literal_flag|. | 2485 // by |literal_flag|. |
2515 void InterpreterGenerator::DoTestTypeOf(InterpreterAssembler* assembler) { | 2486 void InterpreterGenerator::DoTestTypeOf(InterpreterAssembler* assembler) { |
2516 Node* object = __ GetAccumulator(); | 2487 Node* object = __ GetAccumulator(); |
2517 Node* literal_flag = __ BytecodeOperandFlag(0); | 2488 Node* literal_flag = __ BytecodeOperandFlag(0); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2790 // if the object referenced by the accumulator is the null constant. | 2761 // if the object referenced by the accumulator is the null constant. |
2791 void InterpreterGenerator::DoJumpIfNullConstant( | 2762 void InterpreterGenerator::DoJumpIfNullConstant( |
2792 InterpreterAssembler* assembler) { | 2763 InterpreterAssembler* assembler) { |
2793 Node* accumulator = __ GetAccumulator(); | 2764 Node* accumulator = __ GetAccumulator(); |
2794 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); | 2765 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
2795 Node* index = __ BytecodeOperandIdx(0); | 2766 Node* index = __ BytecodeOperandIdx(0); |
2796 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); | 2767 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
2797 __ JumpIfWordEqual(accumulator, null_value, relative_jump); | 2768 __ JumpIfWordEqual(accumulator, null_value, relative_jump); |
2798 } | 2769 } |
2799 | 2770 |
| 2771 // JumpIfNotNull <imm> |
| 2772 // |
| 2773 // Jump by number of bytes represented by an immediate operand if the object |
| 2774 // referenced by the accumulator is not the null constant. |
| 2775 void InterpreterGenerator::DoJumpIfNotNull(InterpreterAssembler* assembler) { |
| 2776 Node* accumulator = __ GetAccumulator(); |
| 2777 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
| 2778 Node* relative_jump = __ BytecodeOperandUImmWord(0); |
| 2779 __ JumpIfWordNotEqual(accumulator, null_value, relative_jump); |
| 2780 } |
| 2781 |
| 2782 // JumpIfNotNullConstant <idx> |
| 2783 // |
| 2784 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 2785 // if the object referenced by the accumulator is not the null constant. |
| 2786 void InterpreterGenerator::DoJumpIfNotNullConstant( |
| 2787 InterpreterAssembler* assembler) { |
| 2788 Node* accumulator = __ GetAccumulator(); |
| 2789 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
| 2790 Node* index = __ BytecodeOperandIdx(0); |
| 2791 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
| 2792 __ JumpIfWordNotEqual(accumulator, null_value, relative_jump); |
| 2793 } |
| 2794 |
2800 // JumpIfUndefined <imm> | 2795 // JumpIfUndefined <imm> |
2801 // | 2796 // |
2802 // Jump by number of bytes represented by an immediate operand if the object | 2797 // Jump by number of bytes represented by an immediate operand if the object |
2803 // referenced by the accumulator is the undefined constant. | 2798 // referenced by the accumulator is the undefined constant. |
2804 void InterpreterGenerator::DoJumpIfUndefined(InterpreterAssembler* assembler) { | 2799 void InterpreterGenerator::DoJumpIfUndefined(InterpreterAssembler* assembler) { |
2805 Node* accumulator = __ GetAccumulator(); | 2800 Node* accumulator = __ GetAccumulator(); |
2806 Node* undefined_value = | 2801 Node* undefined_value = |
2807 __ HeapConstant(isolate_->factory()->undefined_value()); | 2802 __ HeapConstant(isolate_->factory()->undefined_value()); |
2808 Node* relative_jump = __ BytecodeOperandUImmWord(0); | 2803 Node* relative_jump = __ BytecodeOperandUImmWord(0); |
2809 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); | 2804 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); |
2810 } | 2805 } |
2811 | 2806 |
2812 // JumpIfUndefinedConstant <idx> | 2807 // JumpIfUndefinedConstant <idx> |
2813 // | 2808 // |
2814 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 2809 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
2815 // if the object referenced by the accumulator is the undefined constant. | 2810 // if the object referenced by the accumulator is the undefined constant. |
2816 void InterpreterGenerator::DoJumpIfUndefinedConstant( | 2811 void InterpreterGenerator::DoJumpIfUndefinedConstant( |
2817 InterpreterAssembler* assembler) { | 2812 InterpreterAssembler* assembler) { |
2818 Node* accumulator = __ GetAccumulator(); | 2813 Node* accumulator = __ GetAccumulator(); |
2819 Node* undefined_value = | 2814 Node* undefined_value = |
2820 __ HeapConstant(isolate_->factory()->undefined_value()); | 2815 __ HeapConstant(isolate_->factory()->undefined_value()); |
2821 Node* index = __ BytecodeOperandIdx(0); | 2816 Node* index = __ BytecodeOperandIdx(0); |
2822 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); | 2817 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
2823 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); | 2818 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); |
2824 } | 2819 } |
2825 | 2820 |
| 2821 // JumpIfNotUndefined <imm> |
| 2822 // |
| 2823 // Jump by number of bytes represented by an immediate operand if the object |
| 2824 // referenced by the accumulator is not the undefined constant. |
| 2825 void InterpreterGenerator::DoJumpIfNotUndefined( |
| 2826 InterpreterAssembler* assembler) { |
| 2827 Node* accumulator = __ GetAccumulator(); |
| 2828 Node* undefined_value = |
| 2829 __ HeapConstant(isolate_->factory()->undefined_value()); |
| 2830 Node* relative_jump = __ BytecodeOperandUImmWord(0); |
| 2831 __ JumpIfWordNotEqual(accumulator, undefined_value, relative_jump); |
| 2832 } |
| 2833 |
| 2834 // JumpIfNotUndefinedConstant <idx> |
| 2835 // |
| 2836 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 2837 // if the object referenced by the accumulator is not the undefined constant. |
| 2838 void InterpreterGenerator::DoJumpIfNotUndefinedConstant( |
| 2839 InterpreterAssembler* assembler) { |
| 2840 Node* accumulator = __ GetAccumulator(); |
| 2841 Node* undefined_value = |
| 2842 __ HeapConstant(isolate_->factory()->undefined_value()); |
| 2843 Node* index = __ BytecodeOperandIdx(0); |
| 2844 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); |
| 2845 __ JumpIfWordNotEqual(accumulator, undefined_value, relative_jump); |
| 2846 } |
| 2847 |
2826 // JumpIfJSReceiver <imm> | 2848 // JumpIfJSReceiver <imm> |
2827 // | 2849 // |
2828 // Jump by number of bytes represented by an immediate operand if the object | 2850 // Jump by number of bytes represented by an immediate operand if the object |
2829 // referenced by the accumulator is a JSReceiver. | 2851 // referenced by the accumulator is a JSReceiver. |
2830 void InterpreterGenerator::DoJumpIfJSReceiver(InterpreterAssembler* assembler) { | 2852 void InterpreterGenerator::DoJumpIfJSReceiver(InterpreterAssembler* assembler) { |
2831 Node* accumulator = __ GetAccumulator(); | 2853 Node* accumulator = __ GetAccumulator(); |
2832 Node* relative_jump = __ BytecodeOperandUImmWord(0); | 2854 Node* relative_jump = __ BytecodeOperandUImmWord(0); |
2833 | 2855 |
2834 Label if_object(assembler), if_notobject(assembler, Label::kDeferred), | 2856 Label if_object(assembler), if_notobject(assembler, Label::kDeferred), |
2835 if_notsmi(assembler); | 2857 if_notsmi(assembler); |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3574 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 3596 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
3575 __ SmiTag(new_state)); | 3597 __ SmiTag(new_state)); |
3576 __ SetAccumulator(old_state); | 3598 __ SetAccumulator(old_state); |
3577 | 3599 |
3578 __ Dispatch(); | 3600 __ Dispatch(); |
3579 } | 3601 } |
3580 | 3602 |
3581 } // namespace interpreter | 3603 } // namespace interpreter |
3582 } // namespace internal | 3604 } // namespace internal |
3583 } // namespace v8 | 3605 } // namespace v8 |
OLD | NEW |