| 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_COMMON_OPERATOR_H_ | 5 #ifndef V8_COMPILER_COMMON_OPERATOR_H_ |
| 6 #define V8_COMPILER_COMMON_OPERATOR_H_ | 6 #define V8_COMPILER_COMMON_OPERATOR_H_ |
| 7 | 7 |
| 8 #include "src/compiler/machine-type.h" | 8 #include "src/compiler/machine-type.h" |
| 9 #include "src/unique.h" | 9 #include "src/unique.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 // Forward declarations. | 14 // Forward declarations. |
| 15 class ExternalReference; | 15 class ExternalReference; |
| 16 | 16 |
| 17 | 17 |
| 18 namespace compiler { | 18 namespace compiler { |
| 19 | 19 |
| 20 // Forward declarations. | 20 // Forward declarations. |
| 21 class CallDescriptor; | 21 class CallDescriptor; |
| 22 struct CommonOperatorBuilderImpl; | 22 struct CommonOperatorBuilderImpl; |
| 23 class Operator; | 23 class Operator; |
| 24 | 24 |
| 25 | 25 |
| 26 // Flag that describes how to combine the current environment with | 26 // Flag that describes how to combine the current environment with |
| 27 // the output of a node to obtain a framestate for lazy bailout. | 27 // the output of a node to obtain a framestate for lazy bailout. |
| 28 class OutputFrameStateCombine { | 28 class OutputFrameStateCombine { |
| 29 public: | 29 public: |
| 30 enum CombineKind { | 30 enum Kind { |
| 31 kPushOutput, // Push the output on the expression stack. | 31 kPushOutput, // Push the output on the expression stack. |
| 32 kPokeAt // Poke at the given environment location, | 32 kPokeAt // Poke at the given environment location, |
| 33 // counting from the top of the stack. | 33 // counting from the top of the stack. |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 static OutputFrameStateCombine Ignore(); | 36 static OutputFrameStateCombine Ignore() { |
| 37 static OutputFrameStateCombine Push(size_t count = 1); | 37 return OutputFrameStateCombine(kPushOutput, 0); |
| 38 static OutputFrameStateCombine PokeAt(size_t index); | 38 } |
| 39 static OutputFrameStateCombine Push(size_t count = 1) { |
| 40 return OutputFrameStateCombine(kPushOutput, count); |
| 41 } |
| 42 static OutputFrameStateCombine PokeAt(size_t index) { |
| 43 return OutputFrameStateCombine(kPokeAt, index); |
| 44 } |
| 39 | 45 |
| 40 CombineKind kind(); | 46 Kind kind() const { return kind_; } |
| 41 size_t GetPushCount(); | 47 size_t GetPushCount() const { |
| 42 size_t GetOffsetToPokeAt(); | 48 DCHECK_EQ(kPushOutput, kind()); |
| 49 return parameter_; |
| 50 } |
| 51 size_t GetOffsetToPokeAt() const { |
| 52 DCHECK_EQ(kPokeAt, kind()); |
| 53 return parameter_; |
| 54 } |
| 43 | 55 |
| 44 bool IsOutputIgnored(); | 56 bool IsOutputIgnored() const { |
| 57 return kind_ == kPushOutput && parameter_ == 0; |
| 58 } |
| 59 |
| 60 bool operator==(OutputFrameStateCombine const& other) const { |
| 61 return kind_ == other.kind_ && parameter_ == other.parameter_; |
| 62 } |
| 63 bool operator!=(OutputFrameStateCombine const& other) const { |
| 64 return !(*this == other); |
| 65 } |
| 66 |
| 67 friend size_t hash_value(OutputFrameStateCombine const&); |
| 68 friend std::ostream& operator<<(std::ostream&, |
| 69 OutputFrameStateCombine const&); |
| 45 | 70 |
| 46 private: | 71 private: |
| 47 OutputFrameStateCombine(CombineKind kind, size_t parameter); | 72 OutputFrameStateCombine(Kind kind, size_t parameter) |
| 73 : kind_(kind), parameter_(parameter) {} |
| 48 | 74 |
| 49 CombineKind kind_; | 75 Kind const kind_; |
| 50 size_t parameter_; | 76 size_t const parameter_; |
| 51 }; | 77 }; |
| 52 | 78 |
| 53 | 79 |
| 54 // The type of stack frame that a FrameState node represents. | 80 // The type of stack frame that a FrameState node represents. |
| 55 enum FrameStateType { | 81 enum FrameStateType { |
| 56 JS_FRAME, // Represents an unoptimized JavaScriptFrame. | 82 JS_FRAME, // Represents an unoptimized JavaScriptFrame. |
| 57 ARGUMENTS_ADAPTOR // Represents an ArgumentsAdaptorFrame. | 83 ARGUMENTS_ADAPTOR // Represents an ArgumentsAdaptorFrame. |
| 58 }; | 84 }; |
| 59 | 85 |
| 60 | 86 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 OutputFrameStateCombine state_combine() const { return frame_state_combine_; } | 100 OutputFrameStateCombine state_combine() const { return frame_state_combine_; } |
| 75 MaybeHandle<JSFunction> jsfunction() const { return jsfunction_; } | 101 MaybeHandle<JSFunction> jsfunction() const { return jsfunction_; } |
| 76 | 102 |
| 77 private: | 103 private: |
| 78 FrameStateType type_; | 104 FrameStateType type_; |
| 79 BailoutId bailout_id_; | 105 BailoutId bailout_id_; |
| 80 OutputFrameStateCombine frame_state_combine_; | 106 OutputFrameStateCombine frame_state_combine_; |
| 81 MaybeHandle<JSFunction> jsfunction_; | 107 MaybeHandle<JSFunction> jsfunction_; |
| 82 }; | 108 }; |
| 83 | 109 |
| 110 bool operator==(FrameStateCallInfo const&, FrameStateCallInfo const&); |
| 111 bool operator!=(FrameStateCallInfo const&, FrameStateCallInfo const&); |
| 112 |
| 113 size_t hash_value(FrameStateCallInfo const&); |
| 114 |
| 115 std::ostream& operator<<(std::ostream&, FrameStateCallInfo const&); |
| 116 |
| 84 | 117 |
| 85 // Interface for building common operators that can be used at any level of IR, | 118 // Interface for building common operators that can be used at any level of IR, |
| 86 // including JavaScript, mid-level, and low-level. | 119 // including JavaScript, mid-level, and low-level. |
| 87 class CommonOperatorBuilder FINAL { | 120 class CommonOperatorBuilder FINAL { |
| 88 public: | 121 public: |
| 89 explicit CommonOperatorBuilder(Zone* zone); | 122 explicit CommonOperatorBuilder(Zone* zone); |
| 90 | 123 |
| 91 const Operator* Dead(); | 124 const Operator* Dead(); |
| 92 const Operator* End(); | 125 const Operator* End(); |
| 93 const Operator* Branch(); | 126 const Operator* Branch(); |
| 94 const Operator* IfTrue(); | 127 const Operator* IfTrue(); |
| 95 const Operator* IfFalse(); | 128 const Operator* IfFalse(); |
| 96 const Operator* Throw(); | 129 const Operator* Throw(); |
| 97 const Operator* Return(); | 130 const Operator* Return(); |
| 98 | 131 |
| 99 const Operator* Start(int num_formal_parameters); | 132 const Operator* Start(int num_formal_parameters); |
| 100 const Operator* Merge(int controls); | 133 const Operator* Merge(int controls); |
| 101 const Operator* Loop(int controls); | 134 const Operator* Loop(int controls); |
| 102 const Operator* Parameter(int index); | 135 const Operator* Parameter(int index); |
| 103 | 136 |
| 104 const Operator* Int32Constant(int32_t); | 137 const Operator* Int32Constant(int32_t); |
| 105 const Operator* Int64Constant(int64_t); | 138 const Operator* Int64Constant(int64_t); |
| 106 const Operator* Float32Constant(volatile float); | 139 const Operator* Float32Constant(volatile float); |
| 107 const Operator* Float64Constant(volatile double); | 140 const Operator* Float64Constant(volatile double); |
| 108 const Operator* ExternalConstant(const ExternalReference&); | 141 const Operator* ExternalConstant(const ExternalReference&); |
| 109 const Operator* NumberConstant(volatile double); | 142 const Operator* NumberConstant(volatile double); |
| 110 const Operator* HeapConstant(const Unique<Object>&); | 143 const Operator* HeapConstant(const Unique<HeapObject>&); |
| 111 | 144 |
| 112 const Operator* Phi(MachineType type, int arguments); | 145 const Operator* Phi(MachineType type, int arguments); |
| 113 const Operator* EffectPhi(int arguments); | 146 const Operator* EffectPhi(int arguments); |
| 114 const Operator* ValueEffect(int arguments); | 147 const Operator* ValueEffect(int arguments); |
| 115 const Operator* Finish(int arguments); | 148 const Operator* Finish(int arguments); |
| 116 const Operator* StateValues(int arguments); | 149 const Operator* StateValues(int arguments); |
| 117 const Operator* FrameState( | 150 const Operator* FrameState( |
| 118 FrameStateType type, BailoutId bailout_id, | 151 FrameStateType type, BailoutId bailout_id, |
| 119 OutputFrameStateCombine state_combine, | 152 OutputFrameStateCombine state_combine, |
| 120 MaybeHandle<JSFunction> jsfunction = MaybeHandle<JSFunction>()); | 153 MaybeHandle<JSFunction> jsfunction = MaybeHandle<JSFunction>()); |
| 121 const Operator* Call(const CallDescriptor* descriptor); | 154 const Operator* Call(const CallDescriptor* descriptor); |
| 122 const Operator* Projection(size_t index); | 155 const Operator* Projection(size_t index); |
| 123 | 156 |
| 124 private: | 157 private: |
| 125 Zone* zone() const { return zone_; } | 158 Zone* zone() const { return zone_; } |
| 126 | 159 |
| 127 const CommonOperatorBuilderImpl& impl_; | 160 const CommonOperatorBuilderImpl& impl_; |
| 128 Zone* const zone_; | 161 Zone* const zone_; |
| 129 }; | 162 }; |
| 130 | 163 |
| 131 } // namespace compiler | 164 } // namespace compiler |
| 132 } // namespace internal | 165 } // namespace internal |
| 133 } // namespace v8 | 166 } // namespace v8 |
| 134 | 167 |
| 135 #endif // V8_COMPILER_COMMON_OPERATOR_H_ | 168 #endif // V8_COMPILER_COMMON_OPERATOR_H_ |
| OLD | NEW |