Line data Source code
1 : // Copyright 2013 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_JS_OPERATOR_H_
6 : #define V8_COMPILER_JS_OPERATOR_H_
7 :
8 : #include "src/base/compiler-specific.h"
9 : #include "src/globals.h"
10 : #include "src/maybe-handles.h"
11 : #include "src/runtime/runtime.h"
12 : #include "src/type-hints.h"
13 : #include "src/vector-slot-pair.h"
14 :
15 : namespace v8 {
16 : namespace internal {
17 :
18 : class AllocationSite;
19 : class ObjectBoilerplateDescription;
20 : class ArrayBoilerplateDescription;
21 : class FeedbackCell;
22 : class SharedFunctionInfo;
23 :
24 : namespace compiler {
25 :
26 : // Forward declarations.
27 : class Operator;
28 : struct JSOperatorGlobalCache;
29 :
30 : // Defines the frequency a given Call/Construct site was executed. For some
31 : // call sites the frequency is not known.
32 : class CallFrequency final {
33 : public:
34 602424 : CallFrequency() : value_(std::numeric_limits<float>::quiet_NaN()) {}
35 653942 : explicit CallFrequency(float value) : value_(value) {
36 : DCHECK(!std::isnan(value));
37 : }
38 :
39 : bool IsKnown() const { return !IsUnknown(); }
40 983907 : bool IsUnknown() const { return std::isnan(value_); }
41 : float value() const {
42 : DCHECK(IsKnown());
43 160760 : return value_;
44 : }
45 :
46 : bool operator==(CallFrequency const& that) const {
47 0 : return bit_cast<uint32_t>(this->value_) == bit_cast<uint32_t>(that.value_);
48 : }
49 : bool operator!=(CallFrequency const& that) const { return !(*this == that); }
50 :
51 : friend size_t hash_value(CallFrequency f) {
52 0 : return bit_cast<uint32_t>(f.value_);
53 : }
54 :
55 : static constexpr float kNoFeedbackCallFrequency = -1;
56 :
57 : private:
58 : float value_;
59 : };
60 :
61 : std::ostream& operator<<(std::ostream&, CallFrequency);
62 :
63 : CallFrequency CallFrequencyOf(Operator const* op) V8_WARN_UNUSED_RESULT;
64 :
65 : // Defines the flags for a JavaScript call forwarding parameters. This
66 : // is used as parameter by JSConstructForwardVarargs operators.
67 : class ConstructForwardVarargsParameters final {
68 : public:
69 : ConstructForwardVarargsParameters(size_t arity, uint32_t start_index)
70 461 : : bit_field_(ArityField::encode(arity) |
71 : StartIndexField::encode(start_index)) {}
72 :
73 : size_t arity() const { return ArityField::decode(bit_field_); }
74 0 : uint32_t start_index() const { return StartIndexField::decode(bit_field_); }
75 :
76 : bool operator==(ConstructForwardVarargsParameters const& that) const {
77 0 : return this->bit_field_ == that.bit_field_;
78 : }
79 : bool operator!=(ConstructForwardVarargsParameters const& that) const {
80 : return !(*this == that);
81 : }
82 :
83 : private:
84 : friend size_t hash_value(ConstructForwardVarargsParameters const& p) {
85 0 : return p.bit_field_;
86 : }
87 :
88 : typedef BitField<size_t, 0, 16> ArityField;
89 : typedef BitField<uint32_t, 16, 16> StartIndexField;
90 :
91 : uint32_t const bit_field_;
92 : };
93 :
94 : std::ostream& operator<<(std::ostream&,
95 : ConstructForwardVarargsParameters const&);
96 :
97 : ConstructForwardVarargsParameters const& ConstructForwardVarargsParametersOf(
98 : Operator const*) V8_WARN_UNUSED_RESULT;
99 :
100 : // Defines the arity and the feedback for a JavaScript constructor call. This is
101 : // used as a parameter by JSConstruct and JSConstructWithSpread operators.
102 : class ConstructParameters final {
103 : public:
104 : ConstructParameters(uint32_t arity, CallFrequency frequency,
105 : VectorSlotPair const& feedback)
106 41873 : : arity_(arity), frequency_(frequency), feedback_(feedback) {}
107 :
108 : uint32_t arity() const { return arity_; }
109 : CallFrequency frequency() const { return frequency_; }
110 0 : VectorSlotPair const& feedback() const { return feedback_; }
111 :
112 : private:
113 : uint32_t const arity_;
114 : CallFrequency const frequency_;
115 : VectorSlotPair const feedback_;
116 : };
117 :
118 : bool operator==(ConstructParameters const&, ConstructParameters const&);
119 : bool operator!=(ConstructParameters const&, ConstructParameters const&);
120 :
121 : size_t hash_value(ConstructParameters const&);
122 :
123 : std::ostream& operator<<(std::ostream&, ConstructParameters const&);
124 :
125 : ConstructParameters const& ConstructParametersOf(Operator const*);
126 :
127 : // Defines the flags for a JavaScript call forwarding parameters. This
128 : // is used as parameter by JSCallForwardVarargs operators.
129 : class CallForwardVarargsParameters final {
130 : public:
131 : CallForwardVarargsParameters(size_t arity, uint32_t start_index)
132 370 : : bit_field_(ArityField::encode(arity) |
133 : StartIndexField::encode(start_index)) {}
134 :
135 : size_t arity() const { return ArityField::decode(bit_field_); }
136 0 : uint32_t start_index() const { return StartIndexField::decode(bit_field_); }
137 :
138 : bool operator==(CallForwardVarargsParameters const& that) const {
139 0 : return this->bit_field_ == that.bit_field_;
140 : }
141 : bool operator!=(CallForwardVarargsParameters const& that) const {
142 : return !(*this == that);
143 : }
144 :
145 : private:
146 : friend size_t hash_value(CallForwardVarargsParameters const& p) {
147 0 : return p.bit_field_;
148 : }
149 :
150 : typedef BitField<size_t, 0, 15> ArityField;
151 : typedef BitField<uint32_t, 15, 15> StartIndexField;
152 :
153 : uint32_t const bit_field_;
154 : };
155 :
156 : std::ostream& operator<<(std::ostream&, CallForwardVarargsParameters const&);
157 :
158 : CallForwardVarargsParameters const& CallForwardVarargsParametersOf(
159 : Operator const*) V8_WARN_UNUSED_RESULT;
160 :
161 : // Defines the arity and the call flags for a JavaScript function call. This is
162 : // used as a parameter by JSCall and JSCallWithSpread operators.
163 : class CallParameters final {
164 : public:
165 : CallParameters(size_t arity, CallFrequency const& frequency,
166 : VectorSlotPair const& feedback,
167 : ConvertReceiverMode convert_mode,
168 : SpeculationMode speculation_mode)
169 801055 : : bit_field_(ArityField::encode(arity) |
170 801055 : SpeculationModeField::encode(speculation_mode) |
171 : ConvertReceiverModeField::encode(convert_mode)),
172 : frequency_(frequency),
173 801055 : feedback_(feedback) {}
174 :
175 : size_t arity() const { return ArityField::decode(bit_field_); }
176 141609 : CallFrequency const& frequency() const { return frequency_; }
177 : ConvertReceiverMode convert_mode() const {
178 : return ConvertReceiverModeField::decode(bit_field_);
179 : }
180 204227 : VectorSlotPair const& feedback() const { return feedback_; }
181 :
182 : SpeculationMode speculation_mode() const {
183 : return SpeculationModeField::decode(bit_field_);
184 : }
185 :
186 0 : bool operator==(CallParameters const& that) const {
187 0 : return this->bit_field_ == that.bit_field_ &&
188 0 : this->frequency_ == that.frequency_ &&
189 0 : this->feedback_ == that.feedback_;
190 : }
191 : bool operator!=(CallParameters const& that) const { return !(*this == that); }
192 :
193 : private:
194 0 : friend size_t hash_value(CallParameters const& p) {
195 0 : return base::hash_combine(p.bit_field_, p.frequency_, p.feedback_);
196 : }
197 :
198 : typedef BitField<size_t, 0, 28> ArityField;
199 : typedef BitField<SpeculationMode, 28, 1> SpeculationModeField;
200 : typedef BitField<ConvertReceiverMode, 29, 2> ConvertReceiverModeField;
201 :
202 : uint32_t const bit_field_;
203 : CallFrequency const frequency_;
204 : VectorSlotPair const feedback_;
205 : };
206 :
207 : size_t hash_value(CallParameters const&);
208 :
209 : std::ostream& operator<<(std::ostream&, CallParameters const&);
210 :
211 : const CallParameters& CallParametersOf(const Operator* op);
212 :
213 :
214 : // Defines the arity and the ID for a runtime function call. This is used as a
215 : // parameter by JSCallRuntime operators.
216 : class CallRuntimeParameters final {
217 : public:
218 : CallRuntimeParameters(Runtime::FunctionId id, size_t arity)
219 : : id_(id), arity_(arity) {}
220 :
221 : Runtime::FunctionId id() const { return id_; }
222 : size_t arity() const { return arity_; }
223 :
224 : private:
225 : const Runtime::FunctionId id_;
226 : const size_t arity_;
227 : };
228 :
229 : bool operator==(CallRuntimeParameters const&, CallRuntimeParameters const&);
230 : bool operator!=(CallRuntimeParameters const&, CallRuntimeParameters const&);
231 :
232 : size_t hash_value(CallRuntimeParameters const&);
233 :
234 : std::ostream& operator<<(std::ostream&, CallRuntimeParameters const&);
235 :
236 : const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op);
237 :
238 :
239 : // Defines the location of a context slot relative to a specific scope. This is
240 : // used as a parameter by JSLoadContext and JSStoreContext operators and allows
241 : // accessing a context-allocated variable without keeping track of the scope.
242 : class ContextAccess final {
243 : public:
244 : ContextAccess(size_t depth, size_t index, bool immutable);
245 :
246 2456187 : size_t depth() const { return depth_; }
247 1717948 : size_t index() const { return index_; }
248 : bool immutable() const { return immutable_; }
249 :
250 : private:
251 : // For space reasons, we keep this tightly packed, otherwise we could just use
252 : // a simple int/int/bool POD.
253 : const bool immutable_;
254 : const uint16_t depth_;
255 : const uint32_t index_;
256 : };
257 :
258 : bool operator==(ContextAccess const&, ContextAccess const&);
259 : bool operator!=(ContextAccess const&, ContextAccess const&);
260 :
261 : size_t hash_value(ContextAccess const&);
262 :
263 : V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, ContextAccess const&);
264 :
265 : V8_EXPORT_PRIVATE ContextAccess const& ContextAccessOf(Operator const*);
266 :
267 : // Defines the slot count and ScopeType for a new function or eval context. This
268 : // is used as a parameter by the JSCreateFunctionContext operator.
269 : class CreateFunctionContextParameters final {
270 : public:
271 : CreateFunctionContextParameters(Handle<ScopeInfo> scope_info, int slot_count,
272 : ScopeType scope_type);
273 :
274 : Handle<ScopeInfo> scope_info() const { return scope_info_; }
275 : int slot_count() const { return slot_count_; }
276 : ScopeType scope_type() const { return scope_type_; }
277 :
278 : private:
279 : Handle<ScopeInfo> scope_info_;
280 : int const slot_count_;
281 : ScopeType const scope_type_;
282 : };
283 :
284 : bool operator==(CreateFunctionContextParameters const& lhs,
285 : CreateFunctionContextParameters const& rhs);
286 : bool operator!=(CreateFunctionContextParameters const& lhs,
287 : CreateFunctionContextParameters const& rhs);
288 :
289 : size_t hash_value(CreateFunctionContextParameters const& parameters);
290 :
291 : std::ostream& operator<<(std::ostream& os,
292 : CreateFunctionContextParameters const& parameters);
293 :
294 : CreateFunctionContextParameters const& CreateFunctionContextParametersOf(
295 : Operator const*);
296 :
297 : // Defines parameters for JSStoreNamedOwn operator.
298 : class StoreNamedOwnParameters final {
299 : public:
300 : StoreNamedOwnParameters(Handle<Name> name, VectorSlotPair const& feedback)
301 31932 : : name_(name), feedback_(feedback) {}
302 :
303 : Handle<Name> name() const { return name_; }
304 30253 : VectorSlotPair const& feedback() const { return feedback_; }
305 :
306 : private:
307 : Handle<Name> const name_;
308 : VectorSlotPair const feedback_;
309 : };
310 :
311 : bool operator==(StoreNamedOwnParameters const&, StoreNamedOwnParameters const&);
312 : bool operator!=(StoreNamedOwnParameters const&, StoreNamedOwnParameters const&);
313 :
314 : size_t hash_value(StoreNamedOwnParameters const&);
315 :
316 : std::ostream& operator<<(std::ostream&, StoreNamedOwnParameters const&);
317 :
318 : const StoreNamedOwnParameters& StoreNamedOwnParametersOf(const Operator* op);
319 :
320 : // Defines the feedback, i.e., vector and index, for storing a data property in
321 : // an object literal. This is used as a parameter by JSCreateEmptyLiteralArray
322 : // and JSStoreDataPropertyInLiteral operators.
323 : class FeedbackParameter final {
324 : public:
325 : explicit FeedbackParameter(VectorSlotPair const& feedback)
326 76321 : : feedback_(feedback) {}
327 :
328 68767 : VectorSlotPair const& feedback() const { return feedback_; }
329 :
330 : private:
331 : VectorSlotPair const feedback_;
332 : };
333 :
334 : bool operator==(FeedbackParameter const&, FeedbackParameter const&);
335 : bool operator!=(FeedbackParameter const&, FeedbackParameter const&);
336 :
337 : size_t hash_value(FeedbackParameter const&);
338 :
339 : std::ostream& operator<<(std::ostream&, FeedbackParameter const&);
340 :
341 : const FeedbackParameter& FeedbackParameterOf(const Operator* op);
342 :
343 : // Defines the property of an object for a named access. This is
344 : // used as a parameter by the JSLoadNamed and JSStoreNamed operators.
345 : class NamedAccess final {
346 : public:
347 : NamedAccess(LanguageMode language_mode, Handle<Name> name,
348 : VectorSlotPair const& feedback)
349 633065 : : name_(name), feedback_(feedback), language_mode_(language_mode) {}
350 :
351 : Handle<Name> name() const { return name_; }
352 : LanguageMode language_mode() const { return language_mode_; }
353 317609 : VectorSlotPair const& feedback() const { return feedback_; }
354 :
355 : private:
356 : Handle<Name> const name_;
357 : VectorSlotPair const feedback_;
358 : LanguageMode const language_mode_;
359 : };
360 :
361 : bool operator==(NamedAccess const&, NamedAccess const&);
362 : bool operator!=(NamedAccess const&, NamedAccess const&);
363 :
364 : size_t hash_value(NamedAccess const&);
365 :
366 : std::ostream& operator<<(std::ostream&, NamedAccess const&);
367 :
368 : const NamedAccess& NamedAccessOf(const Operator* op);
369 :
370 :
371 : // Defines the property being loaded from an object by a named load. This is
372 : // used as a parameter by JSLoadGlobal operator.
373 : class LoadGlobalParameters final {
374 : public:
375 : LoadGlobalParameters(const Handle<Name>& name, const VectorSlotPair& feedback,
376 : TypeofMode typeof_mode)
377 1002106 : : name_(name), feedback_(feedback), typeof_mode_(typeof_mode) {}
378 :
379 176479 : const Handle<Name>& name() const { return name_; }
380 : TypeofMode typeof_mode() const { return typeof_mode_; }
381 :
382 1833094 : const VectorSlotPair& feedback() const { return feedback_; }
383 :
384 : private:
385 : const Handle<Name> name_;
386 : const VectorSlotPair feedback_;
387 : const TypeofMode typeof_mode_;
388 : };
389 :
390 : bool operator==(LoadGlobalParameters const&, LoadGlobalParameters const&);
391 : bool operator!=(LoadGlobalParameters const&, LoadGlobalParameters const&);
392 :
393 : size_t hash_value(LoadGlobalParameters const&);
394 :
395 : std::ostream& operator<<(std::ostream&, LoadGlobalParameters const&);
396 :
397 : const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op);
398 :
399 :
400 : // Defines the property being stored to an object by a named store. This is
401 : // used as a parameter by JSStoreGlobal operator.
402 : class StoreGlobalParameters final {
403 : public:
404 : StoreGlobalParameters(LanguageMode language_mode,
405 : const VectorSlotPair& feedback,
406 : const Handle<Name>& name)
407 219047 : : language_mode_(language_mode), name_(name), feedback_(feedback) {}
408 :
409 : LanguageMode language_mode() const { return language_mode_; }
410 425219 : const VectorSlotPair& feedback() const { return feedback_; }
411 16257 : const Handle<Name>& name() const { return name_; }
412 :
413 : private:
414 : const LanguageMode language_mode_;
415 : const Handle<Name> name_;
416 : const VectorSlotPair feedback_;
417 : };
418 :
419 : bool operator==(StoreGlobalParameters const&, StoreGlobalParameters const&);
420 : bool operator!=(StoreGlobalParameters const&, StoreGlobalParameters const&);
421 :
422 : size_t hash_value(StoreGlobalParameters const&);
423 :
424 : std::ostream& operator<<(std::ostream&, StoreGlobalParameters const&);
425 :
426 : const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op);
427 :
428 :
429 : // Defines the property of an object for a keyed access. This is used
430 : // as a parameter by the JSLoadProperty and JSStoreProperty operators.
431 : class PropertyAccess final {
432 : public:
433 : PropertyAccess(LanguageMode language_mode, VectorSlotPair const& feedback)
434 56854 : : feedback_(feedback), language_mode_(language_mode) {}
435 :
436 : LanguageMode language_mode() const { return language_mode_; }
437 47630 : VectorSlotPair const& feedback() const { return feedback_; }
438 :
439 : private:
440 : VectorSlotPair const feedback_;
441 : LanguageMode const language_mode_;
442 : };
443 :
444 : bool operator==(PropertyAccess const&, PropertyAccess const&);
445 : bool operator!=(PropertyAccess const&, PropertyAccess const&);
446 :
447 : size_t hash_value(PropertyAccess const&);
448 :
449 : std::ostream& operator<<(std::ostream&, PropertyAccess const&);
450 :
451 : PropertyAccess const& PropertyAccessOf(const Operator* op);
452 :
453 :
454 : // CreateArgumentsType is used as parameter to JSCreateArguments nodes.
455 : CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op);
456 :
457 :
458 : // Defines shared information for the array that should be created. This is
459 : // used as parameter by JSCreateArray operators.
460 : class CreateArrayParameters final {
461 : public:
462 : explicit CreateArrayParameters(size_t arity, MaybeHandle<AllocationSite> site)
463 : : arity_(arity), site_(site) {}
464 :
465 : size_t arity() const { return arity_; }
466 : MaybeHandle<AllocationSite> site() const { return site_; }
467 :
468 : private:
469 : size_t const arity_;
470 : MaybeHandle<AllocationSite> const site_;
471 : };
472 :
473 : bool operator==(CreateArrayParameters const&, CreateArrayParameters const&);
474 : bool operator!=(CreateArrayParameters const&, CreateArrayParameters const&);
475 :
476 : size_t hash_value(CreateArrayParameters const&);
477 :
478 : std::ostream& operator<<(std::ostream&, CreateArrayParameters const&);
479 :
480 : const CreateArrayParameters& CreateArrayParametersOf(const Operator* op);
481 :
482 : // Defines shared information for the array iterator that should be created.
483 : // This is used as parameter by JSCreateArrayIterator operators.
484 : class CreateArrayIteratorParameters final {
485 : public:
486 : explicit CreateArrayIteratorParameters(IterationKind kind) : kind_(kind) {}
487 :
488 1746 : IterationKind kind() const { return kind_; }
489 :
490 : private:
491 : IterationKind const kind_;
492 : };
493 :
494 : bool operator==(CreateArrayIteratorParameters const&,
495 : CreateArrayIteratorParameters const&);
496 : bool operator!=(CreateArrayIteratorParameters const&,
497 : CreateArrayIteratorParameters const&);
498 :
499 : size_t hash_value(CreateArrayIteratorParameters const&);
500 :
501 : std::ostream& operator<<(std::ostream&, CreateArrayIteratorParameters const&);
502 :
503 : const CreateArrayIteratorParameters& CreateArrayIteratorParametersOf(
504 : const Operator* op);
505 :
506 : // Defines shared information for the array iterator that should be created.
507 : // This is used as parameter by JSCreateCollectionIterator operators.
508 : class CreateCollectionIteratorParameters final {
509 : public:
510 : explicit CreateCollectionIteratorParameters(CollectionKind collection_kind,
511 : IterationKind iteration_kind)
512 : : collection_kind_(collection_kind), iteration_kind_(iteration_kind) {
513 163 : CHECK(!(collection_kind == CollectionKind::kSet &&
514 : iteration_kind == IterationKind::kKeys));
515 : }
516 :
517 : CollectionKind collection_kind() const { return collection_kind_; }
518 : IterationKind iteration_kind() const { return iteration_kind_; }
519 :
520 : private:
521 : CollectionKind const collection_kind_;
522 : IterationKind const iteration_kind_;
523 : };
524 :
525 : bool operator==(CreateCollectionIteratorParameters const&,
526 : CreateCollectionIteratorParameters const&);
527 : bool operator!=(CreateCollectionIteratorParameters const&,
528 : CreateCollectionIteratorParameters const&);
529 :
530 : size_t hash_value(CreateCollectionIteratorParameters const&);
531 :
532 : std::ostream& operator<<(std::ostream&,
533 : CreateCollectionIteratorParameters const&);
534 :
535 : const CreateCollectionIteratorParameters& CreateCollectionIteratorParametersOf(
536 : const Operator* op);
537 :
538 : // Defines shared information for the bound function that should be created.
539 : // This is used as parameter by JSCreateBoundFunction operators.
540 : class CreateBoundFunctionParameters final {
541 : public:
542 : CreateBoundFunctionParameters(size_t arity, Handle<Map> map)
543 : : arity_(arity), map_(map) {}
544 :
545 : size_t arity() const { return arity_; }
546 : Handle<Map> map() const { return map_; }
547 :
548 : private:
549 : size_t const arity_;
550 : Handle<Map> const map_;
551 : };
552 :
553 : bool operator==(CreateBoundFunctionParameters const&,
554 : CreateBoundFunctionParameters const&);
555 : bool operator!=(CreateBoundFunctionParameters const&,
556 : CreateBoundFunctionParameters const&);
557 :
558 : size_t hash_value(CreateBoundFunctionParameters const&);
559 :
560 : std::ostream& operator<<(std::ostream&, CreateBoundFunctionParameters const&);
561 :
562 : const CreateBoundFunctionParameters& CreateBoundFunctionParametersOf(
563 : const Operator* op);
564 :
565 : // Defines shared information for the closure that should be created. This is
566 : // used as a parameter by JSCreateClosure operators.
567 : class CreateClosureParameters final {
568 : public:
569 : CreateClosureParameters(Handle<SharedFunctionInfo> shared_info,
570 : Handle<FeedbackCell> feedback_cell, Handle<Code> code,
571 : AllocationType allocation)
572 : : shared_info_(shared_info),
573 : feedback_cell_(feedback_cell),
574 : code_(code),
575 : allocation_(allocation) {}
576 :
577 : Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
578 : Handle<FeedbackCell> feedback_cell() const { return feedback_cell_; }
579 : Handle<Code> code() const { return code_; }
580 : AllocationType allocation() const { return allocation_; }
581 :
582 : private:
583 : Handle<SharedFunctionInfo> const shared_info_;
584 : Handle<FeedbackCell> const feedback_cell_;
585 : Handle<Code> const code_;
586 : AllocationType const allocation_;
587 : };
588 :
589 : bool operator==(CreateClosureParameters const&, CreateClosureParameters const&);
590 : bool operator!=(CreateClosureParameters const&, CreateClosureParameters const&);
591 :
592 : size_t hash_value(CreateClosureParameters const&);
593 :
594 : std::ostream& operator<<(std::ostream&, CreateClosureParameters const&);
595 :
596 : const CreateClosureParameters& CreateClosureParametersOf(const Operator* op);
597 :
598 : // Defines shared information for the literal that should be created. This is
599 : // used as parameter by JSCreateLiteralArray, JSCreateLiteralObject and
600 : // JSCreateLiteralRegExp operators.
601 : class CreateLiteralParameters final {
602 : public:
603 : CreateLiteralParameters(Handle<HeapObject> constant,
604 : VectorSlotPair const& feedback, int length, int flags)
605 : : constant_(constant),
606 : feedback_(feedback),
607 : length_(length),
608 30285 : flags_(flags) {}
609 :
610 : Handle<HeapObject> constant() const { return constant_; }
611 24322 : VectorSlotPair const& feedback() const { return feedback_; }
612 : int length() const { return length_; }
613 : int flags() const { return flags_; }
614 :
615 : private:
616 : Handle<HeapObject> const constant_;
617 : VectorSlotPair const feedback_;
618 : int const length_;
619 : int const flags_;
620 : };
621 :
622 : bool operator==(CreateLiteralParameters const&, CreateLiteralParameters const&);
623 : bool operator!=(CreateLiteralParameters const&, CreateLiteralParameters const&);
624 :
625 : size_t hash_value(CreateLiteralParameters const&);
626 :
627 : std::ostream& operator<<(std::ostream&, CreateLiteralParameters const&);
628 :
629 : const CreateLiteralParameters& CreateLiteralParametersOf(const Operator* op);
630 :
631 : class CloneObjectParameters final {
632 : public:
633 : CloneObjectParameters(VectorSlotPair const& feedback, int flags)
634 77 : : feedback_(feedback), flags_(flags) {}
635 :
636 93 : VectorSlotPair const& feedback() const { return feedback_; }
637 : int flags() const { return flags_; }
638 :
639 : private:
640 : VectorSlotPair const feedback_;
641 : int const flags_;
642 : };
643 :
644 : bool operator==(CloneObjectParameters const&, CloneObjectParameters const&);
645 : bool operator!=(CloneObjectParameters const&, CloneObjectParameters const&);
646 :
647 : size_t hash_value(CloneObjectParameters const&);
648 :
649 : std::ostream& operator<<(std::ostream&, CloneObjectParameters const&);
650 :
651 : const CloneObjectParameters& CloneObjectParametersOf(const Operator* op);
652 :
653 : // Descriptor used by the JSForInPrepare and JSForInNext opcodes.
654 : enum class ForInMode : uint8_t {
655 : kUseEnumCacheKeysAndIndices,
656 : kUseEnumCacheKeys,
657 : kGeneric
658 : };
659 :
660 : size_t hash_value(ForInMode);
661 :
662 : std::ostream& operator<<(std::ostream&, ForInMode);
663 :
664 : ForInMode ForInModeOf(Operator const* op) V8_WARN_UNUSED_RESULT;
665 :
666 : BinaryOperationHint BinaryOperationHintOf(const Operator* op);
667 :
668 : CompareOperationHint CompareOperationHintOf(const Operator* op);
669 :
670 : int RegisterCountOf(Operator const* op) V8_WARN_UNUSED_RESULT;
671 :
672 : int GeneratorStoreValueCountOf(const Operator* op) V8_WARN_UNUSED_RESULT;
673 : int RestoreRegisterIndexOf(const Operator* op) V8_WARN_UNUSED_RESULT;
674 :
675 : Handle<ScopeInfo> ScopeInfoOf(const Operator* op) V8_WARN_UNUSED_RESULT;
676 :
677 : // Interface for building JavaScript-level operators, e.g. directly from the
678 : // AST. Most operators have no parameters, thus can be globally shared for all
679 : // graphs.
680 : class V8_EXPORT_PRIVATE JSOperatorBuilder final
681 : : public NON_EXPORTED_BASE(ZoneObject) {
682 : public:
683 : explicit JSOperatorBuilder(Zone* zone);
684 :
685 : const Operator* Equal(CompareOperationHint hint);
686 : const Operator* StrictEqual(CompareOperationHint hint);
687 : const Operator* LessThan(CompareOperationHint hint);
688 : const Operator* GreaterThan(CompareOperationHint hint);
689 : const Operator* LessThanOrEqual(CompareOperationHint hint);
690 : const Operator* GreaterThanOrEqual(CompareOperationHint hint);
691 :
692 : const Operator* BitwiseOr();
693 : const Operator* BitwiseXor();
694 : const Operator* BitwiseAnd();
695 : const Operator* ShiftLeft();
696 : const Operator* ShiftRight();
697 : const Operator* ShiftRightLogical();
698 : const Operator* Add(BinaryOperationHint hint);
699 : const Operator* Subtract();
700 : const Operator* Multiply();
701 : const Operator* Divide();
702 : const Operator* Modulus();
703 : const Operator* Exponentiate();
704 :
705 : const Operator* BitwiseNot();
706 : const Operator* Decrement();
707 : const Operator* Increment();
708 : const Operator* Negate();
709 :
710 : const Operator* ToLength();
711 : const Operator* ToName();
712 : const Operator* ToNumber();
713 : const Operator* ToNumberConvertBigInt();
714 : const Operator* ToNumeric();
715 : const Operator* ToObject();
716 : const Operator* ToString();
717 :
718 : const Operator* Create();
719 : const Operator* CreateArguments(CreateArgumentsType type);
720 : const Operator* CreateArray(size_t arity, MaybeHandle<AllocationSite> site);
721 : const Operator* CreateArrayIterator(IterationKind);
722 : const Operator* CreateAsyncFunctionObject(int register_count);
723 : const Operator* CreateCollectionIterator(CollectionKind, IterationKind);
724 : const Operator* CreateBoundFunction(size_t arity, Handle<Map> map);
725 : const Operator* CreateClosure(
726 : Handle<SharedFunctionInfo> shared_info,
727 : Handle<FeedbackCell> feedback_cell, Handle<Code> code,
728 : AllocationType allocation = AllocationType::kYoung);
729 : const Operator* CreateIterResultObject();
730 : const Operator* CreateStringIterator();
731 : const Operator* CreateKeyValueArray();
732 : const Operator* CreateObject();
733 : const Operator* CreatePromise();
734 : const Operator* CreateTypedArray();
735 : const Operator* CreateLiteralArray(
736 : Handle<ArrayBoilerplateDescription> constant,
737 : VectorSlotPair const& feedback, int literal_flags,
738 : int number_of_elements);
739 : const Operator* CreateEmptyLiteralArray(VectorSlotPair const& feedback);
740 : const Operator* CreateArrayFromIterable();
741 : const Operator* CreateEmptyLiteralObject();
742 :
743 : const Operator* CreateLiteralObject(
744 : Handle<ObjectBoilerplateDescription> constant,
745 : VectorSlotPair const& feedback, int literal_flags,
746 : int number_of_properties);
747 : const Operator* CloneObject(VectorSlotPair const& feedback,
748 : int literal_flags);
749 : const Operator* CreateLiteralRegExp(Handle<String> constant_pattern,
750 : VectorSlotPair const& feedback,
751 : int literal_flags);
752 :
753 : const Operator* CallForwardVarargs(size_t arity, uint32_t start_index);
754 : const Operator* Call(
755 : size_t arity, CallFrequency const& frequency = CallFrequency(),
756 : VectorSlotPair const& feedback = VectorSlotPair(),
757 : ConvertReceiverMode convert_mode = ConvertReceiverMode::kAny,
758 : SpeculationMode speculation_mode = SpeculationMode::kDisallowSpeculation);
759 : const Operator* CallWithArrayLike(CallFrequency frequency);
760 : const Operator* CallWithSpread(
761 : uint32_t arity, CallFrequency const& frequency = CallFrequency(),
762 : VectorSlotPair const& feedback = VectorSlotPair(),
763 : SpeculationMode speculation_mode = SpeculationMode::kDisallowSpeculation);
764 : const Operator* CallRuntime(Runtime::FunctionId id);
765 : const Operator* CallRuntime(Runtime::FunctionId id, size_t arity);
766 : const Operator* CallRuntime(const Runtime::Function* function, size_t arity);
767 :
768 : const Operator* ConstructForwardVarargs(size_t arity, uint32_t start_index);
769 : const Operator* Construct(uint32_t arity,
770 : CallFrequency frequency = CallFrequency(),
771 : VectorSlotPair const& feedback = VectorSlotPair());
772 : const Operator* ConstructWithArrayLike(CallFrequency frequency);
773 : const Operator* ConstructWithSpread(
774 : uint32_t arity, CallFrequency frequency = CallFrequency(),
775 : VectorSlotPair const& feedback = VectorSlotPair());
776 :
777 : const Operator* LoadProperty(VectorSlotPair const& feedback);
778 : const Operator* LoadNamed(Handle<Name> name, VectorSlotPair const& feedback);
779 :
780 : const Operator* StoreProperty(LanguageMode language_mode,
781 : VectorSlotPair const& feedback);
782 : const Operator* StoreNamed(LanguageMode language_mode, Handle<Name> name,
783 : VectorSlotPair const& feedback);
784 :
785 : const Operator* StoreNamedOwn(Handle<Name> name,
786 : VectorSlotPair const& feedback);
787 : const Operator* StoreDataPropertyInLiteral(const VectorSlotPair& feedback);
788 : const Operator* StoreInArrayLiteral(const VectorSlotPair& feedback);
789 :
790 : const Operator* DeleteProperty();
791 :
792 : const Operator* HasProperty(VectorSlotPair const& feedback);
793 :
794 : const Operator* GetSuperConstructor();
795 :
796 : const Operator* CreateGeneratorObject();
797 :
798 : const Operator* LoadGlobal(const Handle<Name>& name,
799 : const VectorSlotPair& feedback,
800 : TypeofMode typeof_mode = NOT_INSIDE_TYPEOF);
801 : const Operator* StoreGlobal(LanguageMode language_mode,
802 : const Handle<Name>& name,
803 : const VectorSlotPair& feedback);
804 :
805 : const Operator* LoadContext(size_t depth, size_t index, bool immutable);
806 : const Operator* StoreContext(size_t depth, size_t index);
807 :
808 : const Operator* LoadModule(int32_t cell_index);
809 : const Operator* StoreModule(int32_t cell_index);
810 :
811 : const Operator* HasInPrototypeChain();
812 : const Operator* InstanceOf(const VectorSlotPair& feedback);
813 : const Operator* OrdinaryHasInstance();
814 :
815 : const Operator* AsyncFunctionEnter();
816 : const Operator* AsyncFunctionReject();
817 : const Operator* AsyncFunctionResolve();
818 :
819 : const Operator* ForInEnumerate();
820 : const Operator* ForInNext(ForInMode);
821 : const Operator* ForInPrepare(ForInMode);
822 :
823 : const Operator* LoadMessage();
824 : const Operator* StoreMessage();
825 :
826 : // Used to implement Ignition's SuspendGenerator bytecode.
827 : const Operator* GeneratorStore(int value_count);
828 :
829 : // Used to implement Ignition's SwitchOnGeneratorState bytecode.
830 : const Operator* GeneratorRestoreContinuation();
831 : const Operator* GeneratorRestoreContext();
832 :
833 : // Used to implement Ignition's ResumeGenerator bytecode.
834 : const Operator* GeneratorRestoreRegister(int index);
835 : const Operator* GeneratorRestoreInputOrDebugPos();
836 :
837 : const Operator* StackCheck();
838 : const Operator* Debugger();
839 :
840 : const Operator* FulfillPromise();
841 : const Operator* PerformPromiseThen();
842 : const Operator* PromiseResolve();
843 : const Operator* RejectPromise();
844 : const Operator* ResolvePromise();
845 :
846 : const Operator* CreateFunctionContext(Handle<ScopeInfo> scope_info,
847 : int slot_count, ScopeType scope_type);
848 : const Operator* CreateCatchContext(const Handle<ScopeInfo>& scope_info);
849 : const Operator* CreateWithContext(const Handle<ScopeInfo>& scope_info);
850 : const Operator* CreateBlockContext(const Handle<ScopeInfo>& scpope_info);
851 :
852 : const Operator* ObjectIsArray();
853 : const Operator* ParseInt();
854 : const Operator* RegExpTest();
855 :
856 : private:
857 : Zone* zone() const { return zone_; }
858 :
859 : const JSOperatorGlobalCache& cache_;
860 : Zone* const zone_;
861 :
862 : DISALLOW_COPY_AND_ASSIGN(JSOperatorBuilder);
863 : };
864 :
865 : } // namespace compiler
866 : } // namespace internal
867 : } // namespace v8
868 :
869 : #endif // V8_COMPILER_JS_OPERATOR_H_
|