OLD | NEW |
1 // Copyright 2014 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 #include "src/compiler/js-operator.h" | 5 #include "src/compiler/js-operator.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/lazy-instance.h" | 9 #include "src/base/lazy-instance.h" |
10 #include "src/compiler/opcodes.h" | 10 #include "src/compiler/opcodes.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 ContextAccess const& ContextAccessOf(Operator const* op) { | 104 ContextAccess const& ContextAccessOf(Operator const* op) { |
105 DCHECK(op->opcode() == IrOpcode::kJSLoadContext || | 105 DCHECK(op->opcode() == IrOpcode::kJSLoadContext || |
106 op->opcode() == IrOpcode::kJSStoreContext); | 106 op->opcode() == IrOpcode::kJSStoreContext); |
107 return OpParameter<ContextAccess>(op); | 107 return OpParameter<ContextAccess>(op); |
108 } | 108 } |
109 | 109 |
110 | 110 |
111 bool operator==(LoadNamedParameters const& lhs, | 111 bool operator==(LoadNamedParameters const& lhs, |
112 LoadNamedParameters const& rhs) { | 112 LoadNamedParameters const& rhs) { |
113 return lhs.name() == rhs.name() && | 113 return lhs.name() == rhs.name() && |
114 lhs.contextual_mode() == rhs.contextual_mode(); | 114 lhs.contextual_mode() == rhs.contextual_mode() && |
| 115 lhs.feedback() == rhs.feedback(); |
115 } | 116 } |
116 | 117 |
117 | 118 |
118 bool operator!=(LoadNamedParameters const& lhs, | 119 bool operator!=(LoadNamedParameters const& lhs, |
119 LoadNamedParameters const& rhs) { | 120 LoadNamedParameters const& rhs) { |
120 return !(lhs == rhs); | 121 return !(lhs == rhs); |
121 } | 122 } |
122 | 123 |
123 | 124 |
124 size_t hash_value(LoadNamedParameters const& p) { | 125 size_t hash_value(LoadNamedParameters const& p) { |
125 return base::hash_combine(p.name(), p.contextual_mode()); | 126 return base::hash_combine(p.name(), p.contextual_mode()); |
126 } | 127 } |
127 | 128 |
128 | 129 |
129 std::ostream& operator<<(std::ostream& os, LoadNamedParameters const& p) { | 130 std::ostream& operator<<(std::ostream& os, LoadNamedParameters const& p) { |
130 return os << Brief(*p.name().handle()) << ", " << p.contextual_mode(); | 131 return os << Brief(*p.name().handle()) << ", " << p.contextual_mode(); |
131 } | 132 } |
132 | 133 |
133 | 134 |
| 135 std::ostream& operator<<(std::ostream& os, LoadPropertyParameters const& p) { |
| 136 // Nothing special to print. |
| 137 return os; |
| 138 } |
| 139 |
| 140 |
| 141 bool operator==(LoadPropertyParameters const& lhs, |
| 142 LoadPropertyParameters const& rhs) { |
| 143 return lhs.feedback() == rhs.feedback(); |
| 144 } |
| 145 |
| 146 |
| 147 bool operator!=(LoadPropertyParameters const& lhs, |
| 148 LoadPropertyParameters const& rhs) { |
| 149 return !(lhs == rhs); |
| 150 } |
| 151 |
| 152 |
| 153 const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op) { |
| 154 DCHECK_EQ(IrOpcode::kJSLoadProperty, op->opcode()); |
| 155 return OpParameter<LoadPropertyParameters>(op); |
| 156 } |
| 157 |
| 158 |
| 159 size_t hash_value(LoadPropertyParameters const& p) { |
| 160 return hash_value(p.feedback()); |
| 161 } |
| 162 |
| 163 |
134 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { | 164 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { |
135 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); | 165 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); |
136 return OpParameter<LoadNamedParameters>(op); | 166 return OpParameter<LoadNamedParameters>(op); |
137 } | 167 } |
138 | 168 |
139 | 169 |
140 bool operator==(StoreNamedParameters const& lhs, | 170 bool operator==(StoreNamedParameters const& lhs, |
141 StoreNamedParameters const& rhs) { | 171 StoreNamedParameters const& rhs) { |
142 return lhs.strict_mode() == rhs.strict_mode() && lhs.name() == rhs.name(); | 172 return lhs.strict_mode() == rhs.strict_mode() && lhs.name() == rhs.name(); |
143 } | 173 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 V(Divide, Operator::kNoProperties, 2, 1) \ | 216 V(Divide, Operator::kNoProperties, 2, 1) \ |
187 V(Modulus, Operator::kNoProperties, 2, 1) \ | 217 V(Modulus, Operator::kNoProperties, 2, 1) \ |
188 V(UnaryNot, Operator::kNoProperties, 1, 1) \ | 218 V(UnaryNot, Operator::kNoProperties, 1, 1) \ |
189 V(ToBoolean, Operator::kNoProperties, 1, 1) \ | 219 V(ToBoolean, Operator::kNoProperties, 1, 1) \ |
190 V(ToNumber, Operator::kNoProperties, 1, 1) \ | 220 V(ToNumber, Operator::kNoProperties, 1, 1) \ |
191 V(ToString, Operator::kNoProperties, 1, 1) \ | 221 V(ToString, Operator::kNoProperties, 1, 1) \ |
192 V(ToName, Operator::kNoProperties, 1, 1) \ | 222 V(ToName, Operator::kNoProperties, 1, 1) \ |
193 V(ToObject, Operator::kNoProperties, 1, 1) \ | 223 V(ToObject, Operator::kNoProperties, 1, 1) \ |
194 V(Yield, Operator::kNoProperties, 1, 1) \ | 224 V(Yield, Operator::kNoProperties, 1, 1) \ |
195 V(Create, Operator::kEliminatable, 0, 1) \ | 225 V(Create, Operator::kEliminatable, 0, 1) \ |
196 V(LoadProperty, Operator::kNoProperties, 2, 1) \ | |
197 V(HasProperty, Operator::kNoProperties, 2, 1) \ | 226 V(HasProperty, Operator::kNoProperties, 2, 1) \ |
198 V(TypeOf, Operator::kPure, 1, 1) \ | 227 V(TypeOf, Operator::kPure, 1, 1) \ |
199 V(InstanceOf, Operator::kNoProperties, 2, 1) \ | 228 V(InstanceOf, Operator::kNoProperties, 2, 1) \ |
200 V(Debugger, Operator::kNoProperties, 0, 0) \ | 229 V(Debugger, Operator::kNoProperties, 0, 0) \ |
201 V(CreateFunctionContext, Operator::kNoProperties, 1, 1) \ | 230 V(CreateFunctionContext, Operator::kNoProperties, 1, 1) \ |
202 V(CreateWithContext, Operator::kNoProperties, 2, 1) \ | 231 V(CreateWithContext, Operator::kNoProperties, 2, 1) \ |
203 V(CreateBlockContext, Operator::kNoProperties, 2, 1) \ | 232 V(CreateBlockContext, Operator::kNoProperties, 2, 1) \ |
204 V(CreateModuleContext, Operator::kNoProperties, 2, 1) \ | 233 V(CreateModuleContext, Operator::kNoProperties, 2, 1) \ |
205 V(CreateGlobalContext, Operator::kNoProperties, 2, 1) | 234 V(CreateGlobalContext, Operator::kNoProperties, 2, 1) |
206 | 235 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 283 |
255 | 284 |
256 const Operator* JSOperatorBuilder::CallConstruct(int arguments) { | 285 const Operator* JSOperatorBuilder::CallConstruct(int arguments) { |
257 return new (zone()) | 286 return new (zone()) |
258 Operator1<int>(IrOpcode::kJSCallConstruct, Operator::kNoProperties, | 287 Operator1<int>(IrOpcode::kJSCallConstruct, Operator::kNoProperties, |
259 arguments, 1, "JSCallConstruct", arguments); | 288 arguments, 1, "JSCallConstruct", arguments); |
260 } | 289 } |
261 | 290 |
262 | 291 |
263 const Operator* JSOperatorBuilder::LoadNamed(const Unique<Name>& name, | 292 const Operator* JSOperatorBuilder::LoadNamed(const Unique<Name>& name, |
| 293 const LoadICFeedbackNode& feedback, |
264 ContextualMode contextual_mode) { | 294 ContextualMode contextual_mode) { |
265 LoadNamedParameters parameters(name, contextual_mode); | 295 LoadNamedParameters parameters(name, feedback, contextual_mode); |
266 return new (zone()) Operator1<LoadNamedParameters>( | 296 return new (zone()) Operator1<LoadNamedParameters>( |
267 IrOpcode::kJSLoadNamed, Operator::kNoProperties, 1, 1, "JSLoadNamed", | 297 IrOpcode::kJSLoadNamed, Operator::kNoProperties, 1, 1, "JSLoadNamed", |
268 parameters); | 298 parameters); |
269 } | 299 } |
270 | 300 |
271 | 301 |
| 302 const Operator* JSOperatorBuilder::LoadProperty( |
| 303 const KeyedLoadICFeedbackNode& feedback) { |
| 304 LoadPropertyParameters parameters(feedback); |
| 305 return new (zone()) Operator1<LoadPropertyParameters>( |
| 306 IrOpcode::kJSLoadProperty, Operator::kNoProperties, 2, 1, |
| 307 "JSLoadProperty", parameters); |
| 308 } |
| 309 |
| 310 |
272 const Operator* JSOperatorBuilder::StoreProperty(StrictMode strict_mode) { | 311 const Operator* JSOperatorBuilder::StoreProperty(StrictMode strict_mode) { |
273 return new (zone()) | 312 return new (zone()) |
274 Operator1<StrictMode>(IrOpcode::kJSStoreProperty, Operator::kNoProperties, | 313 Operator1<StrictMode>(IrOpcode::kJSStoreProperty, Operator::kNoProperties, |
275 3, 0, "JSStoreProperty", strict_mode); | 314 3, 0, "JSStoreProperty", strict_mode); |
276 } | 315 } |
277 | 316 |
278 | 317 |
279 const Operator* JSOperatorBuilder::StoreNamed(StrictMode strict_mode, | 318 const Operator* JSOperatorBuilder::StoreNamed(StrictMode strict_mode, |
280 const Unique<Name>& name) { | 319 const Unique<Name>& name) { |
281 StoreNamedParameters parameters(strict_mode, name); | 320 StoreNamedParameters parameters(strict_mode, name); |
(...skipping 30 matching lines...) Expand all Loading... |
312 const Operator* JSOperatorBuilder::CreateCatchContext( | 351 const Operator* JSOperatorBuilder::CreateCatchContext( |
313 const Unique<String>& name) { | 352 const Unique<String>& name) { |
314 return new (zone()) Operator1<Unique<String>>(IrOpcode::kJSCreateCatchContext, | 353 return new (zone()) Operator1<Unique<String>>(IrOpcode::kJSCreateCatchContext, |
315 Operator::kNoProperties, 1, 1, | 354 Operator::kNoProperties, 1, 1, |
316 "JSCreateCatchContext", name); | 355 "JSCreateCatchContext", name); |
317 } | 356 } |
318 | 357 |
319 } // namespace compiler | 358 } // namespace compiler |
320 } // namespace internal | 359 } // namespace internal |
321 } // namespace v8 | 360 } // namespace v8 |
OLD | NEW |