| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 dest_frame_(NULL), | 31 dest_frame_(NULL), |
| 32 dest_frame_size_(0), | 32 dest_frame_size_(0), |
| 33 source_frame_is_allocated_(false), | 33 source_frame_is_allocated_(false), |
| 34 source_frame_(NULL), | 34 source_frame_(NULL), |
| 35 source_frame_size_(0), | 35 source_frame_size_(0), |
| 36 cpu_registers_(cpu_registers), | 36 cpu_registers_(cpu_registers), |
| 37 fpu_registers_(fpu_registers), | 37 fpu_registers_(fpu_registers), |
| 38 num_args_(0), | 38 num_args_(0), |
| 39 deopt_reason_(ICData::kDeoptUnknown), | 39 deopt_reason_(ICData::kDeoptUnknown), |
| 40 isolate_(Isolate::Current()), | 40 isolate_(Isolate::Current()), |
| 41 deferred_boxes_(NULL), | 41 deferred_slots_(NULL), |
| 42 deferred_object_refs_(NULL), | |
| 43 deferred_objects_count_(0), | 42 deferred_objects_count_(0), |
| 44 deferred_objects_(NULL) { | 43 deferred_objects_(NULL) { |
| 45 object_table_ = code.object_table(); | 44 object_table_ = code.object_table(); |
| 46 | 45 |
| 47 ICData::DeoptReasonId deopt_reason = ICData::kDeoptUnknown; | 46 ICData::DeoptReasonId deopt_reason = ICData::kDeoptUnknown; |
| 48 const DeoptInfo& deopt_info = | 47 const DeoptInfo& deopt_info = |
| 49 DeoptInfo::Handle(code.GetDeoptInfoAtPc(frame->pc(), &deopt_reason)); | 48 DeoptInfo::Handle(code.GetDeoptInfoAtPc(frame->pc(), &deopt_reason)); |
| 50 ASSERT(!deopt_info.IsNull()); | 49 ASSERT(!deopt_info.IsNull()); |
| 51 deopt_info_ = deopt_info.raw(); | 50 deopt_info_ = deopt_info.raw(); |
| 52 deopt_reason_ = deopt_reason; | 51 deopt_reason_ = deopt_reason; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 current->Materialize(deopt_context); | 315 current->Materialize(deopt_context); |
| 317 | 316 |
| 318 delete current; | 317 delete current; |
| 319 } | 318 } |
| 320 } | 319 } |
| 321 | 320 |
| 322 | 321 |
| 323 // Materializes all deferred objects. Returns the total number of | 322 // Materializes all deferred objects. Returns the total number of |
| 324 // artificial arguments used during deoptimization. | 323 // artificial arguments used during deoptimization. |
| 325 intptr_t DeoptContext::MaterializeDeferredObjects() { | 324 intptr_t DeoptContext::MaterializeDeferredObjects() { |
| 326 // First materialize all unboxed "primitive" values (doubles, mints, simd) | 325 // Populate slots with references to all unboxed "primitive" values (doubles, |
| 327 // then materialize objects. The order is important: objects might be | 326 // mints, simd) and deferred objects. Deferred objects are only allocated |
| 328 // referencing boxes allocated on the first step. At the same time | 327 // but not filled with data. This is done later because deferred objects |
| 329 // objects can't be referencing other deferred objects because storing | 328 // can references each other. |
| 330 // an object into a field is always conservatively treated as escaping by | 329 FillDeferredSlots(this, &deferred_slots_); |
| 331 // allocation sinking and load forwarding. | |
| 332 FillDeferredSlots(this, &deferred_boxes_); | |
| 333 FillDeferredSlots(this, &deferred_object_refs_); | |
| 334 | 330 |
| 335 // Compute total number of artificial arguments used during deoptimization. | 331 // Compute total number of artificial arguments used during deoptimization. |
| 336 intptr_t deopt_arg_count = 0; | 332 intptr_t deopt_arg_count = 0; |
| 337 for (intptr_t i = 0; i < DeferredObjectsCount(); i++) { | 333 for (intptr_t i = 0; i < DeferredObjectsCount(); i++) { |
| 334 GetDeferredObject(i)->Fill(); |
| 338 deopt_arg_count += GetDeferredObject(i)->ArgumentCount(); | 335 deopt_arg_count += GetDeferredObject(i)->ArgumentCount(); |
| 339 } | 336 } |
| 340 | 337 |
| 341 // Since this is the only step where GC can occur during deoptimization, | 338 // Since this is the only step where GC can occur during deoptimization, |
| 342 // use it to report the source line where deoptimization occured. | 339 // use it to report the source line where deoptimization occured. |
| 343 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { | 340 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { |
| 344 DartFrameIterator iterator; | 341 DartFrameIterator iterator; |
| 345 StackFrame* top_frame = iterator.NextFrame(); | 342 StackFrame* top_frame = iterator.NextFrame(); |
| 346 ASSERT(top_frame != NULL); | 343 ASSERT(top_frame != NULL); |
| 347 const Code& code = Code::Handle(top_frame->LookupDartCode()); | 344 const Code& code = Code::Handle(top_frame->LookupDartCode()); |
| (...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 // initialized by default. | 1623 // initialized by default. |
| 1627 intptr_t non_null_fields = 0; | 1624 intptr_t non_null_fields = 0; |
| 1628 for (intptr_t i = 0; i < mat->InputCount(); i++) { | 1625 for (intptr_t i = 0; i < mat->InputCount(); i++) { |
| 1629 if (!mat->InputAt(i)->BindsToConstantNull()) { | 1626 if (!mat->InputAt(i)->BindsToConstantNull()) { |
| 1630 non_null_fields++; | 1627 non_null_fields++; |
| 1631 } | 1628 } |
| 1632 } | 1629 } |
| 1633 | 1630 |
| 1634 instructions_.Add( | 1631 instructions_.Add( |
| 1635 new(isolate()) DeoptMaterializeObjectInstr(non_null_fields)); | 1632 new(isolate()) DeoptMaterializeObjectInstr(non_null_fields)); |
| 1633 |
| 1634 for (intptr_t i = 0; i < mat->InputCount(); i++) { |
| 1635 MaterializeObjectInstr* nested_mat = mat->InputAt(i)->definition()-> |
| 1636 AsMaterializeObject(); |
| 1637 if (nested_mat != NULL) { |
| 1638 AddMaterialization(nested_mat); |
| 1639 } |
| 1640 } |
| 1636 } | 1641 } |
| 1637 | 1642 |
| 1638 | 1643 |
| 1639 intptr_t DeoptInfoBuilder::EmitMaterializationArguments(intptr_t dest_index) { | 1644 intptr_t DeoptInfoBuilder::EmitMaterializationArguments(intptr_t dest_index) { |
| 1640 ASSERT(dest_index == kDartFrameFixedSize); | 1645 ASSERT(dest_index == kDartFrameFixedSize); |
| 1641 for (intptr_t i = 0; i < materializations_.length(); i++) { | 1646 for (intptr_t i = 0; i < materializations_.length(); i++) { |
| 1642 MaterializeObjectInstr* mat = materializations_[i]; | 1647 MaterializeObjectInstr* mat = materializations_[i]; |
| 1643 // Class of the instance to allocate. | 1648 // Class of the instance to allocate. |
| 1644 AddConstant(mat->cls(), dest_index++); | 1649 AddConstant(mat->cls(), dest_index++); |
| 1645 for (intptr_t i = 0; i < mat->InputCount(); i++) { | 1650 for (intptr_t i = 0; i < mat->InputCount(); i++) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 Smi* offset, | 1756 Smi* offset, |
| 1752 DeoptInfo* info, | 1757 DeoptInfo* info, |
| 1753 Smi* reason) { | 1758 Smi* reason) { |
| 1754 intptr_t i = index * kEntrySize; | 1759 intptr_t i = index * kEntrySize; |
| 1755 *offset ^= table.At(i); | 1760 *offset ^= table.At(i); |
| 1756 *info ^= table.At(i + 1); | 1761 *info ^= table.At(i + 1); |
| 1757 *reason ^= table.At(i + 2); | 1762 *reason ^= table.At(i + 2); |
| 1758 } | 1763 } |
| 1759 | 1764 |
| 1760 } // namespace dart | 1765 } // namespace dart |
| OLD | NEW |