Index: runtime/vm/deopt_instructions.h |
=================================================================== |
--- runtime/vm/deopt_instructions.h (revision 27970) |
+++ runtime/vm/deopt_instructions.h (working copy) |
@@ -8,6 +8,7 @@ |
#include "vm/allocation.h" |
#include "vm/assembler.h" |
#include "vm/code_generator.h" |
+#include "vm/deferred_objects.h" |
#include "vm/growable_array.h" |
#include "vm/object.h" |
@@ -18,23 +19,41 @@ |
class MaterializeObjectInstr; |
// Holds all data relevant for execution of deoptimization instructions. |
-class DeoptimizationContext : public ValueObject { |
+class DeoptContext { |
public: |
- // 'to_frame_start' points to the fixed size portion of the frame under sp. |
// 'num_args' is 0 if there are no arguments or if there are optional |
// arguments. |
- DeoptimizationContext(intptr_t* to_frame_start, |
- intptr_t to_frame_size, |
- const Array& object_table, |
- intptr_t num_args, |
- DeoptReasonId deopt_reason); |
+ DeoptContext(const Array& object_table, |
+ intptr_t num_args, |
+ DeoptReasonId deopt_reason); |
+ ~DeoptContext(); |
srdjan
2013/09/27 17:04:54
virtual, just in case?
turnidge
2013/09/30 17:40:22
Done.
|
+ |
+ // 'start' points to the fixed size portion of the frame under sp. |
+ // |
+ // DeoptContext does not claim ownership of the frame memory. |
+ void SetToFrame(intptr_t* start, intptr_t size); |
+ |
+ // DeoptContext does not claim ownership of the frame memory. |
+ void SetFromFrame(intptr_t* start, intptr_t size); |
+ |
+ // DeoptContext does not claim ownership of the memory used for the |
+ // saved registers. |
+ void SetSavedRegisters(fpu_register_t* fpu_registers, |
+ intptr_t* cpu_registers); |
+ |
+ intptr_t* from_frame() const { return from_frame_; } |
+ fpu_register_t* fpu_registers() const { return fpu_registers_; } |
+ intptr_t* cpu_registers() const { return cpu_registers_; } |
+ |
intptr_t* GetFromFrameAddressAt(intptr_t index) const { |
+ ASSERT(from_frame_ != NULL); |
ASSERT((0 <= index) && (index < from_frame_size_)); |
return &from_frame_[index]; |
} |
intptr_t* GetToFrameAddressAt(intptr_t index) const { |
+ ASSERT(to_frame_ != NULL); |
ASSERT((0 <= index) && (index < to_frame_size_)); |
return &to_frame_[index]; |
} |
@@ -47,23 +66,24 @@ |
void SetCallerFp(intptr_t callers_fp); |
RawObject* ObjectAt(intptr_t index) const { |
- return object_table_.At(index); |
+ const Array& object_table = Array::Handle(object_table_); |
+ return object_table.At(index); |
} |
intptr_t RegisterValue(Register reg) const { |
- return registers_copy_[reg]; |
+ return cpu_registers_[reg]; |
} |
double FpuRegisterValue(FpuRegister reg) const { |
- return *reinterpret_cast<double*>(&fpu_registers_copy_[reg]); |
+ return *reinterpret_cast<double*>(&fpu_registers_[reg]); |
} |
int64_t FpuRegisterValueAsInt64(FpuRegister reg) const { |
- return *reinterpret_cast<int64_t*>(&fpu_registers_copy_[reg]); |
+ return *reinterpret_cast<int64_t*>(&fpu_registers_[reg]); |
} |
simd128_value_t FpuRegisterValueAsSimd128(FpuRegister reg) const { |
- const float* address = reinterpret_cast<float*>(&fpu_registers_copy_[reg]); |
+ const float* address = reinterpret_cast<float*>(&fpu_registers_[reg]); |
return simd128_value_t().readFrom(address); |
} |
@@ -73,20 +93,91 @@ |
DeoptReasonId deopt_reason() const { return deopt_reason_; } |
+ void VisitObjectPointers(ObjectPointerVisitor* visitor); |
+ |
+ void PrepareForDeferredMaterialization(intptr_t count) { |
+ if (count > 0) { |
+ deferred_objects_ = new DeferredObject*[count]; |
+ deferred_objects_count_ = count; |
+ } |
+ } |
+ |
+ DeferredObject* GetDeferredObject(intptr_t idx) const { |
+ return deferred_objects_[idx]; |
+ } |
+ |
+ // Sets the materialized value for some deferred object. |
+ // |
+ // Claims ownership of the memory for 'object'. |
+ void SetDeferredObjectAt(intptr_t idx, DeferredObject* object) { |
+ deferred_objects_[idx] = object; |
+ } |
+ |
+ intptr_t DeferredObjectsCount() const { |
+ return deferred_objects_count_; |
+ } |
+ |
+ void DeferMaterializedObjectRef(intptr_t idx, intptr_t* slot) { |
+ deferred_object_refs_ = new DeferredObjectRef( |
+ idx, |
+ reinterpret_cast<RawInstance**>(slot), |
+ deferred_object_refs_); |
+ } |
+ |
+ void DeferDoubleMaterialization(double value, RawDouble** slot) { |
+ deferred_boxes_ = new DeferredDouble( |
+ value, |
+ reinterpret_cast<RawInstance**>(slot), |
+ deferred_boxes_); |
+ } |
+ |
+ void DeferMintMaterialization(int64_t value, RawMint** slot) { |
+ deferred_boxes_ = new DeferredMint( |
+ value, |
+ reinterpret_cast<RawInstance**>(slot), |
+ deferred_boxes_); |
+ } |
+ |
+ void DeferFloat32x4Materialization(simd128_value_t value, |
+ RawFloat32x4** slot) { |
+ deferred_boxes_ = new DeferredFloat32x4( |
+ value, |
+ reinterpret_cast<RawInstance**>(slot), |
+ deferred_boxes_); |
+ } |
+ |
+ void DeferUint32x4Materialization(simd128_value_t value, |
+ RawUint32x4** slot) { |
+ deferred_boxes_ = new DeferredUint32x4( |
+ value, |
+ reinterpret_cast<RawInstance**>(slot), |
+ deferred_boxes_); |
+ } |
+ |
+ // Materializes all deferred objects. Returns the total number of |
+ // artificial arguments used during deoptimization. |
+ intptr_t MaterializeDeferredObjects(); |
+ |
private: |
- const Array& object_table_; |
+ RawArray* object_table_; |
intptr_t* to_frame_; |
- const intptr_t to_frame_size_; |
+ intptr_t to_frame_size_; |
intptr_t* from_frame_; |
intptr_t from_frame_size_; |
- intptr_t* registers_copy_; |
- fpu_register_t* fpu_registers_copy_; |
+ intptr_t* cpu_registers_; |
+ fpu_register_t* fpu_registers_; |
const intptr_t num_args_; |
const DeoptReasonId deopt_reason_; |
intptr_t caller_fp_; |
Isolate* isolate_; |
- DISALLOW_COPY_AND_ASSIGN(DeoptimizationContext); |
+ DeferredSlot* deferred_boxes_; |
+ DeferredSlot* deferred_object_refs_; |
+ |
+ intptr_t deferred_objects_count_; |
+ DeferredObject** deferred_objects_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DeoptContext); |
}; |
@@ -126,8 +217,7 @@ |
virtual const char* ToCString() const = 0; |
- virtual void Execute(DeoptimizationContext* deopt_context, |
- intptr_t* to_addr) = 0; |
+ virtual void Execute(DeoptContext* deopt_context, intptr_t* to_addr) = 0; |
virtual DeoptInstr::Kind kind() const = 0; |