Chromium Code Reviews| 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/compiler/interpreter-assembler.h" | 5 #include "src/compiler/interpreter-assembler.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| 11 #include "src/compiler/instruction-selector.h" | 11 #include "src/compiler/instruction-selector.h" |
| 12 #include "src/compiler/linkage.h" | 12 #include "src/compiler/linkage.h" |
| 13 #include "src/compiler/node-properties.h" | |
| 13 #include "src/compiler/pipeline.h" | 14 #include "src/compiler/pipeline.h" |
| 14 #include "src/compiler/raw-machine-assembler.h" | 15 #include "src/compiler/raw-machine-assembler.h" |
| 15 #include "src/compiler/schedule.h" | 16 #include "src/compiler/schedule.h" |
| 16 #include "src/frames.h" | 17 #include "src/frames.h" |
| 17 #include "src/interface-descriptors.h" | 18 #include "src/interface-descriptors.h" |
| 18 #include "src/interpreter/bytecodes.h" | 19 #include "src/interpreter/bytecodes.h" |
| 19 #include "src/machine-type.h" | 20 #include "src/machine-type.h" |
| 20 #include "src/macro-assembler.h" | 21 #include "src/macro-assembler.h" |
| 21 #include "src/zone.h" | 22 #include "src/zone.h" |
| 22 | 23 |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id, | 613 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id, |
| 613 Node* arg1, Node* arg2, Node* arg3, | 614 Node* arg1, Node* arg2, Node* arg3, |
| 614 Node* arg4) { | 615 Node* arg4) { |
| 615 CallPrologue(); | 616 CallPrologue(); |
| 616 Node* return_val = raw_assembler_->CallRuntime4(function_id, arg1, arg2, arg3, | 617 Node* return_val = raw_assembler_->CallRuntime4(function_id, arg1, arg2, arg3, |
| 617 arg4, GetContext()); | 618 arg4, GetContext()); |
| 618 CallEpilogue(); | 619 CallEpilogue(); |
| 619 return return_val; | 620 return return_val; |
| 620 } | 621 } |
| 621 | 622 |
| 623 Node* InterpreterAssembler::ToBoolean(Node* value) { | |
| 624 RawMachineLabel true_val, false_val, merge; | |
| 625 raw_assembler_->Branch( | |
| 626 raw_assembler_->WordNotEqual(value, raw_assembler_->IntPtrConstant(0)), | |
| 627 &true_val, &false_val); | |
| 628 raw_assembler_->Bind(&true_val); | |
| 629 Node* true_result = raw_assembler_->BooleanConstant(true); | |
| 630 raw_assembler_->Goto(&merge); | |
| 631 raw_assembler_->Bind(&false_val); | |
| 632 Node* false_result = raw_assembler_->BooleanConstant(false); | |
| 633 raw_assembler_->Goto(&merge); | |
| 634 raw_assembler_->Bind(&merge); | |
| 635 return raw_assembler_->Phi(MachineRepresentation::kTagged, true_result, | |
| 636 false_result); | |
| 637 } | |
| 638 | |
| 639 Node* InterpreterAssembler::IsJSReceiver(Node* arg) { | |
| 640 RawMachineLabel is_smi, not_smi, merge; | |
| 641 | |
| 642 Node* check = raw_assembler_->WordEqual( | |
| 643 raw_assembler_->WordAnd(arg, raw_assembler_->IntPtrConstant(kSmiTagMask)), | |
| 644 raw_assembler_->IntPtrConstant(kSmiTag)); | |
| 645 raw_assembler_->Branch(check, &is_smi, ¬_smi); | |
| 646 raw_assembler_->Bind(¬_smi); | |
| 647 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); | |
| 648 | |
| 649 Node* map = raw_assembler_->Load( | |
| 650 MachineType::AnyTagged(), | |
| 651 raw_assembler_->IntPtrAdd( | |
| 652 arg, raw_assembler_->IntPtrConstant(HeapObject::kMapOffset - | |
| 653 kHeapObjectTag))); | |
| 654 Node* result = ToBoolean(raw_assembler_->Uint32LessThanOrEqual( | |
| 655 raw_assembler_->Int32Constant(FIRST_JS_RECEIVER_TYPE), | |
| 656 raw_assembler_->Load( | |
| 657 MachineType::Uint32(), | |
| 658 raw_assembler_->IntPtrAdd( | |
| 659 map, raw_assembler_->IntPtrConstant(Map::kInstanceTypeOffset - | |
| 660 kHeapObjectTag))))); | |
| 661 raw_assembler_->Goto(&merge); | |
| 662 | |
| 663 raw_assembler_->Bind(&is_smi); | |
| 664 Node* fail_value = raw_assembler_->BooleanConstant(false); | |
| 665 raw_assembler_->Goto(&merge); | |
| 666 | |
| 667 raw_assembler_->Bind(&merge); | |
| 668 return raw_assembler_->Phi(MachineRepresentation::kTagged, result, | |
| 669 fail_value); | |
| 670 } | |
| 671 | |
| 672 Node* InterpreterAssembler::IsJSArray(Node* arg) { | |
| 673 RawMachineLabel is_smi, not_smi, merge; | |
| 674 Node* check = raw_assembler_->WordEqual( | |
| 675 raw_assembler_->WordAnd(arg, raw_assembler_->IntPtrConstant(kSmiTagMask)), | |
| 676 raw_assembler_->IntPtrConstant(kSmiTag)); | |
| 677 raw_assembler_->Branch(check, &is_smi, ¬_smi); | |
| 678 | |
| 679 raw_assembler_->Bind(¬_smi); | |
| 680 Node* map = raw_assembler_->Load( | |
| 681 MachineType::AnyTagged(), arg, | |
| 682 raw_assembler_->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag)); | |
| 683 Node* result = raw_assembler_->Word32Equal( | |
| 684 raw_assembler_->Int32Constant(JS_ARRAY_TYPE), | |
| 685 raw_assembler_->Load(MachineType::Uint8(), map, | |
| 686 raw_assembler_->IntPtrConstant( | |
| 687 Map::kInstanceTypeOffset - kHeapObjectTag))); | |
| 688 result = ToBoolean(result); | |
| 689 raw_assembler_->Goto(&merge); | |
| 690 | |
| 691 raw_assembler_->Bind(&is_smi); | |
| 692 Node* fail_value = raw_assembler_->BooleanConstant(false); | |
| 693 raw_assembler_->Goto(&merge); | |
| 694 | |
| 695 raw_assembler_->Bind(&merge); | |
| 696 return raw_assembler_->Phi(MachineRepresentation::kTagged, result, | |
| 697 fail_value); | |
| 698 } | |
| 699 | |
| 700 Node* InterpreterAssembler::IntrinsicOneArg(Node* function_id, Node* arg) { | |
| 701 RawMachineLabel default_label, is_js_receiver, is_array, end; | |
| 702 | |
| 703 int32_t cases[] = {static_cast<int32_t>(Runtime::kInlineIsJSReceiver), | |
| 704 static_cast<int32_t>(Runtime::kInlineIsArray)}; | |
| 705 RawMachineLabel* labels[] = {&is_js_receiver, &is_array}; | |
| 706 Node* return_values[arraysize(cases) + 1]; | |
| 707 arg = raw_assembler_->Load(MachineType::AnyTagged(), arg); | |
| 708 raw_assembler_->Switch(function_id, &default_label, cases, labels, 2); | |
| 709 raw_assembler_->Bind(&is_js_receiver); | |
| 710 return_values[0] = IsJSReceiver(arg); | |
| 711 raw_assembler_->Goto(&end); | |
| 712 // IsArray | |
| 713 raw_assembler_->Bind(&is_array); | |
| 714 return_values[1] = IsJSArray(arg); | |
| 715 raw_assembler_->Goto(&end); | |
| 716 // Default | |
| 717 raw_assembler_->Bind(&default_label); | |
| 718 return_values[2] = raw_assembler_->BooleanConstant(false); | |
| 719 /* return_values[2] = | |
|
oth
2016/02/01 09:52:33
Dead code.
epertoso
2016/03/03 11:20:39
Removed.
| |
| 720 CallRuntime(function_id, arg, raw_assembler_->Int32Constant(1), 1);*/ | |
| 721 raw_assembler_->Goto(&end); | |
| 722 | |
| 723 raw_assembler_->Bind(&end); | |
| 724 return raw_assembler_->AddNode( | |
| 725 raw_assembler_->common()->Phi(MachineRepresentation::kBit, 3), 3, | |
| 726 return_values); | |
| 727 } | |
| 622 | 728 |
| 623 void InterpreterAssembler::Return() { | 729 void InterpreterAssembler::Return() { |
| 624 Node* exit_trampoline_code_object = | 730 Node* exit_trampoline_code_object = |
| 625 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); | 731 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); |
| 626 // If the order of the parameters you need to change the call signature below. | 732 // If the order of the parameters you need to change the call signature below. |
| 627 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter); | 733 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter); |
| 628 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); | 734 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); |
| 629 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter); | 735 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter); |
| 630 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter); | 736 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter); |
| 631 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter); | 737 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 return raw_assembler_->call_descriptor(); | 848 return raw_assembler_->call_descriptor(); |
| 743 } | 849 } |
| 744 | 850 |
| 745 | 851 |
| 746 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } | 852 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } |
| 747 | 853 |
| 748 | 854 |
| 749 } // namespace compiler | 855 } // namespace compiler |
| 750 } // namespace internal | 856 } // namespace internal |
| 751 } // namespace v8 | 857 } // namespace v8 |
| OLD | NEW |