| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/frame-states.h" |
| 8 #include "src/compiler/machine-type.h" | 9 #include "src/compiler/machine-type.h" |
| 9 #include "src/unique.h" | 10 #include "src/unique.h" |
| 10 | 11 |
| 11 namespace v8 { | 12 namespace v8 { |
| 12 namespace internal { | 13 namespace internal { |
| 13 | 14 |
| 14 // Forward declarations. | 15 // Forward declarations. |
| 15 class ExternalReference; | 16 class ExternalReference; |
| 16 | 17 |
| 17 | 18 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 bool operator==(SelectParameters const&, SelectParameters const&); | 51 bool operator==(SelectParameters const&, SelectParameters const&); |
| 51 bool operator!=(SelectParameters const&, SelectParameters const&); | 52 bool operator!=(SelectParameters const&, SelectParameters const&); |
| 52 | 53 |
| 53 size_t hash_value(SelectParameters const& p); | 54 size_t hash_value(SelectParameters const& p); |
| 54 | 55 |
| 55 std::ostream& operator<<(std::ostream&, SelectParameters const& p); | 56 std::ostream& operator<<(std::ostream&, SelectParameters const& p); |
| 56 | 57 |
| 57 SelectParameters const& SelectParametersOf(const Operator* const); | 58 SelectParameters const& SelectParametersOf(const Operator* const); |
| 58 | 59 |
| 59 | 60 |
| 60 // Flag that describes how to combine the current environment with | |
| 61 // the output of a node to obtain a framestate for lazy bailout. | |
| 62 class OutputFrameStateCombine { | |
| 63 public: | |
| 64 enum Kind { | |
| 65 kPushOutput, // Push the output on the expression stack. | |
| 66 kPokeAt // Poke at the given environment location, | |
| 67 // counting from the top of the stack. | |
| 68 }; | |
| 69 | |
| 70 static OutputFrameStateCombine Ignore() { | |
| 71 return OutputFrameStateCombine(kPushOutput, 0); | |
| 72 } | |
| 73 static OutputFrameStateCombine Push(size_t count = 1) { | |
| 74 return OutputFrameStateCombine(kPushOutput, count); | |
| 75 } | |
| 76 static OutputFrameStateCombine PokeAt(size_t index) { | |
| 77 return OutputFrameStateCombine(kPokeAt, index); | |
| 78 } | |
| 79 | |
| 80 Kind kind() const { return kind_; } | |
| 81 size_t GetPushCount() const { | |
| 82 DCHECK_EQ(kPushOutput, kind()); | |
| 83 return parameter_; | |
| 84 } | |
| 85 size_t GetOffsetToPokeAt() const { | |
| 86 DCHECK_EQ(kPokeAt, kind()); | |
| 87 return parameter_; | |
| 88 } | |
| 89 | |
| 90 bool IsOutputIgnored() const { | |
| 91 return kind_ == kPushOutput && parameter_ == 0; | |
| 92 } | |
| 93 | |
| 94 size_t ConsumedOutputCount() const { | |
| 95 return kind_ == kPushOutput ? GetPushCount() : 1; | |
| 96 } | |
| 97 | |
| 98 bool operator==(OutputFrameStateCombine const& other) const { | |
| 99 return kind_ == other.kind_ && parameter_ == other.parameter_; | |
| 100 } | |
| 101 bool operator!=(OutputFrameStateCombine const& other) const { | |
| 102 return !(*this == other); | |
| 103 } | |
| 104 | |
| 105 friend size_t hash_value(OutputFrameStateCombine const&); | |
| 106 friend std::ostream& operator<<(std::ostream&, | |
| 107 OutputFrameStateCombine const&); | |
| 108 | |
| 109 private: | |
| 110 OutputFrameStateCombine(Kind kind, size_t parameter) | |
| 111 : kind_(kind), parameter_(parameter) {} | |
| 112 | |
| 113 Kind const kind_; | |
| 114 size_t const parameter_; | |
| 115 }; | |
| 116 | |
| 117 | |
| 118 // The type of stack frame that a FrameState node represents. | |
| 119 enum FrameStateType { | |
| 120 JS_FRAME, // Represents an unoptimized JavaScriptFrame. | |
| 121 ARGUMENTS_ADAPTOR // Represents an ArgumentsAdaptorFrame. | |
| 122 }; | |
| 123 | |
| 124 | |
| 125 class FrameStateCallInfo final { | |
| 126 public: | |
| 127 FrameStateCallInfo( | |
| 128 FrameStateType type, BailoutId bailout_id, | |
| 129 OutputFrameStateCombine state_combine, | |
| 130 MaybeHandle<JSFunction> jsfunction = MaybeHandle<JSFunction>()) | |
| 131 : type_(type), | |
| 132 bailout_id_(bailout_id), | |
| 133 frame_state_combine_(state_combine), | |
| 134 jsfunction_(jsfunction) {} | |
| 135 | |
| 136 FrameStateType type() const { return type_; } | |
| 137 BailoutId bailout_id() const { return bailout_id_; } | |
| 138 OutputFrameStateCombine state_combine() const { return frame_state_combine_; } | |
| 139 MaybeHandle<JSFunction> jsfunction() const { return jsfunction_; } | |
| 140 | |
| 141 private: | |
| 142 FrameStateType type_; | |
| 143 BailoutId bailout_id_; | |
| 144 OutputFrameStateCombine frame_state_combine_; | |
| 145 MaybeHandle<JSFunction> jsfunction_; | |
| 146 }; | |
| 147 | |
| 148 bool operator==(FrameStateCallInfo const&, FrameStateCallInfo const&); | |
| 149 bool operator!=(FrameStateCallInfo const&, FrameStateCallInfo const&); | |
| 150 | |
| 151 size_t hash_value(FrameStateCallInfo const&); | |
| 152 | |
| 153 std::ostream& operator<<(std::ostream&, FrameStateCallInfo const&); | |
| 154 | |
| 155 | |
| 156 size_t ProjectionIndexOf(const Operator* const); | 61 size_t ProjectionIndexOf(const Operator* const); |
| 157 | 62 |
| 158 | 63 |
| 159 // The {IrOpcode::kParameter} opcode represents an incoming parameter to the | 64 // The {IrOpcode::kParameter} opcode represents an incoming parameter to the |
| 160 // function. This class bundles the index and a debug name for such operators. | 65 // function. This class bundles the index and a debug name for such operators. |
| 161 class ParameterInfo final { | 66 class ParameterInfo final { |
| 162 public: | 67 public: |
| 163 ParameterInfo(int index, const char* debug_name) | 68 ParameterInfo(int index, const char* debug_name) |
| 164 : index_(index), debug_name_(debug_name) {} | 69 : index_(index), debug_name_(debug_name) {} |
| 165 | 70 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 Zone* const zone_; | 147 Zone* const zone_; |
| 243 | 148 |
| 244 DISALLOW_COPY_AND_ASSIGN(CommonOperatorBuilder); | 149 DISALLOW_COPY_AND_ASSIGN(CommonOperatorBuilder); |
| 245 }; | 150 }; |
| 246 | 151 |
| 247 } // namespace compiler | 152 } // namespace compiler |
| 248 } // namespace internal | 153 } // namespace internal |
| 249 } // namespace v8 | 154 } // namespace v8 |
| 250 | 155 |
| 251 #endif // V8_COMPILER_COMMON_OPERATOR_H_ | 156 #endif // V8_COMPILER_COMMON_OPERATOR_H_ |
| OLD | NEW |