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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/base/lazy-instance.h" | 8 #include "src/base/lazy-instance.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 size_t hash_value(RelocatablePtrConstantInfo const& p) { | 161 size_t hash_value(RelocatablePtrConstantInfo const& p) { |
162 return base::hash_combine(p.value(), p.rmode(), p.type()); | 162 return base::hash_combine(p.value(), p.rmode(), p.type()); |
163 } | 163 } |
164 | 164 |
165 std::ostream& operator<<(std::ostream& os, | 165 std::ostream& operator<<(std::ostream& os, |
166 RelocatablePtrConstantInfo const& p) { | 166 RelocatablePtrConstantInfo const& p) { |
167 return os << p.value() << "|" << p.rmode() << "|" << p.type(); | 167 return os << p.value() << "|" << p.rmode() << "|" << p.type(); |
168 } | 168 } |
169 | 169 |
| 170 size_t hash_value(RegionObservability observability) { |
| 171 return static_cast<size_t>(observability); |
| 172 } |
| 173 |
| 174 std::ostream& operator<<(std::ostream& os, RegionObservability observability) { |
| 175 switch (observability) { |
| 176 case RegionObservability::kObservable: |
| 177 return os << "observable"; |
| 178 case RegionObservability::kNotObservable: |
| 179 return os << "not-observable"; |
| 180 } |
| 181 UNREACHABLE(); |
| 182 return os; |
| 183 } |
| 184 |
| 185 RegionObservability RegionObservabilityOf(Operator const* op) { |
| 186 DCHECK_EQ(IrOpcode::kBeginRegion, op->opcode()); |
| 187 return OpParameter<RegionObservability>(op); |
| 188 } |
| 189 |
170 std::ostream& operator<<(std::ostream& os, | 190 std::ostream& operator<<(std::ostream& os, |
171 const ZoneVector<MachineType>* types) { | 191 const ZoneVector<MachineType>* types) { |
172 // Print all the MachineTypes, separated by commas. | 192 // Print all the MachineTypes, separated by commas. |
173 bool first = true; | 193 bool first = true; |
174 for (MachineType elem : *types) { | 194 for (MachineType elem : *types) { |
175 if (!first) { | 195 if (!first) { |
176 os << ", "; | 196 os << ", "; |
177 } | 197 } |
178 first = false; | 198 first = false; |
179 os << elem; | 199 os << elem; |
180 } | 200 } |
181 return os; | 201 return os; |
182 } | 202 } |
183 | 203 |
184 #define CACHED_OP_LIST(V) \ | 204 #define CACHED_OP_LIST(V) \ |
185 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \ | 205 V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1) \ |
186 V(DeoptimizeIf, Operator::kFoldable, 2, 1, 1, 0, 1, 1) \ | 206 V(DeoptimizeIf, Operator::kFoldable, 2, 1, 1, 0, 1, 1) \ |
187 V(DeoptimizeUnless, Operator::kFoldable, 2, 1, 1, 0, 1, 1) \ | 207 V(DeoptimizeUnless, Operator::kFoldable, 2, 1, 1, 0, 1, 1) \ |
188 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 208 V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
189 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 209 V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
190 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 210 V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
191 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ | 211 V(IfDefault, Operator::kKontrol, 0, 0, 1, 0, 0, 1) \ |
192 V(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1) \ | 212 V(Throw, Operator::kKontrol, 1, 1, 1, 0, 0, 1) \ |
193 V(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) \ | 213 V(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1) \ |
194 V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ | 214 V(OsrNormalEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ |
195 V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ | 215 V(OsrLoopEntry, Operator::kFoldable, 0, 1, 1, 0, 1, 1) \ |
196 V(Checkpoint, Operator::kKontrol, 0, 1, 1, 0, 1, 0) \ | 216 V(Checkpoint, Operator::kKontrol, 0, 1, 1, 0, 1, 0) \ |
197 V(BeginRegion, Operator::kNoThrow, 0, 1, 0, 0, 1, 0) \ | 217 V(FinishRegion, Operator::kKontrol, 1, 1, 0, 1, 1, 0) |
198 V(FinishRegion, Operator::kNoThrow, 1, 1, 0, 1, 1, 0) | |
199 | 218 |
200 #define CACHED_RETURN_LIST(V) \ | 219 #define CACHED_RETURN_LIST(V) \ |
201 V(1) \ | 220 V(1) \ |
202 V(2) \ | 221 V(2) \ |
203 V(3) | 222 V(3) |
204 | 223 |
205 | 224 |
206 #define CACHED_END_LIST(V) \ | 225 #define CACHED_END_LIST(V) \ |
207 V(1) \ | 226 V(1) \ |
208 V(2) \ | 227 V(2) \ |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 : Operator( // -- | 386 : Operator( // -- |
368 IrOpcode::kEffectPhi, Operator::kPure, // opcode | 387 IrOpcode::kEffectPhi, Operator::kPure, // opcode |
369 "EffectPhi", // name | 388 "EffectPhi", // name |
370 0, kEffectInputCount, 1, 0, 1, 0) {} // counts | 389 0, kEffectInputCount, 1, 0, 1, 0) {} // counts |
371 }; | 390 }; |
372 #define CACHED_EFFECT_PHI(input_count) \ | 391 #define CACHED_EFFECT_PHI(input_count) \ |
373 EffectPhiOperator<input_count> kEffectPhi##input_count##Operator; | 392 EffectPhiOperator<input_count> kEffectPhi##input_count##Operator; |
374 CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI) | 393 CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI) |
375 #undef CACHED_EFFECT_PHI | 394 #undef CACHED_EFFECT_PHI |
376 | 395 |
| 396 template <RegionObservability kRegionObservability> |
| 397 struct BeginRegionOperator final : public Operator1<RegionObservability> { |
| 398 BeginRegionOperator() |
| 399 : Operator1<RegionObservability>( // -- |
| 400 IrOpcode::kBeginRegion, Operator::kKontrol, // opcode |
| 401 "BeginRegion", // name |
| 402 0, 1, 0, 0, 1, 0, // counts |
| 403 kRegionObservability) {} // parameter |
| 404 }; |
| 405 BeginRegionOperator<RegionObservability::kObservable> |
| 406 kBeginRegionObservableOperator; |
| 407 BeginRegionOperator<RegionObservability::kNotObservable> |
| 408 kBeginRegionNotObservableOperator; |
| 409 |
377 template <size_t kInputCount> | 410 template <size_t kInputCount> |
378 struct LoopOperator final : public Operator { | 411 struct LoopOperator final : public Operator { |
379 LoopOperator() | 412 LoopOperator() |
380 : Operator( // -- | 413 : Operator( // -- |
381 IrOpcode::kLoop, Operator::kKontrol, // opcode | 414 IrOpcode::kLoop, Operator::kKontrol, // opcode |
382 "Loop", // name | 415 "Loop", // name |
383 0, 0, kInputCount, 0, 0, 1) {} // counts | 416 0, 0, kInputCount, 0, 0, 1) {} // counts |
384 }; | 417 }; |
385 #define CACHED_LOOP(input_count) \ | 418 #define CACHED_LOOP(input_count) \ |
386 LoopOperator<input_count> kLoop##input_count##Operator; | 419 LoopOperator<input_count> kLoop##input_count##Operator; |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 default: | 799 default: |
767 break; | 800 break; |
768 } | 801 } |
769 // Uncached. | 802 // Uncached. |
770 return new (zone()) Operator( // -- | 803 return new (zone()) Operator( // -- |
771 IrOpcode::kEffectPhi, Operator::kPure, // opcode | 804 IrOpcode::kEffectPhi, Operator::kPure, // opcode |
772 "EffectPhi", // name | 805 "EffectPhi", // name |
773 0, effect_input_count, 1, 0, 1, 0); // counts | 806 0, effect_input_count, 1, 0, 1, 0); // counts |
774 } | 807 } |
775 | 808 |
| 809 const Operator* CommonOperatorBuilder::BeginRegion( |
| 810 RegionObservability region_observability) { |
| 811 switch (region_observability) { |
| 812 case RegionObservability::kObservable: |
| 813 return &cache_.kBeginRegionObservableOperator; |
| 814 case RegionObservability::kNotObservable: |
| 815 return &cache_.kBeginRegionNotObservableOperator; |
| 816 } |
| 817 UNREACHABLE(); |
| 818 return nullptr; |
| 819 } |
776 | 820 |
777 const Operator* CommonOperatorBuilder::StateValues(int arguments) { | 821 const Operator* CommonOperatorBuilder::StateValues(int arguments) { |
778 switch (arguments) { | 822 switch (arguments) { |
779 #define CACHED_STATE_VALUES(arguments) \ | 823 #define CACHED_STATE_VALUES(arguments) \ |
780 case arguments: \ | 824 case arguments: \ |
781 return &cache_.kStateValues##arguments##Operator; | 825 return &cache_.kStateValues##arguments##Operator; |
782 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES) | 826 CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES) |
783 #undef CACHED_STATE_VALUES | 827 #undef CACHED_STATE_VALUES |
784 default: | 828 default: |
785 break; | 829 break; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 CommonOperatorBuilder::CreateFrameStateFunctionInfo( | 945 CommonOperatorBuilder::CreateFrameStateFunctionInfo( |
902 FrameStateType type, int parameter_count, int local_count, | 946 FrameStateType type, int parameter_count, int local_count, |
903 Handle<SharedFunctionInfo> shared_info) { | 947 Handle<SharedFunctionInfo> shared_info) { |
904 return new (zone()->New(sizeof(FrameStateFunctionInfo))) | 948 return new (zone()->New(sizeof(FrameStateFunctionInfo))) |
905 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); | 949 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); |
906 } | 950 } |
907 | 951 |
908 } // namespace compiler | 952 } // namespace compiler |
909 } // namespace internal | 953 } // namespace internal |
910 } // namespace v8 | 954 } // namespace v8 |
OLD | NEW |