Chromium Code Reviews| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); | 206 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); |
| 207 return OpParameter<StoreNamedParameters>(op); | 207 return OpParameter<StoreNamedParameters>(op); |
| 208 } | 208 } |
| 209 | 209 |
| 210 | 210 |
| 211 #define CACHED_OP_LIST(V) \ | 211 #define CACHED_OP_LIST(V) \ |
| 212 V(Equal, Operator::kNoProperties, 2, 1) \ | 212 V(Equal, Operator::kNoProperties, 2, 1) \ |
| 213 V(NotEqual, Operator::kNoProperties, 2, 1) \ | 213 V(NotEqual, Operator::kNoProperties, 2, 1) \ |
| 214 V(StrictEqual, Operator::kPure, 2, 1) \ | 214 V(StrictEqual, Operator::kPure, 2, 1) \ |
| 215 V(StrictNotEqual, Operator::kPure, 2, 1) \ | 215 V(StrictNotEqual, Operator::kPure, 2, 1) \ |
| 216 V(LessThan, Operator::kNoProperties, 2, 1) \ | |
| 217 V(GreaterThan, Operator::kNoProperties, 2, 1) \ | |
| 218 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \ | |
| 219 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ | |
| 220 V(BitwiseOr, Operator::kNoProperties, 2, 1) \ | |
| 221 V(BitwiseXor, Operator::kNoProperties, 2, 1) \ | |
| 222 V(BitwiseAnd, Operator::kNoProperties, 2, 1) \ | |
| 223 V(ShiftLeft, Operator::kNoProperties, 2, 1) \ | |
| 224 V(ShiftRight, Operator::kNoProperties, 2, 1) \ | |
| 225 V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \ | |
| 226 V(Add, Operator::kNoProperties, 2, 1) \ | |
| 227 V(Subtract, Operator::kNoProperties, 2, 1) \ | |
| 228 V(Multiply, Operator::kNoProperties, 2, 1) \ | |
| 229 V(Divide, Operator::kNoProperties, 2, 1) \ | |
| 230 V(Modulus, Operator::kNoProperties, 2, 1) \ | |
| 231 V(UnaryNot, Operator::kPure, 1, 1) \ | |
| 232 V(ToBoolean, Operator::kPure, 1, 1) \ | 216 V(ToBoolean, Operator::kPure, 1, 1) \ |
| 233 V(ToNumber, Operator::kNoProperties, 1, 1) \ | 217 V(ToNumber, Operator::kNoProperties, 1, 1) \ |
| 234 V(ToString, Operator::kNoProperties, 1, 1) \ | 218 V(ToString, Operator::kNoProperties, 1, 1) \ |
| 235 V(ToName, Operator::kNoProperties, 1, 1) \ | 219 V(ToName, Operator::kNoProperties, 1, 1) \ |
| 236 V(ToObject, Operator::kNoProperties, 1, 1) \ | 220 V(ToObject, Operator::kNoProperties, 1, 1) \ |
| 237 V(Yield, Operator::kNoProperties, 1, 1) \ | 221 V(Yield, Operator::kNoProperties, 1, 1) \ |
| 238 V(Create, Operator::kEliminatable, 0, 1) \ | 222 V(Create, Operator::kEliminatable, 0, 1) \ |
| 239 V(HasProperty, Operator::kNoProperties, 2, 1) \ | 223 V(HasProperty, Operator::kNoProperties, 2, 1) \ |
| 240 V(TypeOf, Operator::kPure, 1, 1) \ | 224 V(TypeOf, Operator::kPure, 1, 1) \ |
| 241 V(InstanceOf, Operator::kNoProperties, 2, 1) \ | 225 V(InstanceOf, Operator::kNoProperties, 2, 1) \ |
| 242 V(StackCheck, Operator::kNoProperties, 0, 0) \ | 226 V(StackCheck, Operator::kNoProperties, 0, 0) \ |
| 243 V(CreateFunctionContext, Operator::kNoProperties, 1, 1) \ | 227 V(CreateFunctionContext, Operator::kNoProperties, 1, 1) \ |
| 244 V(CreateWithContext, Operator::kNoProperties, 2, 1) \ | 228 V(CreateWithContext, Operator::kNoProperties, 2, 1) \ |
| 245 V(CreateBlockContext, Operator::kNoProperties, 2, 1) \ | 229 V(CreateBlockContext, Operator::kNoProperties, 2, 1) \ |
| 246 V(CreateModuleContext, Operator::kNoProperties, 2, 1) \ | 230 V(CreateModuleContext, Operator::kNoProperties, 2, 1) \ |
| 247 V(CreateScriptContext, Operator::kNoProperties, 2, 1) | 231 V(CreateScriptContext, Operator::kNoProperties, 2, 1) |
| 248 | 232 |
| 233 #define CACHED_OP_LIST_WITH_STRONG(V) \ | |
|
Michael Starzinger
2015/04/23 13:47:51
nit: s/WITH_STRONG/WITH_LANGUAGE_MODE/
conradw
2015/04/23 14:51:54
These operators are specifically associated with a
Michael Starzinger
2015/04/23 15:20:53
Yep, the implementation only provides caches for S
conradw
2015/04/23 16:08:02
I'd like to keep something in the code drawing att
| |
| 234 V(LessThan, Operator::kNoProperties, 2, 1) \ | |
| 235 V(GreaterThan, Operator::kNoProperties, 2, 1) \ | |
| 236 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \ | |
| 237 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ | |
| 238 V(BitwiseOr, Operator::kNoProperties, 2, 1) \ | |
| 239 V(BitwiseXor, Operator::kNoProperties, 2, 1) \ | |
| 240 V(BitwiseAnd, Operator::kNoProperties, 2, 1) \ | |
| 241 V(ShiftLeft, Operator::kNoProperties, 2, 1) \ | |
| 242 V(ShiftRight, Operator::kNoProperties, 2, 1) \ | |
| 243 V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \ | |
| 244 V(Add, Operator::kNoProperties, 2, 1) \ | |
| 245 V(Subtract, Operator::kNoProperties, 2, 1) \ | |
| 246 V(Multiply, Operator::kNoProperties, 2, 1) \ | |
| 247 V(Divide, Operator::kNoProperties, 2, 1) \ | |
| 248 V(Modulus, Operator::kNoProperties, 2, 1) \ | |
| 249 V(UnaryNot, Operator::kPure, 1, 1) | |
| 250 | |
| 249 | 251 |
| 250 struct JSOperatorGlobalCache final { | 252 struct JSOperatorGlobalCache final { |
| 251 #define CACHED(Name, properties, value_input_count, value_output_count) \ | 253 #define CACHED(Name, properties, value_input_count, value_output_count) \ |
| 252 struct Name##Operator final : public Operator { \ | 254 struct Name##Operator final : public Operator { \ |
| 253 Name##Operator() \ | 255 Name##Operator() \ |
| 254 : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \ | 256 : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \ |
| 255 value_input_count, Operator::ZeroIfPure(properties), \ | 257 value_input_count, Operator::ZeroIfPure(properties), \ |
| 256 Operator::ZeroIfEliminatable(properties), \ | 258 Operator::ZeroIfEliminatable(properties), \ |
| 257 value_output_count, Operator::ZeroIfPure(properties), \ | 259 value_output_count, Operator::ZeroIfPure(properties), \ |
| 258 Operator::ZeroIfNoThrow(properties)) {} \ | 260 Operator::ZeroIfNoThrow(properties)) {} \ |
| 259 }; \ | 261 }; \ |
| 260 Name##Operator k##Name##Operator; | 262 Name##Operator k##Name##Operator; |
| 261 CACHED_OP_LIST(CACHED) | 263 CACHED_OP_LIST(CACHED) |
| 262 #undef CACHED | 264 #undef CACHED |
| 263 | 265 |
| 266 #define CACHED(Name, properties, value_input_count, value_output_count) \ | |
| 267 template <LanguageMode kLanguageMode> \ | |
| 268 struct Name##Operator final : public Operator1<LanguageMode> { \ | |
| 269 Name##Operator() \ | |
| 270 : Operator1<LanguageMode>(IrOpcode::kJS##Name, properties, "JS" #Name, \ | |
| 271 value_input_count, Operator::ZeroIfPure(properties), \ | |
| 272 Operator::ZeroIfEliminatable(properties), \ | |
| 273 value_output_count, Operator::ZeroIfPure(properties), \ | |
| 274 Operator::ZeroIfNoThrow(properties), kLanguageMode) {} \ | |
| 275 }; \ | |
| 276 Name##Operator<SLOPPY> k##Name##SloppyOperator; \ | |
| 277 Name##Operator<STRONG> k##Name##StrongOperator; | |
| 278 CACHED_OP_LIST_WITH_STRONG(CACHED) | |
| 279 #undef CACHED | |
| 280 | |
| 264 template <LanguageMode kLanguageMode> | 281 template <LanguageMode kLanguageMode> |
| 265 struct StorePropertyOperator final : public Operator1<LanguageMode> { | 282 struct StorePropertyOperator final : public Operator1<LanguageMode> { |
| 266 StorePropertyOperator() | 283 StorePropertyOperator() |
| 267 : Operator1<LanguageMode>(IrOpcode::kJSStoreProperty, | 284 : Operator1<LanguageMode>(IrOpcode::kJSStoreProperty, |
| 268 Operator::kNoProperties, "JSStoreProperty", 3, | 285 Operator::kNoProperties, "JSStoreProperty", 3, |
| 269 1, 1, 0, 1, 2, kLanguageMode) {} | 286 1, 1, 0, 1, 2, kLanguageMode) {} |
| 270 }; | 287 }; |
| 271 StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator; | 288 StorePropertyOperator<SLOPPY> kStorePropertySloppyOperator; |
| 272 StorePropertyOperator<STRICT> kStorePropertyStrictOperator; | 289 StorePropertyOperator<STRICT> kStorePropertyStrictOperator; |
| 273 }; | 290 }; |
| 274 | 291 |
| 275 | 292 |
| 276 static base::LazyInstance<JSOperatorGlobalCache>::type kCache = | 293 static base::LazyInstance<JSOperatorGlobalCache>::type kCache = |
| 277 LAZY_INSTANCE_INITIALIZER; | 294 LAZY_INSTANCE_INITIALIZER; |
| 278 | 295 |
| 279 | 296 |
| 280 JSOperatorBuilder::JSOperatorBuilder(Zone* zone) | 297 JSOperatorBuilder::JSOperatorBuilder(Zone* zone) |
| 281 : cache_(kCache.Get()), zone_(zone) {} | 298 : cache_(kCache.Get()), zone_(zone) {} |
| 282 | 299 |
| 283 | 300 |
| 284 #define CACHED(Name, properties, value_input_count, value_output_count) \ | 301 #define CACHED(Name, properties, value_input_count, value_output_count) \ |
| 285 const Operator* JSOperatorBuilder::Name() { \ | 302 const Operator* JSOperatorBuilder::Name() { \ |
| 286 return &cache_.k##Name##Operator; \ | 303 return &cache_.k##Name##Operator; \ |
| 287 } | 304 } |
| 288 CACHED_OP_LIST(CACHED) | 305 CACHED_OP_LIST(CACHED) |
| 289 #undef CACHED | 306 #undef CACHED |
| 290 | 307 |
| 308 #define CACHED(Name, properties, value_input_count, value_output_count) \ | |
| 309 const Operator* JSOperatorBuilder::Name(LanguageMode language_mode) { \ | |
| 310 if (is_strong(language_mode)) { \ | |
| 311 return &cache_.k##Name##StrongOperator; \ | |
| 312 } else { \ | |
| 313 return &cache_.k##Name##SloppyOperator; \ | |
| 314 } \ | |
| 315 UNREACHABLE(); \ | |
| 316 return nullptr; \ | |
| 317 } | |
| 318 CACHED_OP_LIST_WITH_STRONG(CACHED) | |
| 319 #undef CACHED | |
| 291 | 320 |
| 292 const Operator* JSOperatorBuilder::CallFunction(size_t arity, | 321 const Operator* JSOperatorBuilder::CallFunction(size_t arity, |
| 293 CallFunctionFlags flags) { | 322 CallFunctionFlags flags) { |
| 294 CallFunctionParameters parameters(arity, flags); | 323 CallFunctionParameters parameters(arity, flags); |
| 295 return new (zone()) Operator1<CallFunctionParameters>( // -- | 324 return new (zone()) Operator1<CallFunctionParameters>( // -- |
| 296 IrOpcode::kJSCallFunction, Operator::kNoProperties, // opcode | 325 IrOpcode::kJSCallFunction, Operator::kNoProperties, // opcode |
| 297 "JSCallFunction", // name | 326 "JSCallFunction", // name |
| 298 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs | 327 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs |
| 299 parameters); // parameter | 328 parameters); // parameter |
| 300 } | 329 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 return new (zone()) Operator1<Unique<String>>( // -- | 435 return new (zone()) Operator1<Unique<String>>( // -- |
| 407 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode | 436 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode |
| 408 "JSCreateCatchContext", // name | 437 "JSCreateCatchContext", // name |
| 409 2, 1, 1, 1, 1, 2, // counts | 438 2, 1, 1, 1, 1, 2, // counts |
| 410 name); // parameter | 439 name); // parameter |
| 411 } | 440 } |
| 412 | 441 |
| 413 } // namespace compiler | 442 } // namespace compiler |
| 414 } // namespace internal | 443 } // namespace internal |
| 415 } // namespace v8 | 444 } // namespace v8 |
| OLD | NEW |