OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 int gap_code_size() const { | 66 int gap_code_size() const { |
67 ASSERT(is_valid()); | 67 ASSERT(is_valid()); |
68 return GapCodeSizeField::decode(info_); | 68 return GapCodeSizeField::decode(info_); |
69 } | 69 } |
70 | 70 |
71 int argument_count() const { | 71 int argument_count() const { |
72 ASSERT(is_valid()); | 72 ASSERT(is_valid()); |
73 return ArgumentsField::decode(info_); | 73 return ArgumentsField::decode(info_); |
74 } | 74 } |
75 | 75 |
| 76 bool has_doubles() const { |
| 77 ASSERT(is_valid()); |
| 78 return SaveDoublesField::decode(info_); |
| 79 } |
| 80 |
76 uint8_t* bits() { | 81 uint8_t* bits() { |
77 ASSERT(is_valid()); | 82 ASSERT(is_valid()); |
78 return bits_; | 83 return bits_; |
79 } | 84 } |
80 | 85 |
81 bool HasRegisters() const; | 86 bool HasRegisters() const; |
82 bool HasRegisterAt(int reg_index) const; | 87 bool HasRegisterAt(int reg_index) const; |
83 | 88 |
84 // Reserve 13 bits for the gap code size. On ARM a constant pool can be | 89 // Reserve 13 bits for the gap code size. On ARM a constant pool can be |
85 // emitted when generating the gap code. The size of the const pool is less | 90 // emitted when generating the gap code. The size of the const pool is less |
86 // than what can be represented in 12 bits, so 13 bits gives room for having | 91 // than what can be represented in 12 bits, so 13 bits gives room for having |
87 // instructions before potentially emitting a constant pool. | 92 // instructions before potentially emitting a constant pool. |
88 static const int kGapCodeSizeBits = 13; | 93 static const int kGapCodeSizeBits = 13; |
89 static const int kArgumentsFieldBits = 3; | 94 static const int kArgumentsFieldBits = 3; |
| 95 static const int kSaveDoublesFieldBits = 1; |
90 static const int kDeoptIndexBits = | 96 static const int kDeoptIndexBits = |
91 32 - kGapCodeSizeBits - kArgumentsFieldBits; | 97 32 - kGapCodeSizeBits - kArgumentsFieldBits - kSaveDoublesFieldBits; |
92 class GapCodeSizeField: public BitField<unsigned, 0, kGapCodeSizeBits> {}; | 98 class GapCodeSizeField: public BitField<unsigned, 0, kGapCodeSizeBits> {}; |
93 class DeoptimizationIndexField: public BitField<int, | 99 class DeoptimizationIndexField: public BitField<int, |
94 kGapCodeSizeBits, | 100 kGapCodeSizeBits, |
95 kDeoptIndexBits> {}; // NOLIN
T | 101 kDeoptIndexBits> {}; // NOLIN
T |
96 class ArgumentsField: public BitField<unsigned, | 102 class ArgumentsField: public BitField<unsigned, |
97 kGapCodeSizeBits + kDeoptIndexBits, | 103 kGapCodeSizeBits + kDeoptIndexBits, |
98 kArgumentsFieldBits> {}; // NOLINT | 104 kArgumentsFieldBits> {}; // NOLINT |
| 105 class SaveDoublesField: public BitField<bool, |
| 106 kGapCodeSizeBits + kDeoptIndexBits + |
| 107 kArgumentsFieldBits, |
| 108 kSaveDoublesFieldBits> { }; // NOLINT |
| 109 |
99 private: | 110 private: |
100 unsigned info_; | 111 unsigned info_; |
101 uint8_t* bits_; | 112 uint8_t* bits_; |
102 }; | 113 }; |
103 | 114 |
104 | 115 |
105 class SafepointTable BASE_EMBEDDED { | 116 class SafepointTable BASE_EMBEDDED { |
106 public: | 117 public: |
107 explicit SafepointTable(Code* code); | 118 explicit SafepointTable(Code* code); |
108 | 119 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 int deoptimization_index = Safepoint::kNoDeoptimizationIndex); | 213 int deoptimization_index = Safepoint::kNoDeoptimizationIndex); |
203 | 214 |
204 // Define a new safepoint with registers on the stack for the | 215 // Define a new safepoint with registers on the stack for the |
205 // current position in the body and take the number of arguments on | 216 // current position in the body and take the number of arguments on |
206 // top of the registers into account. | 217 // top of the registers into account. |
207 Safepoint DefineSafepointWithRegisters( | 218 Safepoint DefineSafepointWithRegisters( |
208 Assembler* assembler, | 219 Assembler* assembler, |
209 int arguments, | 220 int arguments, |
210 int deoptimization_index = Safepoint::kNoDeoptimizationIndex); | 221 int deoptimization_index = Safepoint::kNoDeoptimizationIndex); |
211 | 222 |
| 223 // Define a new safepoint with all double registers and the normal |
| 224 // registers on the stack for the current position in the body and |
| 225 // take the number of arguments on top of the registers into account. |
| 226 // TODO(1043) Rewrite the three SafepointTableBuilder::DefineSafepoint |
| 227 // methods to one method that uses template arguments. |
| 228 Safepoint DefineSafepointWithRegistersAndDoubles( |
| 229 Assembler* assembler, |
| 230 int arguments, |
| 231 int deoptimization_index = Safepoint::kNoDeoptimizationIndex); |
| 232 |
212 // Update the last safepoint with the size of the code generated for the gap | 233 // Update the last safepoint with the size of the code generated for the gap |
213 // following it. | 234 // following it. |
214 void SetPcAfterGap(int pc) { | 235 void SetPcAfterGap(int pc) { |
215 ASSERT(!deoptimization_info_.is_empty()); | 236 ASSERT(!deoptimization_info_.is_empty()); |
216 int index = deoptimization_info_.length() - 1; | 237 int index = deoptimization_info_.length() - 1; |
217 deoptimization_info_[index].pc_after_gap = pc; | 238 deoptimization_info_[index].pc_after_gap = pc; |
218 } | 239 } |
219 | 240 |
220 // Emit the safepoint table after the body. The number of bits per | 241 // Emit the safepoint table after the body. The number of bits per |
221 // entry must be enough to hold all the pointer indexes. | 242 // entry must be enough to hold all the pointer indexes. |
222 void Emit(Assembler* assembler, int bits_per_entry); | 243 void Emit(Assembler* assembler, int bits_per_entry); |
223 | 244 |
224 private: | 245 private: |
225 struct DeoptimizationInfo { | 246 struct DeoptimizationInfo { |
226 unsigned pc; | 247 unsigned pc; |
227 unsigned deoptimization_index; | 248 unsigned deoptimization_index; |
228 unsigned pc_after_gap; | 249 unsigned pc_after_gap; |
229 unsigned arguments; | 250 unsigned arguments; |
| 251 bool has_doubles; |
230 }; | 252 }; |
231 | 253 |
232 uint32_t EncodeExceptPC(const DeoptimizationInfo& info); | 254 uint32_t EncodeExceptPC(const DeoptimizationInfo& info); |
233 | 255 |
234 ZoneList<DeoptimizationInfo> deoptimization_info_; | 256 ZoneList<DeoptimizationInfo> deoptimization_info_; |
235 ZoneList<ZoneList<int>*> indexes_; | 257 ZoneList<ZoneList<int>*> indexes_; |
236 ZoneList<ZoneList<int>*> registers_; | 258 ZoneList<ZoneList<int>*> registers_; |
237 | 259 |
238 bool emitted_; | 260 bool emitted_; |
239 unsigned offset_; | 261 unsigned offset_; |
240 | 262 |
241 DISALLOW_COPY_AND_ASSIGN(SafepointTableBuilder); | 263 DISALLOW_COPY_AND_ASSIGN(SafepointTableBuilder); |
242 }; | 264 }; |
243 | 265 |
244 } } // namespace v8::internal | 266 } } // namespace v8::internal |
245 | 267 |
246 #endif // V8_SAFEPOINT_TABLE_H_ | 268 #endif // V8_SAFEPOINT_TABLE_H_ |
OLD | NEW |