Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: runtime/vm/stub_code.cc

Issue 1708013002: Minor fixes for background compilation (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: i Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/compiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/disassembler.h" 10 #include "vm/disassembler.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return AllocateArray_entry()->code(); 117 return AllocateArray_entry()->code();
118 } 118 }
119 Code& stub = Code::Handle(zone, cls.allocation_stub()); 119 Code& stub = Code::Handle(zone, cls.allocation_stub());
120 if (stub.IsNull()) { 120 if (stub.IsNull()) {
121 Assembler assembler; 121 Assembler assembler;
122 const char* name = cls.ToCString(); 122 const char* name = cls.ToCString();
123 StubCode::GenerateAllocationStubForClass(&assembler, cls); 123 StubCode::GenerateAllocationStubForClass(&assembler, cls);
124 124
125 if (thread->IsMutatorThread()) { 125 if (thread->IsMutatorThread()) {
126 stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); 126 stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */);
127 stub.set_owner(cls); 127 // Check if background compilation thread has not already added the stub.
128 cls.set_allocation_stub(stub); 128 if (cls.allocation_stub() == Code::null()) {
129 stub.set_owner(cls);
130 cls.set_allocation_stub(stub);
131 }
129 } else { 132 } else {
130 // This part of stub code generation must be at a safepoint. 133 // This part of stub code generation must be at a safepoint.
131 // Stop mutator thread before creating the instruction object and 134 // Stop mutator thread before creating the instruction object and
132 // installing code. 135 // installing code.
133 // Mutator thread may not run code while we are creating the 136 // Mutator thread may not run code while we are creating the
134 // instruction object, since the creation of instruction object 137 // instruction object, since the creation of instruction object
135 // changes code page access permissions (makes them temporary not 138 // changes code page access permissions (makes them temporary not
136 // executable). 139 // executable).
137 { 140 {
138 SafepointOperationScope safepoint_scope(thread); 141 SafepointOperationScope safepoint_scope(thread);
142 stub = cls.allocation_stub();
143 // Check if stub was already generated.
144 if (!stub.IsNull()) {
145 return stub.raw();
146 }
139 // Do not Garbage collect during this stage and instead allow the 147 // Do not Garbage collect during this stage and instead allow the
140 // heap to grow. 148 // heap to grow.
141 NoHeapGrowthControlScope no_growth_control; 149 NoHeapGrowthControlScope no_growth_control;
142 stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); 150 stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */);
143 stub.set_owner(cls); 151 stub.set_owner(cls);
144 cls.set_allocation_stub(stub); 152 cls.set_allocation_stub(stub);
145 } 153 }
146 Isolate* isolate = thread->isolate(); 154 Isolate* isolate = thread->isolate();
147 if (isolate->heap()->NeedsGarbageCollection()) { 155 if (isolate->heap()->NeedsGarbageCollection()) {
148 isolate->heap()->CollectAllGarbage(); 156 isolate->heap()->CollectAllGarbage();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 if ((name##_entry() != NULL) && \ 212 if ((name##_entry() != NULL) && \
205 (entry_point == name##_entry()->EntryPoint())) { \ 213 (entry_point == name##_entry()->EntryPoint())) { \
206 return ""#name; \ 214 return ""#name; \
207 } 215 }
208 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); 216 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER);
209 #undef VM_STUB_CODE_TESTER 217 #undef VM_STUB_CODE_TESTER
210 return NULL; 218 return NULL;
211 } 219 }
212 220
213 } // namespace dart 221 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698