| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 | 242 |
| 243 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { | 243 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { |
| 244 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); | 244 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); |
| 245 return OpParameter<LoadNamedParameters>(op); | 245 return OpParameter<LoadNamedParameters>(op); |
| 246 } | 246 } |
| 247 | 247 |
| 248 | 248 |
| 249 bool operator==(StoreNamedParameters const& lhs, | 249 bool operator==(StoreNamedParameters const& lhs, |
| 250 StoreNamedParameters const& rhs) { | 250 StoreNamedParameters const& rhs) { |
| 251 return lhs.language_mode() == rhs.language_mode() && lhs.name() == rhs.name(); | 251 return lhs.language_mode() == rhs.language_mode() && |
| 252 lhs.name() == rhs.name() && lhs.feedback() == rhs.feedback(); |
| 252 } | 253 } |
| 253 | 254 |
| 254 | 255 |
| 255 bool operator!=(StoreNamedParameters const& lhs, | 256 bool operator!=(StoreNamedParameters const& lhs, |
| 256 StoreNamedParameters const& rhs) { | 257 StoreNamedParameters const& rhs) { |
| 257 return !(lhs == rhs); | 258 return !(lhs == rhs); |
| 258 } | 259 } |
| 259 | 260 |
| 260 | 261 |
| 261 size_t hash_value(StoreNamedParameters const& p) { | 262 size_t hash_value(StoreNamedParameters const& p) { |
| 262 return base::hash_combine(p.language_mode(), p.name()); | 263 return base::hash_combine(p.language_mode(), p.name(), p.feedback()); |
| 263 } | 264 } |
| 264 | 265 |
| 265 | 266 |
| 266 std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) { | 267 std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) { |
| 267 return os << p.language_mode() << ", " << Brief(*p.name().handle()); | 268 return os << p.language_mode() << ", " << Brief(*p.name().handle()); |
| 268 } | 269 } |
| 269 | 270 |
| 270 | 271 |
| 271 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { | 272 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { |
| 272 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); | 273 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); |
| 273 return OpParameter<StoreNamedParameters>(op); | 274 return OpParameter<StoreNamedParameters>(op); |
| 274 } | 275 } |
| 275 | 276 |
| 276 | 277 |
| 278 bool operator==(StorePropertyParameters const& lhs, |
| 279 StorePropertyParameters const& rhs) { |
| 280 return lhs.language_mode() == rhs.language_mode() && |
| 281 lhs.feedback() == rhs.feedback(); |
| 282 } |
| 283 |
| 284 |
| 285 bool operator!=(StorePropertyParameters const& lhs, |
| 286 StorePropertyParameters const& rhs) { |
| 287 return !(lhs == rhs); |
| 288 } |
| 289 |
| 290 |
| 291 size_t hash_value(StorePropertyParameters const& p) { |
| 292 return base::hash_combine(p.language_mode(), p.feedback()); |
| 293 } |
| 294 |
| 295 |
| 296 std::ostream& operator<<(std::ostream& os, StorePropertyParameters const& p) { |
| 297 return os << p.language_mode(); |
| 298 } |
| 299 |
| 300 |
| 301 const StorePropertyParameters& StorePropertyParametersOf(const Operator* op) { |
| 302 DCHECK_EQ(IrOpcode::kJSStoreProperty, op->opcode()); |
| 303 return OpParameter<StorePropertyParameters>(op); |
| 304 } |
| 305 |
| 306 |
| 277 bool operator==(CreateClosureParameters const& lhs, | 307 bool operator==(CreateClosureParameters const& lhs, |
| 278 CreateClosureParameters const& rhs) { | 308 CreateClosureParameters const& rhs) { |
| 279 return lhs.pretenure() == rhs.pretenure() && | 309 return lhs.pretenure() == rhs.pretenure() && |
| 280 lhs.shared_info().is_identical_to(rhs.shared_info()); | 310 lhs.shared_info().is_identical_to(rhs.shared_info()); |
| 281 } | 311 } |
| 282 | 312 |
| 283 | 313 |
| 284 bool operator!=(CreateClosureParameters const& lhs, | 314 bool operator!=(CreateClosureParameters const& lhs, |
| 285 CreateClosureParameters const& rhs) { | 315 CreateClosureParameters const& rhs) { |
| 286 return !(lhs == rhs); | 316 return !(lhs == rhs); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 V(BitwiseOr, Operator::kNoProperties, 2, 1) \ | 371 V(BitwiseOr, Operator::kNoProperties, 2, 1) \ |
| 342 V(BitwiseXor, Operator::kNoProperties, 2, 1) \ | 372 V(BitwiseXor, Operator::kNoProperties, 2, 1) \ |
| 343 V(BitwiseAnd, Operator::kNoProperties, 2, 1) \ | 373 V(BitwiseAnd, Operator::kNoProperties, 2, 1) \ |
| 344 V(ShiftLeft, Operator::kNoProperties, 2, 1) \ | 374 V(ShiftLeft, Operator::kNoProperties, 2, 1) \ |
| 345 V(ShiftRight, Operator::kNoProperties, 2, 1) \ | 375 V(ShiftRight, Operator::kNoProperties, 2, 1) \ |
| 346 V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \ | 376 V(ShiftRightLogical, Operator::kNoProperties, 2, 1) \ |
| 347 V(Add, Operator::kNoProperties, 2, 1) \ | 377 V(Add, Operator::kNoProperties, 2, 1) \ |
| 348 V(Subtract, Operator::kNoProperties, 2, 1) \ | 378 V(Subtract, Operator::kNoProperties, 2, 1) \ |
| 349 V(Multiply, Operator::kNoProperties, 2, 1) \ | 379 V(Multiply, Operator::kNoProperties, 2, 1) \ |
| 350 V(Divide, Operator::kNoProperties, 2, 1) \ | 380 V(Divide, Operator::kNoProperties, 2, 1) \ |
| 351 V(Modulus, Operator::kNoProperties, 2, 1) \ | 381 V(Modulus, Operator::kNoProperties, 2, 1) |
| 352 V(StoreProperty, Operator::kNoProperties, 3, 0) | |
| 353 | 382 |
| 354 | 383 |
| 355 struct JSOperatorGlobalCache final { | 384 struct JSOperatorGlobalCache final { |
| 356 #define CACHED(Name, properties, value_input_count, value_output_count) \ | 385 #define CACHED(Name, properties, value_input_count, value_output_count) \ |
| 357 struct Name##Operator final : public Operator { \ | 386 struct Name##Operator final : public Operator { \ |
| 358 Name##Operator() \ | 387 Name##Operator() \ |
| 359 : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \ | 388 : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \ |
| 360 value_input_count, Operator::ZeroIfPure(properties), \ | 389 value_input_count, Operator::ZeroIfPure(properties), \ |
| 361 Operator::ZeroIfEliminatable(properties), \ | 390 Operator::ZeroIfEliminatable(properties), \ |
| 362 value_output_count, Operator::ZeroIfPure(properties), \ | 391 value_output_count, Operator::ZeroIfPure(properties), \ |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 const ResolvedFeedbackSlot& feedback) { | 502 const ResolvedFeedbackSlot& feedback) { |
| 474 LoadPropertyParameters parameters(feedback); | 503 LoadPropertyParameters parameters(feedback); |
| 475 return new (zone()) Operator1<LoadPropertyParameters>( // -- | 504 return new (zone()) Operator1<LoadPropertyParameters>( // -- |
| 476 IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode | 505 IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode |
| 477 "JSLoadProperty", // name | 506 "JSLoadProperty", // name |
| 478 3, 1, 1, 1, 1, 2, // counts | 507 3, 1, 1, 1, 1, 2, // counts |
| 479 parameters); // parameter | 508 parameters); // parameter |
| 480 } | 509 } |
| 481 | 510 |
| 482 | 511 |
| 483 const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode, | 512 const Operator* JSOperatorBuilder::StoreNamed( |
| 484 const Unique<Name>& name) { | 513 LanguageMode language_mode, const Unique<Name>& name, |
| 485 StoreNamedParameters parameters(language_mode, name); | 514 const ResolvedFeedbackSlot& feedback) { |
| 515 StoreNamedParameters parameters(language_mode, feedback, name); |
| 486 return new (zone()) Operator1<StoreNamedParameters>( // -- | 516 return new (zone()) Operator1<StoreNamedParameters>( // -- |
| 487 IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode | 517 IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode |
| 488 "JSStoreNamed", // name | 518 "JSStoreNamed", // name |
| 489 2, 1, 1, 0, 1, 2, // counts | 519 2, 1, 1, 0, 1, 2, // counts |
| 490 parameters); // parameter | 520 parameters); // parameter |
| 491 } | 521 } |
| 492 | 522 |
| 493 | 523 |
| 524 const Operator* JSOperatorBuilder::StoreProperty( |
| 525 LanguageMode language_mode, const ResolvedFeedbackSlot& feedback) { |
| 526 StorePropertyParameters parameters(language_mode, feedback); |
| 527 return new (zone()) Operator1<StorePropertyParameters>( // -- |
| 528 IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode |
| 529 "JSStoreProperty", // name |
| 530 3, 1, 1, 0, 1, 2, // counts |
| 531 parameters); // parameter |
| 532 } |
| 533 |
| 534 |
| 494 const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { | 535 const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { |
| 495 return new (zone()) Operator1<LanguageMode>( // -- | 536 return new (zone()) Operator1<LanguageMode>( // -- |
| 496 IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode | 537 IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode |
| 497 "JSDeleteProperty", // name | 538 "JSDeleteProperty", // name |
| 498 2, 1, 1, 1, 1, 2, // counts | 539 2, 1, 1, 1, 1, 2, // counts |
| 499 language_mode); // parameter | 540 language_mode); // parameter |
| 500 } | 541 } |
| 501 | 542 |
| 502 | 543 |
| 503 const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index, | 544 const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 return new (zone()) Operator1<Unique<String>>( // -- | 623 return new (zone()) Operator1<Unique<String>>( // -- |
| 583 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode | 624 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode |
| 584 "JSCreateCatchContext", // name | 625 "JSCreateCatchContext", // name |
| 585 2, 1, 1, 1, 1, 2, // counts | 626 2, 1, 1, 1, 1, 2, // counts |
| 586 name); // parameter | 627 name); // parameter |
| 587 } | 628 } |
| 588 | 629 |
| 589 } // namespace compiler | 630 } // namespace compiler |
| 590 } // namespace internal | 631 } // namespace internal |
| 591 } // namespace v8 | 632 } // namespace v8 |
| OLD | NEW |