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