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