Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(946)

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 10831179: Allocate the environment's location backing store during register allocation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Store location count to enable bounds checking assertions. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/vm/flow_graph_allocator.cc ('K') | « runtime/vm/il_printer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 DISALLOW_COPY_AND_ASSIGN(BranchInstr); 2671 DISALLOW_COPY_AND_ASSIGN(BranchInstr);
2672 }; 2672 };
2673 2673
2674 2674
2675 #undef DECLARE_INSTRUCTION 2675 #undef DECLARE_INSTRUCTION
2676 2676
2677 2677
2678 class Environment : public ZoneAllocated { 2678 class Environment : public ZoneAllocated {
2679 public: 2679 public:
2680 // Construct an environment by copying from an array of values. 2680 // Construct an environment by copying from an array of values.
2681 // TODO(vegorov): it's absolutely crucial that locations_ backing store
2682 // is preallocated and never reallocated. We use pointers into it
2683 // during register allocation.
2684 explicit Environment(const GrowableArray<Value*>& values, 2681 explicit Environment(const GrowableArray<Value*>& values,
2685 intptr_t fixed_parameter_count) 2682 intptr_t fixed_parameter_count)
2686 : values_(values.length()), 2683 : values_(values.length()),
2687 locations_(values.length()), 2684 location_count_(0),
2685 locations_(NULL),
2688 fixed_parameter_count_(fixed_parameter_count) { 2686 fixed_parameter_count_(fixed_parameter_count) {
2689 values_.AddArray(values); 2687 values_.AddArray(values);
2690 } 2688 }
2691 2689
2692 const GrowableArray<Value*>& values() const { 2690 const GrowableArray<Value*>& values() const {
2693 return values_; 2691 return values_;
2694 } 2692 }
2695 2693
2696 void AddLocation(Location value) { 2694 void InitializeLocations() {
2697 locations_.Add(value); 2695 location_count_ = values_.length();
srdjan 2012/08/06 22:49:25 ASSERT(locations_ == NULL), guaranteeing that we d
2696 if (location_count_ > 0) {
2697 locations_ =
2698 Isolate::Current()->current_zone()->Alloc<Location>(location_count_);
srdjan 2012/08/06 22:49:25 Please initialize locations_ with default Location
2699 }
2698 } 2700 }
2699 2701
2700 Location LocationAt(intptr_t ix) const { 2702 Location LocationAt(intptr_t ix) const {
2703 ASSERT((ix >= 0) && (ix < location_count_));
srdjan 2012/08/06 22:49:25 ASSERT(locations_ != NULL) .
2701 return locations_[ix]; 2704 return locations_[ix];
2702 } 2705 }
2703 2706
2704 Location* LocationSlotAt(intptr_t ix) const { 2707 Location* LocationSlotAt(intptr_t ix) const {
2705 return & locations_[ix]; 2708 ASSERT((ix >= 0) && (ix < location_count_));
srdjan 2012/08/06 22:49:25 ditto
2709 return &locations_[ix];
2706 } 2710 }
2707 2711
2708 intptr_t fixed_parameter_count() const { 2712 intptr_t fixed_parameter_count() const {
2709 return fixed_parameter_count_; 2713 return fixed_parameter_count_;
2710 } 2714 }
2711 2715
2712 void PrintTo(BufferFormatter* f) const; 2716 void PrintTo(BufferFormatter* f) const;
2713 2717
2714 private: 2718 private:
2715 GrowableArray<Value*> values_; 2719 GrowableArray<Value*> values_;
2716 GrowableArray<Location> locations_; 2720 intptr_t location_count_;
2721 Location* locations_;
2717 const intptr_t fixed_parameter_count_; 2722 const intptr_t fixed_parameter_count_;
2718 2723
2719 DISALLOW_COPY_AND_ASSIGN(Environment); 2724 DISALLOW_COPY_AND_ASSIGN(Environment);
2720 }; 2725 };
2721 2726
2722 2727
2723 // Visitor base class to visit each instruction and computation in a flow 2728 // Visitor base class to visit each instruction and computation in a flow
2724 // graph as defined by a reversed list of basic blocks. 2729 // graph as defined by a reversed list of basic blocks.
2725 class FlowGraphVisitor : public ValueObject { 2730 class FlowGraphVisitor : public ValueObject {
2726 public: 2731 public:
(...skipping 23 matching lines...) Expand all
2750 const GrowableArray<BlockEntryInstr*>& block_order_; 2755 const GrowableArray<BlockEntryInstr*>& block_order_;
2751 2756
2752 private: 2757 private:
2753 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2758 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2754 }; 2759 };
2755 2760
2756 2761
2757 } // namespace dart 2762 } // namespace dart
2758 2763
2759 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2764 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« runtime/vm/flow_graph_allocator.cc ('K') | « runtime/vm/il_printer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698