Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/stub_code.h" | 5 #include "vm/stub_code.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #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.
| |
| 10 #include "vm/disassembler.h" | 11 #include "vm/disassembler.h" |
| 11 #include "vm/flags.h" | 12 #include "vm/flags.h" |
| 12 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 13 #include "vm/snapshot.h" | 14 #include "vm/snapshot.h" |
| 14 #include "vm/virtual_memory.h" | 15 #include "vm/virtual_memory.h" |
| 15 #include "vm/visitor.h" | 16 #include "vm/visitor.h" |
| 16 | 17 |
| 17 namespace dart { | 18 namespace dart { |
| 18 | 19 |
| 19 DEFINE_FLAG(bool, disassemble_stubs, false, "Disassemble generated stubs."); | 20 DEFINE_FLAG(bool, disassemble_stubs, false, "Disassemble generated stubs."); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 const Error& error = Error::Handle(zone, cls.EnsureIsFinalized(thread)); | 114 const Error& error = Error::Handle(zone, cls.EnsureIsFinalized(thread)); |
| 114 ASSERT(error.IsNull()); | 115 ASSERT(error.IsNull()); |
| 115 if (cls.id() == kArrayCid) { | 116 if (cls.id() == kArrayCid) { |
| 116 return AllocateArray_entry()->code(); | 117 return AllocateArray_entry()->code(); |
| 117 } | 118 } |
| 118 Code& stub = Code::Handle(zone, cls.allocation_stub()); | 119 Code& stub = Code::Handle(zone, cls.allocation_stub()); |
| 119 if (stub.IsNull()) { | 120 if (stub.IsNull()) { |
| 120 Assembler assembler; | 121 Assembler assembler; |
| 121 const char* name = cls.ToCString(); | 122 const char* name = cls.ToCString(); |
| 122 StubCode::GenerateAllocationStubForClass(&assembler, cls); | 123 StubCode::GenerateAllocationStubForClass(&assembler, cls); |
| 123 stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); | 124 |
| 124 stub.set_owner(cls); | 125 if (thread->IsMutatorThread()) { |
| 125 cls.set_allocation_stub(stub); | 126 stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); |
| 127 stub.set_owner(cls); | |
| 128 cls.set_allocation_stub(stub); | |
| 129 } else { | |
| 130 // 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.
| |
| 131 // Stop mutator thread before creating the instruction object and | |
| 132 // installing code. | |
| 133 // Mutator thread may not run code while we are creating the | |
| 134 // instruction object, since the creation of instruction object | |
| 135 // changes code page access permissions (makes them temporary not | |
| 136 // executable). | |
| 137 { | |
| 138 SafepointOperationScope safepoint_scope(thread); | |
| 139 // Do not Garbage collect during this stage and instead allow the | |
| 140 // heap to grow. | |
| 141 NoHeapGrowthControlScope no_growth_control; | |
| 142 stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); | |
| 143 stub.set_owner(cls); | |
| 144 cls.set_allocation_stub(stub); | |
| 145 } | |
| 146 Isolate* isolate = thread->isolate(); | |
| 147 if (isolate->heap()->NeedsGarbageCollection()) { | |
| 148 isolate->heap()->CollectAllGarbage(); | |
| 149 } | |
| 150 } | |
|
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
| |
| 126 if (FLAG_support_disassembler && FLAG_disassemble_stubs) { | 151 if (FLAG_support_disassembler && FLAG_disassemble_stubs) { |
| 127 LogBlock lb; | 152 LogBlock lb; |
| 128 THR_Print("Code for allocation stub '%s': {\n", name); | 153 THR_Print("Code for allocation stub '%s': {\n", name); |
| 129 #ifndef PRODUCT | 154 #ifndef PRODUCT |
| 130 DisassembleToStdout formatter; | 155 DisassembleToStdout formatter; |
| 131 stub.Disassemble(&formatter); | 156 stub.Disassemble(&formatter); |
| 132 #endif | 157 #endif |
| 133 THR_Print("}\n"); | 158 THR_Print("}\n"); |
| 134 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); | 159 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); |
| 135 object_pool.DebugPrint(); | 160 object_pool.DebugPrint(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 if ((name##_entry() != NULL) && \ | 204 if ((name##_entry() != NULL) && \ |
| 180 (entry_point == name##_entry()->EntryPoint())) { \ | 205 (entry_point == name##_entry()->EntryPoint())) { \ |
| 181 return ""#name; \ | 206 return ""#name; \ |
| 182 } | 207 } |
| 183 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); | 208 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); |
| 184 #undef VM_STUB_CODE_TESTER | 209 #undef VM_STUB_CODE_TESTER |
| 185 return NULL; | 210 return NULL; |
| 186 } | 211 } |
| 187 | 212 |
| 188 } // namespace dart | 213 } // namespace dart |
| OLD | NEW |