OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 public: | 594 public: |
595 explicit PolymorphicInstanceCallComp(InstanceCallComp* comp) | 595 explicit PolymorphicInstanceCallComp(InstanceCallComp* comp) |
596 : instance_call_(comp) { | 596 : instance_call_(comp) { |
597 ASSERT(instance_call_ != NULL); | 597 ASSERT(instance_call_ != NULL); |
598 } | 598 } |
599 | 599 |
600 InstanceCallComp* instance_call() const { return instance_call_; } | 600 InstanceCallComp* instance_call() const { return instance_call_; } |
601 | 601 |
602 void PrintTo(BufferFormatter* f) const; | 602 void PrintTo(BufferFormatter* f) const; |
603 | 603 |
604 DECLARE_COMPUTATION(PolymorphicInstanceCall) | 604 virtual intptr_t ArgumentCount() const { |
| 605 return instance_call()->ArgumentCount(); |
| 606 } |
| 607 |
| 608 DECLARE_CALL_COMPUTATION(PolymorphicInstanceCall) |
605 | 609 |
606 virtual bool CanDeoptimize() const { return true; } | 610 virtual bool CanDeoptimize() const { return true; } |
607 | 611 |
608 private: | 612 private: |
609 InstanceCallComp* instance_call_; | 613 InstanceCallComp* instance_call_; |
610 | 614 |
611 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallComp); | 615 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallComp); |
612 }; | 616 }; |
613 | 617 |
614 | 618 |
(...skipping 1896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2511 | 2515 |
2512 virtual void RemoveInputUses() { } | 2516 virtual void RemoveInputUses() { } |
2513 | 2517 |
2514 private: | 2518 private: |
2515 const intptr_t index_; | 2519 const intptr_t index_; |
2516 | 2520 |
2517 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); | 2521 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); |
2518 }; | 2522 }; |
2519 | 2523 |
2520 | 2524 |
2521 class PushArgumentInstr : public TemplateInstruction<1> { | 2525 class PushArgumentInstr : public Definition { |
2522 public: | 2526 public: |
2523 explicit PushArgumentInstr(Value* value) { | 2527 explicit PushArgumentInstr(Value* value) : value_(value), locs_(NULL) { |
2524 ASSERT(value != NULL); | 2528 ASSERT(value != NULL); |
2525 inputs_[0] = value; | |
2526 } | 2529 } |
2527 | 2530 |
2528 DECLARE_INSTRUCTION(PushArgument) | 2531 DECLARE_INSTRUCTION(PushArgument) |
2529 | 2532 |
| 2533 intptr_t InputCount() const { return 1; } |
| 2534 Value* InputAt(intptr_t i) const { |
| 2535 ASSERT(i == 0); |
| 2536 return value_; |
| 2537 } |
| 2538 void SetInputAt(intptr_t i, Value* value) { |
| 2539 ASSERT(i == 0); |
| 2540 value_ = value; |
| 2541 } |
| 2542 |
2530 virtual intptr_t ArgumentCount() const { return 0; } | 2543 virtual intptr_t ArgumentCount() const { return 0; } |
2531 | 2544 |
2532 Value* value() const { return inputs_[0]; } | 2545 virtual RawAbstractType* CompileType() const; |
2533 | 2546 |
2534 virtual LocationSummary* MakeLocationSummary() const; | 2547 Value* value() const { return value_; } |
| 2548 |
| 2549 virtual LocationSummary* locs() { |
| 2550 if (locs_ == NULL) { |
| 2551 locs_ = MakeLocationSummary(); |
| 2552 } |
| 2553 return locs_; |
| 2554 } |
| 2555 |
| 2556 LocationSummary* MakeLocationSummary() const; |
2535 | 2557 |
2536 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | 2558 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
2537 | 2559 |
2538 virtual bool CanDeoptimize() const { return false; } | 2560 virtual bool CanDeoptimize() const { return false; } |
2539 | 2561 |
| 2562 bool WasEliminated() const { |
| 2563 return next() == NULL; |
| 2564 } |
| 2565 |
| 2566 virtual void RemoveInputUses() { value_->RemoveFromUseList(); } |
| 2567 |
2540 private: | 2568 private: |
| 2569 Value* value_; |
| 2570 LocationSummary* locs_; |
| 2571 |
2541 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); | 2572 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); |
2542 }; | 2573 }; |
2543 | 2574 |
2544 | 2575 |
2545 class ReturnInstr : public TemplateInstruction<1> { | 2576 class ReturnInstr : public TemplateInstruction<1> { |
2546 public: | 2577 public: |
2547 ReturnInstr(intptr_t token_pos, Value* value) | 2578 ReturnInstr(intptr_t token_pos, Value* value) |
2548 : deopt_id_(Isolate::Current()->GetNextDeoptId()), | 2579 : deopt_id_(Isolate::Current()->GetNextDeoptId()), |
2549 token_pos_(token_pos) { | 2580 token_pos_(token_pos) { |
2550 ASSERT(value != NULL); | 2581 ASSERT(value != NULL); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2771 | 2802 |
2772 #undef DECLARE_INSTRUCTION | 2803 #undef DECLARE_INSTRUCTION |
2773 | 2804 |
2774 | 2805 |
2775 class Environment : public ZoneAllocated { | 2806 class Environment : public ZoneAllocated { |
2776 public: | 2807 public: |
2777 // Construct an environment by copying from an array of values. | 2808 // Construct an environment by copying from an array of values. |
2778 explicit Environment(const GrowableArray<Value*>& values, | 2809 explicit Environment(const GrowableArray<Value*>& values, |
2779 intptr_t fixed_parameter_count) | 2810 intptr_t fixed_parameter_count) |
2780 : values_(values.length()), | 2811 : values_(values.length()), |
2781 location_count_(0), | |
2782 locations_(NULL), | 2812 locations_(NULL), |
2783 fixed_parameter_count_(fixed_parameter_count) { | 2813 fixed_parameter_count_(fixed_parameter_count) { |
2784 values_.AddArray(values); | 2814 values_.AddArray(values); |
2785 } | 2815 } |
2786 | 2816 |
| 2817 void set_locations(Location* locations) { |
| 2818 ASSERT(locations_ == NULL); |
| 2819 locations_ = locations; |
| 2820 } |
| 2821 |
2787 const GrowableArray<Value*>& values() const { | 2822 const GrowableArray<Value*>& values() const { |
2788 return values_; | 2823 return values_; |
2789 } | 2824 } |
2790 | 2825 |
2791 // Initialize locations for the environment values on behalf of the | |
2792 // register allocator. The initial live ranges of environment uses extend | |
2793 // from the block start position to the environment position. | |
2794 void InitializeLocations(FlowGraphAllocator* allocator, | |
2795 intptr_t block_start_pos, | |
2796 intptr_t environment_pos); | |
2797 | |
2798 GrowableArray<Value*>* values_ptr() { | 2826 GrowableArray<Value*>* values_ptr() { |
2799 return &values_; | 2827 return &values_; |
2800 } | 2828 } |
2801 | 2829 |
2802 Location LocationAt(intptr_t ix) const { | 2830 Location LocationAt(intptr_t ix) const { |
2803 ASSERT((ix >= 0) && (ix < location_count_)); | 2831 ASSERT((ix >= 0) && (ix < values_.length())); |
2804 return locations_[ix]; | 2832 return locations_[ix]; |
2805 } | 2833 } |
2806 | 2834 |
2807 Location* LocationSlotAt(intptr_t ix) const { | 2835 Location* LocationSlotAt(intptr_t ix) const { |
2808 ASSERT((ix >= 0) && (ix < location_count_)); | 2836 ASSERT((ix >= 0) && (ix < values_.length())); |
2809 return &locations_[ix]; | 2837 return &locations_[ix]; |
2810 } | 2838 } |
2811 | 2839 |
2812 intptr_t fixed_parameter_count() const { | 2840 intptr_t fixed_parameter_count() const { |
2813 return fixed_parameter_count_; | 2841 return fixed_parameter_count_; |
2814 } | 2842 } |
2815 | 2843 |
2816 void PrintTo(BufferFormatter* f) const; | 2844 void PrintTo(BufferFormatter* f) const; |
2817 | 2845 |
2818 private: | 2846 private: |
2819 GrowableArray<Value*> values_; | 2847 GrowableArray<Value*> values_; |
2820 intptr_t location_count_; | |
2821 Location* locations_; | 2848 Location* locations_; |
2822 const intptr_t fixed_parameter_count_; | 2849 const intptr_t fixed_parameter_count_; |
2823 | 2850 |
2824 DISALLOW_COPY_AND_ASSIGN(Environment); | 2851 DISALLOW_COPY_AND_ASSIGN(Environment); |
2825 }; | 2852 }; |
2826 | 2853 |
2827 | 2854 |
2828 // Visitor base class to visit each instruction and computation in a flow | 2855 // Visitor base class to visit each instruction and computation in a flow |
2829 // graph as defined by a reversed list of basic blocks. | 2856 // graph as defined by a reversed list of basic blocks. |
2830 class FlowGraphVisitor : public ValueObject { | 2857 class FlowGraphVisitor : public ValueObject { |
(...skipping 24 matching lines...) Expand all Loading... |
2855 const GrowableArray<BlockEntryInstr*>& block_order_; | 2882 const GrowableArray<BlockEntryInstr*>& block_order_; |
2856 | 2883 |
2857 private: | 2884 private: |
2858 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2885 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
2859 }; | 2886 }; |
2860 | 2887 |
2861 | 2888 |
2862 } // namespace dart | 2889 } // namespace dart |
2863 | 2890 |
2864 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2891 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |