OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 void Reset() { | 55 void Reset() { |
56 info_ = 0; | 56 info_ = 0; |
57 bits_ = NULL; | 57 bits_ = NULL; |
58 } | 58 } |
59 | 59 |
60 int deoptimization_index() const { | 60 int deoptimization_index() const { |
61 ASSERT(is_valid()); | 61 ASSERT(is_valid()); |
62 return DeoptimizationIndexField::decode(info_); | 62 return DeoptimizationIndexField::decode(info_); |
63 } | 63 } |
64 | 64 |
65 int gap_code_size() const { | 65 static const int kArgumentsFieldBits = 3; |
66 ASSERT(is_valid()); | 66 static const int kSaveDoublesFieldBits = 1; |
67 return GapCodeSizeField::decode(info_); | 67 static const int kDeoptIndexBits = |
68 } | 68 32 - kArgumentsFieldBits - kSaveDoublesFieldBits; |
69 class DeoptimizationIndexField: public BitField<int, | |
70 0, | |
71 kDeoptIndexBits> {}; // NOLIN T | |
Vyacheslav Egorov (Chromium)
2011/11/10 15:50:54
LONG LINE
fschneider
2011/11/11 14:09:08
Done.
| |
72 class ArgumentsField: public BitField<unsigned, | |
73 kDeoptIndexBits, | |
74 kArgumentsFieldBits> {}; // NOLINT | |
75 class SaveDoublesField: public BitField<bool, | |
76 kDeoptIndexBits + kArgumentsFieldBits, | |
77 kSaveDoublesFieldBits> { }; // NOLINT | |
69 | 78 |
70 int argument_count() const { | 79 int argument_count() const { |
71 ASSERT(is_valid()); | 80 ASSERT(is_valid()); |
72 return ArgumentsField::decode(info_); | 81 return ArgumentsField::decode(info_); |
73 } | 82 } |
74 | 83 |
75 bool has_doubles() const { | 84 bool has_doubles() const { |
76 ASSERT(is_valid()); | 85 ASSERT(is_valid()); |
77 return SaveDoublesField::decode(info_); | 86 return SaveDoublesField::decode(info_); |
78 } | 87 } |
79 | 88 |
80 uint8_t* bits() { | 89 uint8_t* bits() { |
81 ASSERT(is_valid()); | 90 ASSERT(is_valid()); |
82 return bits_; | 91 return bits_; |
83 } | 92 } |
84 | 93 |
85 bool HasRegisters() const; | 94 bool HasRegisters() const; |
86 bool HasRegisterAt(int reg_index) const; | 95 bool HasRegisterAt(int reg_index) const; |
87 | 96 |
88 // Reserve 13 bits for the gap code size. On ARM a constant pool can be | |
89 // emitted when generating the gap code. The size of the const pool is less | |
90 // than what can be represented in 12 bits, so 13 bits gives room for having | |
91 // instructions before potentially emitting a constant pool. | |
92 static const int kGapCodeSizeBits = 13; | |
93 static const int kArgumentsFieldBits = 3; | |
94 static const int kSaveDoublesFieldBits = 1; | |
95 static const int kDeoptIndexBits = | |
96 32 - kGapCodeSizeBits - kArgumentsFieldBits - kSaveDoublesFieldBits; | |
97 class GapCodeSizeField: public BitField<unsigned, 0, kGapCodeSizeBits> {}; | |
98 class DeoptimizationIndexField: public BitField<int, | |
99 kGapCodeSizeBits, | |
100 kDeoptIndexBits> {}; // NOLIN T | |
101 class ArgumentsField: public BitField<unsigned, | |
102 kGapCodeSizeBits + kDeoptIndexBits, | |
103 kArgumentsFieldBits> {}; // NOLINT | |
104 class SaveDoublesField: public BitField<bool, | |
105 kGapCodeSizeBits + kDeoptIndexBits + | |
106 kArgumentsFieldBits, | |
107 kSaveDoublesFieldBits> { }; // NOLINT | |
108 | |
109 private: | 97 private: |
110 unsigned info_; | 98 unsigned info_; |
111 uint8_t* bits_; | 99 uint8_t* bits_; |
112 }; | 100 }; |
113 | 101 |
114 | 102 |
115 class SafepointTable BASE_EMBEDDED { | 103 class SafepointTable BASE_EMBEDDED { |
116 public: | 104 public: |
117 explicit SafepointTable(Code* code); | 105 explicit SafepointTable(Code* code); |
118 | 106 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 | 167 |
180 class Safepoint BASE_EMBEDDED { | 168 class Safepoint BASE_EMBEDDED { |
181 public: | 169 public: |
182 typedef enum { | 170 typedef enum { |
183 kSimple = 0, | 171 kSimple = 0, |
184 kWithRegisters = 1 << 0, | 172 kWithRegisters = 1 << 0, |
185 kWithDoubles = 1 << 1, | 173 kWithDoubles = 1 << 1, |
186 kWithRegistersAndDoubles = kWithRegisters | kWithDoubles | 174 kWithRegistersAndDoubles = kWithRegisters | kWithDoubles |
187 } Kind; | 175 } Kind; |
188 | 176 |
177 enum DeoptMode { | |
178 kNoDeopt, | |
179 kLazyDeopt | |
180 }; | |
181 | |
189 static const int kNoDeoptimizationIndex = | 182 static const int kNoDeoptimizationIndex = |
190 (1 << (SafepointEntry::kDeoptIndexBits)) - 1; | 183 (1 << (SafepointEntry::kDeoptIndexBits)) - 1; |
191 | 184 |
192 void DefinePointerSlot(int index) { indexes_->Add(index); } | 185 void DefinePointerSlot(int index) { indexes_->Add(index); } |
193 void DefinePointerRegister(Register reg); | 186 void DefinePointerRegister(Register reg); |
194 | 187 |
195 private: | 188 private: |
196 Safepoint(ZoneList<int>* indexes, ZoneList<int>* registers) : | 189 Safepoint(ZoneList<int>* indexes, ZoneList<int>* registers) : |
197 indexes_(indexes), registers_(registers) { } | 190 indexes_(indexes), registers_(registers) { } |
198 ZoneList<int>* indexes_; | 191 ZoneList<int>* indexes_; |
199 ZoneList<int>* registers_; | 192 ZoneList<int>* registers_; |
200 | 193 |
201 friend class SafepointTableBuilder; | 194 friend class SafepointTableBuilder; |
202 }; | 195 }; |
203 | 196 |
204 | 197 |
205 class SafepointTableBuilder BASE_EMBEDDED { | 198 class SafepointTableBuilder BASE_EMBEDDED { |
206 public: | 199 public: |
207 SafepointTableBuilder() | 200 SafepointTableBuilder() |
208 : deoptimization_info_(32), | 201 : deoptimization_info_(32), |
202 deopt_index_list_(32), | |
209 indexes_(32), | 203 indexes_(32), |
210 registers_(32), | 204 registers_(32), |
211 emitted_(false) { } | 205 emitted_(false), |
206 last_lazy_safepoint_(0) { } | |
212 | 207 |
213 // Get the offset of the emitted safepoint table in the code. | 208 // Get the offset of the emitted safepoint table in the code. |
214 unsigned GetCodeOffset() const; | 209 unsigned GetCodeOffset() const; |
215 | 210 |
216 // Define a new safepoint for the current position in the body. | 211 // Define a new safepoint for the current position in the body. |
217 Safepoint DefineSafepoint(Assembler* assembler, | 212 Safepoint DefineSafepoint(Assembler* assembler, |
218 Safepoint::Kind kind, | 213 Safepoint::Kind kind, |
219 int arguments, | 214 int arguments, |
220 int deoptimization_index); | 215 Safepoint::DeoptMode mode); |
221 | 216 |
222 // Update the last safepoint with the size of the code generated until the | 217 // Record deoptimization index for lazy deoptimization for the last |
223 // end of the gap following it. | 218 // outstanding safepoints. |
224 void SetPcAfterGap(int pc) { | 219 void RecordLazyDeoptimizationIndex(int index); |
225 ASSERT(!deoptimization_info_.is_empty()); | |
226 int index = deoptimization_info_.length() - 1; | |
227 deoptimization_info_[index].pc_after_gap = pc; | |
228 } | |
229 | |
230 // Get the end pc offset of the last safepoint, including the code generated | |
231 // until the end of the gap following it. | |
232 unsigned GetPcAfterGap() { | |
233 int index = deoptimization_info_.length(); | |
234 if (index == 0) return 0; | |
235 return deoptimization_info_[index - 1].pc_after_gap; | |
236 } | |
237 | 220 |
238 // Emit the safepoint table after the body. The number of bits per | 221 // Emit the safepoint table after the body. The number of bits per |
239 // entry must be enough to hold all the pointer indexes. | 222 // entry must be enough to hold all the pointer indexes. |
240 void Emit(Assembler* assembler, int bits_per_entry); | 223 void Emit(Assembler* assembler, int bits_per_entry); |
241 | 224 |
242 // Count the number of deoptimization points where the next | |
243 // following deoptimization point comes less than limit bytes | |
244 // after the end of this point's gap. | |
245 int CountShortDeoptimizationIntervals(unsigned limit); | |
246 | 225 |
247 private: | 226 private: |
248 struct DeoptimizationInfo { | 227 struct DeoptimizationInfo { |
249 unsigned pc; | 228 unsigned pc; |
250 unsigned deoptimization_index; | |
251 unsigned pc_after_gap; | |
252 unsigned arguments; | 229 unsigned arguments; |
253 bool has_doubles; | 230 bool has_doubles; |
254 }; | 231 }; |
255 | 232 |
256 uint32_t EncodeExceptPC(const DeoptimizationInfo& info); | 233 uint32_t EncodeExceptPC(const DeoptimizationInfo& info, unsigned index); |
257 | 234 |
258 ZoneList<DeoptimizationInfo> deoptimization_info_; | 235 ZoneList<DeoptimizationInfo> deoptimization_info_; |
236 ZoneList<unsigned> deopt_index_list_; | |
259 ZoneList<ZoneList<int>*> indexes_; | 237 ZoneList<ZoneList<int>*> indexes_; |
260 ZoneList<ZoneList<int>*> registers_; | 238 ZoneList<ZoneList<int>*> registers_; |
261 | 239 |
262 unsigned offset_; | 240 unsigned offset_; |
263 bool emitted_; | 241 bool emitted_; |
242 int last_lazy_safepoint_; | |
264 | 243 |
265 DISALLOW_COPY_AND_ASSIGN(SafepointTableBuilder); | 244 DISALLOW_COPY_AND_ASSIGN(SafepointTableBuilder); |
266 }; | 245 }; |
267 | 246 |
268 } } // namespace v8::internal | 247 } } // namespace v8::internal |
269 | 248 |
270 #endif // V8_SAFEPOINT_TABLE_H_ | 249 #endif // V8_SAFEPOINT_TABLE_H_ |
OLD | NEW |