| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 DCHECK_EQ(IrOpcode::kJSConvertReceiver, op->opcode()); | 45 DCHECK_EQ(IrOpcode::kJSConvertReceiver, op->opcode()); |
| 46 return OpParameter<ConvertReceiverMode>(op); | 46 return OpParameter<ConvertReceiverMode>(op); |
| 47 } | 47 } |
| 48 | 48 |
| 49 | 49 |
| 50 ToBooleanHints ToBooleanHintsOf(Operator const* op) { | 50 ToBooleanHints ToBooleanHintsOf(Operator const* op) { |
| 51 DCHECK_EQ(IrOpcode::kJSToBoolean, op->opcode()); | 51 DCHECK_EQ(IrOpcode::kJSToBoolean, op->opcode()); |
| 52 return OpParameter<ToBooleanHints>(op); | 52 return OpParameter<ToBooleanHints>(op); |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 bool operator==(ConstructParameters const& lhs, |
| 56 bool operator==(CallConstructParameters const& lhs, | 56 ConstructParameters const& rhs) { |
| 57 CallConstructParameters const& rhs) { | |
| 58 return lhs.arity() == rhs.arity() && lhs.frequency() == rhs.frequency() && | 57 return lhs.arity() == rhs.arity() && lhs.frequency() == rhs.frequency() && |
| 59 lhs.feedback() == rhs.feedback(); | 58 lhs.feedback() == rhs.feedback(); |
| 60 } | 59 } |
| 61 | 60 |
| 62 | 61 bool operator!=(ConstructParameters const& lhs, |
| 63 bool operator!=(CallConstructParameters const& lhs, | 62 ConstructParameters const& rhs) { |
| 64 CallConstructParameters const& rhs) { | |
| 65 return !(lhs == rhs); | 63 return !(lhs == rhs); |
| 66 } | 64 } |
| 67 | 65 |
| 68 | 66 size_t hash_value(ConstructParameters const& p) { |
| 69 size_t hash_value(CallConstructParameters const& p) { | |
| 70 return base::hash_combine(p.arity(), p.frequency(), p.feedback()); | 67 return base::hash_combine(p.arity(), p.frequency(), p.feedback()); |
| 71 } | 68 } |
| 72 | 69 |
| 73 | 70 std::ostream& operator<<(std::ostream& os, ConstructParameters const& p) { |
| 74 std::ostream& operator<<(std::ostream& os, CallConstructParameters const& p) { | |
| 75 return os << p.arity() << ", " << p.frequency(); | 71 return os << p.arity() << ", " << p.frequency(); |
| 76 } | 72 } |
| 77 | 73 |
| 78 | 74 ConstructParameters const& ConstructParametersOf(Operator const* op) { |
| 79 CallConstructParameters const& CallConstructParametersOf(Operator const* op) { | 75 DCHECK_EQ(IrOpcode::kJSConstruct, op->opcode()); |
| 80 DCHECK_EQ(IrOpcode::kJSCallConstruct, op->opcode()); | 76 return OpParameter<ConstructParameters>(op); |
| 81 return OpParameter<CallConstructParameters>(op); | |
| 82 } | 77 } |
| 83 | 78 |
| 84 bool operator==(CallConstructWithSpreadParameters const& lhs, | 79 bool operator==(ConstructWithSpreadParameters const& lhs, |
| 85 CallConstructWithSpreadParameters const& rhs) { | 80 ConstructWithSpreadParameters const& rhs) { |
| 86 return lhs.arity() == rhs.arity(); | 81 return lhs.arity() == rhs.arity(); |
| 87 } | 82 } |
| 88 | 83 |
| 89 bool operator!=(CallConstructWithSpreadParameters const& lhs, | 84 bool operator!=(ConstructWithSpreadParameters const& lhs, |
| 90 CallConstructWithSpreadParameters const& rhs) { | 85 ConstructWithSpreadParameters const& rhs) { |
| 91 return !(lhs == rhs); | 86 return !(lhs == rhs); |
| 92 } | 87 } |
| 93 | 88 |
| 94 size_t hash_value(CallConstructWithSpreadParameters const& p) { | 89 size_t hash_value(ConstructWithSpreadParameters const& p) { |
| 95 return base::hash_combine(p.arity()); | 90 return base::hash_combine(p.arity()); |
| 96 } | 91 } |
| 97 | 92 |
| 98 std::ostream& operator<<(std::ostream& os, | 93 std::ostream& operator<<(std::ostream& os, |
| 99 CallConstructWithSpreadParameters const& p) { | 94 ConstructWithSpreadParameters const& p) { |
| 100 return os << p.arity(); | 95 return os << p.arity(); |
| 101 } | 96 } |
| 102 | 97 |
| 103 CallConstructWithSpreadParameters const& CallConstructWithSpreadParametersOf( | 98 ConstructWithSpreadParameters const& ConstructWithSpreadParametersOf( |
| 104 Operator const* op) { | 99 Operator const* op) { |
| 105 DCHECK_EQ(IrOpcode::kJSCallConstructWithSpread, op->opcode()); | 100 DCHECK_EQ(IrOpcode::kJSConstructWithSpread, op->opcode()); |
| 106 return OpParameter<CallConstructWithSpreadParameters>(op); | 101 return OpParameter<ConstructWithSpreadParameters>(op); |
| 107 } | 102 } |
| 108 | 103 |
| 109 std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) { | 104 std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) { |
| 110 os << p.arity() << ", " << p.frequency() << ", " << p.convert_mode() << ", " | 105 os << p.arity() << ", " << p.frequency() << ", " << p.convert_mode() << ", " |
| 111 << p.tail_call_mode(); | 106 << p.tail_call_mode(); |
| 112 return os; | 107 return os; |
| 113 } | 108 } |
| 114 | 109 |
| 115 | 110 |
| 116 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) { | 111 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) { |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 size_t arity) { | 779 size_t arity) { |
| 785 CallRuntimeParameters parameters(f->function_id, arity); | 780 CallRuntimeParameters parameters(f->function_id, arity); |
| 786 DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity())); | 781 DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity())); |
| 787 return new (zone()) Operator1<CallRuntimeParameters>( // -- | 782 return new (zone()) Operator1<CallRuntimeParameters>( // -- |
| 788 IrOpcode::kJSCallRuntime, Operator::kNoProperties, // opcode | 783 IrOpcode::kJSCallRuntime, Operator::kNoProperties, // opcode |
| 789 "JSCallRuntime", // name | 784 "JSCallRuntime", // name |
| 790 parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs | 785 parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs |
| 791 parameters); // parameter | 786 parameters); // parameter |
| 792 } | 787 } |
| 793 | 788 |
| 794 const Operator* JSOperatorBuilder::CallConstruct( | 789 const Operator* JSOperatorBuilder::Construct(uint32_t arity, float frequency, |
| 795 uint32_t arity, float frequency, VectorSlotPair const& feedback) { | 790 VectorSlotPair const& feedback) { |
| 796 CallConstructParameters parameters(arity, frequency, feedback); | 791 ConstructParameters parameters(arity, frequency, feedback); |
| 797 return new (zone()) Operator1<CallConstructParameters>( // -- | 792 return new (zone()) Operator1<ConstructParameters>( // -- |
| 798 IrOpcode::kJSCallConstruct, Operator::kNoProperties, // opcode | 793 IrOpcode::kJSConstruct, Operator::kNoProperties, // opcode |
| 799 "JSCallConstruct", // name | 794 "JSConstruct", // name |
| 800 parameters.arity(), 1, 1, 1, 1, 2, // counts | 795 parameters.arity(), 1, 1, 1, 1, 2, // counts |
| 801 parameters); // parameter | 796 parameters); // parameter |
| 802 } | 797 } |
| 803 | 798 |
| 804 const Operator* JSOperatorBuilder::CallConstructWithSpread(uint32_t arity) { | 799 const Operator* JSOperatorBuilder::ConstructWithSpread(uint32_t arity) { |
| 805 CallConstructWithSpreadParameters parameters(arity); | 800 ConstructWithSpreadParameters parameters(arity); |
| 806 return new (zone()) Operator1<CallConstructWithSpreadParameters>( // -- | 801 return new (zone()) Operator1<ConstructWithSpreadParameters>( // -- |
| 807 IrOpcode::kJSCallConstructWithSpread, Operator::kNoProperties, // opcode | 802 IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode |
| 808 "JSCallConstructWithSpread", // name | 803 "JSConstructWithSpread", // name |
| 809 parameters.arity(), 1, 1, 1, 1, 2, // counts | 804 parameters.arity(), 1, 1, 1, 1, 2, // counts |
| 810 parameters); // parameter | 805 parameters); // parameter |
| 811 } | 806 } |
| 812 | 807 |
| 813 const Operator* JSOperatorBuilder::ConvertReceiver( | 808 const Operator* JSOperatorBuilder::ConvertReceiver( |
| 814 ConvertReceiverMode convert_mode) { | 809 ConvertReceiverMode convert_mode) { |
| 815 return new (zone()) Operator1<ConvertReceiverMode>( // -- | 810 return new (zone()) Operator1<ConvertReceiverMode>( // -- |
| 816 IrOpcode::kJSConvertReceiver, Operator::kEliminatable, // opcode | 811 IrOpcode::kJSConvertReceiver, Operator::kEliminatable, // opcode |
| 817 "JSConvertReceiver", // name | 812 "JSConvertReceiver", // name |
| 818 1, 1, 1, 1, 1, 0, // counts | 813 1, 1, 1, 1, 1, 0, // counts |
| 819 convert_mode); // parameter | 814 convert_mode); // parameter |
| 820 } | 815 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- | 1057 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- |
| 1063 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode | 1058 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode |
| 1064 "JSCreateScriptContext", // name | 1059 "JSCreateScriptContext", // name |
| 1065 1, 1, 1, 1, 1, 2, // counts | 1060 1, 1, 1, 1, 1, 2, // counts |
| 1066 scope_info); // parameter | 1061 scope_info); // parameter |
| 1067 } | 1062 } |
| 1068 | 1063 |
| 1069 } // namespace compiler | 1064 } // namespace compiler |
| 1070 } // namespace internal | 1065 } // namespace internal |
| 1071 } // namespace v8 | 1066 } // namespace v8 |
| OLD | NEW |