v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
simplified-operator.h
Go to the documentation of this file.
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
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_SIMPLIFIED_OPERATOR_H_
6#define V8_COMPILER_SIMPLIFIED_OPERATOR_H_
7
8#include <iosfwd>
9
13#include "src/codegen/tnode.h"
14#include "src/common/globals.h"
23#include "src/handles/handles.h"
25#include "src/objects/objects.h"
26
27#ifdef V8_ENABLE_WEBASSEMBLY
29#endif
30
31namespace v8 {
32class CFunctionInfo;
33
34namespace internal {
35
36// Forward declarations.
37enum class AbortReason : uint8_t;
38class Zone;
39
40namespace compiler {
41
42// Forward declarations.
43class CallDescriptor;
44class Operator;
45struct SimplifiedOperatorGlobalCache;
46struct WasmTypeCheckConfig;
47
49
50std::ostream& operator<<(std::ostream&, BaseTaggedness);
51
53 // the map that introduced the const field, if any. An access is considered
54 // mutable iff the handle is null.
55 OptionalMapRef owner_map;
56
57 ConstFieldInfo() : owner_map(OptionalMapRef()) {}
59
60 bool IsConst() const { return owner_map.has_value(); }
61
62 // No const field owner, i.e., a mutable field
63 static ConstFieldInfo None() { return ConstFieldInfo(); }
64};
65
66V8_EXPORT_PRIVATE bool operator==(ConstFieldInfo const&, ConstFieldInfo const&);
67
68size_t hash_value(ConstFieldInfo const&);
69
70V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
71 ConstFieldInfo const&);
72
73#if V8_ENABLE_WEBASSEMBLY
74struct WasmFieldInfo {
76 int field_index;
77 bool is_signed;
78 CheckForNull null_check;
79};
80
81V8_EXPORT_PRIVATE bool operator==(WasmFieldInfo const&, WasmFieldInfo const&);
82
83size_t hash_value(WasmFieldInfo const&);
84
85V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, WasmFieldInfo const&);
86
87struct WasmElementInfo {
88 const wasm::ArrayType* type;
89 bool is_signed;
90};
91
92V8_EXPORT_PRIVATE bool operator==(WasmElementInfo const&,
93 WasmElementInfo const&);
94
95size_t hash_value(WasmElementInfo const&);
96
97V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
98 WasmElementInfo const&);
99#endif
100
101// An access descriptor for loads/stores of fixed structures like field
102// accesses of heap objects. Accesses from either tagged or untagged base
103// pointers are supported; untagging is done automatically during lowering.
105 BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged.
106 int offset; // offset of the field, without tag.
107 MaybeHandle<Name> name; // debugging only.
108 OptionalMapRef map; // map of the field value (if known).
109 Type type; // type of the field.
110 MachineType machine_type; // machine type of the field.
111 WriteBarrierKind write_barrier_kind; // write barrier hint.
112 const char* creator_mnemonic; // store the name of factory/creator method
113 ConstFieldInfo const_field_info;// the constness of this access, and the
114 // field owner map, if the access is const
115 bool is_store_in_literal; // originates from a kStoreInLiteral access
117 bool maybe_initializing_or_transitioning_store; // store is potentially
118 // initializing a newly
119 // allocated object or part
120 // of a map transition.
121 bool is_bounded_size_access = false; // Whether this field is stored as a
122 // bounded size field. In that case,
123 // the size is shifted to the left to
124 // guarantee that the value is at most
125 // kMaxSafeBufferSizeForSandbox after
126 // decoding.
127 bool is_immutable = false; // Whether this field is known to be immutable for
128 // the purpose of loads.
130
141
143 OptionalMapRef map, Type type, MachineType machine_type,
145 const char* creator_mnemonic = nullptr,
147 bool is_store_in_literal = false,
150 bool is_immutable = false,
153 offset(offset),
154 name(name),
155 map(map),
156 type(type),
166 DCHECK_GE(offset, 0);
174 #if !defined(OFFICIAL_BUILD)
175 this->creator_mnemonic = creator_mnemonic;
176 #else
177 this->creator_mnemonic = nullptr;
178 #endif
179 }
180
181 int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; }
182};
183
184V8_EXPORT_PRIVATE bool operator==(FieldAccess const&, FieldAccess const&);
185
186size_t hash_value(FieldAccess const&);
187
188V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, FieldAccess const&);
189
190V8_EXPORT_PRIVATE FieldAccess const& FieldAccessOf(const Operator* op)
192
193template <>
195 PrintVerbosity verbose) const;
196
197// An access descriptor for loads/stores of indexed structures like characters
198// in strings or off-heap backing stores. Accesses from either tagged or
199// untagged base pointers are supported; untagging is done automatically during
200// lowering.
202 BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged.
203 int header_size; // size of the header, without tag.
204 Type type; // type of the element.
205 MachineType machine_type; // machine type of the element.
206 WriteBarrierKind write_barrier_kind; // write barrier hint.
207
214
222
223 int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; }
224};
225
226V8_EXPORT_PRIVATE bool operator==(ElementAccess const&, ElementAccess const&);
227
228size_t hash_value(ElementAccess const&);
229
230V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, ElementAccess const&);
231
232V8_EXPORT_PRIVATE ElementAccess const& ElementAccessOf(const Operator* op)
234
236
237// An access descriptor for loads/stores of CSA-accessible structures.
251
252V8_EXPORT_PRIVATE bool operator==(ObjectAccess const&, ObjectAccess const&);
253
254size_t hash_value(ObjectAccess const&);
255
256V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, ObjectAccess const&);
257
258V8_EXPORT_PRIVATE ObjectAccess const& ObjectAccessOf(const Operator* op)
260
261// The ConvertReceiverMode is used as parameter by ConvertReceiver operators.
264
265// A the parameters for several Check nodes. The {feedback} parameter is
266// optional. If {feedback} references a valid CallIC slot and this MapCheck
267// fails, then speculation on that CallIC slot will be disabled.
268class CheckParameters final {
269 public:
270 explicit CheckParameters(const FeedbackSource& feedback)
271 : feedback_(feedback) {}
272
273 FeedbackSource const& feedback() const { return feedback_; }
274
275 private:
277};
278
279bool operator==(CheckParameters const&, CheckParameters const&);
280
281size_t hash_value(CheckParameters const&);
282
283std::ostream& operator<<(std::ostream&, CheckParameters const&);
284
286
287enum class CheckBoundsFlag : uint8_t {
288 kConvertStringAndMinusZero = 1 << 0, // instead of deopting on such inputs
289 kAbortOnOutOfBounds = 1 << 1, // instead of deopting if input is OOB
290};
293
295 public:
297 : check_parameters_(feedback), flags_(flags) {}
298
299 CheckBoundsFlags flags() const { return flags_; }
300 const CheckParameters& check_parameters() const { return check_parameters_; }
301
302 private:
305};
306
308
309size_t hash_value(CheckBoundsParameters const&);
310
311std::ostream& operator<<(std::ostream&, CheckBoundsParameters const&);
312
315
316class CheckIfParameters final {
317 public:
319 const FeedbackSource& feedback)
320 : reason_(reason), feedback_(feedback) {}
321
322 FeedbackSource const& feedback() const { return feedback_; }
323 DeoptimizeReason reason() const { return reason_; }
324
325 private:
328};
329
331
332size_t hash_value(CheckIfParameters const&);
333
334std::ostream& operator<<(std::ostream&, CheckIfParameters const&);
335
338
339enum class CheckFloat64HoleMode : uint8_t {
340 kNeverReturnHole, // Never return the hole (deoptimize instead).
341 kAllowReturnHole // Allow to return the hole (signaling NaN).
342};
343
345
346std::ostream& operator<<(std::ostream&, CheckFloat64HoleMode);
347
349 public:
351 FeedbackSource const& feedback)
352 : mode_(mode), feedback_(feedback) {}
353
354 CheckFloat64HoleMode mode() const { return mode_; }
355 FeedbackSource const& feedback() const { return feedback_; }
356
357 private:
360};
361
364
365std::ostream& operator<<(std::ostream&, CheckFloat64HoleParameters const&);
366
368
373
374// Parameter for CheckClosure node.
376
383
385
386V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, CheckTaggedInputMode);
387
389 public:
391 const FeedbackSource& feedback)
392 : mode_(mode), feedback_(feedback) {}
393
394 CheckTaggedInputMode mode() const { return mode_; }
395 const FeedbackSource& feedback() const { return feedback_; }
396
397 private:
400};
401
404
405std::ostream& operator<<(std::ostream&,
406 const CheckTaggedInputParameters& params);
407
408size_t hash_value(const CheckTaggedInputParameters& params);
409
412
415
417 public:
419 const FeedbackSource& feedback)
420 : mode_(mode), feedback_(feedback) {}
421
422 CheckForMinusZeroMode mode() const { return mode_; }
423 const FeedbackSource& feedback() const { return feedback_; }
424
425 private:
428};
429
432
433V8_EXPORT_PRIVATE std::ostream& operator<<(
434 std::ostream&, const CheckMinusZeroParameters& params);
435
436size_t hash_value(const CheckMinusZeroParameters& params);
437
440
441enum class CheckMapsFlag : uint8_t {
442 kNone = 0u,
443 kTryMigrateInstance = 1u << 0,
445};
447
449
450std::ostream& operator<<(std::ostream&, CheckMapsFlags);
451
452// A descriptor for map checks. The {feedback} parameter is optional.
453// If {feedback} references a valid CallIC slot and this MapCheck fails,
454// then speculation on that CallIC slot will be disabled.
456 public:
458 const FeedbackSource& feedback)
459 : flags_(flags), maps_(maps), feedback_(feedback) {}
460
461 CheckMapsFlags flags() const { return flags_; }
462 ZoneRefSet<Map> const& maps() const { return maps_; }
463 FeedbackSource const& feedback() const { return feedback_; }
464
465 private:
469};
470
472
473size_t hash_value(CheckMapsParameters const&);
474
475std::ostream& operator<<(std::ostream&, CheckMapsParameters const&);
476
479
481
482// Parameters for CompareMaps operator.
485
486// A descriptor for growing elements backing stores.
487enum class GrowFastElementsMode : uint8_t {
490};
491
492inline size_t hash_value(GrowFastElementsMode mode) {
493 return static_cast<uint8_t>(mode);
494}
495
496std::ostream& operator<<(std::ostream&, GrowFastElementsMode);
497
499 public:
501 const FeedbackSource& feedback)
502 : mode_(mode), feedback_(feedback) {}
503
504 GrowFastElementsMode mode() const { return mode_; }
505 const FeedbackSource& feedback() const { return feedback_; }
506
507 private:
510};
511
514
515inline size_t hash_value(const GrowFastElementsParameters&);
516
517std::ostream& operator<<(std::ostream&, const GrowFastElementsParameters&);
518
521
522// A descriptor for elements kind transitions.
524 public:
525 enum Mode : uint8_t {
526 kFastTransition, // simple transition, just updating the map.
527 kSlowTransition // full transition, round-trip to the runtime.
528 };
529
530 ElementsTransition(Mode mode, MapRef source, MapRef target)
531 : mode_(mode), source_(source), target_(target) {}
532
533 Mode mode() const { return mode_; }
534 MapRef source() const { return source_; }
535 MapRef target() const { return target_; }
536
537 private:
538 Mode const mode_;
541};
542
544 public:
549
550 const ZoneRefSet<Map>& sources() const { return sources_; }
551 MapRef target() const { return target_; }
552 const FeedbackSource& feedback() const { return feedback_; }
553
554 private:
558};
559
563
566
567std::ostream& operator<<(std::ostream&, ElementsTransition);
568std::ostream& operator<<(std::ostream&, ElementsTransitionWithMultipleSources);
569
572
576
577// Parameters for TransitionAndStoreElement, or
578// TransitionAndStoreNonNumberElement, or
579// TransitionAndStoreNumberElement.
582
583// Parameters for TransitionAndStoreNonNumberElement.
585
586// A hint for speculative number operations.
587enum class NumberOperationHint : uint8_t {
588 kSignedSmall, // Inputs were Smi, output was in Smi.
589 kSignedSmallInputs, // Inputs were Smi, output was Number.
590 kAdditiveSafeInteger, // Inputs were AdditiveSafeInteger, output was
591 // AdditiveSafeInteger.
592 kNumber, // Inputs were Number, output was Number.
593 kNumberOrBoolean, // Inputs were Number or Boolean, output was Number.
594 kNumberOrOddball, // Inputs were Number or Oddball, output was Number.
595};
596
597enum class BigIntOperationHint : uint8_t {
598 kBigInt,
599 kBigInt64,
600};
601
604
605V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, NumberOperationHint);
606V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, BigIntOperationHint);
611
613 public:
617
618 NumberOperationHint hint() const { return hint_; }
619 const FeedbackSource& feedback() const { return feedback_; }
620
621 private:
624};
625
627V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
633
635 public:
639
640 BigIntOperationHint hint() const { return hint_; }
641 const FeedbackSource& feedback() const { return feedback_; }
642
643 private:
646};
647
649V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
655
657 public:
659 : bits_(bits), feedback_(feedback) {
660 DCHECK_GE(bits_, 0);
661 DCHECK_LE(bits_, 64);
662 }
663
664 int bits() const { return bits_; }
665 const FeedbackSource& feedback() const { return feedback_; }
666
667 private:
668 int bits_;
670};
671
673V8_EXPORT_PRIVATE std::ostream& operator<<(
674 std::ostream&, const SpeculativeBigIntAsNParameters&);
679
681
694
695bool IsCheckedWithFeedback(const Operator* op);
696
698
699V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, AllocateParameters);
700
702
705
707
709
711
713
715
729
732
733inline size_t hash_value(const NewArgumentsElementsParameters&);
734
735std::ostream& operator<<(std::ostream&, const NewArgumentsElementsParameters&);
736
739
743
744 bool operator==(const FastApiCallFunction& rhs) const {
745 return address == rhs.address && signature == rhs.signature;
746 }
747};
748
750 public:
755
757 FeedbackSource const& feedback() const { return feedback_; }
759 const CFunctionInfo* signature() const { return c_function_.signature; }
760 unsigned int argument_count() const {
761 const unsigned int count = signature()->ArgumentCount();
762 return count;
763 }
764
765 private:
767
770};
771
774
775V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
776 FastApiCallParameters const&);
777
778size_t hash_value(FastApiCallParameters const&);
779
781
782#if V8_ENABLE_WEBASSEMBLY
783struct AssertNotNullParameters {
785 TrapId trap_id;
786};
787
788V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
789 AssertNotNullParameters const&);
790
791size_t hash_value(AssertNotNullParameters const&);
792
793bool operator==(AssertNotNullParameters const&, AssertNotNullParameters const&);
794
795#endif
796
797// Interface for building simplified operators, which represent the
798// medium-level operations of V8, including adding numbers, allocating objects,
799// indexing into objects and arrays, etc.
800// All operators are typed but many are representation independent.
801
802// Number values from JS can be in one of these representations:
803// - Tagged: word-sized integer that is either
804// - a signed small integer (31 or 32 bits plus a tag)
805// - a tagged pointer to a HeapNumber object that has a float64 field
806// - Int32: an untagged signed 32-bit integer
807// - Uint32: an untagged unsigned 32-bit integer
808// - Float64: an untagged float64
809
810// Additional representations for intermediate code or non-JS code:
811// - Int64: an untagged signed 64-bit integer
812// - Uint64: an untagged unsigned 64-bit integer
813// - Float32: an untagged float32
814
815// Boolean values can be:
816// - Bool: a tagged pointer to either the canonical JS #false or
817// the canonical JS #true object
818// - Bit: an untagged integer 0 or 1, but word-sized
820 : public NON_EXPORTED_BASE(ZoneObject) {
821 public:
822 explicit SimplifiedOperatorBuilder(Zone* zone);
825 delete;
826
828
883
885
897
901
907
920
923 const Operator* SpeculativeNumberEqual(NumberOperationHint hint);
924
935 const Operator* SpeculativeBigIntNegate(BigIntOperationHint hint);
936 const Operator* SpeculativeBigIntAsIntN(int bits,
937 const FeedbackSource& feedback);
938 const Operator* SpeculativeBigIntAsUintN(int bits,
939 const FeedbackSource& feedback);
940
944
948
949 const Operator* TypeOf();
950
952
968
969 const Operator* TypedArrayLength(ElementsKind elements_kind);
970
972 const Operator* FindOrderedCollectionEntry(CollectionKind collection_kind);
973
974 const Operator* SpeculativeToNumber(NumberOperationHint hint,
975 const FeedbackSource& feedback);
976
977 const Operator* SpeculativeToBigInt(BigIntOperationHint hint,
978 const FeedbackSource& feedback);
979
984
997 const Operator* ChangeFloat64ToTagged(CheckForMinusZeroMode);
1009
1010 const Operator* CompareMaps(ZoneRefSet<Map>);
1011 const Operator* MapGuard(ZoneRefSet<Map> maps);
1012
1013 const Operator* CheckBounds(const FeedbackSource& feedback,
1014 CheckBoundsFlags flags = {});
1016 CheckBoundsFlags flags);
1018 CheckBoundsFlags flags);
1019
1020 const Operator* CheckClosure(const Handle<FeedbackCell>& feedback_cell);
1023 const Operator* CheckFloat64Hole(CheckFloat64HoleMode, FeedbackSource const&);
1025 const Operator* CheckIf(DeoptimizeReason deoptimize_reason,
1026 const FeedbackSource& feedback = FeedbackSource());
1028 const Operator* CheckMaps(CheckMapsFlags, ZoneRefSet<Map>,
1029 const FeedbackSource& = FeedbackSource());
1031 const Operator* CheckNumber(const FeedbackSource& feedback);
1035 const Operator* CheckSmi(const FeedbackSource& feedback);
1036 const Operator* CheckString(const FeedbackSource& feedback);
1039
1040 const Operator* CheckedFloat64ToInt32(CheckForMinusZeroMode,
1041 const FeedbackSource& feedback);
1042 const Operator* CheckedFloat64ToAdditiveSafeInteger(
1043 CheckForMinusZeroMode, const FeedbackSource& feedback);
1044 const Operator* CheckedFloat64ToInt64(CheckForMinusZeroMode,
1045 const FeedbackSource& feedback);
1049 const Operator* CheckedInt32Mul(CheckForMinusZeroMode);
1062 const Operator* CheckedTaggedToFloat64(CheckTaggedInputMode,
1063 const FeedbackSource& feedback);
1064 const Operator* CheckedTaggedToInt32(CheckForMinusZeroMode,
1065 const FeedbackSource& feedback);
1067 const Operator* CheckedTaggedToAdditiveSafeInteger(
1068 CheckForMinusZeroMode, const FeedbackSource& feedback);
1069 const Operator* CheckedTaggedToInt64(CheckForMinusZeroMode,
1070 const FeedbackSource& feedback);
1073 const Operator* CheckBigInt(const FeedbackSource& feedback);
1075 const Operator* CheckedTruncateTaggedToWord32(CheckTaggedInputMode,
1076 const FeedbackSource& feedback);
1084
1085 const Operator* ConvertReceiver(ConvertReceiverMode);
1086
1088
1105
1113
1114 const Operator* ArgumentsLength();
1115 const Operator* RestLength(int formal_parameter_count);
1116
1117 const Operator* NewDoubleElements(AllocationType);
1118 const Operator* NewSmiOrObjectElements(AllocationType);
1119
1120 // new-arguments-elements arguments-length
1121 const Operator* NewArgumentsElements(CreateArgumentsType type,
1122 int formal_parameter_count);
1123
1124 // new-cons-string length, first, second
1126
1127 // ensure-writable-fast-elements object, elements
1128 const Operator* EnsureWritableFastElements();
1129
1130 // maybe-grow-fast-elements object, elements, index, length
1131 const Operator* MaybeGrowFastElements(GrowFastElementsMode mode,
1132 const FeedbackSource& feedback);
1133
1134 // transition-elements-kind object, from-map, to-map
1135 const Operator* TransitionElementsKind(ElementsTransition transition);
1136 const Operator* TransitionElementsKindOrCheckMap(
1138
1139 const Operator* Allocate(Type type,
1140 AllocationType allocation = AllocationType::kYoung);
1141 const Operator* AllocateRaw(
1142 Type type, AllocationType allocation = AllocationType::kYoung);
1143
1144 const Operator* LoadMessage();
1145 const Operator* StoreMessage();
1146
1149 const Operator* StoreField(FieldAccess const&,
1150 bool maybe_initializing_or_transitioning = true);
1151
1152 // load-element [base + index]
1154
1155 // load-stack-argument [base + index]
1156 const Operator* LoadStackArgument();
1157
1158 // store-element [base + index], value
1160
1161 // store-element [base + index], value, only with fast arrays.
1162 const Operator* TransitionAndStoreElement(MapRef double_map, MapRef fast_map);
1163 // store-element [base + index], smi value, only with fast arrays.
1164 const Operator* StoreSignedSmallElement();
1165
1166 // store-element [base + index], double value, only with fast arrays.
1167 const Operator* TransitionAndStoreNumberElement(MapRef double_map);
1168
1169 // store-element [base + index], object value, only with fast arrays.
1170 const Operator* TransitionAndStoreNonNumberElement(MapRef fast_map,
1171 Type value_type);
1172
1173 // load-from-object [base + offset]
1174 // This operator comes in two flavors: LoadImmutableFromObject guarantees that
1175 // the underlying object field will be initialized at most once for the
1176 // duration of the program. This enables more optimizations in
1177 // CsaLoadElimination.
1178 // Note: LoadImmutableFromObject is unrelated to LoadImmutable and is lowered
1179 // into a regular Load.
1182
1183 // store-to-object [base + offset], value
1184 // This operator comes in two flavors: InitializeImmutableInObject guarantees
1185 // that the underlying object field has not and will not be initialized again
1186 // for the duration of the program. This enables more optimizations in
1187 // CsaLoadElimination.
1190
1191 // load-typed-element buffer, [base + external + index]
1193
1194 // load-data-view-element object, [base + index]
1196
1197 // store-typed-element buffer, [base + external + index], value
1199
1200 // store-data-view-element object, [base + index], value
1202
1203 // Abort (for terminating execution on internal error).
1204 const Operator* RuntimeAbort(AbortReason reason);
1205
1206 // Abort if the value input does not inhabit the given type
1207 const Operator* AssertType(Type type);
1208
1209 // Abort if the value does not match the node's computed type after
1210 // SimplifiedLowering.
1211 const Operator* VerifyType();
1212 const Operator* CheckTurboshaftTypeOf();
1213
1214#if V8_ENABLE_WEBASSEMBLY
1215 const Operator* AssertNotNull(wasm::ValueType type, TrapId trap_id);
1216 const Operator* IsNull(wasm::ValueType type);
1217 const Operator* IsNotNull(wasm::ValueType type);
1218 const Operator* Null(wasm::ValueType type);
1219 const Operator* RttCanon(wasm::ModuleTypeIndex index);
1220 const Operator* WasmTypeCheck(WasmTypeCheckConfig config);
1221 const Operator* WasmTypeCheckAbstract(WasmTypeCheckConfig config);
1222 const Operator* WasmTypeCast(WasmTypeCheckConfig config);
1223 const Operator* WasmTypeCastAbstract(WasmTypeCheckConfig config);
1224 const Operator* WasmAnyConvertExtern();
1225 const Operator* WasmExternConvertAny();
1226 const Operator* WasmStructGet(const wasm::StructType* type, int field_index,
1227 bool is_signed, CheckForNull null_check);
1228 const Operator* WasmStructSet(const wasm::StructType* type, int field_index,
1229 CheckForNull null_check);
1230 const Operator* WasmArrayGet(const wasm::ArrayType* type, bool is_signed);
1231 const Operator* WasmArraySet(const wasm::ArrayType* type);
1232 const Operator* WasmArrayLength(CheckForNull);
1233 const Operator* WasmArrayInitializeLength();
1234 const Operator* StringAsWtf16();
1235 const Operator* StringPrepareForGetCodeunit();
1236#endif
1237
1239
1240 // Math.min/max for JSArray with PACKED_DOUBLE_ELEMENTS.
1243
1244 // Unsigned32Divide is a special operator to express the division of two
1245 // Unsigned32 inputs and truncating the result to Unsigned32. It's semantics
1246 // is equivalent to NumberFloor(NumberDivide(x:Unsigned32, y:Unsigned32)) but
1247 // is required to allow consistent typing of the graph.
1249
1250 // Represents the inputs necessary to construct a fast and a slow API call.
1251 const Operator* FastApiCall(FastApiCallFunction c_function,
1252 FeedbackSource const& feedback,
1253 CallDescriptor* descriptor);
1254
1255#ifdef V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
1256 const Operator* GetContinuationPreservedEmbedderData();
1257 const Operator* SetContinuationPreservedEmbedderData();
1258#endif // V8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA
1259
1260 private:
1261 Zone* zone() const { return zone_; }
1262
1264 Zone* const zone_;
1265};
1266
1267// Node wrappers.
1268
1269// TODO(jgruber): Consider merging with JSNodeWrapperBase.
1271 public:
1272 explicit constexpr SimplifiedNodeWrapperBase(Node* node)
1273 : NodeWrapper(node) {}
1274
1275 // Valid iff this node has a context input.
1277 // Could be a Context or NoContextConstant.
1280 }
1281
1282 // Valid iff this node has exactly one effect input.
1283 Effect effect() const {
1284 DCHECK_EQ(node()->op()->EffectInputCount(), 1);
1286 }
1287
1288 // Valid iff this node has exactly one control input.
1290 DCHECK_EQ(node()->op()->ControlInputCount(), 1);
1292 }
1293
1294 // Valid iff this node has a frame state input.
1298};
1299
1300#define DEFINE_INPUT_ACCESSORS(Name, name, TheIndex, Type) \
1301 static constexpr int Name##Index() { return TheIndex; } \
1302 TNode<Type> name() const { \
1303 return TNode<Type>::UncheckedCast( \
1304 NodeProperties::GetValueInput(node(), TheIndex)); \
1305 }
1306
1308 public:
1309 explicit FastApiCallNode(Node* node)
1313 DCHECK_EQ(IrOpcode::kFastApiCall, node->opcode());
1314 }
1315
1317 return FastApiCallParametersOf(node()->op());
1318 }
1319
1320#define INPUTS(V) V(Receiver, receiver, 0, Object)
1322#undef INPUTS
1323
1324 // Callback data passed to fast calls via FastApiCallbackOptions struct.
1325 constexpr int CallbackDataIndex() const {
1326 // The last fast argument is the callback data.
1327 return FastCallArgumentCount() - 1;
1328 }
1333
1334 // Context passed to slow fallback.
1335 constexpr int ContextIndex() const {
1336 // The last slow call argument is the frame state, the one before is the
1337 // context.
1339 }
1344
1345 // Frame state to slow fallback.
1346 constexpr int FrameStateIndex() const {
1347 // The last slow call argument is the frame state.
1349 }
1350
1351 // Besides actual C arguments (which already include receiver), FastApiCall
1352 // nodes also take extra arguments for fast call and a pack of arguments for
1353 // generating a slow call.
1354 // Extra fast arguments:
1355 // - callback data (passed to fast callback via FastApiCallbackOptions
1356 // struct),
1357 static constexpr int kCallbackData = 1;
1358
1359 // A pack of arguments required for a call to slow version (one of the
1360 // CallApiCallbackOptimizedXXX builtins) includes:
1361 // - builtin target code,
1362 static constexpr int kSlowCodeTarget = 1;
1363 // - params for builtin including context plus JS arguments including
1364 // receiver, see CallApiCallbackOptimizedDescriptor. This value is
1365 // provided as |slow_arg_count|,
1366 // - a frame state.
1367 static constexpr int kFrameState = 1;
1368
1369 // This is the number of inputs fed into FastApiCall operator.
1370 // |slow_arg_count| is the number of params for the slow builtin plus
1371 // JS arguments including receiver.
1372 static constexpr int ArityForArgc(int c_arg_count, int slow_arg_count) {
1373 return c_arg_count + kCallbackData + kSlowCodeTarget + slow_arg_count +
1375 }
1376
1377 constexpr int CArgumentCount() const { return c_arg_count_; }
1378
1379 constexpr int FastCallArgumentCount() const {
1380 return CArgumentCount() + kCallbackData;
1381 }
1382 constexpr int SlowCallArgumentCount() const { return slow_arg_count_; }
1383
1384 constexpr int FirstFastCallArgumentIndex() const {
1385 return ReceiverIndex() + 1;
1386 }
1387 constexpr int FastCallArgumentIndex(int i) const {
1388 return FirstFastCallArgumentIndex() + i;
1389 }
1395
1396 constexpr int FirstSlowCallArgumentIndex() const {
1397 return FastCallArgumentCount();
1398 }
1399 constexpr int SlowCallArgumentIndex(int i) const {
1400 return FirstSlowCallArgumentIndex() + i;
1401 }
1407
1408 private:
1409 static int FastCallArgumentCount(Node* node);
1410 static int SlowCallArgumentCount(Node* node);
1411
1412 const int c_arg_count_;
1414};
1415
1416#undef DEFINE_INPUT_ACCESSORS
1417
1418} // namespace compiler
1419} // namespace internal
1420} // namespace v8
1421
1422#endif // V8_COMPILER_SIMPLIFIED_OPERATOR_H_
friend Zone
Definition asm-types.cc:195
#define DEFINE_OPERATORS_FOR_FLAGS(Type)
Definition flags.h:100
static constexpr int kMapOffset
constexpr bool IsMapWord() const
static TNode UncheckedCast(compiler::Node *node)
Definition tnode.h:413
AllocateParameters(Type type, AllocationType allocation_type)
BigIntOperationParameters(BigIntOperationHint hint, const FeedbackSource &feedback)
CheckBoundsParameters(const FeedbackSource &feedback, CheckBoundsFlags flags)
const CheckParameters & check_parameters() const
CheckFloat64HoleParameters(CheckFloat64HoleMode mode, FeedbackSource const &feedback)
CheckIfParameters(DeoptimizeReason reason, const FeedbackSource &feedback)
CheckMapsParameters(CheckMapsFlags flags, ZoneRefSet< Map > const &maps, const FeedbackSource &feedback)
CheckMinusZeroParameters(CheckForMinusZeroMode mode, const FeedbackSource &feedback)
CheckParameters(const FeedbackSource &feedback)
FeedbackSource const & feedback() const
CheckTaggedInputParameters(CheckTaggedInputMode mode, const FeedbackSource &feedback)
ElementsTransitionWithMultipleSources(ZoneRefSet< Map > sources, MapRef target, const FeedbackSource &feedback=FeedbackSource())
ElementsTransition(Mode mode, MapRef source, MapRef target)
constexpr int FastCallArgumentIndex(int i) const
const FastApiCallParameters & Parameters() const
TNode< Object > SlowCallArgument(int i) const
static constexpr int ArityForArgc(int c_arg_count, int slow_arg_count)
constexpr int SlowCallArgumentIndex(int i) const
TNode< Object > FastCallArgument(int i) const
FastApiCallParameters(FastApiCallFunction c_function, FeedbackSource const &feedback, CallDescriptor *descriptor)
GrowFastElementsParameters(GrowFastElementsMode mode, const FeedbackSource &feedback)
NewArgumentsElementsParameters(CreateArgumentsType type, int formal_parameter_count)
static Node * GetEffectInput(Node *node, int index=0)
static Node * GetContextInput(Node *node)
static Node * GetFrameStateInput(Node *node)
static Node * GetValueInput(Node *node, int index)
static Node * GetControlInput(Node *node, int index=0)
NumberOperationParameters(NumberOperationHint hint, const FeedbackSource &feedback)
virtual void PrintParameter(std::ostream &os, PrintVerbosity verbose) const
Definition operator.h:196
const Operator * SpeculativeSmallIntegerSubtract(NumberOperationHint hint)
const Operator * SpeculativeAdditiveSafeIntegerAdd(NumberOperationHint hint)
const Operator * LoadFromObject(ObjectAccess const &)
const Operator * LoadImmutableFromObject(ObjectAccess const &)
const Operator * CheckedInt64ToInt32(const FeedbackSource &feedback)
const Operator * CheckedUint32ToInt32(const FeedbackSource &feedback)
const Operator * CheckedTaggedToTaggedPointer(const FeedbackSource &feedback)
const Operator * SpeculativeNumberLessThanOrEqual(NumberOperationHint hint)
const Operator * CheckSmi(const FeedbackSource &feedback)
const Operator * SpeculativeBigIntLessThanOrEqual(BigIntOperationHint hint)
const Operator * CheckBigInt(const FeedbackSource &feedback)
const Operator * SpeculativeBigIntLessThan(BigIntOperationHint hint)
const Operator * StoreToObject(ObjectAccess const &)
const Operator * SpeculativeBigIntModulus(BigIntOperationHint hint)
const Operator * CheckString(const FeedbackSource &feedback)
const Operator * SpeculativeNumberLessThan(NumberOperationHint hint)
const Operator * SpeculativeBigIntBitwiseXor(BigIntOperationHint hint)
const Operator * CheckedInt32ToTaggedSigned(const FeedbackSource &feedback)
const Operator * LoadTypedElement(ExternalArrayType const &)
const Operator * SpeculativeNumberSubtract(NumberOperationHint hint)
const Operator * CheckedUint64ToTaggedSigned(const FeedbackSource &feedback)
const Operator * CheckedUint32Bounds(const FeedbackSource &feedback, CheckBoundsFlags flags)
const Operator * SpeculativeBigIntAdd(BigIntOperationHint hint)
const Operator * LoadDataViewElement(ExternalArrayType const &)
const Operator * CheckedUint64ToInt32(const FeedbackSource &feedback)
const Operator * SpeculativeBigIntSubtract(BigIntOperationHint hint)
const Operator * SpeculativeBigIntEqual(BigIntOperationHint hint)
const Operator * SpeculativeBigIntBitwiseOr(BigIntOperationHint hint)
const Operator * CheckedTaggedToArrayIndex(const FeedbackSource &feedback)
const Operator * SpeculativeNumberAdd(NumberOperationHint hint)
const Operator * SpeculativeAdditiveSafeIntegerSubtract(NumberOperationHint hint)
const Operator * SpeculativeNumberModulus(NumberOperationHint hint)
const Operator * CheckedUint32ToTaggedSigned(const FeedbackSource &feedback)
const Operator * CheckedInt64ToTaggedSigned(const FeedbackSource &feedback)
const Operator * SpeculativeBigIntShiftRight(BigIntOperationHint hint)
const Operator * SpeculativeNumberBitwiseAnd(NumberOperationHint hint)
const Operator * SpeculativeNumberShiftLeft(NumberOperationHint hint)
const Operator * SpeculativeNumberShiftRightLogical(NumberOperationHint hint)
const Operator * SpeculativeNumberMultiply(NumberOperationHint hint)
const Operator * SpeculativeNumberShiftRight(NumberOperationHint hint)
const Operator * LoadElement(ElementAccess const &)
const Operator * CheckNumberFitsInt32(const FeedbackSource &feedback)
SimplifiedOperatorBuilder(const SimplifiedOperatorBuilder &)=delete
const Operator * StoreTypedElement(ExternalArrayType const &)
const Operator * CheckedBigIntToBigInt64(const FeedbackSource &feedback)
const Operator * SpeculativeSmallIntegerAdd(NumberOperationHint hint)
const Operator * SpeculativeBigIntBitwiseAnd(BigIntOperationHint hint)
const Operator * CheckNumber(const FeedbackSource &feedback)
const Operator * SpeculativeNumberBitwiseXor(NumberOperationHint hint)
const Operator * StoreDataViewElement(ExternalArrayType const &)
const Operator * StoreElement(ElementAccess const &)
const Operator * InitializeImmutableInObject(ObjectAccess const &)
const Operator * SpeculativeNumberDivide(NumberOperationHint hint)
const Operator * SpeculativeBigIntDivide(BigIntOperationHint hint)
const Operator * SpeculativeNumberBitwiseOr(NumberOperationHint hint)
const Operator * SpeculativeBigIntMultiply(BigIntOperationHint hint)
const Operator * SpeculativeNumberPow(NumberOperationHint hint)
const Operator * CheckStringOrStringWrapper(const FeedbackSource &feedback)
const Operator * CheckedUint64Bounds(const FeedbackSource &feedback, CheckBoundsFlags flags)
const Operator * SpeculativeBigIntShiftLeft(BigIntOperationHint hint)
const Operator * CheckedTaggedSignedToInt32(const FeedbackSource &feedback)
const Operator * CheckedTaggedToTaggedSigned(const FeedbackSource &feedback)
const Operator * LoadField(FieldAccess const &)
const Operator * CheckedUint64ToInt64(const FeedbackSource &feedback)
SimplifiedOperatorBuilder & operator=(const SimplifiedOperatorBuilder &)=delete
SpeculativeBigIntAsNParameters(int bits, const FeedbackSource &feedback)
Zone * zone_
#define DEFINE_INPUT_ACCESSORS(Name, name, TheIndex, Type)
JSRegExp::Flags flags_
uint32_t count
#define INPUTS(V)
NumberOperationParameters const & NumberOperationParametersOf(Operator const *op)
FastApiCallParameters const & FastApiCallParametersOf(const Operator *op)
const GrowFastElementsParameters & GrowFastElementsParametersOf(const Operator *op)
CheckParameters const & CheckParametersOf(Operator const *op)
const CheckTaggedInputParameters & CheckTaggedInputParametersOf(const Operator *op)
const NewArgumentsElementsParameters & NewArgumentsElementsParametersOf(const Operator *op)
CheckMapsParameters const & CheckMapsParametersOf(Operator const *op)
CheckFloat64HoleParameters const & CheckFloat64HoleParametersOf(Operator const *op)
CheckIfParameters const & CheckIfParametersOf(Operator const *op)
const CheckMinusZeroParameters & CheckMinusZeroParametersOf(const Operator *op)
int FormalParameterCountOf(const Operator *op)
ZoneRefSet< Map > const & MapGuardMapsOf(Operator const *op)
NumberOperationHint NumberOperationHintOf(const Operator *op)
const FieldAccess & FieldAccessOf(const Operator *op)
const ElementAccess & ElementAccessOf(const Operator *op)
const AllocateParameters & AllocateParametersOf(const Operator *op)
ZoneRefSet< Map > const & CompareMapsParametersOf(Operator const *op)
CheckBoundsParameters const & CheckBoundsParametersOf(Operator const *op)
const ObjectAccess & ObjectAccessOf(const Operator *op)
Type AllocateTypeOf(const Operator *op)
MapRef FastMapParameterOf(const Operator *op)
Handle< FeedbackCell > FeedbackCellOf(const Operator *op)
Type ValueTypeParameterOf(const Operator *op)
size_t hash_value(const BranchParameters &p)
ExternalArrayType ExternalArrayTypeOf(const Operator *op)
DeoptimizeReason DeoptimizeReasonOf(const Operator *op) V8_WARN_UNUSED_RESULT
UnicodeEncoding UnicodeEncodingOf(const Operator *) V8_WARN_UNUSED_RESULT
ConvertReceiverMode ConvertReceiverModeOf(Operator const *op)
AllocationType AllocationTypeOf(const Operator *op)
bool operator!=(DeoptimizeParameters lhs, DeoptimizeParameters rhs)
bool operator==(const BranchParameters &lhs, const BranchParameters &rhs)
CheckForMinusZeroMode CheckMinusZeroModeOf(const Operator *op)
ElementsTransitionWithMultipleSources const & ElementsTransitionWithMultipleSourcesOf(const Operator *op)
std::ostream & operator<<(std::ostream &os, AccessMode access_mode)
BigIntOperationParameters const & BigIntOperationParametersOf(Operator const *op)
ElementsTransition const & ElementsTransitionOf(const Operator *op)
AbortReason AbortReasonOf(const Operator *op)
SpeculativeBigIntAsNParameters const & SpeculativeBigIntAsNParametersOf(Operator const *op)
bool IsCheckedWithFeedback(const Operator *op)
BigIntOperationHint BigIntOperationHintOf(const Operator *op)
MapRef DoubleMapParameterOf(const Operator *op)
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage report a tick only when allocated zone memory changes by this amount TracingFlags::gc_stats TracingFlags::gc_stats track native contexts that are expected to be garbage collected verify heap pointers before and after GC memory reducer runs GC with ReduceMemoryFootprint flag Maximum number of memory reducer GCs scheduled Old gen GC speed is computed directly from gc tracer counters Perform compaction on full GCs based on V8 s default heuristics Perform compaction on every full GC Perform code space compaction when finalizing a full GC with stack Stress GC compaction to flush out bugs with moving objects flush of baseline code when it has not been executed recently Use time base code flushing instead of age Use a progress bar to scan large objects in increments when incremental marking is active force incremental marking for small heaps and run it more often force marking at random points between and force scavenge at random points between and reclaim otherwise unreachable unmodified wrapper objects when possible less compaction in non memory reducing mode use high priority threads for concurrent Marking Test mode only flag It allows an unit test to select evacuation candidates use incremental marking for CppHeap cppheap_concurrent_marking c value for membalancer A special constant to balance between memory and space tradeoff The smaller the more memory it uses enable use of SSE4 instructions if available enable use of AVX VNNI instructions if available enable use of POPCNT instruction if available force all emitted branches to be in long mode(MIPS/PPC only)") DEFINE_BOOL(partial_constant_pool
const int kHeapObjectTag
Definition v8-internal.h:72
@ kExternalPointerNullTag
kInstanceDescriptorsOffset kTransitionsOrPrototypeInfoOffset IsNull(value)||IsJSProxy(value)||IsWasmObject(value)||(IsJSObject(value) &&(HeapLayout
Definition map-inl.h:70
bool is_signed(Condition cond)
#define NON_EXPORTED_BASE(code)
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define DCHECK_IMPLIES(v1, v2)
Definition logging.h:493
#define DCHECK_GE(v1, v2)
Definition logging.h:488
#define DCHECK_LT(v1, v2)
Definition logging.h:489
#define DCHECK_EQ(v1, v2)
Definition logging.h:485
#define V8_EXPORT_PRIVATE
Definition macros.h:460
ElementAccess(BaseTaggedness base_is_tagged, int header_size, Type type, MachineType machine_type, WriteBarrierKind write_barrier_kind)
bool operator==(const FastApiCallFunction &rhs) const
FieldAccess(BaseTaggedness base_is_tagged, int offset, MaybeHandle< Name > name, OptionalMapRef map, Type type, MachineType machine_type, WriteBarrierKind write_barrier_kind, const char *creator_mnemonic=nullptr, ConstFieldInfo const_field_info=ConstFieldInfo::None(), bool is_store_in_literal=false, ExternalPointerTag external_pointer_tag=kExternalPointerNullTag, bool maybe_initializing_or_transitioning_store=false, bool is_immutable=false, IndirectPointerTag indirect_pointer_tag=kIndirectPointerNullTag)
ObjectAccess(MachineType machine_type, WriteBarrierKind write_barrier_kind)
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671
wasm::ValueType type