OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_JS_OPERATOR_H_ | 5 #ifndef V8_COMPILER_JS_OPERATOR_H_ |
6 #define V8_COMPILER_JS_OPERATOR_H_ | 6 #define V8_COMPILER_JS_OPERATOR_H_ |
7 | 7 |
8 #include "src/runtime/runtime.h" | 8 #include "src/runtime/runtime.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 23 matching lines...) Expand all Loading... |
34 private: | 34 private: |
35 const Handle<TypeFeedbackVector> vector_; | 35 const Handle<TypeFeedbackVector> vector_; |
36 const FeedbackVectorSlot slot_; | 36 const FeedbackVectorSlot slot_; |
37 }; | 37 }; |
38 | 38 |
39 bool operator==(VectorSlotPair const&, VectorSlotPair const&); | 39 bool operator==(VectorSlotPair const&, VectorSlotPair const&); |
40 bool operator!=(VectorSlotPair const&, VectorSlotPair const&); | 40 bool operator!=(VectorSlotPair const&, VectorSlotPair const&); |
41 | 41 |
42 size_t hash_value(VectorSlotPair const&); | 42 size_t hash_value(VectorSlotPair const&); |
43 | 43 |
| 44 |
| 45 // Defines hints about receiver values based on structural knowledge. This is |
| 46 // used as a parameter by JSConvertReceiver operators. |
| 47 enum class ConvertReceiverMode { |
| 48 kNullOrUndefined, // Guaranteed to be null or undefined. |
| 49 kNotNullOrUndefined, // Guaranteed to never be null or undefined. |
| 50 kAny // No specific knowledge about receiver. |
| 51 }; |
| 52 |
| 53 size_t hash_value(ConvertReceiverMode const&); |
| 54 |
| 55 std::ostream& operator<<(std::ostream&, ConvertReceiverMode const&); |
| 56 |
| 57 const ConvertReceiverMode& ConvertReceiverModeOf(const Operator* op); |
| 58 |
| 59 |
| 60 // Defines whether tail call optimization is allowed. |
44 enum TailCallMode { NO_TAIL_CALLS, ALLOW_TAIL_CALLS }; | 61 enum TailCallMode { NO_TAIL_CALLS, ALLOW_TAIL_CALLS }; |
45 | 62 |
| 63 |
46 // Defines the arity and the call flags for a JavaScript function call. This is | 64 // Defines the arity and the call flags for a JavaScript function call. This is |
47 // used as a parameter by JSCallFunction operators. | 65 // used as a parameter by JSCallFunction operators. |
48 class CallFunctionParameters final { | 66 class CallFunctionParameters final { |
49 public: | 67 public: |
50 CallFunctionParameters(size_t arity, CallFunctionFlags flags, | 68 CallFunctionParameters(size_t arity, CallFunctionFlags flags, |
51 LanguageMode language_mode, | 69 LanguageMode language_mode, |
52 VectorSlotPair const& feedback, | 70 VectorSlotPair const& feedback, |
53 TailCallMode tail_call_mode) | 71 TailCallMode tail_call_mode, |
| 72 ConvertReceiverMode convert_mode) |
54 : bit_field_(ArityField::encode(arity) | FlagsField::encode(flags) | | 73 : bit_field_(ArityField::encode(arity) | FlagsField::encode(flags) | |
55 LanguageModeField::encode(language_mode)), | 74 LanguageModeField::encode(language_mode)), |
56 feedback_(feedback), | 75 feedback_(feedback), |
57 tail_call_mode_(tail_call_mode) {} | 76 tail_call_mode_(tail_call_mode), |
| 77 convert_mode_(convert_mode) {} |
58 | 78 |
59 size_t arity() const { return ArityField::decode(bit_field_); } | 79 size_t arity() const { return ArityField::decode(bit_field_); } |
60 CallFunctionFlags flags() const { return FlagsField::decode(bit_field_); } | 80 CallFunctionFlags flags() const { return FlagsField::decode(bit_field_); } |
61 LanguageMode language_mode() const { | 81 LanguageMode language_mode() const { |
62 return LanguageModeField::decode(bit_field_); | 82 return LanguageModeField::decode(bit_field_); |
63 } | 83 } |
| 84 ConvertReceiverMode convert_mode() const { return convert_mode_; } |
64 VectorSlotPair const& feedback() const { return feedback_; } | 85 VectorSlotPair const& feedback() const { return feedback_; } |
65 | 86 |
66 bool operator==(CallFunctionParameters const& that) const { | 87 bool operator==(CallFunctionParameters const& that) const { |
67 return this->bit_field_ == that.bit_field_ && | 88 return this->bit_field_ == that.bit_field_ && |
68 this->feedback_ == that.feedback_; | 89 this->feedback_ == that.feedback_ && |
| 90 this->tail_call_mode_ == that.tail_call_mode_ && |
| 91 this->convert_mode_ == that.convert_mode_; |
69 } | 92 } |
70 bool operator!=(CallFunctionParameters const& that) const { | 93 bool operator!=(CallFunctionParameters const& that) const { |
71 return !(*this == that); | 94 return !(*this == that); |
72 } | 95 } |
73 | 96 |
74 bool AllowTailCalls() const { return tail_call_mode_ == ALLOW_TAIL_CALLS; } | 97 bool AllowTailCalls() const { return tail_call_mode_ == ALLOW_TAIL_CALLS; } |
75 | 98 |
76 private: | 99 private: |
77 friend size_t hash_value(CallFunctionParameters const& p) { | 100 friend size_t hash_value(CallFunctionParameters const& p) { |
78 return base::hash_combine(p.bit_field_, p.feedback_); | 101 return base::hash_combine(p.bit_field_, p.feedback_, p.convert_mode_); |
79 } | 102 } |
80 | 103 |
81 typedef BitField<size_t, 0, 28> ArityField; | 104 typedef BitField<size_t, 0, 28> ArityField; |
82 typedef BitField<CallFunctionFlags, 28, 2> FlagsField; | 105 typedef BitField<CallFunctionFlags, 28, 2> FlagsField; |
83 typedef BitField<LanguageMode, 30, 2> LanguageModeField; | 106 typedef BitField<LanguageMode, 30, 2> LanguageModeField; |
84 | 107 |
85 const uint32_t bit_field_; | 108 const uint32_t bit_field_; |
86 const VectorSlotPair feedback_; | 109 const VectorSlotPair feedback_; |
87 bool tail_call_mode_; | 110 TailCallMode tail_call_mode_; |
| 111 ConvertReceiverMode convert_mode_; |
88 }; | 112 }; |
89 | 113 |
90 size_t hash_value(CallFunctionParameters const&); | 114 size_t hash_value(CallFunctionParameters const&); |
91 | 115 |
92 std::ostream& operator<<(std::ostream&, CallFunctionParameters const&); | 116 std::ostream& operator<<(std::ostream&, CallFunctionParameters const&); |
93 | 117 |
94 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op); | 118 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op); |
95 | 119 |
96 | 120 |
97 // Defines the arity and the ID for a runtime function call. This is used as a | 121 // Defines the arity and the ID for a runtime function call. This is used as a |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 const Operator* CreateArguments(CreateArgumentsParameters::Type type, | 457 const Operator* CreateArguments(CreateArgumentsParameters::Type type, |
434 int start_index); | 458 int start_index); |
435 const Operator* CreateClosure(Handle<SharedFunctionInfo> shared_info, | 459 const Operator* CreateClosure(Handle<SharedFunctionInfo> shared_info, |
436 PretenureFlag pretenure); | 460 PretenureFlag pretenure); |
437 const Operator* CreateLiteralArray(int literal_flags); | 461 const Operator* CreateLiteralArray(int literal_flags); |
438 const Operator* CreateLiteralObject(int literal_flags); | 462 const Operator* CreateLiteralObject(int literal_flags); |
439 | 463 |
440 const Operator* CallFunction( | 464 const Operator* CallFunction( |
441 size_t arity, CallFunctionFlags flags, LanguageMode language_mode, | 465 size_t arity, CallFunctionFlags flags, LanguageMode language_mode, |
442 VectorSlotPair const& feedback = VectorSlotPair(), | 466 VectorSlotPair const& feedback = VectorSlotPair(), |
| 467 ConvertReceiverMode convert_mode = ConvertReceiverMode::kAny, |
443 TailCallMode tail_call_mode = NO_TAIL_CALLS); | 468 TailCallMode tail_call_mode = NO_TAIL_CALLS); |
444 const Operator* CallRuntime(Runtime::FunctionId id, size_t arity); | 469 const Operator* CallRuntime(Runtime::FunctionId id, size_t arity); |
| 470 const Operator* CallConstruct(int arguments); |
445 | 471 |
446 const Operator* CallConstruct(int arguments); | 472 const Operator* ConvertReceiver(ConvertReceiverMode convert_mode); |
447 | 473 |
448 const Operator* LoadProperty(LanguageMode language_mode, | 474 const Operator* LoadProperty(LanguageMode language_mode, |
449 VectorSlotPair const& feedback); | 475 VectorSlotPair const& feedback); |
450 const Operator* LoadNamed(LanguageMode language_mode, Handle<Name> name, | 476 const Operator* LoadNamed(LanguageMode language_mode, Handle<Name> name, |
451 VectorSlotPair const& feedback); | 477 VectorSlotPair const& feedback); |
452 | 478 |
453 const Operator* StoreProperty(LanguageMode language_mode, | 479 const Operator* StoreProperty(LanguageMode language_mode, |
454 VectorSlotPair const& feedback); | 480 VectorSlotPair const& feedback); |
455 const Operator* StoreNamed(LanguageMode language_mode, Handle<Name> name, | 481 const Operator* StoreNamed(LanguageMode language_mode, Handle<Name> name, |
456 VectorSlotPair const& feedback); | 482 VectorSlotPair const& feedback); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 Zone* const zone_; | 527 Zone* const zone_; |
502 | 528 |
503 DISALLOW_COPY_AND_ASSIGN(JSOperatorBuilder); | 529 DISALLOW_COPY_AND_ASSIGN(JSOperatorBuilder); |
504 }; | 530 }; |
505 | 531 |
506 } // namespace compiler | 532 } // namespace compiler |
507 } // namespace internal | 533 } // namespace internal |
508 } // namespace v8 | 534 } // namespace v8 |
509 | 535 |
510 #endif // V8_COMPILER_JS_OPERATOR_H_ | 536 #endif // V8_COMPILER_JS_OPERATOR_H_ |
OLD | NEW |