5 #ifndef V8_COMPILER_COMMON_OPERATOR_H_ 6 #define V8_COMPILER_COMMON_OPERATOR_H_ 8 #include "src/base/compiler-specific.h" 9 #include "src/compiler/frame-states.h" 10 #include "src/deoptimize-reason.h" 11 #include "src/globals.h" 12 #include "src/machine-type.h" 13 #include "src/reloc-info.h" 14 #include "src/string-constants.h" 15 #include "src/vector-slot-pair.h" 16 #include "src/zone/zone-containers.h" 17 #include "src/zone/zone-handle-set.h" 22 class StringConstantBase;
28 struct CommonOperatorGlobalCache;
34 enum class BranchHint : uint8_t {
kNone, kTrue, kFalse };
36 inline BranchHint NegateBranchHint(BranchHint hint) {
38 case BranchHint::kNone:
40 case BranchHint::kTrue:
41 return BranchHint::kFalse;
42 case BranchHint::kFalse:
43 return BranchHint::kTrue;
48 inline size_t hash_value(BranchHint hint) {
return static_cast<size_t>(hint); }
50 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, BranchHint);
52 enum class IsSafetyCheck : uint8_t {
59 IsSafetyCheck CombineSafetyChecks(IsSafetyCheck, IsSafetyCheck);
61 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, IsSafetyCheck);
62 inline size_t hash_value(IsSafetyCheck is_safety_check) {
63 return static_cast<size_t>(is_safety_check);
67 #define DEF_ENUM(Name, ...) k##Name, 68 FOREACH_WASM_TRAPREASON(DEF_ENUM)
73 inline size_t hash_value(TrapId
id) {
return static_cast<uint32_t>(id); }
75 std::ostream& operator<<(std::ostream&, TrapId trap_id);
77 TrapId TrapIdOf(
const Operator*
const op);
81 IsSafetyCheck is_safety_check;
85 return base::hash_combine(info.hint, info.is_safety_check);
88 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, BranchOperatorInfo);
90 inline bool operator==(
const BranchOperatorInfo& a,
91 const BranchOperatorInfo& b) {
92 return a.hint == b.hint && a.is_safety_check == b.is_safety_check;
95 V8_EXPORT_PRIVATE
const BranchOperatorInfo& BranchOperatorInfoOf(
96 const Operator*
const) V8_WARN_UNUSED_RESULT;
97 V8_EXPORT_PRIVATE BranchHint BranchHintOf(
const Operator*
const)
98 V8_WARN_UNUSED_RESULT;
101 int ValueInputCountOfReturn(Operator
const*
const op);
108 IsSafetyCheck is_safety_check)
112 is_safety_check_(is_safety_check) {}
114 DeoptimizeKind kind()
const {
return kind_; }
115 DeoptimizeReason reason()
const {
return reason_; }
117 IsSafetyCheck is_safety_check()
const {
return is_safety_check_; }
120 DeoptimizeKind
const kind_;
121 DeoptimizeReason
const reason_;
123 IsSafetyCheck is_safety_check_;
134 V8_WARN_UNUSED_RESULT;
136 IsSafetyCheck IsSafetyCheckOf(
const Operator* op) V8_WARN_UNUSED_RESULT;
141 BranchHint hint = BranchHint::kNone)
142 : representation_(representation), hint_(hint) {}
144 MachineRepresentation representation()
const {
return representation_; }
145 BranchHint hint()
const {
return hint_; }
148 const MachineRepresentation representation_;
149 const BranchHint hint_;
160 const Operator*
const) V8_WARN_UNUSED_RESULT;
163 V8_WARN_UNUSED_RESULT;
165 V8_EXPORT_PRIVATE
size_t ProjectionIndexOf(
const Operator*
const)
166 V8_WARN_UNUSED_RESULT;
168 V8_EXPORT_PRIVATE MachineRepresentation
169 PhiRepresentationOf(
const Operator*
const) V8_WARN_UNUSED_RESULT;
176 : index_(index), debug_name_(debug_name) {}
178 int index()
const {
return index_; }
179 const char* debug_name()
const {
return debug_name_; }
183 const char* debug_name_;
186 std::ostream& operator<<(std::ostream&,
ParameterInfo const&);
188 V8_EXPORT_PRIVATE
int ParameterIndexOf(
const Operator*
const)
189 V8_WARN_UNUSED_RESULT;
191 V8_WARN_UNUSED_RESULT;
195 : std::pair<uint32_t, int>(object_id, size) {}
196 uint32_t object_id()
const {
return first; }
197 int size()
const {
return second; }
203 : std::pair<uint32_t, const ZoneVector<MachineType>*> {
206 : std::pair<uint32_t, const ZoneVector<MachineType>*>(object_id,
208 uint32_t object_id()
const {
return first; }
216 enum Type { kInt32, kInt64 };
219 : value_(value), rmode_(rmode), type_(kInt32) {}
221 : value_(value), rmode_(rmode), type_(kInt64) {}
223 intptr_t value()
const {
return value_; }
224 RelocInfo::Mode rmode()
const {
return rmode_; }
225 Type
type()
const {
return type_; }
229 RelocInfo::Mode rmode_;
257 static const int kMaxSparseInputs = (
sizeof(
BitMaskType) * kBitsPerByte - 1);
265 Node* parent()
const {
return parent_; }
266 int real_index()
const {
return real_index_; }
274 Node* GetReal()
const;
279 Node* Get(
Node* empty_value)
const {
280 return IsReal() ? GetReal() : empty_value;
287 bool IsEmpty()
const {
return !IsReal(); }
303 BitMaskType mask()
const {
return bit_mask_; }
305 bool IsDense()
const {
return bit_mask_ == SparseInputMask::kDenseBitMask; }
309 int CountReal()
const;
312 InputIterator IterateOverInputs(Node* node);
330 BitMaskType bit_mask_;
333 bool operator==(SparseInputMask
const& lhs, SparseInputMask
const& rhs);
334 bool operator!=(SparseInputMask
const& lhs, SparseInputMask
const& rhs);
340 : machine_types_(machine_types), sparse_input_mask_(sparse_input_mask) {}
343 return machine_types_;
345 SparseInputMask sparse_input_mask()
const {
return sparse_input_mask_; }
362 enum class RegionObservability : uint8_t { kObservable, kNotObservable };
364 size_t hash_value(RegionObservability);
366 std::ostream& operator<<(std::ostream&, RegionObservability);
368 RegionObservability RegionObservabilityOf(Operator
const*)
369 V8_WARN_UNUSED_RESULT;
371 std::ostream& operator<<(std::ostream& os,
374 Type TypeGuardTypeOf(Operator
const*) V8_WARN_UNUSED_RESULT;
376 int OsrValueIndexOf(Operator
const*) V8_WARN_UNUSED_RESULT;
378 SparseInputMask SparseInputMaskOf(Operator
const*) V8_WARN_UNUSED_RESULT;
381 V8_WARN_UNUSED_RESULT;
402 typedef CreateArgumentsType ArgumentsStateType;
404 ArgumentsStateType ArgumentsStateTypeOf(Operator
const*) V8_WARN_UNUSED_RESULT;
406 uint32_t ObjectIdOf(Operator
const*);
408 MachineRepresentation DeadValueRepresentationOf(Operator
const*)
409 V8_WARN_UNUSED_RESULT;
414 : value_(value), comparison_order_(comparison_order) {}
416 int32_t value()
const {
return value_; }
417 int32_t comparison_order()
const {
return comparison_order_; }
421 int32_t comparison_order_;
429 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
433 const Operator* op) V8_WARN_UNUSED_RESULT;
436 V8_WARN_UNUSED_RESULT;
441 V8_WARN_UNUSED_RESULT;
446 :
public NON_EXPORTED_BASE(ZoneObject) {
451 const Operator* DeadValue(MachineRepresentation rep);
453 const Operator* End(
size_t control_input_count);
454 const Operator* Branch(BranchHint = BranchHint::kNone,
455 IsSafetyCheck = IsSafetyCheck::kSafetyCheck);
460 const Operator* Switch(
size_t control_output_count);
461 const Operator* IfValue(int32_t value, int32_t order = 0);
464 const Operator* Deoptimize(DeoptimizeKind kind, DeoptimizeReason reason,
467 DeoptimizeKind kind, DeoptimizeReason reason,
469 IsSafetyCheck is_safety_check = IsSafetyCheck::kSafetyCheck);
471 DeoptimizeKind kind, DeoptimizeReason reason,
473 IsSafetyCheck is_safety_check = IsSafetyCheck::kSafetyCheck);
474 const Operator* TrapIf(TrapId trap_id);
475 const Operator* TrapUnless(TrapId trap_id);
476 const Operator* Return(
int value_input_count = 1);
479 const Operator* Start(
int value_output_count);
480 const Operator* Loop(
int control_input_count);
481 const Operator* Merge(
int control_input_count);
482 const Operator* Parameter(
int index,
const char* debug_name =
nullptr);
486 const Operator* OsrValue(
int index);
488 const Operator* Int32Constant(int32_t);
490 const Operator* Float32Constant(
volatile float);
491 const Operator* Float64Constant(
volatile double);
493 const Operator* NumberConstant(
volatile double);
494 const Operator* PointerConstant(intptr_t);
498 const Operator* RelocatableInt32Constant(int32_t value,
499 RelocInfo::Mode rmode);
501 RelocInfo::Mode rmode);
503 const Operator* Select(MachineRepresentation, BranchHint = BranchHint::kNone);
504 const Operator* Phi(MachineRepresentation representation,
505 int value_input_count);
506 const Operator* EffectPhi(
int effect_input_count);
507 const Operator* InductionVariablePhi(
int value_input_count);
512 const Operator* BeginRegion(RegionObservability);
517 const Operator* ArgumentsElementsState(ArgumentsStateType
type);
518 const Operator* ArgumentsLengthState(ArgumentsStateType
type);
526 const Operator* CallWithCallerSavedRegisters(
529 const Operator* Projection(
size_t index);
539 FrameStateType
type,
int parameter_count,
int local_count,
543 IsSafetyCheck safety_check);
548 Zone* zone()
const {
return zone_; }
560 #endif // V8_COMPILER_COMMON_OPERATOR_H_