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

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

Issue 11040058: Compress deoptimization information by sharing common suffixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
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_DEOPT_INSTRUCTIONS_H_ 5 #ifndef VM_DEOPT_INSTRUCTIONS_H_
6 #define VM_DEOPT_INSTRUCTIONS_H_ 6 #define VM_DEOPT_INSTRUCTIONS_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 DISALLOW_COPY_AND_ASSIGN(DeoptimizationContext); 77 DISALLOW_COPY_AND_ASSIGN(DeoptimizationContext);
78 }; 78 };
79 79
80 80
81 81
82 // Represents one deopt instruction, e.g, setup return address, store object, 82 // Represents one deopt instruction, e.g, setup return address, store object,
83 // store register, etc. The target is defined by instruction's position in 83 // store register, etc. The target is defined by instruction's position in
84 // the deopt-info array. 84 // the deopt-info array.
85 class DeoptInstr : public ZoneAllocated { 85 class DeoptInstr : public ZoneAllocated {
86 public: 86 public:
87 enum Kind {
88 kRetAfterAddress,
Kevin Millikin (Google) 2012/10/05 14:31:55 I renamed these and some of the class names so the
89 kRetBeforeAddress,
90 kConstant,
91 kRegister,
92 kXmmRegister,
93 kInt64XmmRegister,
94 kStackSlot,
95 kDoubleStackSlot,
96 kInt64StackSlot,
97 kPcMarker,
98 kCallerFp,
99 kCallerPc,
100 kSuffix,
101 };
102
87 static DeoptInstr* Create(intptr_t kind_as_int, intptr_t from_index); 103 static DeoptInstr* Create(intptr_t kind_as_int, intptr_t from_index);
88 104
89 DeoptInstr() {} 105 DeoptInstr() {}
90 virtual ~DeoptInstr() {} 106 virtual ~DeoptInstr() {}
91 107
92 virtual const char* ToCString() const = 0; 108 virtual const char* ToCString() const = 0;
93 109
94 virtual void Execute(DeoptimizationContext* deopt_context, 110 virtual void Execute(DeoptimizationContext* deopt_context,
95 intptr_t to_index) = 0; 111 intptr_t to_index) = 0;
96 112
113 bool Equals(const DeoptInstr& other) const {
114 return (kind() == other.kind()) && (from_index() == other.from_index());
115 }
116
117 // Decode the payload of a suffix command. Return the suffix length and
118 // set the output parameter info_number to the index of the shared suffix.
119 static intptr_t DecodeSuffix(intptr_t from_index, intptr_t* info_number);
120
97 protected: 121 protected:
98 enum Kind {
99 kSetRetAfterAddress,
100 kSetRetBeforeAddress,
101 kCopyConstant,
102 kCopyRegister,
103 kCopyXmmRegister,
104 kCopyInt64XmmRegister,
105 kCopyStackSlot,
106 kCopyDoubleStackSlot,
107 kCopyInt64StackSlot,
108 kSetPcMarker,
109 kSetCallerFp,
110 kSetCallerPc,
111 };
112
113 virtual DeoptInstr::Kind kind() const = 0; 122 virtual DeoptInstr::Kind kind() const = 0;
114 virtual intptr_t from_index() const = 0; 123 virtual intptr_t from_index() const = 0;
115 124
116 friend class DeoptInfoBuilder; 125 friend class DeoptInfoBuilder;
117 126
118 private: 127 private:
119 DISALLOW_COPY_AND_ASSIGN(DeoptInstr); 128 DISALLOW_COPY_AND_ASSIGN(DeoptInstr);
120 }; 129 };
121 130
122 131
123 // Builds one instance of DeoptInfo. Call AddXXX methods in the order of 132 // Builds a deoptimization info table, one DeoptInfo at a time. Call AddXXX
124 // their target, starting wih deoptimized code continuation pc and ending with 133 // methods in the order of their target, starting wih deoptimized code
125 // the first argument of the deoptimized code. 134 // continuation pc and ending with the first argument of the deoptimized
135 // code. Call CreateDeoptInfo to write the accumulated instructions into
136 // the heap and reset the builder's internal state for the next DeoptInfo.
126 class DeoptInfoBuilder : public ValueObject { 137 class DeoptInfoBuilder : public ValueObject {
Kevin Millikin (Google) 2012/10/05 14:31:55 This class had to be refactored to build all the D
127 public: 138 public:
139 explicit DeoptInfoBuilder(const intptr_t num_args);
140
128 // 'object_table' holds all objects referred to by DeoptInstr in 141 // 'object_table' holds all objects referred to by DeoptInstr in
129 // all DeoptInfo instances for a single Code object. 142 // all DeoptInfo instances for a single Code object.
130 DeoptInfoBuilder(const GrowableObjectArray& object_table, 143 const GrowableObjectArray& object_table() { return object_table_; }
131 const intptr_t num_args)
132 : instructions_(),
133 object_table_(object_table),
134 num_args_(num_args) {}
135 144
136 // Return address before instruction. 145 // Return address before instruction.
137 void AddReturnAddressBefore(const Function& function, 146 void AddReturnAddressBefore(const Function& function,
138 intptr_t deopt_id, 147 intptr_t deopt_id,
139 intptr_t to_index); 148 intptr_t to_index);
140 149
141 // Return address after instruction. 150 // Return address after instruction.
142 void AddReturnAddressAfter(const Function& function, 151 void AddReturnAddressAfter(const Function& function,
143 intptr_t deopt_id, 152 intptr_t deopt_id,
144 intptr_t to_index); 153 intptr_t to_index);
145 154
146 // Copy from optimized frame to unoptimized. 155 // Copy from optimized frame to unoptimized.
147 void AddCopy(const Location& from_loc, 156 void AddCopy(const Location& from_loc,
148 const Value& from_value, 157 const Value& from_value,
149 intptr_t to_index); 158 intptr_t to_index);
150 void AddPcMarker(const Function& function, intptr_t to_index); 159 void AddPcMarker(const Function& function, intptr_t to_index);
151 void AddCallerFp(intptr_t to_index); 160 void AddCallerFp(intptr_t to_index);
152 void AddCallerPc(intptr_t to_index); 161 void AddCallerPc(intptr_t to_index);
153 162
154 RawDeoptInfo* CreateDeoptInfo() const; 163 RawDeoptInfo* CreateDeoptInfo();
155 164
156 private: 165 private:
166 class TrieNode;
167
157 intptr_t FindOrAddObjectInTable(const Object& obj) const; 168 intptr_t FindOrAddObjectInTable(const Object& obj) const;
158 169
159 GrowableArray<DeoptInstr*> instructions_; 170 GrowableArray<DeoptInstr*> instructions_;
160 const GrowableObjectArray& object_table_; 171 const GrowableObjectArray& object_table_;
161 const intptr_t num_args_; 172 const intptr_t num_args_;
173 TrieNode* trie_root_;
srdjan 2012/10/08 16:37:58 Add comment: used to compress by sharing suffixes
174 intptr_t current_info_number_;
162 175
163 DISALLOW_COPY_AND_ASSIGN(DeoptInfoBuilder); 176 DISALLOW_COPY_AND_ASSIGN(DeoptInfoBuilder);
164 }; 177 };
165 178
166 179
167 // Utilities for managing the deopt table and its entries. The table is 180 // Utilities for managing the deopt table and its entries. The table is
168 // stored in an Array in the heap. It consists of triples of (PC offset, 181 // stored in an Array in the heap. It consists of triples of (PC offset,
169 // info, reason). Elements of each entry are stored consecutively in the 182 // info, reason). Elements of each entry are stored consecutively in the
170 // array. 183 // array.
171 class DeoptTable : public AllStatic { 184 class DeoptTable : public AllStatic {
(...skipping 19 matching lines...) Expand all
191 DeoptInfo* info, 204 DeoptInfo* info,
192 Smi* reason); 205 Smi* reason);
193 206
194 private: 207 private:
195 static const intptr_t kEntrySize = 3; 208 static const intptr_t kEntrySize = 3;
196 }; 209 };
197 210
198 } // namespace dart 211 } // namespace dart
199 212
200 #endif // VM_DEOPT_INSTRUCTIONS_H_ 213 #endif // VM_DEOPT_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698