| 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 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2209 } | 2209 } |
| 2210 | 2210 |
| 2211 // Returns -1 if pred is not in the list. | 2211 // Returns -1 if pred is not in the list. |
| 2212 intptr_t IndexOfPredecessor(BlockEntryInstr* pred) const; | 2212 intptr_t IndexOfPredecessor(BlockEntryInstr* pred) const; |
| 2213 | 2213 |
| 2214 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } | 2214 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } |
| 2215 | 2215 |
| 2216 virtual void PrepareEntry(FlowGraphCompiler* compiler); | 2216 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
| 2217 | 2217 |
| 2218 void InsertPhi(intptr_t var_index, intptr_t var_count); | 2218 void InsertPhi(intptr_t var_index, intptr_t var_count); |
| 2219 void RemoveDeadPhis(); |
| 2219 | 2220 |
| 2220 intptr_t phi_count() const { return phi_count_; } | 2221 intptr_t phi_count() const { return phi_count_; } |
| 2221 | 2222 |
| 2222 private: | 2223 private: |
| 2223 GrowableArray<BlockEntryInstr*> predecessors_; | 2224 GrowableArray<BlockEntryInstr*> predecessors_; |
| 2224 ZoneGrowableArray<PhiInstr*>* phis_; | 2225 ZoneGrowableArray<PhiInstr*>* phis_; |
| 2225 intptr_t phi_count_; | 2226 intptr_t phi_count_; |
| 2226 | 2227 |
| 2227 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr); | 2228 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr); |
| 2228 }; | 2229 }; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 private: | 2356 private: |
| 2356 Computation* computation_; | 2357 Computation* computation_; |
| 2357 const bool is_used_; | 2358 const bool is_used_; |
| 2358 | 2359 |
| 2359 DISALLOW_COPY_AND_ASSIGN(BindInstr); | 2360 DISALLOW_COPY_AND_ASSIGN(BindInstr); |
| 2360 }; | 2361 }; |
| 2361 | 2362 |
| 2362 | 2363 |
| 2363 class PhiInstr : public Definition { | 2364 class PhiInstr : public Definition { |
| 2364 public: | 2365 public: |
| 2365 explicit PhiInstr(intptr_t num_inputs) : inputs_(num_inputs) { | 2366 explicit PhiInstr(intptr_t num_inputs) |
| 2367 : inputs_(num_inputs), is_alive_(false) { |
| 2366 for (intptr_t i = 0; i < num_inputs; ++i) { | 2368 for (intptr_t i = 0; i < num_inputs; ++i) { |
| 2367 inputs_.Add(NULL); | 2369 inputs_.Add(NULL); |
| 2368 } | 2370 } |
| 2369 } | 2371 } |
| 2370 | 2372 |
| 2371 // Least upper bound of the static types of the inputs. | 2373 // Least upper bound of the static types of the inputs. |
| 2372 virtual RawAbstractType* StaticType() const; | 2374 virtual RawAbstractType* StaticType() const; |
| 2373 | 2375 |
| 2374 virtual intptr_t ArgumentCount() const { return 0; } | 2376 virtual intptr_t ArgumentCount() const { return 0; } |
| 2375 | 2377 |
| 2376 intptr_t InputCount() const { return inputs_.length(); } | 2378 intptr_t InputCount() const { return inputs_.length(); } |
| 2377 | 2379 |
| 2378 Value* InputAt(intptr_t i) const { return inputs_[i]; } | 2380 Value* InputAt(intptr_t i) const { return inputs_[i]; } |
| 2379 | 2381 |
| 2380 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } | 2382 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } |
| 2381 | 2383 |
| 2382 virtual bool CanDeoptimize() const { return false; } | 2384 virtual bool CanDeoptimize() const { return false; } |
| 2383 | 2385 |
| 2386 // Phi is alive if it reaches a non-environment use. |
| 2387 bool is_alive() const { return is_alive_; } |
| 2388 void mark_alive() { is_alive_ = true; } |
| 2389 |
| 2384 DECLARE_INSTRUCTION(Phi) | 2390 DECLARE_INSTRUCTION(Phi) |
| 2385 | 2391 |
| 2386 private: | 2392 private: |
| 2387 GrowableArray<Value*> inputs_; | 2393 GrowableArray<Value*> inputs_; |
| 2394 bool is_alive_; |
| 2388 | 2395 |
| 2389 DISALLOW_COPY_AND_ASSIGN(PhiInstr); | 2396 DISALLOW_COPY_AND_ASSIGN(PhiInstr); |
| 2390 }; | 2397 }; |
| 2391 | 2398 |
| 2392 | 2399 |
| 2393 class ParameterInstr : public Definition { | 2400 class ParameterInstr : public Definition { |
| 2394 public: | 2401 public: |
| 2395 explicit ParameterInstr(intptr_t index) : index_(index) { } | 2402 explicit ParameterInstr(intptr_t index) : index_(index) { } |
| 2396 | 2403 |
| 2397 DECLARE_INSTRUCTION(Parameter) | 2404 DECLARE_INSTRUCTION(Parameter) |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2683 location_count_(0), | 2690 location_count_(0), |
| 2684 locations_(NULL), | 2691 locations_(NULL), |
| 2685 fixed_parameter_count_(fixed_parameter_count) { | 2692 fixed_parameter_count_(fixed_parameter_count) { |
| 2686 values_.AddArray(values); | 2693 values_.AddArray(values); |
| 2687 } | 2694 } |
| 2688 | 2695 |
| 2689 const GrowableArray<Value*>& values() const { | 2696 const GrowableArray<Value*>& values() const { |
| 2690 return values_; | 2697 return values_; |
| 2691 } | 2698 } |
| 2692 | 2699 |
| 2700 GrowableArray<Value*>* values_ptr() { |
| 2701 return &values_; |
| 2702 } |
| 2703 |
| 2693 void InitializeLocations() { | 2704 void InitializeLocations() { |
| 2694 location_count_ = values_.length(); | 2705 location_count_ = values_.length(); |
| 2695 if (location_count_ > 0) { | 2706 if (location_count_ > 0) { |
| 2696 locations_ = | 2707 locations_ = |
| 2697 Isolate::Current()->current_zone()->Alloc<Location>(location_count_); | 2708 Isolate::Current()->current_zone()->Alloc<Location>(location_count_); |
| 2698 } | 2709 } |
| 2699 } | 2710 } |
| 2700 | 2711 |
| 2701 Location LocationAt(intptr_t ix) const { | 2712 Location LocationAt(intptr_t ix) const { |
| 2702 ASSERT((ix >= 0) && (ix < location_count_)); | 2713 ASSERT((ix >= 0) && (ix < location_count_)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2754 const GrowableArray<BlockEntryInstr*>& block_order_; | 2765 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 2755 | 2766 |
| 2756 private: | 2767 private: |
| 2757 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2768 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 2758 }; | 2769 }; |
| 2759 | 2770 |
| 2760 | 2771 |
| 2761 } // namespace dart | 2772 } // namespace dart |
| 2762 | 2773 |
| 2763 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2774 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |