| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 return hash_value(p.feedback()); | 242 return hash_value(p.feedback()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 | 245 |
| 246 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { | 246 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { |
| 247 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); | 247 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); |
| 248 return OpParameter<LoadNamedParameters>(op); | 248 return OpParameter<LoadNamedParameters>(op); |
| 249 } | 249 } |
| 250 | 250 |
| 251 | 251 |
| 252 const LoadNamedParameters& LoadGlobalParametersOf(const Operator* op) { |
| 253 DCHECK_EQ(IrOpcode::kJSLoadGlobal, op->opcode()); |
| 254 return OpParameter<LoadNamedParameters>(op); |
| 255 } |
| 256 |
| 257 |
| 252 bool operator==(StoreNamedParameters const& lhs, | 258 bool operator==(StoreNamedParameters const& lhs, |
| 253 StoreNamedParameters const& rhs) { | 259 StoreNamedParameters const& rhs) { |
| 254 return lhs.language_mode() == rhs.language_mode() && | 260 return lhs.language_mode() == rhs.language_mode() && |
| 255 lhs.name() == rhs.name() && lhs.feedback() == rhs.feedback(); | 261 lhs.name() == rhs.name() && lhs.feedback() == rhs.feedback(); |
| 256 } | 262 } |
| 257 | 263 |
| 258 | 264 |
| 259 bool operator!=(StoreNamedParameters const& lhs, | 265 bool operator!=(StoreNamedParameters const& lhs, |
| 260 StoreNamedParameters const& rhs) { | 266 StoreNamedParameters const& rhs) { |
| 261 return !(lhs == rhs); | 267 return !(lhs == rhs); |
| 262 } | 268 } |
| 263 | 269 |
| 264 | 270 |
| 265 size_t hash_value(StoreNamedParameters const& p) { | 271 size_t hash_value(StoreNamedParameters const& p) { |
| 266 return base::hash_combine(p.language_mode(), p.name(), p.feedback()); | 272 return base::hash_combine(p.language_mode(), p.name(), p.feedback()); |
| 267 } | 273 } |
| 268 | 274 |
| 269 | 275 |
| 270 std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) { | 276 std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) { |
| 271 return os << p.language_mode() << ", " << Brief(*p.name().handle()); | 277 return os << p.language_mode() << ", " << Brief(*p.name().handle()); |
| 272 } | 278 } |
| 273 | 279 |
| 274 | 280 |
| 275 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { | 281 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { |
| 276 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); | 282 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); |
| 277 return OpParameter<StoreNamedParameters>(op); | 283 return OpParameter<StoreNamedParameters>(op); |
| 278 } | 284 } |
| 279 | 285 |
| 280 | 286 |
| 287 const StoreNamedParameters& StoreGlobalParametersOf(const Operator* op) { |
| 288 DCHECK_EQ(IrOpcode::kJSStoreGlobal, op->opcode()); |
| 289 return OpParameter<StoreNamedParameters>(op); |
| 290 } |
| 291 |
| 292 |
| 281 bool operator==(StorePropertyParameters const& lhs, | 293 bool operator==(StorePropertyParameters const& lhs, |
| 282 StorePropertyParameters const& rhs) { | 294 StorePropertyParameters const& rhs) { |
| 283 return lhs.language_mode() == rhs.language_mode() && | 295 return lhs.language_mode() == rhs.language_mode() && |
| 284 lhs.feedback() == rhs.feedback(); | 296 lhs.feedback() == rhs.feedback(); |
| 285 } | 297 } |
| 286 | 298 |
| 287 | 299 |
| 288 bool operator!=(StorePropertyParameters const& lhs, | 300 bool operator!=(StorePropertyParameters const& lhs, |
| 289 StorePropertyParameters const& rhs) { | 301 StorePropertyParameters const& rhs) { |
| 290 return !(lhs == rhs); | 302 return !(lhs == rhs); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 const Operator* JSOperatorBuilder::CallConstruct(int arguments) { | 495 const Operator* JSOperatorBuilder::CallConstruct(int arguments) { |
| 484 return new (zone()) Operator1<int>( // -- | 496 return new (zone()) Operator1<int>( // -- |
| 485 IrOpcode::kJSCallConstruct, Operator::kNoProperties, // opcode | 497 IrOpcode::kJSCallConstruct, Operator::kNoProperties, // opcode |
| 486 "JSCallConstruct", // name | 498 "JSCallConstruct", // name |
| 487 arguments, 1, 1, 1, 1, 2, // counts | 499 arguments, 1, 1, 1, 1, 2, // counts |
| 488 arguments); // parameter | 500 arguments); // parameter |
| 489 } | 501 } |
| 490 | 502 |
| 491 | 503 |
| 492 const Operator* JSOperatorBuilder::LoadNamed(const Unique<Name>& name, | 504 const Operator* JSOperatorBuilder::LoadNamed(const Unique<Name>& name, |
| 493 const VectorSlotPair& feedback, | 505 const VectorSlotPair& feedback) { |
| 494 ContextualMode contextual_mode) { | 506 LoadNamedParameters parameters(name, feedback, NOT_CONTEXTUAL); |
| 495 LoadNamedParameters parameters(name, feedback, contextual_mode); | |
| 496 return new (zone()) Operator1<LoadNamedParameters>( // -- | 507 return new (zone()) Operator1<LoadNamedParameters>( // -- |
| 497 IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode | 508 IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode |
| 498 "JSLoadNamed", // name | 509 "JSLoadNamed", // name |
| 499 2, 1, 1, 1, 1, 2, // counts | 510 2, 1, 1, 1, 1, 2, // counts |
| 500 parameters); // parameter | 511 parameters); // parameter |
| 501 } | 512 } |
| 502 | 513 |
| 503 | 514 |
| 504 const Operator* JSOperatorBuilder::LoadProperty( | 515 const Operator* JSOperatorBuilder::LoadProperty( |
| 505 const VectorSlotPair& feedback) { | 516 const VectorSlotPair& feedback) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 | 548 |
| 538 const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { | 549 const Operator* JSOperatorBuilder::DeleteProperty(LanguageMode language_mode) { |
| 539 return new (zone()) Operator1<LanguageMode>( // -- | 550 return new (zone()) Operator1<LanguageMode>( // -- |
| 540 IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode | 551 IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode |
| 541 "JSDeleteProperty", // name | 552 "JSDeleteProperty", // name |
| 542 2, 1, 1, 1, 1, 2, // counts | 553 2, 1, 1, 1, 1, 2, // counts |
| 543 language_mode); // parameter | 554 language_mode); // parameter |
| 544 } | 555 } |
| 545 | 556 |
| 546 | 557 |
| 558 const Operator* JSOperatorBuilder::LoadGlobal(const Unique<Name>& name, |
| 559 const VectorSlotPair& feedback, |
| 560 ContextualMode contextual_mode) { |
| 561 LoadNamedParameters parameters(name, feedback, contextual_mode); |
| 562 return new (zone()) Operator1<LoadNamedParameters>( // -- |
| 563 IrOpcode::kJSLoadGlobal, Operator::kNoProperties, // opcode |
| 564 "JSLoadGlobal", // name |
| 565 2, 1, 1, 1, 1, 2, // counts |
| 566 parameters); // parameter |
| 567 } |
| 568 |
| 569 |
| 570 const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode, |
| 571 const Unique<Name>& name, |
| 572 const VectorSlotPair& feedback) { |
| 573 StoreNamedParameters parameters(language_mode, feedback, name); |
| 574 return new (zone()) Operator1<StoreNamedParameters>( // -- |
| 575 IrOpcode::kJSStoreGlobal, Operator::kNoProperties, // opcode |
| 576 "JSStoreGlobal", // name |
| 577 3, 1, 1, 0, 1, 2, // counts |
| 578 parameters); // parameter |
| 579 } |
| 580 |
| 581 |
| 547 const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index, | 582 const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index, |
| 548 bool immutable) { | 583 bool immutable) { |
| 549 ContextAccess access(depth, index, immutable); | 584 ContextAccess access(depth, index, immutable); |
| 550 return new (zone()) Operator1<ContextAccess>( // -- | 585 return new (zone()) Operator1<ContextAccess>( // -- |
| 551 IrOpcode::kJSLoadContext, // opcode | 586 IrOpcode::kJSLoadContext, // opcode |
| 552 Operator::kNoWrite | Operator::kNoThrow, // flags | 587 Operator::kNoWrite | Operator::kNoThrow, // flags |
| 553 "JSLoadContext", // name | 588 "JSLoadContext", // name |
| 554 1, 1, 0, 1, 1, 0, // counts | 589 1, 1, 0, 1, 1, 0, // counts |
| 555 access); // parameter | 590 access); // parameter |
| 556 } | 591 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 return new (zone()) Operator1<Unique<String>>( // -- | 661 return new (zone()) Operator1<Unique<String>>( // -- |
| 627 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode | 662 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode |
| 628 "JSCreateCatchContext", // name | 663 "JSCreateCatchContext", // name |
| 629 2, 1, 1, 1, 1, 2, // counts | 664 2, 1, 1, 1, 1, 2, // counts |
| 630 name); // parameter | 665 name); // parameter |
| 631 } | 666 } |
| 632 | 667 |
| 633 } // namespace compiler | 668 } // namespace compiler |
| 634 } // namespace internal | 669 } // namespace internal |
| 635 } // namespace v8 | 670 } // namespace v8 |
| OLD | NEW |