OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/js-operator.h" | 5 #include "src/compiler/js-operator.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/lazy-instance.h" | 9 #include "src/base/lazy-instance.h" |
10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 std::ostream& operator<<(std::ostream& os, ConstructParameters const& p) { | 70 std::ostream& operator<<(std::ostream& os, ConstructParameters const& p) { |
71 return os << p.arity() << ", " << p.frequency(); | 71 return os << p.arity() << ", " << p.frequency(); |
72 } | 72 } |
73 | 73 |
74 ConstructParameters const& ConstructParametersOf(Operator const* op) { | 74 ConstructParameters const& ConstructParametersOf(Operator const* op) { |
75 DCHECK_EQ(IrOpcode::kJSConstruct, op->opcode()); | 75 DCHECK_EQ(IrOpcode::kJSConstruct, op->opcode()); |
76 return OpParameter<ConstructParameters>(op); | 76 return OpParameter<ConstructParameters>(op); |
77 } | 77 } |
78 | 78 |
79 bool operator==(ConstructWithSpreadParameters const& lhs, | 79 bool operator==(SpreadWithArityParameters const& lhs, |
80 ConstructWithSpreadParameters const& rhs) { | 80 SpreadWithArityParameters const& rhs) { |
81 return lhs.arity() == rhs.arity(); | 81 return lhs.arity() == rhs.arity(); |
82 } | 82 } |
83 | 83 |
84 bool operator!=(ConstructWithSpreadParameters const& lhs, | 84 bool operator!=(SpreadWithArityParameters const& lhs, |
85 ConstructWithSpreadParameters const& rhs) { | 85 SpreadWithArityParameters const& rhs) { |
86 return !(lhs == rhs); | 86 return !(lhs == rhs); |
87 } | 87 } |
88 | 88 |
89 size_t hash_value(ConstructWithSpreadParameters const& p) { | 89 size_t hash_value(SpreadWithArityParameters const& p) { |
90 return base::hash_combine(p.arity()); | 90 return base::hash_combine(p.arity()); |
91 } | 91 } |
92 | 92 |
93 std::ostream& operator<<(std::ostream& os, | 93 std::ostream& operator<<(std::ostream& os, SpreadWithArityParameters const& p) { |
94 ConstructWithSpreadParameters const& p) { | |
95 return os << p.arity(); | 94 return os << p.arity(); |
96 } | 95 } |
97 | 96 |
98 ConstructWithSpreadParameters const& ConstructWithSpreadParametersOf( | 97 SpreadWithArityParameters const& SpreadWithArityParametersOf( |
99 Operator const* op) { | 98 Operator const* op) { |
100 DCHECK_EQ(IrOpcode::kJSConstructWithSpread, op->opcode()); | 99 DCHECK(op->opcode() == IrOpcode::kJSConstructWithSpread || |
101 return OpParameter<ConstructWithSpreadParameters>(op); | 100 op->opcode() == IrOpcode::kJSCallWithSpread); |
| 101 return OpParameter<SpreadWithArityParameters>(op); |
102 } | 102 } |
103 | 103 |
104 std::ostream& operator<<(std::ostream& os, CallParameters const& p) { | 104 std::ostream& operator<<(std::ostream& os, CallParameters const& p) { |
105 os << p.arity() << ", " << p.frequency() << ", " << p.convert_mode() << ", " | 105 os << p.arity() << ", " << p.frequency() << ", " << p.convert_mode() << ", " |
106 << p.tail_call_mode(); | 106 << p.tail_call_mode(); |
107 return os; | 107 return os; |
108 } | 108 } |
109 | 109 |
110 const CallParameters& CallParametersOf(const Operator* op) { | 110 const CallParameters& CallParametersOf(const Operator* op) { |
111 DCHECK_EQ(IrOpcode::kJSCall, op->opcode()); | 111 DCHECK_EQ(IrOpcode::kJSCall, op->opcode()); |
112 return OpParameter<CallParameters>(op); | 112 return OpParameter<CallParameters>(op); |
113 } | 113 } |
114 | 114 |
115 std::ostream& operator<<(std::ostream& os, | 115 std::ostream& operator<<(std::ostream& os, |
116 CallForwardVarargsParameters const& p) { | 116 CallForwardVarargsParameters const& p) { |
117 return os << p.start_index() << ", " << p.tail_call_mode(); | 117 return os << p.start_index() << ", " << p.tail_call_mode(); |
118 } | 118 } |
119 | 119 |
120 CallForwardVarargsParameters const& CallForwardVarargsParametersOf( | 120 CallForwardVarargsParameters const& CallForwardVarargsParametersOf( |
121 Operator const* op) { | 121 Operator const* op) { |
122 DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, op->opcode()); | 122 DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, op->opcode()); |
123 return OpParameter<CallForwardVarargsParameters>(op); | 123 return OpParameter<CallForwardVarargsParameters>(op); |
124 } | 124 } |
125 | 125 |
126 bool operator==(CallWithSpreadParameters const& lhs, | |
127 CallWithSpreadParameters const& rhs) { | |
128 return lhs.arity() == rhs.arity(); | |
129 } | |
130 | |
131 bool operator!=(CallWithSpreadParameters const& lhs, | |
132 CallWithSpreadParameters const& rhs) { | |
133 return !(lhs == rhs); | |
134 } | |
135 | |
136 size_t hash_value(CallWithSpreadParameters const& p) { | |
137 return base::hash_combine(p.arity()); | |
138 } | |
139 | |
140 std::ostream& operator<<(std::ostream& os, CallWithSpreadParameters const& p) { | |
141 return os << p.arity(); | |
142 } | |
143 | |
144 CallWithSpreadParameters const& CallWithSpreadParametersOf(Operator const* op) { | |
145 DCHECK_EQ(IrOpcode::kJSCallWithSpread, op->opcode()); | |
146 return OpParameter<CallWithSpreadParameters>(op); | |
147 } | |
148 | 126 |
149 bool operator==(CallRuntimeParameters const& lhs, | 127 bool operator==(CallRuntimeParameters const& lhs, |
150 CallRuntimeParameters const& rhs) { | 128 CallRuntimeParameters const& rhs) { |
151 return lhs.id() == rhs.id() && lhs.arity() == rhs.arity(); | 129 return lhs.id() == rhs.id() && lhs.arity() == rhs.arity(); |
152 } | 130 } |
153 | 131 |
154 | 132 |
155 bool operator!=(CallRuntimeParameters const& lhs, | 133 bool operator!=(CallRuntimeParameters const& lhs, |
156 CallRuntimeParameters const& rhs) { | 134 CallRuntimeParameters const& rhs) { |
157 return !(lhs == rhs); | 135 return !(lhs == rhs); |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 CallParameters parameters(arity, frequency, feedback, tail_call_mode, | 736 CallParameters parameters(arity, frequency, feedback, tail_call_mode, |
759 convert_mode); | 737 convert_mode); |
760 return new (zone()) Operator1<CallParameters>( // -- | 738 return new (zone()) Operator1<CallParameters>( // -- |
761 IrOpcode::kJSCall, Operator::kNoProperties, // opcode | 739 IrOpcode::kJSCall, Operator::kNoProperties, // opcode |
762 "JSCall", // name | 740 "JSCall", // name |
763 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs | 741 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs |
764 parameters); // parameter | 742 parameters); // parameter |
765 } | 743 } |
766 | 744 |
767 const Operator* JSOperatorBuilder::CallWithSpread(uint32_t arity) { | 745 const Operator* JSOperatorBuilder::CallWithSpread(uint32_t arity) { |
768 CallWithSpreadParameters parameters(arity); | 746 SpreadWithArityParameters parameters(arity); |
769 return new (zone()) Operator1<CallWithSpreadParameters>( // -- | 747 return new (zone()) Operator1<SpreadWithArityParameters>( // -- |
770 IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode | 748 IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode |
771 "JSCallWithSpread", // name | 749 "JSCallWithSpread", // name |
772 parameters.arity(), 1, 1, 1, 1, 2, // counts | 750 parameters.arity(), 1, 1, 1, 1, 2, // counts |
773 parameters); // parameter | 751 parameters); // parameter |
774 } | 752 } |
775 | 753 |
776 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) { | 754 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) { |
777 const Runtime::Function* f = Runtime::FunctionForId(id); | 755 const Runtime::Function* f = Runtime::FunctionForId(id); |
778 return CallRuntime(f, f->nargs); | 756 return CallRuntime(f, f->nargs); |
779 } | 757 } |
(...skipping 21 matching lines...) Expand all Loading... |
801 VectorSlotPair const& feedback) { | 779 VectorSlotPair const& feedback) { |
802 ConstructParameters parameters(arity, frequency, feedback); | 780 ConstructParameters parameters(arity, frequency, feedback); |
803 return new (zone()) Operator1<ConstructParameters>( // -- | 781 return new (zone()) Operator1<ConstructParameters>( // -- |
804 IrOpcode::kJSConstruct, Operator::kNoProperties, // opcode | 782 IrOpcode::kJSConstruct, Operator::kNoProperties, // opcode |
805 "JSConstruct", // name | 783 "JSConstruct", // name |
806 parameters.arity(), 1, 1, 1, 1, 2, // counts | 784 parameters.arity(), 1, 1, 1, 1, 2, // counts |
807 parameters); // parameter | 785 parameters); // parameter |
808 } | 786 } |
809 | 787 |
810 const Operator* JSOperatorBuilder::ConstructWithSpread(uint32_t arity) { | 788 const Operator* JSOperatorBuilder::ConstructWithSpread(uint32_t arity) { |
811 ConstructWithSpreadParameters parameters(arity); | 789 SpreadWithArityParameters parameters(arity); |
812 return new (zone()) Operator1<ConstructWithSpreadParameters>( // -- | 790 return new (zone()) Operator1<SpreadWithArityParameters>( // -- |
813 IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode | 791 IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode |
814 "JSConstructWithSpread", // name | 792 "JSConstructWithSpread", // name |
815 parameters.arity(), 1, 1, 1, 1, 2, // counts | 793 parameters.arity(), 1, 1, 1, 1, 2, // counts |
816 parameters); // parameter | 794 parameters); // parameter |
817 } | 795 } |
818 | 796 |
819 const Operator* JSOperatorBuilder::ConvertReceiver( | 797 const Operator* JSOperatorBuilder::ConvertReceiver( |
820 ConvertReceiverMode convert_mode) { | 798 ConvertReceiverMode convert_mode) { |
821 return new (zone()) Operator1<ConvertReceiverMode>( // -- | 799 return new (zone()) Operator1<ConvertReceiverMode>( // -- |
822 IrOpcode::kJSConvertReceiver, Operator::kEliminatable, // opcode | 800 IrOpcode::kJSConvertReceiver, Operator::kEliminatable, // opcode |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- | 1055 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- |
1078 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode | 1056 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode |
1079 "JSCreateScriptContext", // name | 1057 "JSCreateScriptContext", // name |
1080 1, 1, 1, 1, 1, 2, // counts | 1058 1, 1, 1, 1, 1, 2, // counts |
1081 scope_info); // parameter | 1059 scope_info); // parameter |
1082 } | 1060 } |
1083 | 1061 |
1084 } // namespace compiler | 1062 } // namespace compiler |
1085 } // namespace internal | 1063 } // namespace internal |
1086 } // namespace v8 | 1064 } // namespace v8 |
OLD | NEW |