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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ConstructWithSpreadParameters const& p) { | 94 ConstructWithSpreadParameters const& p) { |
95 return os << p.arity(); | 95 return os << p.arity(); |
96 } | 96 } |
97 | 97 |
98 ConstructWithSpreadParameters const& ConstructWithSpreadParametersOf( | 98 ConstructWithSpreadParameters const& ConstructWithSpreadParametersOf( |
99 Operator const* op) { | 99 Operator const* op) { |
100 DCHECK_EQ(IrOpcode::kJSConstructWithSpread, op->opcode()); | 100 DCHECK_EQ(IrOpcode::kJSConstructWithSpread, op->opcode()); |
101 return OpParameter<ConstructWithSpreadParameters>(op); | 101 return OpParameter<ConstructWithSpreadParameters>(op); |
102 } | 102 } |
103 | 103 |
104 std::ostream& operator<<(std::ostream& os, CallFunctionParameters 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 | 110 const CallParameters& CallParametersOf(const Operator* op) { |
111 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) { | 111 DCHECK_EQ(IrOpcode::kJSCall, op->opcode()); |
112 DCHECK_EQ(IrOpcode::kJSCallFunction, op->opcode()); | 112 return OpParameter<CallParameters>(op); |
113 return OpParameter<CallFunctionParameters>(op); | |
114 } | 113 } |
115 | 114 |
116 std::ostream& operator<<(std::ostream& os, | 115 std::ostream& operator<<(std::ostream& os, |
117 CallForwardVarargsParameters const& p) { | 116 CallForwardVarargsParameters const& p) { |
118 return os << p.start_index() << ", " << p.tail_call_mode(); | 117 return os << p.start_index() << ", " << p.tail_call_mode(); |
119 } | 118 } |
120 | 119 |
121 CallForwardVarargsParameters const& CallForwardVarargsParametersOf( | 120 CallForwardVarargsParameters const& CallForwardVarargsParametersOf( |
122 Operator const* op) { | 121 Operator const* op) { |
123 DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, op->opcode()); | 122 DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, op->opcode()); |
124 return OpParameter<CallForwardVarargsParameters>(op); | 123 return OpParameter<CallForwardVarargsParameters>(op); |
125 } | 124 } |
126 | 125 |
127 bool operator==(CallFunctionWithSpreadParameters const& lhs, | 126 bool operator==(CallWithSpreadParameters const& lhs, |
128 CallFunctionWithSpreadParameters const& rhs) { | 127 CallWithSpreadParameters const& rhs) { |
129 return lhs.arity() == rhs.arity(); | 128 return lhs.arity() == rhs.arity(); |
130 } | 129 } |
131 | 130 |
132 bool operator!=(CallFunctionWithSpreadParameters const& lhs, | 131 bool operator!=(CallWithSpreadParameters const& lhs, |
133 CallFunctionWithSpreadParameters const& rhs) { | 132 CallWithSpreadParameters const& rhs) { |
134 return !(lhs == rhs); | 133 return !(lhs == rhs); |
135 } | 134 } |
136 | 135 |
137 size_t hash_value(CallFunctionWithSpreadParameters const& p) { | 136 size_t hash_value(CallWithSpreadParameters const& p) { |
138 return base::hash_combine(p.arity()); | 137 return base::hash_combine(p.arity()); |
139 } | 138 } |
140 | 139 |
141 std::ostream& operator<<(std::ostream& os, | 140 std::ostream& operator<<(std::ostream& os, CallWithSpreadParameters const& p) { |
142 CallFunctionWithSpreadParameters const& p) { | |
143 return os << p.arity(); | 141 return os << p.arity(); |
144 } | 142 } |
145 | 143 |
146 CallFunctionWithSpreadParameters const& CallFunctionWithSpreadParametersOf( | 144 CallWithSpreadParameters const& CallWithSpreadParametersOf(Operator const* op) { |
147 Operator const* op) { | 145 DCHECK_EQ(IrOpcode::kJSCallWithSpread, op->opcode()); |
148 DCHECK_EQ(IrOpcode::kJSCallFunctionWithSpread, op->opcode()); | 146 return OpParameter<CallWithSpreadParameters>(op); |
149 return OpParameter<CallFunctionWithSpreadParameters>(op); | |
150 } | 147 } |
151 | 148 |
152 bool operator==(CallRuntimeParameters const& lhs, | 149 bool operator==(CallRuntimeParameters const& lhs, |
153 CallRuntimeParameters const& rhs) { | 150 CallRuntimeParameters const& rhs) { |
154 return lhs.id() == rhs.id() && lhs.arity() == rhs.arity(); | 151 return lhs.id() == rhs.id() && lhs.arity() == rhs.arity(); |
155 } | 152 } |
156 | 153 |
157 | 154 |
158 bool operator!=(CallRuntimeParameters const& lhs, | 155 bool operator!=(CallRuntimeParameters const& lhs, |
159 CallRuntimeParameters const& rhs) { | 156 CallRuntimeParameters const& rhs) { |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 const Operator* JSOperatorBuilder::CallForwardVarargs( | 731 const Operator* JSOperatorBuilder::CallForwardVarargs( |
735 uint32_t start_index, TailCallMode tail_call_mode) { | 732 uint32_t start_index, TailCallMode tail_call_mode) { |
736 CallForwardVarargsParameters parameters(start_index, tail_call_mode); | 733 CallForwardVarargsParameters parameters(start_index, tail_call_mode); |
737 return new (zone()) Operator1<CallForwardVarargsParameters>( // -- | 734 return new (zone()) Operator1<CallForwardVarargsParameters>( // -- |
738 IrOpcode::kJSCallForwardVarargs, Operator::kNoProperties, // opcode | 735 IrOpcode::kJSCallForwardVarargs, Operator::kNoProperties, // opcode |
739 "JSCallForwardVarargs", // name | 736 "JSCallForwardVarargs", // name |
740 2, 1, 1, 1, 1, 2, // counts | 737 2, 1, 1, 1, 1, 2, // counts |
741 parameters); // parameter | 738 parameters); // parameter |
742 } | 739 } |
743 | 740 |
744 const Operator* JSOperatorBuilder::CallFunction( | 741 const Operator* JSOperatorBuilder::Call(size_t arity, float frequency, |
745 size_t arity, float frequency, VectorSlotPair const& feedback, | 742 VectorSlotPair const& feedback, |
746 ConvertReceiverMode convert_mode, TailCallMode tail_call_mode) { | 743 ConvertReceiverMode convert_mode, |
747 CallFunctionParameters parameters(arity, frequency, feedback, tail_call_mode, | 744 TailCallMode tail_call_mode) { |
748 convert_mode); | 745 CallParameters parameters(arity, frequency, feedback, tail_call_mode, |
749 return new (zone()) Operator1<CallFunctionParameters>( // -- | 746 convert_mode); |
750 IrOpcode::kJSCallFunction, Operator::kNoProperties, // opcode | 747 return new (zone()) Operator1<CallParameters>( // -- |
751 "JSCallFunction", // name | 748 IrOpcode::kJSCall, Operator::kNoProperties, // opcode |
752 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs | 749 "JSCall", // name |
753 parameters); // parameter | 750 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs |
| 751 parameters); // parameter |
754 } | 752 } |
755 | 753 |
756 const Operator* JSOperatorBuilder::CallFunctionWithSpread(uint32_t arity) { | 754 const Operator* JSOperatorBuilder::CallWithSpread(uint32_t arity) { |
757 CallFunctionWithSpreadParameters parameters(arity); | 755 CallWithSpreadParameters parameters(arity); |
758 return new (zone()) Operator1<CallFunctionWithSpreadParameters>( // -- | 756 return new (zone()) Operator1<CallWithSpreadParameters>( // -- |
759 IrOpcode::kJSCallFunctionWithSpread, Operator::kNoProperties, // opcode | 757 IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode |
760 "JSCallFunctionWithSpread", // name | 758 "JSCallWithSpread", // name |
761 parameters.arity(), 1, 1, 1, 1, 2, // counts | 759 parameters.arity(), 1, 1, 1, 1, 2, // counts |
762 parameters); // parameter | 760 parameters); // parameter |
763 } | 761 } |
764 | 762 |
765 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) { | 763 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) { |
766 const Runtime::Function* f = Runtime::FunctionForId(id); | 764 const Runtime::Function* f = Runtime::FunctionForId(id); |
767 return CallRuntime(f, f->nargs); | 765 return CallRuntime(f, f->nargs); |
768 } | 766 } |
769 | 767 |
770 | 768 |
771 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id, | 769 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id, |
772 size_t arity) { | 770 size_t arity) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- | 1055 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- |
1058 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode | 1056 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode |
1059 "JSCreateScriptContext", // name | 1057 "JSCreateScriptContext", // name |
1060 1, 1, 1, 1, 1, 2, // counts | 1058 1, 1, 1, 1, 1, 2, // counts |
1061 scope_info); // parameter | 1059 scope_info); // parameter |
1062 } | 1060 } |
1063 | 1061 |
1064 } // namespace compiler | 1062 } // namespace compiler |
1065 } // namespace internal | 1063 } // namespace internal |
1066 } // namespace v8 | 1064 } // namespace v8 |
OLD | NEW |