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/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/opcodes.h" | 9 #include "src/compiler/opcodes.h" |
10 #include "src/compiler/operator.h" | 10 #include "src/compiler/operator.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // For space reasons, we keep this tightly packed, otherwise we could just use | 33 // For space reasons, we keep this tightly packed, otherwise we could just use |
34 // a simple int/int/bool POD. | 34 // a simple int/int/bool POD. |
35 const bool immutable_; | 35 const bool immutable_; |
36 const uint16_t depth_; | 36 const uint16_t depth_; |
37 const uint32_t index_; | 37 const uint32_t index_; |
38 }; | 38 }; |
39 | 39 |
40 // Defines the property being loaded from an object by a named load. This is | 40 // Defines the property being loaded from an object by a named load. This is |
41 // used as a parameter by JSLoadNamed operators. | 41 // used as a parameter by JSLoadNamed operators. |
42 struct LoadNamedParameters { | 42 struct LoadNamedParameters { |
43 PrintableUnique<Name> name; | 43 Unique<Name> name; |
44 ContextualMode contextual_mode; | 44 ContextualMode contextual_mode; |
45 }; | 45 }; |
46 | 46 |
47 // Defines the arity and the call flags for a JavaScript function call. This is | 47 // Defines the arity and the call flags for a JavaScript function call. This is |
48 // used as a parameter by JSCall operators. | 48 // used as a parameter by JSCall operators. |
49 struct CallParameters { | 49 struct CallParameters { |
50 int arity; | 50 int arity; |
51 CallFunctionFlags flags; | 51 CallFunctionFlags flags; |
52 }; | 52 }; |
53 | 53 |
54 // Defines the property being stored to an object by a named store. This is | 54 // Defines the property being stored to an object by a named store. This is |
55 // used as a parameter by JSStoreNamed operators. | 55 // used as a parameter by JSStoreNamed operators. |
56 struct StoreNamedParameters { | 56 struct StoreNamedParameters { |
57 StrictMode strict_mode; | 57 StrictMode strict_mode; |
58 PrintableUnique<Name> name; | 58 Unique<Name> name; |
59 }; | 59 }; |
60 | 60 |
61 // Interface for building JavaScript-level operators, e.g. directly from the | 61 // Interface for building JavaScript-level operators, e.g. directly from the |
62 // AST. Most operators have no parameters, thus can be globally shared for all | 62 // AST. Most operators have no parameters, thus can be globally shared for all |
63 // graphs. | 63 // graphs. |
64 class JSOperatorBuilder { | 64 class JSOperatorBuilder { |
65 public: | 65 public: |
66 explicit JSOperatorBuilder(Zone* zone) : zone_(zone) {} | 66 explicit JSOperatorBuilder(Zone* zone) : zone_(zone) {} |
67 | 67 |
68 #define SIMPLE(name, properties, inputs, outputs) \ | 68 #define SIMPLE(name, properties, inputs, outputs) \ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 arguments, 1); | 117 arguments, 1); |
118 } | 118 } |
119 | 119 |
120 Operator* CallNew(int arguments) { | 120 Operator* CallNew(int arguments) { |
121 return new (zone_) | 121 return new (zone_) |
122 Operator1<int>(IrOpcode::kJSCallConstruct, Operator::kNoProperties, | 122 Operator1<int>(IrOpcode::kJSCallConstruct, Operator::kNoProperties, |
123 arguments, 1, "JSCallConstruct", arguments); | 123 arguments, 1, "JSCallConstruct", arguments); |
124 } | 124 } |
125 | 125 |
126 Operator* LoadProperty() { BINOP(JSLoadProperty); } | 126 Operator* LoadProperty() { BINOP(JSLoadProperty); } |
127 Operator* LoadNamed(PrintableUnique<Name> name, | 127 Operator* LoadNamed(Unique<Name> name, |
128 ContextualMode contextual_mode = NOT_CONTEXTUAL) { | 128 ContextualMode contextual_mode = NOT_CONTEXTUAL) { |
129 LoadNamedParameters parameters = {name, contextual_mode}; | 129 LoadNamedParameters parameters = {name, contextual_mode}; |
130 OP1(JSLoadNamed, LoadNamedParameters, parameters, Operator::kNoProperties, | 130 OP1(JSLoadNamed, LoadNamedParameters, parameters, Operator::kNoProperties, |
131 1, 1); | 131 1, 1); |
132 } | 132 } |
133 | 133 |
134 Operator* StoreProperty(StrictMode strict_mode) { | 134 Operator* StoreProperty(StrictMode strict_mode) { |
135 OP1(JSStoreProperty, StrictMode, strict_mode, Operator::kNoProperties, 3, | 135 OP1(JSStoreProperty, StrictMode, strict_mode, Operator::kNoProperties, 3, |
136 0); | 136 0); |
137 } | 137 } |
138 | 138 |
139 Operator* StoreNamed(StrictMode strict_mode, PrintableUnique<Name> name) { | 139 Operator* StoreNamed(StrictMode strict_mode, Unique<Name> name) { |
140 StoreNamedParameters parameters = {strict_mode, name}; | 140 StoreNamedParameters parameters = {strict_mode, name}; |
141 OP1(JSStoreNamed, StoreNamedParameters, parameters, Operator::kNoProperties, | 141 OP1(JSStoreNamed, StoreNamedParameters, parameters, Operator::kNoProperties, |
142 2, 0); | 142 2, 0); |
143 } | 143 } |
144 | 144 |
145 Operator* DeleteProperty(StrictMode strict_mode) { | 145 Operator* DeleteProperty(StrictMode strict_mode) { |
146 OP1(JSDeleteProperty, StrictMode, strict_mode, Operator::kNoProperties, 2, | 146 OP1(JSDeleteProperty, StrictMode, strict_mode, Operator::kNoProperties, 2, |
147 1); | 147 1); |
148 } | 148 } |
149 | 149 |
150 Operator* HasProperty() { NOPROPS(JSHasProperty, 2, 1); } | 150 Operator* HasProperty() { NOPROPS(JSHasProperty, 2, 1); } |
151 | 151 |
152 Operator* LoadContext(uint16_t depth, uint32_t index, bool immutable) { | 152 Operator* LoadContext(uint16_t depth, uint32_t index, bool immutable) { |
153 ContextAccess access(depth, index, immutable); | 153 ContextAccess access(depth, index, immutable); |
154 OP1(JSLoadContext, ContextAccess, access, | 154 OP1(JSLoadContext, ContextAccess, access, |
155 Operator::kEliminatable | Operator::kNoWrite, 1, 1); | 155 Operator::kEliminatable | Operator::kNoWrite, 1, 1); |
156 } | 156 } |
157 Operator* StoreContext(uint16_t depth, uint32_t index) { | 157 Operator* StoreContext(uint16_t depth, uint32_t index) { |
158 ContextAccess access(depth, index, false); | 158 ContextAccess access(depth, index, false); |
159 OP1(JSStoreContext, ContextAccess, access, Operator::kNoProperties, 2, 1); | 159 OP1(JSStoreContext, ContextAccess, access, Operator::kNoProperties, 2, 1); |
160 } | 160 } |
161 | 161 |
162 Operator* TypeOf() { SIMPLE(JSTypeOf, Operator::kPure, 1, 1); } | 162 Operator* TypeOf() { SIMPLE(JSTypeOf, Operator::kPure, 1, 1); } |
163 Operator* InstanceOf() { NOPROPS(JSInstanceOf, 2, 1); } | 163 Operator* InstanceOf() { NOPROPS(JSInstanceOf, 2, 1); } |
164 Operator* Debugger() { NOPROPS(JSDebugger, 0, 0); } | 164 Operator* Debugger() { NOPROPS(JSDebugger, 0, 0); } |
165 | 165 |
166 // TODO(titzer): nail down the static parts of each of these context flavors. | 166 // TODO(titzer): nail down the static parts of each of these context flavors. |
167 Operator* CreateFunctionContext() { NOPROPS(JSCreateFunctionContext, 1, 1); } | 167 Operator* CreateFunctionContext() { NOPROPS(JSCreateFunctionContext, 1, 1); } |
168 Operator* CreateCatchContext(PrintableUnique<String> name) { | 168 Operator* CreateCatchContext(Unique<String> name) { |
169 OP1(JSCreateCatchContext, PrintableUnique<String>, name, | 169 OP1(JSCreateCatchContext, Unique<String>, name, Operator::kNoProperties, 1, |
170 Operator::kNoProperties, 1, 1); | 170 1); |
171 } | 171 } |
172 Operator* CreateWithContext() { NOPROPS(JSCreateWithContext, 2, 1); } | 172 Operator* CreateWithContext() { NOPROPS(JSCreateWithContext, 2, 1); } |
173 Operator* CreateBlockContext() { NOPROPS(JSCreateBlockContext, 2, 1); } | 173 Operator* CreateBlockContext() { NOPROPS(JSCreateBlockContext, 2, 1); } |
174 Operator* CreateModuleContext() { NOPROPS(JSCreateModuleContext, 2, 1); } | 174 Operator* CreateModuleContext() { NOPROPS(JSCreateModuleContext, 2, 1); } |
175 Operator* CreateGlobalContext() { NOPROPS(JSCreateGlobalContext, 2, 1); } | 175 Operator* CreateGlobalContext() { NOPROPS(JSCreateGlobalContext, 2, 1); } |
176 | 176 |
177 Operator* Runtime(Runtime::FunctionId function, int arguments) { | 177 Operator* Runtime(Runtime::FunctionId function, int arguments) { |
178 const Runtime::Function* f = Runtime::FunctionForId(function); | 178 const Runtime::Function* f = Runtime::FunctionForId(function); |
179 DCHECK(f->nargs == -1 || f->nargs == arguments); | 179 DCHECK(f->nargs == -1 || f->nargs == arguments); |
180 OP1(JSCallRuntime, Runtime::FunctionId, function, Operator::kNoProperties, | 180 OP1(JSCallRuntime, Runtime::FunctionId, function, Operator::kNoProperties, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 static int HashCode(Runtime::FunctionId val) { return static_cast<int>(val); } | 217 static int HashCode(Runtime::FunctionId val) { return static_cast<int>(val); } |
218 static bool Equals(Runtime::FunctionId a, Runtime::FunctionId b) { | 218 static bool Equals(Runtime::FunctionId a, Runtime::FunctionId b) { |
219 return a == b; | 219 return a == b; |
220 } | 220 } |
221 }; | 221 }; |
222 } | 222 } |
223 } | 223 } |
224 } // namespace v8::internal::compiler | 224 } // namespace v8::internal::compiler |
225 | 225 |
226 #endif // V8_COMPILER_JS_OPERATOR_H_ | 226 #endif // V8_COMPILER_JS_OPERATOR_H_ |
OLD | NEW |