| 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 #include "src/unique.h" | 9 #include "src/unique.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 // Forward declarations. | 15 // Forward declarations. |
| 16 class Operator; | 16 class Operator; |
| 17 struct JSOperatorGlobalCache; | 17 struct JSOperatorGlobalCache; |
| 18 | 18 |
| 19 | 19 |
| 20 // Defines the arity and the call flags for a JavaScript function call. This is | 20 // Defines the arity and the call flags for a JavaScript function call. This is |
| 21 // used as a parameter by JSCallFunction operators. | 21 // used as a parameter by JSCallFunction operators. |
| 22 class CallFunctionParameters FINAL { | 22 class CallFunctionParameters final { |
| 23 public: | 23 public: |
| 24 CallFunctionParameters(size_t arity, CallFunctionFlags flags) | 24 CallFunctionParameters(size_t arity, CallFunctionFlags flags) |
| 25 : arity_(arity), flags_(flags) {} | 25 : arity_(arity), flags_(flags) {} |
| 26 | 26 |
| 27 size_t arity() const { return arity_; } | 27 size_t arity() const { return arity_; } |
| 28 CallFunctionFlags flags() const { return flags_; } | 28 CallFunctionFlags flags() const { return flags_; } |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 const size_t arity_; | 31 const size_t arity_; |
| 32 const CallFunctionFlags flags_; | 32 const CallFunctionFlags flags_; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 bool operator==(CallFunctionParameters const&, CallFunctionParameters const&); | 35 bool operator==(CallFunctionParameters const&, CallFunctionParameters const&); |
| 36 bool operator!=(CallFunctionParameters const&, CallFunctionParameters const&); | 36 bool operator!=(CallFunctionParameters const&, CallFunctionParameters const&); |
| 37 | 37 |
| 38 size_t hash_value(CallFunctionParameters const&); | 38 size_t hash_value(CallFunctionParameters const&); |
| 39 | 39 |
| 40 std::ostream& operator<<(std::ostream&, CallFunctionParameters const&); | 40 std::ostream& operator<<(std::ostream&, CallFunctionParameters const&); |
| 41 | 41 |
| 42 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op); | 42 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op); |
| 43 | 43 |
| 44 | 44 |
| 45 // Defines the arity and the ID for a runtime function call. This is used as a | 45 // Defines the arity and the ID for a runtime function call. This is used as a |
| 46 // parameter by JSCallRuntime operators. | 46 // parameter by JSCallRuntime operators. |
| 47 class CallRuntimeParameters FINAL { | 47 class CallRuntimeParameters final { |
| 48 public: | 48 public: |
| 49 CallRuntimeParameters(Runtime::FunctionId id, size_t arity) | 49 CallRuntimeParameters(Runtime::FunctionId id, size_t arity) |
| 50 : id_(id), arity_(arity) {} | 50 : id_(id), arity_(arity) {} |
| 51 | 51 |
| 52 Runtime::FunctionId id() const { return id_; } | 52 Runtime::FunctionId id() const { return id_; } |
| 53 size_t arity() const { return arity_; } | 53 size_t arity() const { return arity_; } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 const Runtime::FunctionId id_; | 56 const Runtime::FunctionId id_; |
| 57 const size_t arity_; | 57 const size_t arity_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 bool operator==(CallRuntimeParameters const&, CallRuntimeParameters const&); | 60 bool operator==(CallRuntimeParameters const&, CallRuntimeParameters const&); |
| 61 bool operator!=(CallRuntimeParameters const&, CallRuntimeParameters const&); | 61 bool operator!=(CallRuntimeParameters const&, CallRuntimeParameters const&); |
| 62 | 62 |
| 63 size_t hash_value(CallRuntimeParameters const&); | 63 size_t hash_value(CallRuntimeParameters const&); |
| 64 | 64 |
| 65 std::ostream& operator<<(std::ostream&, CallRuntimeParameters const&); | 65 std::ostream& operator<<(std::ostream&, CallRuntimeParameters const&); |
| 66 | 66 |
| 67 const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op); | 67 const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op); |
| 68 | 68 |
| 69 | 69 |
| 70 // Defines the location of a context slot relative to a specific scope. This is | 70 // Defines the location of a context slot relative to a specific scope. This is |
| 71 // used as a parameter by JSLoadContext and JSStoreContext operators and allows | 71 // used as a parameter by JSLoadContext and JSStoreContext operators and allows |
| 72 // accessing a context-allocated variable without keeping track of the scope. | 72 // accessing a context-allocated variable without keeping track of the scope. |
| 73 class ContextAccess FINAL { | 73 class ContextAccess final { |
| 74 public: | 74 public: |
| 75 ContextAccess(size_t depth, size_t index, bool immutable); | 75 ContextAccess(size_t depth, size_t index, bool immutable); |
| 76 | 76 |
| 77 size_t depth() const { return depth_; } | 77 size_t depth() const { return depth_; } |
| 78 size_t index() const { return index_; } | 78 size_t index() const { return index_; } |
| 79 bool immutable() const { return immutable_; } | 79 bool immutable() const { return immutable_; } |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 // For space reasons, we keep this tightly packed, otherwise we could just use | 82 // For space reasons, we keep this tightly packed, otherwise we could just use |
| 83 // a simple int/int/bool POD. | 83 // a simple int/int/bool POD. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 110 const Handle<TypeFeedbackVector> vector_; | 110 const Handle<TypeFeedbackVector> vector_; |
| 111 const FeedbackVectorICSlot slot_; | 111 const FeedbackVectorICSlot slot_; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 | 114 |
| 115 bool operator==(VectorSlotPair const& lhs, VectorSlotPair const& rhs); | 115 bool operator==(VectorSlotPair const& lhs, VectorSlotPair const& rhs); |
| 116 | 116 |
| 117 | 117 |
| 118 // Defines the property being loaded from an object by a named load. This is | 118 // Defines the property being loaded from an object by a named load. This is |
| 119 // used as a parameter by JSLoadNamed operators. | 119 // used as a parameter by JSLoadNamed operators. |
| 120 class LoadNamedParameters FINAL { | 120 class LoadNamedParameters final { |
| 121 public: | 121 public: |
| 122 LoadNamedParameters(const Unique<Name>& name, const VectorSlotPair& feedback, | 122 LoadNamedParameters(const Unique<Name>& name, const VectorSlotPair& feedback, |
| 123 ContextualMode contextual_mode) | 123 ContextualMode contextual_mode) |
| 124 : name_(name), contextual_mode_(contextual_mode), feedback_(feedback) {} | 124 : name_(name), contextual_mode_(contextual_mode), feedback_(feedback) {} |
| 125 | 125 |
| 126 const Unique<Name>& name() const { return name_; } | 126 const Unique<Name>& name() const { return name_; } |
| 127 ContextualMode contextual_mode() const { return contextual_mode_; } | 127 ContextualMode contextual_mode() const { return contextual_mode_; } |
| 128 | 128 |
| 129 const VectorSlotPair& feedback() const { return feedback_; } | 129 const VectorSlotPair& feedback() const { return feedback_; } |
| 130 | 130 |
| 131 private: | 131 private: |
| 132 const Unique<Name> name_; | 132 const Unique<Name> name_; |
| 133 const ContextualMode contextual_mode_; | 133 const ContextualMode contextual_mode_; |
| 134 const VectorSlotPair feedback_; | 134 const VectorSlotPair feedback_; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 bool operator==(LoadNamedParameters const&, LoadNamedParameters const&); | 137 bool operator==(LoadNamedParameters const&, LoadNamedParameters const&); |
| 138 bool operator!=(LoadNamedParameters const&, LoadNamedParameters const&); | 138 bool operator!=(LoadNamedParameters const&, LoadNamedParameters const&); |
| 139 | 139 |
| 140 size_t hash_value(LoadNamedParameters const&); | 140 size_t hash_value(LoadNamedParameters const&); |
| 141 | 141 |
| 142 std::ostream& operator<<(std::ostream&, LoadNamedParameters const&); | 142 std::ostream& operator<<(std::ostream&, LoadNamedParameters const&); |
| 143 | 143 |
| 144 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op); | 144 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op); |
| 145 | 145 |
| 146 | 146 |
| 147 // Defines the property being loaded from an object. This is | 147 // Defines the property being loaded from an object. This is |
| 148 // used as a parameter by JSLoadProperty operators. | 148 // used as a parameter by JSLoadProperty operators. |
| 149 class LoadPropertyParameters FINAL { | 149 class LoadPropertyParameters final { |
| 150 public: | 150 public: |
| 151 explicit LoadPropertyParameters(const VectorSlotPair& feedback) | 151 explicit LoadPropertyParameters(const VectorSlotPair& feedback) |
| 152 : feedback_(feedback) {} | 152 : feedback_(feedback) {} |
| 153 | 153 |
| 154 const VectorSlotPair& feedback() const { return feedback_; } | 154 const VectorSlotPair& feedback() const { return feedback_; } |
| 155 | 155 |
| 156 private: | 156 private: |
| 157 const VectorSlotPair feedback_; | 157 const VectorSlotPair feedback_; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 bool operator==(LoadPropertyParameters const&, LoadPropertyParameters const&); | 160 bool operator==(LoadPropertyParameters const&, LoadPropertyParameters const&); |
| 161 bool operator!=(LoadPropertyParameters const&, LoadPropertyParameters const&); | 161 bool operator!=(LoadPropertyParameters const&, LoadPropertyParameters const&); |
| 162 | 162 |
| 163 size_t hash_value(LoadPropertyParameters const&); | 163 size_t hash_value(LoadPropertyParameters const&); |
| 164 | 164 |
| 165 std::ostream& operator<<(std::ostream&, LoadPropertyParameters const&); | 165 std::ostream& operator<<(std::ostream&, LoadPropertyParameters const&); |
| 166 | 166 |
| 167 const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op); | 167 const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op); |
| 168 | 168 |
| 169 | 169 |
| 170 // Defines the property being stored to an object by a named store. This is | 170 // Defines the property being stored to an object by a named store. This is |
| 171 // used as a parameter by JSStoreNamed operators. | 171 // used as a parameter by JSStoreNamed operators. |
| 172 class StoreNamedParameters FINAL { | 172 class StoreNamedParameters final { |
| 173 public: | 173 public: |
| 174 StoreNamedParameters(LanguageMode language_mode, const Unique<Name>& name) | 174 StoreNamedParameters(LanguageMode language_mode, const Unique<Name>& name) |
| 175 : language_mode_(language_mode), name_(name) {} | 175 : language_mode_(language_mode), name_(name) {} |
| 176 | 176 |
| 177 LanguageMode language_mode() const { return language_mode_; } | 177 LanguageMode language_mode() const { return language_mode_; } |
| 178 const Unique<Name>& name() const { return name_; } | 178 const Unique<Name>& name() const { return name_; } |
| 179 | 179 |
| 180 private: | 180 private: |
| 181 const LanguageMode language_mode_; | 181 const LanguageMode language_mode_; |
| 182 const Unique<Name> name_; | 182 const Unique<Name> name_; |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 bool operator==(StoreNamedParameters const&, StoreNamedParameters const&); | 185 bool operator==(StoreNamedParameters const&, StoreNamedParameters const&); |
| 186 bool operator!=(StoreNamedParameters const&, StoreNamedParameters const&); | 186 bool operator!=(StoreNamedParameters const&, StoreNamedParameters const&); |
| 187 | 187 |
| 188 size_t hash_value(StoreNamedParameters const&); | 188 size_t hash_value(StoreNamedParameters const&); |
| 189 | 189 |
| 190 std::ostream& operator<<(std::ostream&, StoreNamedParameters const&); | 190 std::ostream& operator<<(std::ostream&, StoreNamedParameters const&); |
| 191 | 191 |
| 192 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op); | 192 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op); |
| 193 | 193 |
| 194 | 194 |
| 195 // Interface for building JavaScript-level operators, e.g. directly from the | 195 // Interface for building JavaScript-level operators, e.g. directly from the |
| 196 // AST. Most operators have no parameters, thus can be globally shared for all | 196 // AST. Most operators have no parameters, thus can be globally shared for all |
| 197 // graphs. | 197 // graphs. |
| 198 class JSOperatorBuilder FINAL : public ZoneObject { | 198 class JSOperatorBuilder final : public ZoneObject { |
| 199 public: | 199 public: |
| 200 explicit JSOperatorBuilder(Zone* zone); | 200 explicit JSOperatorBuilder(Zone* zone); |
| 201 | 201 |
| 202 const Operator* Equal(); | 202 const Operator* Equal(); |
| 203 const Operator* NotEqual(); | 203 const Operator* NotEqual(); |
| 204 const Operator* StrictEqual(); | 204 const Operator* StrictEqual(); |
| 205 const Operator* StrictNotEqual(); | 205 const Operator* StrictNotEqual(); |
| 206 const Operator* LessThan(); | 206 const Operator* LessThan(); |
| 207 const Operator* GreaterThan(); | 207 const Operator* GreaterThan(); |
| 208 const Operator* LessThanOrEqual(); | 208 const Operator* LessThanOrEqual(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 Zone* const zone_; | 270 Zone* const zone_; |
| 271 | 271 |
| 272 DISALLOW_COPY_AND_ASSIGN(JSOperatorBuilder); | 272 DISALLOW_COPY_AND_ASSIGN(JSOperatorBuilder); |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 } // namespace compiler | 275 } // namespace compiler |
| 276 } // namespace internal | 276 } // namespace internal |
| 277 } // namespace v8 | 277 } // namespace v8 |
| 278 | 278 |
| 279 #endif // V8_COMPILER_JS_OPERATOR_H_ | 279 #endif // V8_COMPILER_JS_OPERATOR_H_ |
| OLD | NEW |