Index: runtime/vm/isolate.cc |
=================================================================== |
--- runtime/vm/isolate.cc (revision 28111) |
+++ runtime/vm/isolate.cc (working copy) |
@@ -14,6 +14,7 @@ |
#include "vm/dart_api_state.h" |
#include "vm/dart_entry.h" |
#include "vm/debugger.h" |
+#include "vm/deopt_instructions.h" |
#include "vm/heap.h" |
#include "vm/heap_histogram.h" |
#include "vm/message_handler.h" |
@@ -38,7 +39,6 @@ |
"Track function usage and report."); |
DEFINE_FLAG(bool, trace_isolates, false, |
"Trace isolate creation and shut down."); |
-DECLARE_FLAG(bool, trace_deoptimization_verbose); |
void Isolate::RegisterClass(const Class& cls) { |
@@ -270,113 +270,6 @@ |
#endif |
-void DeferredDouble::Materialize() { |
- RawDouble** double_slot = reinterpret_cast<RawDouble**>(slot()); |
- *double_slot = Double::New(value()); |
- |
- if (FLAG_trace_deoptimization_verbose) { |
- OS::PrintErr("materializing double at %" Px ": %g\n", |
- reinterpret_cast<uword>(slot()), value()); |
- } |
-} |
- |
- |
-void DeferredMint::Materialize() { |
- RawMint** mint_slot = reinterpret_cast<RawMint**>(slot()); |
- ASSERT(!Smi::IsValid64(value())); |
- Mint& mint = Mint::Handle(); |
- mint ^= Integer::New(value()); |
- *mint_slot = mint.raw(); |
- |
- if (FLAG_trace_deoptimization_verbose) { |
- OS::PrintErr("materializing mint at %" Px ": %" Pd64 "\n", |
- reinterpret_cast<uword>(slot()), value()); |
- } |
-} |
- |
- |
-void DeferredFloat32x4::Materialize() { |
- RawFloat32x4** float32x4_slot = reinterpret_cast<RawFloat32x4**>(slot()); |
- RawFloat32x4* raw_float32x4 = Float32x4::New(value()); |
- *float32x4_slot = raw_float32x4; |
- |
- if (FLAG_trace_deoptimization_verbose) { |
- float x = raw_float32x4->x(); |
- float y = raw_float32x4->y(); |
- float z = raw_float32x4->z(); |
- float w = raw_float32x4->w(); |
- OS::PrintErr("materializing Float32x4 at %" Px ": %g,%g,%g,%g\n", |
- reinterpret_cast<uword>(slot()), x, y, z, w); |
- } |
-} |
- |
- |
-void DeferredUint32x4::Materialize() { |
- RawUint32x4** uint32x4_slot = reinterpret_cast<RawUint32x4**>(slot()); |
- RawUint32x4* raw_uint32x4 = Uint32x4::New(value()); |
- *uint32x4_slot = raw_uint32x4; |
- |
- if (FLAG_trace_deoptimization_verbose) { |
- uint32_t x = raw_uint32x4->x(); |
- uint32_t y = raw_uint32x4->y(); |
- uint32_t z = raw_uint32x4->z(); |
- uint32_t w = raw_uint32x4->w(); |
- OS::PrintErr("materializing Uint32x4 at %" Px ": %x,%x,%x,%x\n", |
- reinterpret_cast<uword>(slot()), x, y, z, w); |
- } |
-} |
- |
- |
-void DeferredObjectRef::Materialize() { |
- DeferredObject* obj = Isolate::Current()->GetDeferredObject(index()); |
- *slot() = obj->object(); |
- if (FLAG_trace_deoptimization_verbose) { |
- OS::PrintErr("writing instance ref at %" Px ": %s\n", |
- reinterpret_cast<uword>(slot()), |
- Instance::Handle(obj->object()).ToCString()); |
- } |
-} |
- |
- |
-RawInstance* DeferredObject::object() { |
- if (object_ == NULL) { |
- Materialize(); |
- } |
- return object_->raw(); |
-} |
- |
- |
-void DeferredObject::Materialize() { |
- Class& cls = Class::Handle(); |
- cls ^= GetClass(); |
- |
- if (FLAG_trace_deoptimization_verbose) { |
- OS::PrintErr("materializing instance of %s (%" Px ", %" Pd " fields)\n", |
- cls.ToCString(), |
- reinterpret_cast<uword>(args_), |
- field_count_); |
- } |
- |
- const Instance& obj = Instance::ZoneHandle(Instance::New(cls)); |
- |
- Field& field = Field::Handle(); |
- Object& value = Object::Handle(); |
- for (intptr_t i = 0; i < field_count_; i++) { |
- field ^= GetField(i); |
- value = GetValue(i); |
- obj.SetField(field, value); |
- |
- if (FLAG_trace_deoptimization_verbose) { |
- OS::PrintErr(" %s <- %s\n", |
- String::Handle(field.name()).ToCString(), |
- value.ToCString()); |
- } |
- } |
- |
- object_ = &obj; |
-} |
- |
- |
#define REUSABLE_HANDLE_INITIALIZERS(object) \ |
object##_handle_(NULL), |
@@ -409,14 +302,7 @@ |
gc_prologue_callbacks_(), |
gc_epilogue_callbacks_(), |
defer_finalization_count_(0), |
- deopt_cpu_registers_copy_(NULL), |
- deopt_fpu_registers_copy_(NULL), |
- deopt_frame_copy_(NULL), |
- deopt_frame_copy_size_(0), |
- deferred_boxes_(NULL), |
- deferred_object_refs_(NULL), |
- deferred_objects_count_(0), |
- deferred_objects_(NULL), |
+ deopt_context_(NULL), |
stacktrace_(NULL), |
stack_frame_index_(-1), |
object_histogram_(NULL), |
@@ -444,6 +330,7 @@ |
mutex_ = NULL; // Fail fast if interrupts are scheduled on a dead isolate. |
delete message_handler_; |
message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. |
+ ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. |
delete object_histogram_; |
} |
@@ -864,6 +751,11 @@ |
// Visit objects in the debugger. |
debugger()->VisitObjectPointers(visitor); |
+ |
+ // Visit objects that are being used for deoptimization. |
+ if (deopt_context() != NULL) { |
+ deopt_context()->VisitObjectPointers(visitor); |
+ } |
} |
@@ -1079,31 +971,6 @@ |
} |
-static void FillDeferredSlots(DeferredSlot** slot_list) { |
- DeferredSlot* slot = *slot_list; |
- *slot_list = NULL; |
- |
- while (slot != NULL) { |
- DeferredSlot* current = slot; |
- slot = slot->next(); |
- |
- current->Materialize(); |
- |
- delete current; |
- } |
-} |
- |
- |
-void Isolate::MaterializeDeferredBoxes() { |
- FillDeferredSlots(&deferred_boxes_); |
-} |
- |
- |
-void Isolate::MaterializeDeferredObjects() { |
- FillDeferredSlots(&deferred_object_refs_); |
-} |
- |
- |
static char* GetRootScriptUri(Isolate* isolate) { |
const Library& library = |
Library::Handle(isolate->object_store()->root_library()); |