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

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

Issue 1305223006: Remove allocation in old space .... (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/class_finalizer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | 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/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/block_scheduler.h" 10 #include "vm/block_scheduler.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 Error& error = Error::Handle(); 205 Error& error = Error::Handle();
206 error = isolate->object_store()->sticky_error(); 206 error = isolate->object_store()->sticky_error();
207 isolate->object_store()->clear_sticky_error(); 207 isolate->object_store()->clear_sticky_error();
208 return error.raw(); 208 return error.raw();
209 } 209 }
210 UNREACHABLE(); 210 UNREACHABLE();
211 return Error::null(); 211 return Error::null();
212 } 212 }
213 213
214 214
215 static void AddRelatedClassesToList(const Class& cls, 215
regis 2015/09/01 23:25:08 extra blank line
srdjan 2015/09/02 16:01:12 Done.
216 const GrowableObjectArray& parse_list, 216 static void AddRelatedClassesToList(
217 const GrowableObjectArray& patch_list) { 217 const Class& cls,
218 GrowableHandlePtrArray<const Class>* parse_list,
219 GrowableHandlePtrArray<const Class>* patch_list) {
218 Isolate* isolate = Isolate::Current(); 220 Isolate* isolate = Isolate::Current();
219 Class& parse_class = Class::Handle(isolate); 221 Class& parse_class = Class::Handle(isolate);
220 AbstractType& interface_type = Type::Handle(isolate); 222 AbstractType& interface_type = Type::Handle(isolate);
221 Array& interfaces = Array::Handle(isolate); 223 Array& interfaces = Array::Handle(isolate);
222 224
223 // Add all the interfaces implemented by the class that have not been 225 // Add all the interfaces implemented by the class that have not been
224 // already parsed to the parse list. Mark the interface as parsed so that 226 // already parsed to the parse list. Mark the interface as parsed so that
225 // we don't recursively add it back into the list. 227 // we don't recursively add it back into the list.
226 interfaces ^= cls.interfaces(); 228 interfaces ^= cls.interfaces();
227 for (intptr_t i = 0; i < interfaces.Length(); i++) { 229 for (intptr_t i = 0; i < interfaces.Length(); i++) {
228 interface_type ^= interfaces.At(i); 230 interface_type ^= interfaces.At(i);
229 parse_class ^= interface_type.type_class(); 231 parse_class ^= interface_type.type_class();
230 if (!parse_class.is_finalized() && !parse_class.is_marked_for_parsing()) { 232 if (!parse_class.is_finalized() && !parse_class.is_marked_for_parsing()) {
231 parse_list.Add(parse_class); 233 parse_list->Add(parse_class);
232 parse_class.set_is_marked_for_parsing(); 234 parse_class.set_is_marked_for_parsing();
233 } 235 }
234 } 236 }
235 237
236 // Walk up the super_class chain and add these classes to the list if they 238 // Walk up the super_class chain and add these classes to the list if they
237 // have not been already parsed to the parse list. Mark the class as parsed 239 // have not been already parsed to the parse list. Mark the class as parsed
238 // so that we don't recursively add it back into the list. 240 // so that we don't recursively add it back into the list.
239 parse_class ^= cls.SuperClass(); 241 parse_class ^= cls.SuperClass();
240 while (!parse_class.IsNull()) { 242 while (!parse_class.IsNull()) {
241 if (!parse_class.is_finalized() && !parse_class.is_marked_for_parsing()) { 243 if (!parse_class.is_finalized() && !parse_class.is_marked_for_parsing()) {
242 parse_list.Add(parse_class); 244 parse_list->Add(parse_class);
243 parse_class.set_is_marked_for_parsing(); 245 parse_class.set_is_marked_for_parsing();
244 } 246 }
245 parse_class ^= parse_class.SuperClass(); 247 parse_class ^= parse_class.SuperClass();
246 } 248 }
247 249
248 // Add patch classes if they exist to the parse list if they have not already 250 // Add patch classes if they exist to the parse list if they have not already
249 // been parsed and patched. Mark the class as parsed so that we don't 251 // been parsed and patched. Mark the class as parsed so that we don't
250 // recursively add it back into the list. 252 // recursively add it back into the list.
251 parse_class ^= cls.patch_class(); 253 parse_class ^= cls.patch_class();
252 if (!parse_class.IsNull()) { 254 if (!parse_class.IsNull()) {
253 if (!parse_class.is_finalized() && !parse_class.is_marked_for_parsing()) { 255 if (!parse_class.is_finalized() && !parse_class.is_marked_for_parsing()) {
254 patch_list.Add(parse_class); 256 patch_list->Add(parse_class);
255 parse_class.set_is_marked_for_parsing(); 257 parse_class.set_is_marked_for_parsing();
256 } 258 }
257 } 259 }
258 } 260 }
259 261
260 262
261 RawError* Compiler::CompileClass(const Class& cls) { 263 RawError* Compiler::CompileClass(const Class& cls) {
262 // If class is a top level class it is already parsed. 264 // If class is a top level class it is already parsed.
263 if (cls.IsTopLevel()) { 265 if (cls.IsTopLevel()) {
264 return Error::null(); 266 return Error::null();
(...skipping 19 matching lines...) Expand all
284 Isolate* isolate = Isolate::Current(); 286 Isolate* isolate = Isolate::Current();
285 Error& error = Error::Handle(isolate); 287 Error& error = Error::Handle(isolate);
286 error = isolate->object_store()->sticky_error(); 288 error = isolate->object_store()->sticky_error();
287 isolate->object_store()->clear_sticky_error(); 289 isolate->object_store()->clear_sticky_error();
288 return error.raw(); 290 return error.raw();
289 } 291 }
290 } 292 }
291 293
292 Thread* const thread = Thread::Current(); 294 Thread* const thread = Thread::Current();
293 Isolate* const isolate = thread->isolate(); 295 Isolate* const isolate = thread->isolate();
296 StackZone zone(thread);
regis 2015/09/01 23:25:08 By moving this declaration here, the stack zone wi
srdjan 2015/09/02 16:01:12 I think that is safer now. I had to move it so tha
294 // We remember all the classes that are being compiled in these lists. This 297 // We remember all the classes that are being compiled in these lists. This
295 // also allows us to reset the marked_for_parsing state in case we see an 298 // also allows us to reset the marked_for_parsing state in case we see an
296 // error. 299 // error.
297 VMTagScope tagScope(thread, VMTag::kCompileClassTagId); 300 VMTagScope tagScope(thread, VMTag::kCompileClassTagId);
298 Class& parse_class = Class::Handle(isolate); 301 GrowableHandlePtrArray<const Class> parse_list(thread->zone(), 4);
299 const GrowableObjectArray& parse_list = 302 GrowableHandlePtrArray<const Class> patch_list(thread->zone(), 4);
300 GrowableObjectArray::Handle(thread->zone(), GrowableObjectArray::New(4));
301 const GrowableObjectArray& patch_list =
302 GrowableObjectArray::Handle(thread->zone(), GrowableObjectArray::New(4));
303 303
304 // Parse the class and all the interfaces it implements and super classes. 304 // Parse the class and all the interfaces it implements and super classes.
305 LongJumpScope jump; 305 LongJumpScope jump;
306 if (setjmp(*jump.Set()) == 0) { 306 if (setjmp(*jump.Set()) == 0) {
307 StackZone zone(thread);
308 if (FLAG_trace_compiler) { 307 if (FLAG_trace_compiler) {
309 ISL_Print("Compiling Class %s '%s'\n", "", cls.ToCString()); 308 ISL_Print("Compiling Class %s '%s'\n", "", cls.ToCString());
310 } 309 }
311 310
312 // Add the primary class which needs to be parsed to the parse list. 311 // Add the primary class which needs to be parsed to the parse list.
313 // Mark the class as parsed so that we don't recursively add the same 312 // Mark the class as parsed so that we don't recursively add the same
314 // class back into the list. 313 // class back into the list.
315 parse_list.Add(cls); 314 parse_list.Add(cls);
316 cls.set_is_marked_for_parsing(); 315 cls.set_is_marked_for_parsing();
317 316
318 // Add all super classes, interface classes and patch class if one 317 // Add all super classes, interface classes and patch class if one
319 // exists to the corresponding lists. 318 // exists to the corresponding lists.
320 // NOTE: The parse_list array keeps growing as more classes are added 319 // NOTE: The parse_list array keeps growing as more classes are added
321 // to it by AddRelatedClassesToList. It is not OK to hoist 320 // to it by AddRelatedClassesToList. It is not OK to hoist
322 // parse_list.Length() into a local variable and iterate using the local 321 // parse_list.Length() into a local variable and iterate using the local
323 // variable. 322 // variable.
324 for (intptr_t i = 0; i < parse_list.Length(); i++) { 323 for (intptr_t i = 0; i < parse_list.length(); i++) {
325 parse_class ^= parse_list.At(i); 324 AddRelatedClassesToList(parse_list.At(i), &parse_list, &patch_list);
326 AddRelatedClassesToList(parse_class, parse_list, patch_list);
327 } 325 }
328 326
329 // Parse all the classes that have been added above. 327 // Parse all the classes that have been added above.
330 for (intptr_t i = (parse_list.Length() - 1); i >=0 ; i--) { 328 for (intptr_t i = (parse_list.length() - 1); i >=0 ; i--) {
331 parse_class ^= parse_list.At(i); 329 const Class& parse_class = parse_list.At(i);
332 ASSERT(!parse_class.IsNull()); 330 ASSERT(!parse_class.IsNull());
333 Parser::ParseClass(parse_class); 331 Parser::ParseClass(parse_class);
334 } 332 }
335 333
336 // Parse all the patch classes that have been added above. 334 // Parse all the patch classes that have been added above.
337 for (intptr_t i = 0; i < patch_list.Length(); i++) { 335 for (intptr_t i = 0; i < patch_list.length(); i++) {
338 parse_class ^= patch_list.At(i); 336 const Class& parse_class = patch_list.At(i);
339 ASSERT(!parse_class.IsNull()); 337 ASSERT(!parse_class.IsNull());
340 Parser::ParseClass(parse_class); 338 Parser::ParseClass(parse_class);
341 } 339 }
342 340
343 // Finalize these classes. 341 // Finalize these classes.
344 for (intptr_t i = (parse_list.Length() - 1); i >=0 ; i--) { 342 for (intptr_t i = (parse_list.length() - 1); i >=0 ; i--) {
345 parse_class ^= parse_list.At(i); 343 const Class& parse_class = parse_list.At(i);
346 ASSERT(!parse_class.IsNull()); 344 ASSERT(!parse_class.IsNull());
347 ClassFinalizer::FinalizeClass(parse_class); 345 ClassFinalizer::FinalizeClass(parse_class);
348 parse_class.reset_is_marked_for_parsing(); 346 parse_class.reset_is_marked_for_parsing();
349 } 347 }
350 for (intptr_t i = (patch_list.Length() - 1); i >=0 ; i--) { 348 for (intptr_t i = (patch_list.length() - 1); i >=0 ; i--) {
351 parse_class ^= patch_list.At(i); 349 const Class& parse_class = patch_list.At(i);
352 ASSERT(!parse_class.IsNull()); 350 ASSERT(!parse_class.IsNull());
353 ClassFinalizer::FinalizeClass(parse_class); 351 ClassFinalizer::FinalizeClass(parse_class);
354 parse_class.reset_is_marked_for_parsing(); 352 parse_class.reset_is_marked_for_parsing();
355 } 353 }
356 354
357 return Error::null(); 355 return Error::null();
358 } else { 356 } else {
359 // Reset the marked for parsing flags. 357 // Reset the marked for parsing flags.
360 for (intptr_t i = 0; i < parse_list.Length(); i++) { 358 for (intptr_t i = 0; i < parse_list.length(); i++) {
361 parse_class ^= parse_list.At(i); 359 const Class& parse_class = parse_list.At(i);
362 if (parse_class.is_marked_for_parsing()) { 360 if (parse_class.is_marked_for_parsing()) {
363 parse_class.reset_is_marked_for_parsing(); 361 parse_class.reset_is_marked_for_parsing();
364 } 362 }
365 } 363 }
366 for (intptr_t i = 0; i < patch_list.Length(); i++) { 364 for (intptr_t i = 0; i < patch_list.length(); i++) {
367 parse_class ^= patch_list.At(i); 365 const Class& parse_class = patch_list.At(i);
368 if (parse_class.is_marked_for_parsing()) { 366 if (parse_class.is_marked_for_parsing()) {
369 parse_class.reset_is_marked_for_parsing(); 367 parse_class.reset_is_marked_for_parsing();
370 } 368 }
371 } 369 }
372 Thread* const thread = Thread::Current();
373 Isolate* const isolate = Isolate::Current();
374 StackZone zone(thread);
375 Error& error = Error::Handle(isolate); 370 Error& error = Error::Handle(isolate);
376 error = isolate->object_store()->sticky_error(); 371 error = isolate->object_store()->sticky_error();
377 isolate->object_store()->clear_sticky_error(); 372 isolate->object_store()->clear_sticky_error();
378 return error.raw(); 373 return error.raw();
379 } 374 }
380 UNREACHABLE(); 375 UNREACHABLE();
381 return Error::null(); 376 return Error::null();
382 } 377 }
383 378
384 379
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 const Object& result = 1422 const Object& result =
1428 PassiveObject::Handle(isolate->object_store()->sticky_error()); 1423 PassiveObject::Handle(isolate->object_store()->sticky_error());
1429 isolate->object_store()->clear_sticky_error(); 1424 isolate->object_store()->clear_sticky_error();
1430 return result.raw(); 1425 return result.raw();
1431 } 1426 }
1432 UNREACHABLE(); 1427 UNREACHABLE();
1433 return Object::null(); 1428 return Object::null();
1434 } 1429 }
1435 1430
1436 } // namespace dart 1431 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698