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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 from an object by a named store. This is |
| 55 // used as a parameter by JSStoreNamed operators. |
| 56 struct StoreNamedParameters { |
| 57 StrictMode strict_mode; |
| 58 PrintableUnique<Name> name; |
| 59 }; |
| 60 |
54 // Interface for building JavaScript-level operators, e.g. directly from the | 61 // Interface for building JavaScript-level operators, e.g. directly from the |
55 // 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 |
56 // graphs. | 63 // graphs. |
57 class JSOperatorBuilder { | 64 class JSOperatorBuilder { |
58 public: | 65 public: |
59 explicit JSOperatorBuilder(Zone* zone) : zone_(zone) {} | 66 explicit JSOperatorBuilder(Zone* zone) : zone_(zone) {} |
60 | 67 |
61 #define SIMPLE(name, properties, inputs, outputs) \ | 68 #define SIMPLE(name, properties, inputs, outputs) \ |
62 return new (zone_) \ | 69 return new (zone_) \ |
63 SimpleOperator(IrOpcode::k##name, properties, inputs, outputs, #name); | 70 SimpleOperator(IrOpcode::k##name, properties, inputs, outputs, #name); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 124 } |
118 | 125 |
119 Operator* LoadProperty() { BINOP(JSLoadProperty); } | 126 Operator* LoadProperty() { BINOP(JSLoadProperty); } |
120 Operator* LoadNamed(PrintableUnique<Name> name, | 127 Operator* LoadNamed(PrintableUnique<Name> name, |
121 ContextualMode contextual_mode = NOT_CONTEXTUAL) { | 128 ContextualMode contextual_mode = NOT_CONTEXTUAL) { |
122 LoadNamedParameters parameters = {name, contextual_mode}; | 129 LoadNamedParameters parameters = {name, contextual_mode}; |
123 OP1(JSLoadNamed, LoadNamedParameters, parameters, Operator::kNoProperties, | 130 OP1(JSLoadNamed, LoadNamedParameters, parameters, Operator::kNoProperties, |
124 1, 1); | 131 1, 1); |
125 } | 132 } |
126 | 133 |
127 Operator* StoreProperty() { NOPROPS(JSStoreProperty, 3, 0); } | 134 Operator* StoreProperty(StrictMode strict_mode) { |
128 Operator* StoreNamed(PrintableUnique<Name> name) { | 135 OP1(JSStoreProperty, StrictMode, strict_mode, Operator::kNoProperties, 3, |
129 OP1(JSStoreNamed, PrintableUnique<Name>, name, Operator::kNoProperties, 2, | |
130 0); | 136 0); |
131 } | 137 } |
132 | 138 |
| 139 Operator* StoreNamed(StrictMode strict_mode, PrintableUnique<Name> name) { |
| 140 StoreNamedParameters parameters = {strict_mode, name}; |
| 141 OP1(JSStoreNamed, StoreNamedParameters, parameters, Operator::kNoProperties, |
| 142 2, 0); |
| 143 } |
| 144 |
133 Operator* DeleteProperty(StrictMode strict_mode) { | 145 Operator* DeleteProperty(StrictMode strict_mode) { |
134 OP1(JSDeleteProperty, StrictMode, strict_mode, Operator::kNoProperties, 2, | 146 OP1(JSDeleteProperty, StrictMode, strict_mode, Operator::kNoProperties, 2, |
135 1); | 147 1); |
136 } | 148 } |
137 | 149 |
138 Operator* HasProperty() { NOPROPS(JSHasProperty, 2, 1); } | 150 Operator* HasProperty() { NOPROPS(JSHasProperty, 2, 1); } |
139 | 151 |
140 Operator* LoadContext(uint16_t depth, uint32_t index, bool immutable) { | 152 Operator* LoadContext(uint16_t depth, uint32_t index, bool immutable) { |
141 ContextAccess access(depth, index, immutable); | 153 ContextAccess access(depth, index, immutable); |
142 OP1(JSLoadContext, ContextAccess, access, | 154 OP1(JSLoadContext, ContextAccess, access, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 static int HashCode(Runtime::FunctionId val) { return static_cast<int>(val); } | 217 static int HashCode(Runtime::FunctionId val) { return static_cast<int>(val); } |
206 static bool Equals(Runtime::FunctionId a, Runtime::FunctionId b) { | 218 static bool Equals(Runtime::FunctionId a, Runtime::FunctionId b) { |
207 return a == b; | 219 return a == b; |
208 } | 220 } |
209 }; | 221 }; |
210 } | 222 } |
211 } | 223 } |
212 } // namespace v8::internal::compiler | 224 } // namespace v8::internal::compiler |
213 | 225 |
214 #endif // V8_COMPILER_JS_OPERATOR_H_ | 226 #endif // V8_COMPILER_JS_OPERATOR_H_ |
OLD | NEW |