Chromium Code Reviews| Index: runtime/vm/stub_code.cc |
| diff --git a/runtime/vm/stub_code.cc b/runtime/vm/stub_code.cc |
| index d06b125ee61bef3d586c12ac25bea40a0c138edf..14cd572f52fc275d60e4013a37dfaf68c1679bde 100644 |
| --- a/runtime/vm/stub_code.cc |
| +++ b/runtime/vm/stub_code.cc |
| @@ -7,6 +7,7 @@ |
| #include "platform/assert.h" |
| #include "platform/globals.h" |
| #include "vm/assembler.h" |
| +#include "vm/compiler.h" // SafepointOperationScope. |
|
siva
2016/02/17 21:07:49
#include "vm/safepoint.h"
(SafepointOperationScop
srdjan
2016/02/17 21:15:14
Done.
|
| #include "vm/disassembler.h" |
| #include "vm/flags.h" |
| #include "vm/object_store.h" |
| @@ -120,9 +121,33 @@ RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { |
| Assembler assembler; |
| const char* name = cls.ToCString(); |
| StubCode::GenerateAllocationStubForClass(&assembler, cls); |
| - stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); |
| - stub.set_owner(cls); |
| - cls.set_allocation_stub(stub); |
| + |
| + if (thread->IsMutatorThread()) { |
| + stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); |
| + stub.set_owner(cls); |
| + cls.set_allocation_stub(stub); |
| + } else { |
| + // This part of compilation must be at a safepoint. |
|
siva
2016/02/17 21:07:49
This part of stub code generation must be at a saf
srdjan
2016/02/17 21:15:15
Done.
|
| + // Stop mutator thread before creating the instruction object and |
| + // installing code. |
| + // Mutator thread may not run code while we are creating the |
| + // instruction object, since the creation of instruction object |
| + // changes code page access permissions (makes them temporary not |
| + // executable). |
| + { |
| + SafepointOperationScope safepoint_scope(thread); |
| + // Do not Garbage collect during this stage and instead allow the |
| + // heap to grow. |
| + NoHeapGrowthControlScope no_growth_control; |
| + stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); |
| + stub.set_owner(cls); |
| + cls.set_allocation_stub(stub); |
| + } |
| + Isolate* isolate = thread->isolate(); |
| + if (isolate->heap()->NeedsGarbageCollection()) { |
| + isolate->heap()->CollectAllGarbage(); |
| + } |
| + } |
|
siva
2016/02/17 21:07:49
I am wondering if it makes sense to move this to C
srdjan
2016/02/17 21:15:15
The situations are not exactly identical. Leaving
|
| if (FLAG_support_disassembler && FLAG_disassemble_stubs) { |
| LogBlock lb; |
| THR_Print("Code for allocation stub '%s': {\n", name); |