OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 5 #ifndef V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
7 | 7 |
8 #include <cstring> | 8 #include <cstring> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 | 10 |
(...skipping 2140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 | 2151 |
2152 | 2152 |
2153 class HCallWithDescriptor final : public HInstruction { | 2153 class HCallWithDescriptor final : public HInstruction { |
2154 public: | 2154 public: |
2155 static HCallWithDescriptor* New( | 2155 static HCallWithDescriptor* New( |
2156 Isolate* isolate, Zone* zone, HValue* context, HValue* target, | 2156 Isolate* isolate, Zone* zone, HValue* context, HValue* target, |
2157 int argument_count, CallInterfaceDescriptor descriptor, | 2157 int argument_count, CallInterfaceDescriptor descriptor, |
2158 const Vector<HValue*>& operands, | 2158 const Vector<HValue*>& operands, |
2159 TailCallMode syntactic_tail_call_mode = TailCallMode::kDisallow, | 2159 TailCallMode syntactic_tail_call_mode = TailCallMode::kDisallow, |
2160 TailCallMode tail_call_mode = TailCallMode::kDisallow) { | 2160 TailCallMode tail_call_mode = TailCallMode::kDisallow) { |
2161 HCallWithDescriptor* res = new (zone) | 2161 HCallWithDescriptor* res = new (zone) HCallWithDescriptor( |
2162 HCallWithDescriptor(target, argument_count, descriptor, operands, | 2162 context, target, argument_count, descriptor, operands, |
2163 syntactic_tail_call_mode, tail_call_mode, zone); | 2163 syntactic_tail_call_mode, tail_call_mode, zone); |
2164 return res; | 2164 return res; |
2165 } | 2165 } |
2166 | 2166 |
2167 int OperandCount() const final { return values_.length(); } | 2167 int OperandCount() const final { return values_.length(); } |
2168 HValue* OperandAt(int index) const final { return values_[index]; } | 2168 HValue* OperandAt(int index) const final { return values_[index]; } |
2169 | 2169 |
2170 Representation RequiredInputRepresentation(int index) final { | 2170 Representation RequiredInputRepresentation(int index) final { |
2171 if (index == 0 || index == 1) { | 2171 if (index == 0 || index == 1) { |
2172 // Target + context | 2172 // Target + context |
2173 return Representation::Tagged(); | 2173 return Representation::Tagged(); |
(...skipping 19 matching lines...) Expand all Loading... |
2193 bool IsTailCall() const { return tail_call_mode() == TailCallMode::kAllow; } | 2193 bool IsTailCall() const { return tail_call_mode() == TailCallMode::kAllow; } |
2194 | 2194 |
2195 virtual int argument_count() const { | 2195 virtual int argument_count() const { |
2196 return argument_count_; | 2196 return argument_count_; |
2197 } | 2197 } |
2198 | 2198 |
2199 int argument_delta() const override { return -argument_count_; } | 2199 int argument_delta() const override { return -argument_count_; } |
2200 | 2200 |
2201 CallInterfaceDescriptor descriptor() const { return descriptor_; } | 2201 CallInterfaceDescriptor descriptor() const { return descriptor_; } |
2202 | 2202 |
2203 HValue* target() { | 2203 HValue* target() { return OperandAt(0); } |
2204 return OperandAt(0); | 2204 HValue* context() { return OperandAt(1); } |
| 2205 HValue* parameter(int index) { |
| 2206 DCHECK_LT(index, GetParameterCount()); |
| 2207 return OperandAt(index + 2); |
2205 } | 2208 } |
2206 | 2209 |
2207 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 2210 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
2208 | 2211 |
2209 private: | 2212 private: |
2210 // The argument count includes the receiver. | 2213 // The argument count includes the receiver. |
2211 HCallWithDescriptor(HValue* target, int argument_count, | 2214 HCallWithDescriptor(HValue* context, HValue* target, int argument_count, |
2212 CallInterfaceDescriptor descriptor, | 2215 CallInterfaceDescriptor descriptor, |
2213 const Vector<HValue*>& operands, | 2216 const Vector<HValue*>& operands, |
2214 TailCallMode syntactic_tail_call_mode, | 2217 TailCallMode syntactic_tail_call_mode, |
2215 TailCallMode tail_call_mode, Zone* zone) | 2218 TailCallMode tail_call_mode, Zone* zone) |
2216 : descriptor_(descriptor), | 2219 : descriptor_(descriptor), |
2217 values_(GetParameterCount() + 1, zone), // +1 here is for target. | 2220 values_(GetParameterCount() + 2, zone), // +2 for context and target. |
2218 argument_count_(argument_count), | 2221 argument_count_(argument_count), |
2219 bit_field_( | 2222 bit_field_( |
2220 TailCallModeField::encode(tail_call_mode) | | 2223 TailCallModeField::encode(tail_call_mode) | |
2221 SyntacticTailCallModeField::encode(syntactic_tail_call_mode)) { | 2224 SyntacticTailCallModeField::encode(syntactic_tail_call_mode)) { |
2222 DCHECK_EQ(operands.length(), GetParameterCount()); | 2225 DCHECK_EQ(operands.length(), GetParameterCount()); |
2223 // We can only tail call without any stack arguments. | 2226 // We can only tail call without any stack arguments. |
2224 DCHECK(tail_call_mode != TailCallMode::kAllow || argument_count == 0); | 2227 DCHECK(tail_call_mode != TailCallMode::kAllow || argument_count == 0); |
2225 AddOperand(target, zone); | 2228 AddOperand(target, zone); |
| 2229 AddOperand(context, zone); |
2226 for (int i = 0; i < operands.length(); i++) { | 2230 for (int i = 0; i < operands.length(); i++) { |
2227 AddOperand(operands[i], zone); | 2231 AddOperand(operands[i], zone); |
2228 } | 2232 } |
2229 this->set_representation(Representation::Tagged()); | 2233 this->set_representation(Representation::Tagged()); |
2230 this->SetAllSideEffects(); | 2234 this->SetAllSideEffects(); |
2231 } | 2235 } |
2232 | 2236 |
2233 void AddOperand(HValue* v, Zone* zone) { | 2237 void AddOperand(HValue* v, Zone* zone) { |
2234 values_.Add(NULL, zone); | 2238 values_.Add(NULL, zone); |
2235 SetOperandAt(values_.length() - 1, v); | 2239 SetOperandAt(values_.length() - 1, v); |
2236 } | 2240 } |
2237 | 2241 |
2238 int GetParameterCount() const { | 2242 int GetParameterCount() const { return descriptor_.GetParameterCount(); } |
2239 return descriptor_.GetParameterCount() + 1; // +1 here is for context. | |
2240 } | |
2241 | 2243 |
2242 void InternalSetOperandAt(int index, HValue* value) final { | 2244 void InternalSetOperandAt(int index, HValue* value) final { |
2243 values_[index] = value; | 2245 values_[index] = value; |
2244 } | 2246 } |
2245 | 2247 |
2246 CallInterfaceDescriptor descriptor_; | 2248 CallInterfaceDescriptor descriptor_; |
2247 ZoneList<HValue*> values_; | 2249 ZoneList<HValue*> values_; |
2248 int argument_count_; | 2250 int argument_count_; |
2249 class TailCallModeField : public BitField<TailCallMode, 0, 1> {}; | 2251 class TailCallModeField : public BitField<TailCallMode, 0, 1> {}; |
2250 class SyntacticTailCallModeField | 2252 class SyntacticTailCallModeField |
(...skipping 4698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6949 bool IsDeletable() const override { return true; } | 6951 bool IsDeletable() const override { return true; } |
6950 }; | 6952 }; |
6951 | 6953 |
6952 #undef DECLARE_INSTRUCTION | 6954 #undef DECLARE_INSTRUCTION |
6953 #undef DECLARE_CONCRETE_INSTRUCTION | 6955 #undef DECLARE_CONCRETE_INSTRUCTION |
6954 | 6956 |
6955 } // namespace internal | 6957 } // namespace internal |
6956 } // namespace v8 | 6958 } // namespace v8 |
6957 | 6959 |
6958 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 6960 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |