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 |
(...skipping 14 matching lines...) Expand all Loading... |
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&); |
| 36 bool operator!=(CallFunctionParameters const&, CallFunctionParameters const&); |
| 37 |
| 38 size_t hash_value(CallFunctionParameters const&); |
| 39 |
| 40 std::ostream& operator<<(std::ostream&, CallFunctionParameters const&); |
| 41 |
35 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op); | 42 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op); |
36 | 43 |
37 | 44 |
38 // 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 |
39 // parameter by JSCallRuntime operators. | 46 // parameter by JSCallRuntime operators. |
40 class CallRuntimeParameters FINAL { | 47 class CallRuntimeParameters FINAL { |
41 public: | 48 public: |
42 CallRuntimeParameters(Runtime::FunctionId id, size_t arity) | 49 CallRuntimeParameters(Runtime::FunctionId id, size_t arity) |
43 : id_(id), arity_(arity) {} | 50 : id_(id), arity_(arity) {} |
44 | 51 |
45 Runtime::FunctionId id() const { return id_; } | 52 Runtime::FunctionId id() const { return id_; } |
46 size_t arity() const { return arity_; } | 53 size_t arity() const { return arity_; } |
47 | 54 |
48 private: | 55 private: |
49 const Runtime::FunctionId id_; | 56 const Runtime::FunctionId id_; |
50 const size_t arity_; | 57 const size_t arity_; |
51 }; | 58 }; |
52 | 59 |
| 60 bool operator==(CallRuntimeParameters const&, CallRuntimeParameters const&); |
| 61 bool operator!=(CallRuntimeParameters const&, CallRuntimeParameters const&); |
| 62 |
| 63 size_t hash_value(CallRuntimeParameters const&); |
| 64 |
| 65 std::ostream& operator<<(std::ostream&, CallRuntimeParameters const&); |
| 66 |
53 const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op); | 67 const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op); |
54 | 68 |
55 | 69 |
56 // 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 |
57 // used as a parameter by JSLoadContext and JSStoreContext operators and allows | 71 // used as a parameter by JSLoadContext and JSStoreContext operators and allows |
58 // accessing a context-allocated variable without keeping track of the scope. | 72 // accessing a context-allocated variable without keeping track of the scope. |
59 class ContextAccess FINAL { | 73 class ContextAccess FINAL { |
60 public: | 74 public: |
61 ContextAccess(size_t depth, size_t index, bool immutable); | 75 ContextAccess(size_t depth, size_t index, bool immutable); |
62 | 76 |
63 size_t depth() const { return depth_; } | 77 size_t depth() const { return depth_; } |
64 size_t index() const { return index_; } | 78 size_t index() const { return index_; } |
65 bool immutable() const { return immutable_; } | 79 bool immutable() const { return immutable_; } |
66 | 80 |
67 private: | 81 private: |
68 // 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 |
69 // a simple int/int/bool POD. | 83 // a simple int/int/bool POD. |
70 const bool immutable_; | 84 const bool immutable_; |
71 const uint16_t depth_; | 85 const uint16_t depth_; |
72 const uint32_t index_; | 86 const uint32_t index_; |
73 }; | 87 }; |
74 | 88 |
75 bool operator==(const ContextAccess& lhs, const ContextAccess& rhs); | 89 bool operator==(ContextAccess const&, ContextAccess const&); |
76 bool operator!=(const ContextAccess& lhs, const ContextAccess& rhs); | 90 bool operator!=(ContextAccess const&, ContextAccess const&); |
77 | 91 |
78 const ContextAccess& ContextAccessOf(const Operator* op); | 92 size_t hash_value(ContextAccess const&); |
| 93 |
| 94 std::ostream& operator<<(std::ostream&, ContextAccess const&); |
| 95 |
| 96 ContextAccess const& ContextAccessOf(Operator const*); |
79 | 97 |
80 | 98 |
81 // Defines the property being loaded from an object by a named load. This is | 99 // Defines the property being loaded from an object by a named load. This is |
82 // used as a parameter by JSLoadNamed operators. | 100 // used as a parameter by JSLoadNamed operators. |
83 class LoadNamedParameters FINAL { | 101 class LoadNamedParameters FINAL { |
84 public: | 102 public: |
85 LoadNamedParameters(const Unique<Name>& name, ContextualMode contextual_mode) | 103 LoadNamedParameters(const Unique<Name>& name, ContextualMode contextual_mode) |
86 : name_(name), contextual_mode_(contextual_mode) {} | 104 : name_(name), contextual_mode_(contextual_mode) {} |
87 | 105 |
88 const Unique<Name>& name() const { return name_; } | 106 const Unique<Name>& name() const { return name_; } |
89 ContextualMode contextual_mode() const { return contextual_mode_; } | 107 ContextualMode contextual_mode() const { return contextual_mode_; } |
90 | 108 |
91 private: | 109 private: |
92 const Unique<Name> name_; | 110 const Unique<Name> name_; |
93 const ContextualMode contextual_mode_; | 111 const ContextualMode contextual_mode_; |
94 }; | 112 }; |
95 | 113 |
| 114 bool operator==(LoadNamedParameters const&, LoadNamedParameters const&); |
| 115 bool operator!=(LoadNamedParameters const&, LoadNamedParameters const&); |
| 116 |
| 117 size_t hash_value(LoadNamedParameters const&); |
| 118 |
| 119 std::ostream& operator<<(std::ostream&, LoadNamedParameters const&); |
| 120 |
96 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op); | 121 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op); |
97 | 122 |
98 | 123 |
99 // Defines the property being stored to an object by a named store. This is | 124 // Defines the property being stored to an object by a named store. This is |
100 // used as a parameter by JSStoreNamed operators. | 125 // used as a parameter by JSStoreNamed operators. |
101 class StoreNamedParameters FINAL { | 126 class StoreNamedParameters FINAL { |
102 public: | 127 public: |
103 StoreNamedParameters(StrictMode strict_mode, const Unique<Name>& name) | 128 StoreNamedParameters(StrictMode strict_mode, const Unique<Name>& name) |
104 : strict_mode_(strict_mode), name_(name) {} | 129 : strict_mode_(strict_mode), name_(name) {} |
105 | 130 |
106 StrictMode strict_mode() const { return strict_mode_; } | 131 StrictMode strict_mode() const { return strict_mode_; } |
107 const Unique<Name>& name() const { return name_; } | 132 const Unique<Name>& name() const { return name_; } |
108 | 133 |
109 private: | 134 private: |
110 const StrictMode strict_mode_; | 135 const StrictMode strict_mode_; |
111 const Unique<Name> name_; | 136 const Unique<Name> name_; |
112 }; | 137 }; |
113 | 138 |
| 139 bool operator==(StoreNamedParameters const&, StoreNamedParameters const&); |
| 140 bool operator!=(StoreNamedParameters const&, StoreNamedParameters const&); |
| 141 |
| 142 size_t hash_value(StoreNamedParameters const&); |
| 143 |
| 144 std::ostream& operator<<(std::ostream&, StoreNamedParameters const&); |
| 145 |
114 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op); | 146 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op); |
115 | 147 |
116 | 148 |
117 // Interface for building JavaScript-level operators, e.g. directly from the | 149 // Interface for building JavaScript-level operators, e.g. directly from the |
118 // AST. Most operators have no parameters, thus can be globally shared for all | 150 // AST. Most operators have no parameters, thus can be globally shared for all |
119 // graphs. | 151 // graphs. |
120 class JSOperatorBuilder FINAL { | 152 class JSOperatorBuilder FINAL { |
121 public: | 153 public: |
122 explicit JSOperatorBuilder(Zone* zone); | 154 explicit JSOperatorBuilder(Zone* zone); |
123 | 155 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 219 |
188 const JSOperatorBuilderImpl& impl_; | 220 const JSOperatorBuilderImpl& impl_; |
189 Zone* const zone_; | 221 Zone* const zone_; |
190 }; | 222 }; |
191 | 223 |
192 } // namespace compiler | 224 } // namespace compiler |
193 } // namespace internal | 225 } // namespace internal |
194 } // namespace v8 | 226 } // namespace v8 |
195 | 227 |
196 #endif // V8_COMPILER_JS_OPERATOR_H_ | 228 #endif // V8_COMPILER_JS_OPERATOR_H_ |
OLD | NEW |