Chromium Code Reviews| 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_HYDROGEN_INSTRUCTIONS_H_ | 5 #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ |
| 6 #define V8_HYDROGEN_INSTRUCTIONS_H_ | 6 #define V8_HYDROGEN_INSTRUCTIONS_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2314 | 2314 |
| 2315 bool pass_argument_count_; | 2315 bool pass_argument_count_; |
| 2316 bool has_stack_check_; | 2316 bool has_stack_check_; |
| 2317 }; | 2317 }; |
| 2318 | 2318 |
| 2319 | 2319 |
| 2320 class HCallWithDescriptor V8_FINAL : public HInstruction { | 2320 class HCallWithDescriptor V8_FINAL : public HInstruction { |
| 2321 public: | 2321 public: |
| 2322 static HCallWithDescriptor* New(Zone* zone, HValue* context, | 2322 static HCallWithDescriptor* New(Zone* zone, HValue* context, |
| 2323 HValue* target, | 2323 HValue* target, |
| 2324 HValue* call_context, | |
| 2324 int argument_count, | 2325 int argument_count, |
| 2325 const CallInterfaceDescriptor* descriptor, | 2326 const InterfaceDescriptor* descriptor, |
| 2326 const Vector<HValue*>& operands) { | 2327 const Vector<HValue*>& operands) { |
| 2327 ASSERT(operands.length() == descriptor->environment_length()); | 2328 ASSERT(operands.length() == descriptor->environment_length()); |
| 2328 HCallWithDescriptor* res = | 2329 HCallWithDescriptor* res = |
| 2329 new(zone) HCallWithDescriptor(target, argument_count, | 2330 new(zone) HCallWithDescriptor(target, call_context, argument_count, |
| 2330 descriptor, operands, zone); | 2331 descriptor, operands, zone); |
| 2331 return res; | 2332 return res; |
| 2332 } | 2333 } |
| 2333 | 2334 |
| 2334 virtual int OperandCount() const V8_FINAL V8_OVERRIDE { | 2335 virtual int OperandCount() const V8_FINAL V8_OVERRIDE { |
| 2335 return values_.length(); | 2336 return values_.length(); |
| 2336 } | 2337 } |
| 2337 virtual HValue* OperandAt(int index) const V8_FINAL V8_OVERRIDE { | 2338 virtual HValue* OperandAt(int index) const V8_FINAL V8_OVERRIDE { |
| 2338 return values_[index]; | 2339 return values_[index]; |
| 2339 } | 2340 } |
| 2340 | 2341 |
| 2342 int FirstDescriptorOperandIndex() const { | |
| 2343 // Our Operand array contains target and possibly context before the | |
| 2344 // descriptor parameters. | |
| 2345 return descriptor_->needs_context_register() ? 2 : 1; | |
|
danno
2014/07/15 07:48:31
Is it possible to roll this into the descriptor, t
| |
| 2346 } | |
| 2347 | |
| 2341 virtual Representation RequiredInputRepresentation( | 2348 virtual Representation RequiredInputRepresentation( |
| 2342 int index) V8_FINAL V8_OVERRIDE { | 2349 int index) V8_FINAL V8_OVERRIDE { |
| 2343 if (index == 0) { | 2350 if (index < FirstDescriptorOperandIndex()) { |
| 2344 return Representation::Tagged(); | 2351 return Representation::Tagged(); |
| 2345 } else { | 2352 } else { |
| 2346 int par_index = index - 1; | 2353 int par_index = index - FirstDescriptorOperandIndex(); |
| 2347 ASSERT(par_index < descriptor_->environment_length()); | 2354 ASSERT(par_index < descriptor_->environment_length()); |
| 2348 return descriptor_->GetParameterRepresentation(par_index); | 2355 return descriptor_->GetParameterRepresentation(par_index); |
| 2349 } | 2356 } |
| 2350 } | 2357 } |
| 2351 | 2358 |
| 2352 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor) | 2359 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor) |
| 2353 | 2360 |
| 2354 virtual HType CalculateInferredType() V8_FINAL V8_OVERRIDE { | 2361 virtual HType CalculateInferredType() V8_FINAL V8_OVERRIDE { |
| 2355 return HType::Tagged(); | 2362 return HType::Tagged(); |
| 2356 } | 2363 } |
| 2357 | 2364 |
| 2358 virtual int argument_count() const { | 2365 virtual int argument_count() const { |
| 2359 return argument_count_; | 2366 return argument_count_; |
| 2360 } | 2367 } |
| 2361 | 2368 |
| 2362 virtual int argument_delta() const V8_OVERRIDE { | 2369 virtual int argument_delta() const V8_OVERRIDE { |
| 2363 return -argument_count_; | 2370 return -argument_count_; |
| 2364 } | 2371 } |
| 2365 | 2372 |
| 2366 const CallInterfaceDescriptor* descriptor() const { | 2373 const InterfaceDescriptor* descriptor() const { |
| 2367 return descriptor_; | 2374 return descriptor_; |
| 2368 } | 2375 } |
| 2369 | 2376 |
| 2370 HValue* target() { | 2377 HValue* target() { |
| 2371 return OperandAt(0); | 2378 return OperandAt(0); |
| 2372 } | 2379 } |
| 2373 | 2380 |
| 2381 HValue* context() { | |
| 2382 ASSERT(descriptor_->needs_context_register()); | |
| 2383 return OperandAt(1); | |
| 2384 } | |
| 2385 | |
| 2374 virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT | 2386 virtual OStream& PrintDataTo(OStream& os) const V8_OVERRIDE; // NOLINT |
| 2375 | 2387 |
| 2376 private: | 2388 private: |
| 2377 // The argument count includes the receiver. | 2389 // The argument count includes the receiver. |
| 2378 HCallWithDescriptor(HValue* target, | 2390 HCallWithDescriptor(HValue* target, |
| 2391 HValue* context, | |
| 2379 int argument_count, | 2392 int argument_count, |
| 2380 const CallInterfaceDescriptor* descriptor, | 2393 const InterfaceDescriptor* descriptor, |
| 2381 const Vector<HValue*>& operands, | 2394 const Vector<HValue*>& operands, |
| 2382 Zone* zone) | 2395 Zone* zone) |
| 2383 : descriptor_(descriptor), | 2396 : descriptor_(descriptor), |
| 2384 values_(descriptor->environment_length() + 1, zone) { | 2397 values_(value_array_length(descriptor), zone) { |
| 2385 argument_count_ = argument_count; | 2398 argument_count_ = argument_count; |
| 2386 AddOperand(target, zone); | 2399 AddOperand(target, zone); |
| 2400 if (descriptor->needs_context_register()) { | |
| 2401 ASSERT(context != NULL); | |
| 2402 AddOperand(context, zone); | |
| 2403 } | |
| 2387 for (int i = 0; i < operands.length(); i++) { | 2404 for (int i = 0; i < operands.length(); i++) { |
| 2388 AddOperand(operands[i], zone); | 2405 AddOperand(operands[i], zone); |
| 2389 } | 2406 } |
| 2390 this->set_representation(Representation::Tagged()); | 2407 this->set_representation(Representation::Tagged()); |
| 2391 this->SetAllSideEffects(); | 2408 this->SetAllSideEffects(); |
| 2392 } | 2409 } |
| 2393 | 2410 |
| 2411 static int value_array_length(const InterfaceDescriptor* descriptor) { | |
| 2412 int extra_operands = descriptor->needs_context_register() ? 2 : 1; | |
| 2413 return descriptor->environment_length() + extra_operands; | |
|
danno
2014/07/15 07:48:31
Similar to GetParameterRepresentation, you will ne
| |
| 2414 } | |
| 2415 | |
| 2394 void AddOperand(HValue* v, Zone* zone) { | 2416 void AddOperand(HValue* v, Zone* zone) { |
| 2395 values_.Add(NULL, zone); | 2417 values_.Add(NULL, zone); |
| 2396 SetOperandAt(values_.length() - 1, v); | 2418 SetOperandAt(values_.length() - 1, v); |
| 2397 } | 2419 } |
| 2398 | 2420 |
| 2399 void InternalSetOperandAt(int index, | 2421 void InternalSetOperandAt(int index, |
| 2400 HValue* value) V8_FINAL V8_OVERRIDE { | 2422 HValue* value) V8_FINAL V8_OVERRIDE { |
| 2401 values_[index] = value; | 2423 values_[index] = value; |
| 2402 } | 2424 } |
| 2403 | 2425 |
| 2404 const CallInterfaceDescriptor* descriptor_; | 2426 const InterfaceDescriptor* descriptor_; |
| 2405 ZoneList<HValue*> values_; | 2427 ZoneList<HValue*> values_; |
| 2406 int argument_count_; | 2428 int argument_count_; |
| 2407 }; | 2429 }; |
| 2408 | 2430 |
| 2409 | 2431 |
| 2410 class HInvokeFunction V8_FINAL : public HBinaryCall { | 2432 class HInvokeFunction V8_FINAL : public HBinaryCall { |
| 2411 public: | 2433 public: |
| 2412 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HInvokeFunction, HValue*, int); | 2434 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HInvokeFunction, HValue*, int); |
| 2413 | 2435 |
| 2414 HInvokeFunction(HValue* context, | 2436 HInvokeFunction(HValue* context, |
| (...skipping 5399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7814 }; | 7836 }; |
| 7815 | 7837 |
| 7816 | 7838 |
| 7817 | 7839 |
| 7818 #undef DECLARE_INSTRUCTION | 7840 #undef DECLARE_INSTRUCTION |
| 7819 #undef DECLARE_CONCRETE_INSTRUCTION | 7841 #undef DECLARE_CONCRETE_INSTRUCTION |
| 7820 | 7842 |
| 7821 } } // namespace v8::internal | 7843 } } // namespace v8::internal |
| 7822 | 7844 |
| 7823 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7845 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |