OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "vm/deopt_instructions.h" | 5 #include "vm/deopt_instructions.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
10 #include "vm/locations.h" | 10 #include "vm/locations.h" |
11 #include "vm/parser.h" | 11 #include "vm/parser.h" |
12 #include "vm/stack_frame.h" | 12 #include "vm/stack_frame.h" |
13 | 13 |
14 namespace dart { | 14 namespace dart { |
15 | 15 |
16 DEFINE_FLAG(bool, compress_deopt_info, true, | 16 DEFINE_FLAG(bool, compress_deopt_info, true, |
17 "Compress the size of the deoptimization info for optimized code."); | 17 "Compress the size of the deoptimization info for optimized code."); |
18 DECLARE_FLAG(bool, trace_deoptimization); | 18 DECLARE_FLAG(bool, trace_deoptimization); |
| 19 DECLARE_FLAG(bool, trace_deoptimization_verbose); |
19 | 20 |
20 DeoptimizationContext::DeoptimizationContext(intptr_t* to_frame_start, | 21 DeoptimizationContext::DeoptimizationContext(intptr_t* to_frame_start, |
21 intptr_t to_frame_size, | 22 intptr_t to_frame_size, |
22 const Array& object_table, | 23 const Array& object_table, |
23 intptr_t num_args, | 24 intptr_t num_args, |
24 DeoptReasonId deopt_reason) | 25 DeoptReasonId deopt_reason) |
25 : object_table_(object_table), | 26 : object_table_(object_table), |
26 to_frame_(to_frame_start), | 27 to_frame_(to_frame_start), |
27 to_frame_size_(to_frame_size), | 28 to_frame_size_(to_frame_size), |
28 from_frame_(NULL), | 29 from_frame_(NULL), |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 uword pc = code.GetPcForDeoptId(deopt_id_, PcDescriptors::kIcCall); | 277 uword pc = code.GetPcForDeoptId(deopt_id_, PcDescriptors::kIcCall); |
277 if (pc != 0) { | 278 if (pc != 0) { |
278 // If the deoptimization happened at an IC call, update the IC data | 279 // If the deoptimization happened at an IC call, update the IC data |
279 // to avoid repeated deoptimization at the same site next time around. | 280 // to avoid repeated deoptimization at the same site next time around. |
280 ICData& ic_data = ICData::Handle(); | 281 ICData& ic_data = ICData::Handle(); |
281 CodePatcher::GetInstanceCallAt(pc, code, &ic_data, NULL); | 282 CodePatcher::GetInstanceCallAt(pc, code, &ic_data, NULL); |
282 if (!ic_data.IsNull()) { | 283 if (!ic_data.IsNull()) { |
283 ic_data.set_deopt_reason(deopt_context->deopt_reason()); | 284 ic_data.set_deopt_reason(deopt_context->deopt_reason()); |
284 } | 285 } |
285 } | 286 } |
| 287 |
| 288 const Array& deopt_history = Array::Handle(function.deopt_history()); |
| 289 ASSERT(!deopt_history.IsNull()); |
| 290 intptr_t count = function.deoptimization_counter(); |
| 291 ASSERT(count > 0); |
| 292 if (count <= deopt_history.Length()) { |
| 293 deopt_history.SetAt(count - 1, Smi::Handle(Smi::New(deopt_id_))); |
| 294 if (FLAG_trace_deoptimization_verbose) { |
| 295 OS::Print(" adding id %"Pd" to history at %"Pd"\n", |
| 296 deopt_id_, count - 1); |
| 297 } |
| 298 } |
286 } | 299 } |
287 | 300 |
288 intptr_t object_table_index() const { return object_table_index_; } | 301 intptr_t object_table_index() const { return object_table_index_; } |
289 intptr_t deopt_id() const { return deopt_id_; } | 302 intptr_t deopt_id() const { return deopt_id_; } |
290 | 303 |
291 private: | 304 private: |
292 static const intptr_t kFieldWidth = kBitsPerWord / 2; | 305 static const intptr_t kFieldWidth = kBitsPerWord / 2; |
293 class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { }; | 306 class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { }; |
294 class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; | 307 class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; |
295 | 308 |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 Smi* offset, | 1109 Smi* offset, |
1097 DeoptInfo* info, | 1110 DeoptInfo* info, |
1098 Smi* reason) { | 1111 Smi* reason) { |
1099 intptr_t i = index * kEntrySize; | 1112 intptr_t i = index * kEntrySize; |
1100 *offset ^= table.At(i); | 1113 *offset ^= table.At(i); |
1101 *info ^= table.At(i + 1); | 1114 *info ^= table.At(i + 1); |
1102 *reason ^= table.At(i + 2); | 1115 *reason ^= table.At(i + 2); |
1103 } | 1116 } |
1104 | 1117 |
1105 } // namespace dart | 1118 } // namespace dart |
OLD | NEW |