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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 std::ostream& operator<<(std::ostream& os, ConstructParameters const& p) { | 70 std::ostream& operator<<(std::ostream& os, ConstructParameters const& p) { |
71 return os << p.arity() << ", " << p.frequency(); | 71 return os << p.arity() << ", " << p.frequency(); |
72 } | 72 } |
73 | 73 |
74 ConstructParameters const& ConstructParametersOf(Operator const* op) { | 74 ConstructParameters const& ConstructParametersOf(Operator const* op) { |
75 DCHECK_EQ(IrOpcode::kJSConstruct, op->opcode()); | 75 DCHECK_EQ(IrOpcode::kJSConstruct, op->opcode()); |
76 return OpParameter<ConstructParameters>(op); | 76 return OpParameter<ConstructParameters>(op); |
77 } | 77 } |
78 | 78 |
79 bool operator==(SpreadWithArityParameters const& lhs, | 79 bool operator==(SpreadWithArityParameter const& lhs, |
80 SpreadWithArityParameters const& rhs) { | 80 SpreadWithArityParameter const& rhs) { |
81 return lhs.arity() == rhs.arity(); | 81 return lhs.arity() == rhs.arity(); |
82 } | 82 } |
83 | 83 |
84 bool operator!=(SpreadWithArityParameters const& lhs, | 84 bool operator!=(SpreadWithArityParameter const& lhs, |
85 SpreadWithArityParameters const& rhs) { | 85 SpreadWithArityParameter const& rhs) { |
86 return !(lhs == rhs); | 86 return !(lhs == rhs); |
87 } | 87 } |
88 | 88 |
89 size_t hash_value(SpreadWithArityParameters const& p) { | 89 size_t hash_value(SpreadWithArityParameter const& p) { |
90 return base::hash_combine(p.arity()); | 90 return base::hash_combine(p.arity()); |
91 } | 91 } |
92 | 92 |
93 std::ostream& operator<<(std::ostream& os, SpreadWithArityParameters const& p) { | 93 std::ostream& operator<<(std::ostream& os, SpreadWithArityParameter const& p) { |
94 return os << p.arity(); | 94 return os << p.arity(); |
95 } | 95 } |
96 | 96 |
97 SpreadWithArityParameters const& SpreadWithArityParametersOf( | 97 SpreadWithArityParameter const& SpreadWithArityParameterOf(Operator const* op) { |
98 Operator const* op) { | |
99 DCHECK(op->opcode() == IrOpcode::kJSConstructWithSpread || | 98 DCHECK(op->opcode() == IrOpcode::kJSConstructWithSpread || |
100 op->opcode() == IrOpcode::kJSCallWithSpread); | 99 op->opcode() == IrOpcode::kJSCallWithSpread); |
101 return OpParameter<SpreadWithArityParameters>(op); | 100 return OpParameter<SpreadWithArityParameter>(op); |
102 } | 101 } |
103 | 102 |
104 std::ostream& operator<<(std::ostream& os, CallParameters const& p) { | 103 std::ostream& operator<<(std::ostream& os, CallParameters const& p) { |
105 os << p.arity() << ", " << p.frequency() << ", " << p.convert_mode() << ", " | 104 os << p.arity() << ", " << p.frequency() << ", " << p.convert_mode() << ", " |
106 << p.tail_call_mode(); | 105 << p.tail_call_mode(); |
107 return os; | 106 return os; |
108 } | 107 } |
109 | 108 |
110 const CallParameters& CallParametersOf(const Operator* op) { | 109 const CallParameters& CallParametersOf(const Operator* op) { |
111 DCHECK_EQ(IrOpcode::kJSCall, op->opcode()); | 110 DCHECK_EQ(IrOpcode::kJSCall, op->opcode()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 268 |
270 std::ostream& operator<<(std::ostream& os, StoreNamedOwnParameters const& p) { | 269 std::ostream& operator<<(std::ostream& os, StoreNamedOwnParameters const& p) { |
271 return os << Brief(*p.name()); | 270 return os << Brief(*p.name()); |
272 } | 271 } |
273 | 272 |
274 StoreNamedOwnParameters const& StoreNamedOwnParametersOf(const Operator* op) { | 273 StoreNamedOwnParameters const& StoreNamedOwnParametersOf(const Operator* op) { |
275 DCHECK_EQ(IrOpcode::kJSStoreNamedOwn, op->opcode()); | 274 DCHECK_EQ(IrOpcode::kJSStoreNamedOwn, op->opcode()); |
276 return OpParameter<StoreNamedOwnParameters>(op); | 275 return OpParameter<StoreNamedOwnParameters>(op); |
277 } | 276 } |
278 | 277 |
279 bool operator==(DataPropertyParameters const& lhs, | 278 bool operator==(FeedbackParameter const& lhs, FeedbackParameter const& rhs) { |
280 DataPropertyParameters const& rhs) { | |
281 return lhs.feedback() == rhs.feedback(); | 279 return lhs.feedback() == rhs.feedback(); |
282 } | 280 } |
283 | 281 |
284 bool operator!=(DataPropertyParameters const& lhs, | 282 bool operator!=(FeedbackParameter const& lhs, FeedbackParameter const& rhs) { |
285 DataPropertyParameters const& rhs) { | |
286 return !(lhs == rhs); | 283 return !(lhs == rhs); |
287 } | 284 } |
288 | 285 |
289 size_t hash_value(DataPropertyParameters const& p) { | 286 size_t hash_value(FeedbackParameter const& p) { |
290 return base::hash_combine(p.feedback()); | 287 return base::hash_combine(p.feedback()); |
291 } | 288 } |
292 | 289 |
293 std::ostream& operator<<(std::ostream& os, DataPropertyParameters const& p) { | 290 std::ostream& operator<<(std::ostream& os, FeedbackParameter const& p) { |
294 return os; | 291 return os; |
295 } | 292 } |
296 | 293 |
297 DataPropertyParameters const& DataPropertyParametersOf(const Operator* op) { | 294 FeedbackParameter const& FeedbackParameterOf(const Operator* op) { |
298 DCHECK(op->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral); | 295 DCHECK(op->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral); |
299 return OpParameter<DataPropertyParameters>(op); | 296 return OpParameter<FeedbackParameter>(op); |
300 } | 297 } |
301 | 298 |
302 bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) { | 299 bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) { |
303 return lhs.name().location() == rhs.name().location() && | 300 return lhs.name().location() == rhs.name().location() && |
304 lhs.language_mode() == rhs.language_mode() && | 301 lhs.language_mode() == rhs.language_mode() && |
305 lhs.feedback() == rhs.feedback(); | 302 lhs.feedback() == rhs.feedback(); |
306 } | 303 } |
307 | 304 |
308 | 305 |
309 bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) { | 306 bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) { |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 return &cache_.k##Name##AnyOperator; \ | 691 return &cache_.k##Name##AnyOperator; \ |
695 } \ | 692 } \ |
696 UNREACHABLE(); \ | 693 UNREACHABLE(); \ |
697 return nullptr; \ | 694 return nullptr; \ |
698 } | 695 } |
699 COMPARE_OP_LIST(COMPARE_OP) | 696 COMPARE_OP_LIST(COMPARE_OP) |
700 #undef COMPARE_OP | 697 #undef COMPARE_OP |
701 | 698 |
702 const Operator* JSOperatorBuilder::StoreDataPropertyInLiteral( | 699 const Operator* JSOperatorBuilder::StoreDataPropertyInLiteral( |
703 const VectorSlotPair& feedback) { | 700 const VectorSlotPair& feedback) { |
704 DataPropertyParameters parameters(feedback); | 701 FeedbackParameter parameters(feedback); |
705 return new (zone()) Operator1<DataPropertyParameters>( // -- | 702 return new (zone()) Operator1<FeedbackParameter>( // -- |
706 IrOpcode::kJSStoreDataPropertyInLiteral, | 703 IrOpcode::kJSStoreDataPropertyInLiteral, |
707 Operator::kNoThrow, // opcode | 704 Operator::kNoThrow, // opcode |
708 "JSStoreDataPropertyInLiteral", // name | 705 "JSStoreDataPropertyInLiteral", // name |
709 4, 1, 1, 0, 1, 0, // counts | 706 4, 1, 1, 0, 1, 0, // counts |
710 parameters); // parameter | 707 parameters); // parameter |
711 } | 708 } |
712 | 709 |
713 const Operator* JSOperatorBuilder::ToBoolean(ToBooleanHints hints) { | 710 const Operator* JSOperatorBuilder::ToBoolean(ToBooleanHints hints) { |
714 // TODO(turbofan): Cache most important versions of this operator. | 711 // TODO(turbofan): Cache most important versions of this operator. |
715 return new (zone()) Operator1<ToBooleanHints>( //-- | 712 return new (zone()) Operator1<ToBooleanHints>( //-- |
(...skipping 20 matching lines...) Expand all Loading... |
736 CallParameters parameters(arity, frequency, feedback, tail_call_mode, | 733 CallParameters parameters(arity, frequency, feedback, tail_call_mode, |
737 convert_mode); | 734 convert_mode); |
738 return new (zone()) Operator1<CallParameters>( // -- | 735 return new (zone()) Operator1<CallParameters>( // -- |
739 IrOpcode::kJSCall, Operator::kNoProperties, // opcode | 736 IrOpcode::kJSCall, Operator::kNoProperties, // opcode |
740 "JSCall", // name | 737 "JSCall", // name |
741 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs | 738 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs |
742 parameters); // parameter | 739 parameters); // parameter |
743 } | 740 } |
744 | 741 |
745 const Operator* JSOperatorBuilder::CallWithSpread(uint32_t arity) { | 742 const Operator* JSOperatorBuilder::CallWithSpread(uint32_t arity) { |
746 SpreadWithArityParameters parameters(arity); | 743 SpreadWithArityParameter parameters(arity); |
747 return new (zone()) Operator1<SpreadWithArityParameters>( // -- | 744 return new (zone()) Operator1<SpreadWithArityParameter>( // -- |
748 IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode | 745 IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode |
749 "JSCallWithSpread", // name | 746 "JSCallWithSpread", // name |
750 parameters.arity(), 1, 1, 1, 1, 2, // counts | 747 parameters.arity(), 1, 1, 1, 1, 2, // counts |
751 parameters); // parameter | 748 parameters); // parameter |
752 } | 749 } |
753 | 750 |
754 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) { | 751 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) { |
755 const Runtime::Function* f = Runtime::FunctionForId(id); | 752 const Runtime::Function* f = Runtime::FunctionForId(id); |
756 return CallRuntime(f, f->nargs); | 753 return CallRuntime(f, f->nargs); |
757 } | 754 } |
(...skipping 21 matching lines...) Expand all Loading... |
779 VectorSlotPair const& feedback) { | 776 VectorSlotPair const& feedback) { |
780 ConstructParameters parameters(arity, frequency, feedback); | 777 ConstructParameters parameters(arity, frequency, feedback); |
781 return new (zone()) Operator1<ConstructParameters>( // -- | 778 return new (zone()) Operator1<ConstructParameters>( // -- |
782 IrOpcode::kJSConstruct, Operator::kNoProperties, // opcode | 779 IrOpcode::kJSConstruct, Operator::kNoProperties, // opcode |
783 "JSConstruct", // name | 780 "JSConstruct", // name |
784 parameters.arity(), 1, 1, 1, 1, 2, // counts | 781 parameters.arity(), 1, 1, 1, 1, 2, // counts |
785 parameters); // parameter | 782 parameters); // parameter |
786 } | 783 } |
787 | 784 |
788 const Operator* JSOperatorBuilder::ConstructWithSpread(uint32_t arity) { | 785 const Operator* JSOperatorBuilder::ConstructWithSpread(uint32_t arity) { |
789 SpreadWithArityParameters parameters(arity); | 786 SpreadWithArityParameter parameters(arity); |
790 return new (zone()) Operator1<SpreadWithArityParameters>( // -- | 787 return new (zone()) Operator1<SpreadWithArityParameter>( // -- |
791 IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode | 788 IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode |
792 "JSConstructWithSpread", // name | 789 "JSConstructWithSpread", // name |
793 parameters.arity(), 1, 1, 1, 1, 2, // counts | 790 parameters.arity(), 1, 1, 1, 1, 2, // counts |
794 parameters); // parameter | 791 parameters); // parameter |
795 } | 792 } |
796 | 793 |
797 const Operator* JSOperatorBuilder::ConvertReceiver( | 794 const Operator* JSOperatorBuilder::ConvertReceiver( |
798 ConvertReceiverMode convert_mode) { | 795 ConvertReceiverMode convert_mode) { |
799 return new (zone()) Operator1<ConvertReceiverMode>( // -- | 796 return new (zone()) Operator1<ConvertReceiverMode>( // -- |
800 IrOpcode::kJSConvertReceiver, Operator::kEliminatable, // opcode | 797 IrOpcode::kJSConvertReceiver, Operator::kEliminatable, // opcode |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- | 1052 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- |
1056 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode | 1053 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode |
1057 "JSCreateScriptContext", // name | 1054 "JSCreateScriptContext", // name |
1058 1, 1, 1, 1, 1, 2, // counts | 1055 1, 1, 1, 1, 1, 2, // counts |
1059 scope_info); // parameter | 1056 scope_info); // parameter |
1060 } | 1057 } |
1061 | 1058 |
1062 } // namespace compiler | 1059 } // namespace compiler |
1063 } // namespace internal | 1060 } // namespace internal |
1064 } // namespace v8 | 1061 } // namespace v8 |
OLD | NEW |