Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index d0d19486f6c32707beaf1a246fbfb70a772605de..12a4fea9c24acccee9e6a26770bc991715f75be8 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -37,6 +37,7 @@ |
| #include "vm/stack_frame.h" |
| #include "vm/symbols.h" |
| #include "vm/tags.h" |
| +#include "vm/thread_registry.h" |
| #include "vm/timer.h" |
| #include "vm/unicode.h" |
| #include "vm/verified_memory.h" |
| @@ -2889,7 +2890,8 @@ void Class::RegisterCHACode(const Code& code) { |
| THR_Print("RegisterCHACode %s class %s\n", |
| Function::Handle(code.function()).ToQualifiedCString(), ToCString()); |
| } |
| - ASSERT(Thread::Current()->IsMutatorThread()); |
| + ASSERT(Thread::Current()->IsMutatorThread() || |
| + Isolate::Current()->thread_registry()->InSafepoint()); |
|
siva
2015/11/18 17:46:27
I wonder if it will be more efficient to do:
#if d
srdjan
2015/11/18 19:04:53
Factoring this out into (in object.cc):
static bo
|
| ASSERT(code.is_optimized()); |
| CHACodeArray a(*this); |
| a.Register(code); |
| @@ -5356,7 +5358,8 @@ bool Function::HasBreakpoint() const { |
| void Function::InstallOptimizedCode(const Code& code, bool is_osr) const { |
| - ASSERT(Thread::Current()->IsMutatorThread()); |
| + ASSERT(Thread::Current()->IsMutatorThread() || |
| + Isolate::Current()->thread_registry()->InSafepoint()); |
| // We may not have previous code if 'always_optimize' is set. |
| if (!is_osr && HasCode()) { |
| Code::Handle(CurrentCode()).DisableDartCode(); |
| @@ -5366,7 +5369,8 @@ void Function::InstallOptimizedCode(const Code& code, bool is_osr) const { |
| void Function::SetInstructions(const Code& value) const { |
| - ASSERT(Thread::Current()->IsMutatorThread()); |
| + ASSERT(Thread::Current()->IsMutatorThread() || |
| + Isolate::Current()->thread_registry()->InSafepoint()); |
| SetInstructionsSafe(value); |
| } |
| @@ -5378,7 +5382,8 @@ void Function::SetInstructionsSafe(const Code& value) const { |
| void Function::AttachCode(const Code& value) const { |
| - ASSERT(Thread::Current()->IsMutatorThread()); |
| + ASSERT(Thread::Current()->IsMutatorThread() || |
| + Isolate::Current()->thread_registry()->InSafepoint()); |
| // Finish setting up code before activating it. |
| value.set_owner(*this); |
| SetInstructions(value); |
| @@ -7823,7 +7828,8 @@ class FieldDependentArray : public WeakCodeReferences { |
| void Field::RegisterDependentCode(const Code& code) const { |
| - ASSERT(Thread::Current()->IsMutatorThread()); |
| + ASSERT(Thread::Current()->IsMutatorThread() || |
| + Isolate::Current()->thread_registry()->InSafepoint()); |
| ASSERT(code.is_optimized()); |
| FieldDependentArray a(*this); |
| a.Register(code); |
| @@ -13419,7 +13425,7 @@ RawCode* Code::FinalizeCode(const char* name, |
| } |
| // Hook up Code and Instructions objects. |
| - code.set_active_instructions(instrs.raw()); |
| + code.SetActiveInstructions(instrs.raw()); |
| code.set_instructions(instrs.raw()); |
| code.set_is_alive(true); |
| @@ -13461,7 +13467,7 @@ RawCode* Code::FinalizeCode(const Function& function, |
| assembler, |
| optimized); |
| } else { |
| - return FinalizeCode("", assembler); |
| + return FinalizeCode("", assembler, optimized); |
| } |
| } |
| @@ -13631,12 +13637,13 @@ bool Code::IsFunctionCode() const { |
| void Code::DisableDartCode() const { |
| - ASSERT(Thread::Current()->IsMutatorThread()); |
| + ASSERT(Thread::Current()->IsMutatorThread() || |
| + Isolate::Current()->thread_registry()->InSafepoint()); |
| ASSERT(IsFunctionCode()); |
| ASSERT(instructions() == active_instructions()); |
| const Code& new_code = |
| Code::Handle(StubCode::FixCallersTarget_entry()->code()); |
| - set_active_instructions(new_code.instructions()); |
| + SetActiveInstructions(new_code.instructions()); |
| } |
| @@ -13646,7 +13653,20 @@ void Code::DisableStubCode() const { |
| ASSERT(instructions() == active_instructions()); |
| const Code& new_code = |
| Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()); |
| - set_active_instructions(new_code.instructions()); |
| + SetActiveInstructions(new_code.instructions()); |
| +} |
| + |
| + |
| +void Code::SetActiveInstructions(RawInstructions* instructions) const { |
| + ASSERT(Thread::Current()->IsMutatorThread() || |
| + Isolate::Current()->thread_registry()->InSafepoint() || |
| + !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()); |
| } |