Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index b0b4f4f57626a1215ed5c10b2efe8bfe7834c7d5..e69817737dc05d81b1188c6eaacddbd454fead3b 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -12972,6 +12972,26 @@ void Code::set_static_calls_target_table(const Array& value) const { |
} |
+uword Code::EntryPoint() const { |
+ RawObject* instr = instructions(); |
+ if (!instr->IsHeapObject()) { |
+ return active_entry_point(); |
+ } else { |
+ return Instructions::EntryPoint(instructions()); |
+ } |
+} |
+ |
+ |
+intptr_t Code::Size() const { |
+ RawObject* instr = instructions(); |
+ if (!instr->IsHeapObject()) { |
+ return Smi::Value(raw_ptr()->precompiled_instructions_size_); |
+ } else { |
+ return instructions()->ptr()->size_; |
+ } |
+} |
+ |
+ |
bool Code::HasBreakpoint() const { |
if (!FLAG_support_debugger) { |
return false; |
@@ -13317,10 +13337,13 @@ RawCode* Code::FinalizeCode(const char* name, |
} |
// Hook up Code and Instructions objects. |
- code.SetActiveInstructions(instrs.raw()); |
code.set_instructions(instrs.raw()); |
+ code.SetActiveInstructions(instrs.raw()); |
code.set_is_alive(true); |
+ ASSERT(code.EntryPoint() == instrs.EntryPoint()); |
+ ASSERT(code.Size() == instrs.size()); |
+ |
// Set object pool in Instructions object. |
INC_STAT(Thread::Current(), |
total_code_size, object_pool.Length() * sizeof(uintptr_t)); |
@@ -13518,9 +13541,10 @@ bool Code::IsFunctionCode() const { |
void Code::DisableDartCode() const { |
DEBUG_ASSERT(IsMutatorOrAtSafepoint()); |
ASSERT(IsFunctionCode()); |
- ASSERT(instructions() == active_instructions()); |
+ ASSERT(!IsDisabled()); |
const Code& new_code = |
Code::Handle(StubCode::FixCallersTarget_entry()->code()); |
+ ASSERT(new_code.instructions()->IsVMHeapObject()); |
SetActiveInstructions(new_code.instructions()); |
} |
@@ -13528,9 +13552,10 @@ void Code::DisableDartCode() const { |
void Code::DisableStubCode() const { |
ASSERT(Thread::Current()->IsMutatorThread()); |
ASSERT(IsAllocationStubCode()); |
- ASSERT(instructions() == active_instructions()); |
+ ASSERT(!IsDisabled()); |
const Code& new_code = |
Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()); |
+ ASSERT(new_code.instructions()->IsVMHeapObject()); |
SetActiveInstructions(new_code.instructions()); |
} |
@@ -13539,7 +13564,6 @@ void Code::SetActiveInstructions(RawInstructions* instructions) const { |
DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive()); |
// RawInstructions are never allocated in New space and hence a |
// store buffer update is not needed here. |
- StorePointer(&raw_ptr()->active_instructions_, instructions); |
StoreNonPointer(&raw_ptr()->entry_point_, |
reinterpret_cast<uword>(instructions->ptr()) + |
Instructions::HeaderSize()); |