| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 56     case TailCallMode::kAllow: | 56     case TailCallMode::kAllow: | 
| 57       return os << "ALLOW_TAIL_CALLS"; | 57       return os << "ALLOW_TAIL_CALLS"; | 
| 58     case TailCallMode::kDisallow: | 58     case TailCallMode::kDisallow: | 
| 59       return os << "DISALLOW_TAIL_CALLS"; | 59       return os << "DISALLOW_TAIL_CALLS"; | 
| 60   } | 60   } | 
| 61   UNREACHABLE(); | 61   UNREACHABLE(); | 
| 62   return os; | 62   return os; | 
| 63 } | 63 } | 
| 64 | 64 | 
| 65 | 65 | 
|  | 66 bool operator==(CallConstructParameters const& lhs, | 
|  | 67                 CallConstructParameters const& rhs) { | 
|  | 68   return lhs.arity() == rhs.arity() && lhs.feedback() == rhs.feedback(); | 
|  | 69 } | 
|  | 70 | 
|  | 71 | 
|  | 72 bool operator!=(CallConstructParameters const& lhs, | 
|  | 73                 CallConstructParameters const& rhs) { | 
|  | 74   return !(lhs == rhs); | 
|  | 75 } | 
|  | 76 | 
|  | 77 | 
|  | 78 size_t hash_value(CallConstructParameters const& p) { | 
|  | 79   return base::hash_combine(p.arity(), p.feedback()); | 
|  | 80 } | 
|  | 81 | 
|  | 82 | 
|  | 83 std::ostream& operator<<(std::ostream& os, CallConstructParameters const& p) { | 
|  | 84   return os << p.arity(); | 
|  | 85 } | 
|  | 86 | 
|  | 87 | 
|  | 88 CallConstructParameters const& CallConstructParametersOf(Operator const* op) { | 
|  | 89   DCHECK_EQ(IrOpcode::kJSCallConstruct, op->opcode()); | 
|  | 90   return OpParameter<CallConstructParameters>(op); | 
|  | 91 } | 
|  | 92 | 
|  | 93 | 
| 66 std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) { | 94 std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) { | 
| 67   os << p.arity() << ", " << p.language_mode() << ", " << p.convert_mode() | 95   os << p.arity() << ", " << p.language_mode() << ", " << p.convert_mode() | 
| 68      << ", " << p.tail_call_mode(); | 96      << ", " << p.tail_call_mode(); | 
| 69   return os; | 97   return os; | 
| 70 } | 98 } | 
| 71 | 99 | 
| 72 | 100 | 
| 73 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) { | 101 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) { | 
| 74   DCHECK_EQ(IrOpcode::kJSCallFunction, op->opcode()); | 102   DCHECK_EQ(IrOpcode::kJSCallFunction, op->opcode()); | 
| 75   return OpParameter<CallFunctionParameters>(op); | 103   return OpParameter<CallFunctionParameters>(op); | 
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 315 } | 343 } | 
| 316 | 344 | 
| 317 | 345 | 
| 318 const CreateArgumentsParameters& CreateArgumentsParametersOf( | 346 const CreateArgumentsParameters& CreateArgumentsParametersOf( | 
| 319     const Operator* op) { | 347     const Operator* op) { | 
| 320   DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode()); | 348   DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode()); | 
| 321   return OpParameter<CreateArgumentsParameters>(op); | 349   return OpParameter<CreateArgumentsParameters>(op); | 
| 322 } | 350 } | 
| 323 | 351 | 
| 324 | 352 | 
|  | 353 bool operator==(CreateArrayParameters const& lhs, | 
|  | 354                 CreateArrayParameters const& rhs) { | 
|  | 355   return lhs.arity() == rhs.arity() && | 
|  | 356          lhs.site().location() == rhs.site().location(); | 
|  | 357 } | 
|  | 358 | 
|  | 359 | 
|  | 360 bool operator!=(CreateArrayParameters const& lhs, | 
|  | 361                 CreateArrayParameters const& rhs) { | 
|  | 362   return !(lhs == rhs); | 
|  | 363 } | 
|  | 364 | 
|  | 365 | 
|  | 366 size_t hash_value(CreateArrayParameters const& p) { | 
|  | 367   return base::hash_combine(p.arity(), p.site().location()); | 
|  | 368 } | 
|  | 369 | 
|  | 370 | 
|  | 371 std::ostream& operator<<(std::ostream& os, CreateArrayParameters const& p) { | 
|  | 372   os << p.arity(); | 
|  | 373   if (!p.site().is_null()) os << ", " << Brief(*p.site()); | 
|  | 374   return os; | 
|  | 375 } | 
|  | 376 | 
|  | 377 | 
|  | 378 const CreateArrayParameters& CreateArrayParametersOf(const Operator* op) { | 
|  | 379   DCHECK_EQ(IrOpcode::kJSCreateArray, op->opcode()); | 
|  | 380   return OpParameter<CreateArrayParameters>(op); | 
|  | 381 } | 
|  | 382 | 
|  | 383 | 
| 325 bool operator==(CreateClosureParameters const& lhs, | 384 bool operator==(CreateClosureParameters const& lhs, | 
| 326                 CreateClosureParameters const& rhs) { | 385                 CreateClosureParameters const& rhs) { | 
| 327   return lhs.pretenure() == rhs.pretenure() && | 386   return lhs.pretenure() == rhs.pretenure() && | 
| 328          lhs.shared_info().location() == rhs.shared_info().location(); | 387          lhs.shared_info().location() == rhs.shared_info().location(); | 
| 329 } | 388 } | 
| 330 | 389 | 
| 331 | 390 | 
| 332 bool operator!=(CreateClosureParameters const& lhs, | 391 bool operator!=(CreateClosureParameters const& lhs, | 
| 333                 CreateClosureParameters const& rhs) { | 392                 CreateClosureParameters const& rhs) { | 
| 334   return !(lhs == rhs); | 393   return !(lhs == rhs); | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 367   V(HasProperty, Operator::kNoProperties, 2, 1)       \ | 426   V(HasProperty, Operator::kNoProperties, 2, 1)       \ | 
| 368   V(TypeOf, Operator::kEliminatable, 1, 1)            \ | 427   V(TypeOf, Operator::kEliminatable, 1, 1)            \ | 
| 369   V(InstanceOf, Operator::kNoProperties, 2, 1)        \ | 428   V(InstanceOf, Operator::kNoProperties, 2, 1)        \ | 
| 370   V(ForInDone, Operator::kPure, 2, 1)                 \ | 429   V(ForInDone, Operator::kPure, 2, 1)                 \ | 
| 371   V(ForInNext, Operator::kNoProperties, 4, 1)         \ | 430   V(ForInNext, Operator::kNoProperties, 4, 1)         \ | 
| 372   V(ForInPrepare, Operator::kNoProperties, 1, 3)      \ | 431   V(ForInPrepare, Operator::kNoProperties, 1, 3)      \ | 
| 373   V(ForInStep, Operator::kPure, 1, 1)                 \ | 432   V(ForInStep, Operator::kPure, 1, 1)                 \ | 
| 374   V(LoadMessage, Operator::kNoThrow, 0, 1)            \ | 433   V(LoadMessage, Operator::kNoThrow, 0, 1)            \ | 
| 375   V(StoreMessage, Operator::kNoThrow, 1, 0)           \ | 434   V(StoreMessage, Operator::kNoThrow, 1, 0)           \ | 
| 376   V(StackCheck, Operator::kNoProperties, 0, 0)        \ | 435   V(StackCheck, Operator::kNoProperties, 0, 0)        \ | 
|  | 436   V(LoadNativeContext, Operator::kEliminatable, 1, 1) \ | 
| 377   V(CreateWithContext, Operator::kNoProperties, 2, 1) \ | 437   V(CreateWithContext, Operator::kNoProperties, 2, 1) \ | 
| 378   V(CreateModuleContext, Operator::kNoProperties, 2, 1) | 438   V(CreateModuleContext, Operator::kNoProperties, 2, 1) | 
| 379 | 439 | 
| 380 | 440 | 
| 381 #define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V)           \ | 441 #define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V)           \ | 
| 382   V(LessThan, Operator::kNoProperties, 2, 1)           \ | 442   V(LessThan, Operator::kNoProperties, 2, 1)           \ | 
| 383   V(GreaterThan, Operator::kNoProperties, 2, 1)        \ | 443   V(GreaterThan, Operator::kNoProperties, 2, 1)        \ | 
| 384   V(LessThanOrEqual, Operator::kNoProperties, 2, 1)    \ | 444   V(LessThanOrEqual, Operator::kNoProperties, 2, 1)    \ | 
| 385   V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ | 445   V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ | 
| 386   V(BitwiseOr, Operator::kNoProperties, 2, 1)          \ | 446   V(BitwiseOr, Operator::kNoProperties, 2, 1)          \ | 
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 486   const Runtime::Function* f = Runtime::FunctionForId(parameters.id()); | 546   const Runtime::Function* f = Runtime::FunctionForId(parameters.id()); | 
| 487   DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity())); | 547   DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity())); | 
| 488   return new (zone()) Operator1<CallRuntimeParameters>(   // -- | 548   return new (zone()) Operator1<CallRuntimeParameters>(   // -- | 
| 489       IrOpcode::kJSCallRuntime, Operator::kNoProperties,  // opcode | 549       IrOpcode::kJSCallRuntime, Operator::kNoProperties,  // opcode | 
| 490       "JSCallRuntime",                                    // name | 550       "JSCallRuntime",                                    // name | 
| 491       parameters.arity(), 1, 1, f->result_size, 1, 2,     // inputs/outputs | 551       parameters.arity(), 1, 1, f->result_size, 1, 2,     // inputs/outputs | 
| 492       parameters);                                        // parameter | 552       parameters);                                        // parameter | 
| 493 } | 553 } | 
| 494 | 554 | 
| 495 | 555 | 
| 496 const Operator* JSOperatorBuilder::CallConstruct(int arguments) { | 556 const Operator* JSOperatorBuilder::CallConstruct( | 
| 497   return new (zone()) Operator1<int>(                       // -- | 557     size_t arity, VectorSlotPair const& feedback) { | 
|  | 558   CallConstructParameters parameters(arity, feedback); | 
|  | 559   return new (zone()) Operator1<CallConstructParameters>(   // -- | 
| 498       IrOpcode::kJSCallConstruct, Operator::kNoProperties,  // opcode | 560       IrOpcode::kJSCallConstruct, Operator::kNoProperties,  // opcode | 
| 499       "JSCallConstruct",                                    // name | 561       "JSCallConstruct",                                    // name | 
| 500       arguments, 1, 1, 1, 1, 2,                             // counts | 562       parameters.arity(), 1, 1, 1, 1, 2,                    // counts | 
| 501       arguments);                                           // parameter | 563       parameters);                                          // parameter | 
| 502 } | 564 } | 
| 503 | 565 | 
| 504 | 566 | 
| 505 const Operator* JSOperatorBuilder::ConvertReceiver( | 567 const Operator* JSOperatorBuilder::ConvertReceiver( | 
| 506     ConvertReceiverMode convert_mode) { | 568     ConvertReceiverMode convert_mode) { | 
| 507   return new (zone()) Operator1<ConvertReceiverMode>(    // -- | 569   return new (zone()) Operator1<ConvertReceiverMode>(    // -- | 
| 508       IrOpcode::kJSConvertReceiver, Operator::kNoThrow,  // opcode | 570       IrOpcode::kJSConvertReceiver, Operator::kNoThrow,  // opcode | 
| 509       "JSConvertReceiver",                               // name | 571       "JSConvertReceiver",                               // name | 
| 510       1, 1, 1, 1, 1, 0,                                  // counts | 572       1, 1, 1, 1, 1, 0,                                  // counts | 
| 511       convert_mode);                                     // parameter | 573       convert_mode);                                     // parameter | 
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 630   DCHECK_IMPLIES(start_index, type == CreateArgumentsParameters::kRestArray); | 692   DCHECK_IMPLIES(start_index, type == CreateArgumentsParameters::kRestArray); | 
| 631   CreateArgumentsParameters parameters(type, start_index); | 693   CreateArgumentsParameters parameters(type, start_index); | 
| 632   return new (zone()) Operator1<CreateArgumentsParameters>(  // -- | 694   return new (zone()) Operator1<CreateArgumentsParameters>(  // -- | 
| 633       IrOpcode::kJSCreateArguments, Operator::kNoThrow,      // opcode | 695       IrOpcode::kJSCreateArguments, Operator::kNoThrow,      // opcode | 
| 634       "JSCreateArguments",                                   // name | 696       "JSCreateArguments",                                   // name | 
| 635       1, 1, 1, 1, 1, 0,                                      // counts | 697       1, 1, 1, 1, 1, 0,                                      // counts | 
| 636       parameters);                                           // parameter | 698       parameters);                                           // parameter | 
| 637 } | 699 } | 
| 638 | 700 | 
| 639 | 701 | 
|  | 702 const Operator* JSOperatorBuilder::CreateArray(size_t arity, | 
|  | 703                                                Handle<AllocationSite> site) { | 
|  | 704   // constructor, new_target, arg1, ..., argN | 
|  | 705   int const value_input_count = static_cast<int>(arity) + 2; | 
|  | 706   CreateArrayParameters parameters(arity, site); | 
|  | 707   return new (zone()) Operator1<CreateArrayParameters>(   // -- | 
|  | 708       IrOpcode::kJSCreateArray, Operator::kNoProperties,  // opcode | 
|  | 709       "JSCreateArray",                                    // name | 
|  | 710       value_input_count, 1, 1, 1, 1, 2,                   // counts | 
|  | 711       parameters);                                        // parameter | 
|  | 712 } | 
|  | 713 | 
|  | 714 | 
| 640 const Operator* JSOperatorBuilder::CreateClosure( | 715 const Operator* JSOperatorBuilder::CreateClosure( | 
| 641     Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { | 716     Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { | 
| 642   CreateClosureParameters parameters(shared_info, pretenure); | 717   CreateClosureParameters parameters(shared_info, pretenure); | 
| 643   return new (zone()) Operator1<CreateClosureParameters>(  // -- | 718   return new (zone()) Operator1<CreateClosureParameters>(  // -- | 
| 644       IrOpcode::kJSCreateClosure, Operator::kNoThrow,      // opcode | 719       IrOpcode::kJSCreateClosure, Operator::kNoThrow,      // opcode | 
| 645       "JSCreateClosure",                                   // name | 720       "JSCreateClosure",                                   // name | 
| 646       0, 1, 1, 1, 1, 0,                                    // counts | 721       0, 1, 1, 1, 1, 0,                                    // counts | 
| 647       parameters);                                         // parameter | 722       parameters);                                         // parameter | 
| 648 } | 723 } | 
| 649 | 724 | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 700   return new (zone()) Operator1<Handle<ScopeInfo>>(               // -- | 775   return new (zone()) Operator1<Handle<ScopeInfo>>(               // -- | 
| 701       IrOpcode::kJSCreateScriptContext, Operator::kNoProperties,  // opcode | 776       IrOpcode::kJSCreateScriptContext, Operator::kNoProperties,  // opcode | 
| 702       "JSCreateScriptContext",                                    // name | 777       "JSCreateScriptContext",                                    // name | 
| 703       1, 1, 1, 1, 1, 2,                                           // counts | 778       1, 1, 1, 1, 1, 2,                                           // counts | 
| 704       scpope_info);                                               // parameter | 779       scpope_info);                                               // parameter | 
| 705 } | 780 } | 
| 706 | 781 | 
| 707 }  // namespace compiler | 782 }  // namespace compiler | 
| 708 }  // namespace internal | 783 }  // namespace internal | 
| 709 }  // namespace v8 | 784 }  // namespace v8 | 
| OLD | NEW | 
|---|