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

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

Issue 1314673008: Migrate logging infrastructure Isolate->Thread (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix test. 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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/precompiler.h" 5 #include "vm/precompiler.h"
6 6
7 #include "vm/compiler.h" 7 #include "vm/compiler.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/log.h" 9 #include "vm/log.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 libraries_(GrowableObjectArray::Handle(Z, I->object_store()->libraries())), 55 libraries_(GrowableObjectArray::Handle(Z, I->object_store()->libraries())),
56 pending_functions_(GrowableObjectArray::Handle(Z, 56 pending_functions_(GrowableObjectArray::Handle(Z,
57 GrowableObjectArray::New())), 57 GrowableObjectArray::New())),
58 collected_closures_(GrowableObjectArray::Handle(Z, I->collected_closures())), 58 collected_closures_(GrowableObjectArray::Handle(Z, I->collected_closures())),
59 sent_selectors_(Z), 59 sent_selectors_(Z),
60 error_(Error::Handle(Z)) { 60 error_(Error::Handle(Z)) {
61 } 61 }
62 62
63 63
64 void Precompiler::DoCompileAll() { 64 void Precompiler::DoCompileAll() {
65 LogBlock lb(thread_); 65 LogBlock lb;
66 66
67 // Drop all existing code so we can use the presence of code as an indicator 67 // Drop all existing code so we can use the presence of code as an indicator
68 // that we have already looked for the function's callees. 68 // that we have already looked for the function's callees.
69 ClearAllCode(); 69 ClearAllCode();
70 70
71 // Start with the allocations and invocations that happen from C++. 71 // Start with the allocations and invocations that happen from C++.
72 AddRoots(); 72 AddRoots();
73 73
74 // TODO(rmacnak): Eagerly add field-invocation functions to all signature 74 // TODO(rmacnak): Eagerly add field-invocation functions to all signature
75 // classes so closure calls don't go through the runtime. 75 // classes so closure calls don't go through the runtime.
76 76
77 // Compile newly found targets and add their callees until we reach a fixed 77 // Compile newly found targets and add their callees until we reach a fixed
78 // point. 78 // point.
79 Iterate(); 79 Iterate();
80 80
81 CleanUp(); 81 CleanUp();
82 82
83 if (FLAG_trace_precompiler) { 83 if (FLAG_trace_precompiler) {
84 ISL_Print("Precompiled %" Pd " functions, %" Pd " dynamic types," 84 THR_Print("Precompiled %" Pd " functions, %" Pd " dynamic types,"
85 " %" Pd " dynamic selectors.\n Dropped %" Pd " functions.\n", 85 " %" Pd " dynamic selectors.\n Dropped %" Pd " functions.\n",
86 function_count_, 86 function_count_,
87 class_count_, 87 class_count_,
88 selector_count_, 88 selector_count_,
89 dropped_function_count_); 89 dropped_function_count_);
90 } 90 }
91 91
92 I->set_compilation_allowed(false); 92 I->set_compilation_allowed(false);
93 } 93 }
94 94
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 String& class_name = String::Handle(Z); 269 String& class_name = String::Handle(Z);
270 String& function_name = String::Handle(Z); 270 String& function_name = String::Handle(Z);
271 for (intptr_t i = 0; kExternallyCalled[i].library_ != NULL; i++) { 271 for (intptr_t i = 0; kExternallyCalled[i].library_ != NULL; i++) {
272 library_name = Symbols::New(kExternallyCalled[i].library_); 272 library_name = Symbols::New(kExternallyCalled[i].library_);
273 class_name = Symbols::New(kExternallyCalled[i].class_); 273 class_name = Symbols::New(kExternallyCalled[i].class_);
274 function_name = Symbols::New(kExternallyCalled[i].function_); 274 function_name = Symbols::New(kExternallyCalled[i].function_);
275 275
276 lib = Library::LookupLibrary(library_name); 276 lib = Library::LookupLibrary(library_name);
277 if (lib.IsNull()) { 277 if (lib.IsNull()) {
278 if (FLAG_trace_precompiler) { 278 if (FLAG_trace_precompiler) {
279 ISL_Print("WARNING: Missing %s\n", kExternallyCalled[i].library_); 279 THR_Print("WARNING: Missing %s\n", kExternallyCalled[i].library_);
280 } 280 }
281 continue; 281 continue;
282 } 282 }
283 283
284 if (class_name.raw() == Symbols::TopLevel().raw()) { 284 if (class_name.raw() == Symbols::TopLevel().raw()) {
285 func = lib.LookupFunctionAllowPrivate(function_name); 285 func = lib.LookupFunctionAllowPrivate(function_name);
286 } else { 286 } else {
287 cls = lib.LookupClassAllowPrivate(class_name); 287 cls = lib.LookupClassAllowPrivate(class_name);
288 if (cls.IsNull()) { 288 if (cls.IsNull()) {
289 if (FLAG_trace_precompiler) { 289 if (FLAG_trace_precompiler) {
290 ISL_Print("WARNING: Missing %s %s\n", 290 THR_Print("WARNING: Missing %s %s\n",
291 kExternallyCalled[i].library_, 291 kExternallyCalled[i].library_,
292 kExternallyCalled[i].class_); 292 kExternallyCalled[i].class_);
293 } 293 }
294 continue; 294 continue;
295 } 295 }
296 296
297 ASSERT(!cls.IsNull()); 297 ASSERT(!cls.IsNull());
298 func = cls.LookupFunctionAllowPrivate(function_name); 298 func = cls.LookupFunctionAllowPrivate(function_name);
299 } 299 }
300 300
301 if (func.IsNull()) { 301 if (func.IsNull()) {
302 if (FLAG_trace_precompiler) { 302 if (FLAG_trace_precompiler) {
303 ISL_Print("WARNING: Missing %s %s %s\n", 303 THR_Print("WARNING: Missing %s %s %s\n",
304 kExternallyCalled[i].library_, 304 kExternallyCalled[i].library_,
305 kExternallyCalled[i].class_, 305 kExternallyCalled[i].class_,
306 kExternallyCalled[i].function_); 306 kExternallyCalled[i].function_);
307 } 307 }
308 continue; 308 continue;
309 } 309 }
310 310
311 AddFunction(func); 311 AddFunction(func);
312 } 312 }
313 } 313 }
(...skipping 29 matching lines...) Expand all
343 343
344 // TODO(rmacnak): DropEmptyClasses(); 344 // TODO(rmacnak): DropEmptyClasses();
345 } 345 }
346 346
347 347
348 void Precompiler::ProcessFunction(const Function& function) { 348 void Precompiler::ProcessFunction(const Function& function) {
349 if (!function.HasCode()) { 349 if (!function.HasCode()) {
350 function_count_++; 350 function_count_++;
351 351
352 if (FLAG_trace_precompiler) { 352 if (FLAG_trace_precompiler) {
353 ISL_Print("Precompiling %" Pd " %s (%" Pd ", %s)\n", 353 THR_Print("Precompiling %" Pd " %s (%" Pd ", %s)\n",
354 function_count_, 354 function_count_,
355 function.ToLibNamePrefixedQualifiedCString(), 355 function.ToLibNamePrefixedQualifiedCString(),
356 function.token_pos(), 356 function.token_pos(),
357 Function::KindToCString(function.kind())); 357 Function::KindToCString(function.kind()));
358 } 358 }
359 359
360 ASSERT(!function.is_abstract()); 360 ASSERT(!function.is_abstract());
361 ASSERT(!function.IsRedirectingFactory()); 361 ASSERT(!function.IsRedirectingFactory());
362 362
363 error_ = Compiler::CompileFunction(thread_, function); 363 error_ = Compiler::CompileFunction(thread_, function);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // Potential const object. Uninitialized field will harmlessly do a 435 // Potential const object. Uninitialized field will harmlessly do a
436 // redundant add of the Null class. 436 // redundant add of the Null class.
437 const Object& value = Object::Handle(Z, field.StaticValue()); 437 const Object& value = Object::Handle(Z, field.StaticValue());
438 const Class& cls = Class::Handle(Z, value.clazz()); 438 const Class& cls = Class::Handle(Z, value.clazz());
439 AddClass(cls); 439 AddClass(cls);
440 440
441 if (field.has_initializer()) { 441 if (field.has_initializer()) {
442 if (field.PrecompiledInitializer() != Function::null()) return; 442 if (field.PrecompiledInitializer() != Function::null()) return;
443 443
444 if (FLAG_trace_precompiler) { 444 if (FLAG_trace_precompiler) {
445 ISL_Print("Precompiling initializer for %s\n", field.ToCString()); 445 THR_Print("Precompiling initializer for %s\n", field.ToCString());
446 } 446 }
447 Compiler::CompileStaticInitializer(field); 447 Compiler::CompileStaticInitializer(field);
448 448
449 const Function& function = 449 const Function& function =
450 Function::Handle(Z, field.PrecompiledInitializer()); 450 Function::Handle(Z, field.PrecompiledInitializer());
451 AddCalleesOf(function); 451 AddCalleesOf(function);
452 } 452 }
453 } 453 }
454 } 454 }
455 455
(...skipping 11 matching lines...) Expand all
467 } 467 }
468 468
469 469
470 void Precompiler::AddSelector(const String& selector) { 470 void Precompiler::AddSelector(const String& selector) {
471 if (!IsSent(selector)) { 471 if (!IsSent(selector)) {
472 sent_selectors_.Add(selector); 472 sent_selectors_.Add(selector);
473 selector_count_++; 473 selector_count_++;
474 changed_ = true; 474 changed_ = true;
475 475
476 if (FLAG_trace_precompiler) { 476 if (FLAG_trace_precompiler) {
477 ISL_Print("Enqueueing selector %" Pd " %s\n", 477 THR_Print("Enqueueing selector %" Pd " %s\n",
478 selector_count_, 478 selector_count_,
479 selector.ToCString()); 479 selector.ToCString());
480 } 480 }
481 481
482 if (!Field::IsGetterName(selector) && 482 if (!Field::IsGetterName(selector) &&
483 !Field::IsSetterName(selector)) { 483 !Field::IsSetterName(selector)) {
484 // Regular method may be call-through-getter. 484 // Regular method may be call-through-getter.
485 const String& getter = String::Handle(Field::GetterSymbol(selector)); 485 const String& getter = String::Handle(Field::GetterSymbol(selector));
486 AddSelector(getter); 486 AddSelector(getter);
487 } 487 }
488 } 488 }
489 } 489 }
490 490
491 491
492 void Precompiler::AddClass(const Class& cls) { 492 void Precompiler::AddClass(const Class& cls) {
493 if (cls.is_allocated()) return; 493 if (cls.is_allocated()) return;
494 494
495 class_count_++; 495 class_count_++;
496 cls.set_is_allocated(); 496 cls.set_is_allocated();
497 changed_ = true; 497 changed_ = true;
498 498
499 if (FLAG_trace_precompiler) { 499 if (FLAG_trace_precompiler) {
500 ISL_Print("Allocation %" Pd " %s\n", class_count_, cls.ToCString()); 500 THR_Print("Allocation %" Pd " %s\n", class_count_, cls.ToCString());
501 } 501 }
502 502
503 const Class& superclass = Class::Handle(cls.SuperClass()); 503 const Class& superclass = Class::Handle(cls.SuperClass());
504 if (!superclass.IsNull()) { 504 if (!superclass.IsNull()) {
505 AddClass(superclass); 505 AddClass(superclass);
506 } 506 }
507 } 507 }
508 508
509 509
510 void Precompiler::CheckForNewDynamicFunctions() { 510 void Precompiler::CheckForNewDynamicFunctions() {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
608 functions = cls.functions(); 608 functions = cls.functions();
609 retained_functions = GrowableObjectArray::New(); 609 retained_functions = GrowableObjectArray::New();
610 for (intptr_t j = 0; j < functions.Length(); j++) { 610 for (intptr_t j = 0; j < functions.Length(); j++) {
611 function ^= functions.At(j); 611 function ^= functions.At(j);
612 if (function.HasCode()) { 612 if (function.HasCode()) {
613 retained_functions.Add(function); 613 retained_functions.Add(function);
614 } else { 614 } else {
615 dropped_function_count_++; 615 dropped_function_count_++;
616 if (FLAG_trace_precompiler) { 616 if (FLAG_trace_precompiler) {
617 ISL_Print("Precompilation dropping %s\n", 617 THR_Print("Precompilation dropping %s\n",
618 function.ToLibNamePrefixedQualifiedCString()); 618 function.ToLibNamePrefixedQualifiedCString());
619 } 619 }
620 } 620 }
621 } 621 }
622 622
623 functions = Array::New(retained_functions.Length(), Heap::kOld); 623 functions = Array::New(retained_functions.Length(), Heap::kOld);
624 for (intptr_t j = 0; j < retained_functions.Length(); j++) { 624 for (intptr_t j = 0; j < retained_functions.Length(); j++) {
625 function ^= retained_functions.At(j); 625 function ^= retained_functions.At(j);
626 functions.SetAt(j, function); 626 functions.SetAt(j, function);
627 } 627 }
628 cls.SetFunctions(functions); 628 cls.SetFunctions(functions);
629 629
630 closures = cls.closures(); 630 closures = cls.closures();
631 if (!closures.IsNull()) { 631 if (!closures.IsNull()) {
632 for (intptr_t j = 0; j < closures.Length(); j++) { 632 for (intptr_t j = 0; j < closures.Length(); j++) {
633 function ^= closures.At(j); 633 function ^= closures.At(j);
634 ASSERT(function.HasCode()); 634 ASSERT(function.HasCode());
635 } 635 }
636 } 636 }
637 } 637 }
638 } 638 }
639 } 639 }
640 640
641 } // namespace dart 641 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/stub_code.cc » ('j') | runtime/vm/thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698