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

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

Issue 2933603002: 1. Dynamic compute the main closure that needs to be run by the main isolate (Closed)
Patch Set: Remove redundant check. Created 3 years, 6 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
« runtime/include/dart_api.h ('K') | « runtime/vm/precompiler.h ('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) 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/aot_optimizer.h" 7 #include "vm/aot_optimizer.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/branch_optimizer.h" 10 #include "vm/branch_optimizer.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return true; 339 return true;
340 } 340 }
341 341
342 342
343 Precompiler::Precompiler(Thread* thread) 343 Precompiler::Precompiler(Thread* thread)
344 : thread_(thread), 344 : thread_(thread),
345 zone_(NULL), 345 zone_(NULL),
346 isolate_(thread->isolate()), 346 isolate_(thread->isolate()),
347 jit_feedback_(NULL), 347 jit_feedback_(NULL),
348 changed_(false), 348 changed_(false),
349 retain_root_library_caches_(false),
349 function_count_(0), 350 function_count_(0),
350 class_count_(0), 351 class_count_(0),
351 selector_count_(0), 352 selector_count_(0),
352 dropped_function_count_(0), 353 dropped_function_count_(0),
353 dropped_field_count_(0), 354 dropped_field_count_(0),
354 dropped_class_count_(0), 355 dropped_class_count_(0),
355 dropped_typearg_count_(0), 356 dropped_typearg_count_(0),
356 dropped_type_count_(0), 357 dropped_type_count_(0),
357 dropped_library_count_(0), 358 dropped_library_count_(0),
358 libraries_(GrowableObjectArray::Handle(I->object_store()->libraries())), 359 libraries_(GrowableObjectArray::Handle(I->object_store()->libraries())),
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 {"dart:isolate", "::", "_runPendingImmediateCallback"}, 683 {"dart:isolate", "::", "_runPendingImmediateCallback"},
683 #endif // !PRODUCT 684 #endif // !PRODUCT
684 // Fields 685 // Fields
685 {"dart:core", "Error", "_stackTrace"}, 686 {"dart:core", "Error", "_stackTrace"},
686 {"dart:math", "_Random", "_state"}, 687 {"dart:math", "_Random", "_state"},
687 {NULL, NULL, NULL} // Must be terminated with NULL entries. 688 {NULL, NULL, NULL} // Must be terminated with NULL entries.
688 }; 689 };
689 690
690 AddEntryPoints(vm_entry_points); 691 AddEntryPoints(vm_entry_points);
691 AddEntryPoints(embedder_entry_points); 692 AddEntryPoints(embedder_entry_points);
693 const Library& lib = Library::Handle(I->object_store()->root_library());
694 const String& name = String::Handle(String::New("main"));
695 const Object& main_closure = Object::Handle(lib.GetFunctionClosure(name));
rmacnak 2017/06/15 01:48:54 Propagate if error
siva 2017/06/15 17:34:41 Done.
696 if (main_closure.IsClosure()) {
697 if (lib.LookupLocalFunction(name) == Function::null()) {
698 // Check whether the function is in exported namespace of library, in
699 // this case we have to retain the root library caches.
700 if (lib.LookupFunctionAllowPrivate(name) != Function::null() ||
701 lib.LookupReExport(name) != Object::null()) {
702 retain_root_library_caches_ = true;
703 }
704 }
705 AddConstObject(Closure::Cast(main_closure));
706 }
692 } 707 }
693 708
694 709
695 void Precompiler::AddEntryPoints(Dart_QualifiedFunctionName entry_points[]) { 710 void Precompiler::AddEntryPoints(Dart_QualifiedFunctionName entry_points[]) {
696 Library& lib = Library::Handle(Z); 711 Library& lib = Library::Handle(Z);
697 Class& cls = Class::Handle(Z); 712 Class& cls = Class::Handle(Z);
698 Function& func = Function::Handle(Z); 713 Function& func = Function::Handle(Z);
699 Field& field = Field::Handle(Z); 714 Field& field = Field::Handle(Z);
700 String& library_uri = String::Handle(Z); 715 String& library_uri = String::Handle(Z);
701 String& class_name = String::Handle(Z); 716 String& class_name = String::Handle(Z);
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 continue; 2036 continue;
2022 } 2037 }
2023 } else if (entry.IsLibraryPrefix()) { 2038 } else if (entry.IsLibraryPrefix()) {
2024 // Always drop. 2039 // Always drop.
2025 } else { 2040 } else {
2026 FATAL1("Unexpected library entry: %s", entry.ToCString()); 2041 FATAL1("Unexpected library entry: %s", entry.ToCString());
2027 } 2042 }
2028 dict.SetAt(j, Object::null_object()); 2043 dict.SetAt(j, Object::null_object());
2029 } 2044 }
2030 lib.RehashDictionary(dict, used * 4 / 3 + 1); 2045 lib.RehashDictionary(dict, used * 4 / 3 + 1);
2031 lib.DropDependenciesAndCaches(); 2046 if (!(retain_root_library_caches_ &&
2047 (lib.raw() == I->object_store()->root_library()))) {
2048 lib.DropDependenciesAndCaches();
2049 }
2032 } 2050 }
2033 } 2051 }
2034 2052
2035 2053
2036 void Precompiler::DropClasses() { 2054 void Precompiler::DropClasses() {
2037 Class& cls = Class::Handle(Z); 2055 Class& cls = Class::Handle(Z);
2038 Array& constants = Array::Handle(Z); 2056 Array& constants = Array::Handle(Z);
2039 2057
2040 #if defined(DEBUG) 2058 #if defined(DEBUG)
2041 // We are about to remove classes from the class table. For this to be safe, 2059 // We are about to remove classes from the class table. For this to be safe,
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
3364 3382
3365 ASSERT(FLAG_precompiled_mode); 3383 ASSERT(FLAG_precompiled_mode);
3366 const bool optimized = function.IsOptimizable(); // False for natives. 3384 const bool optimized = function.IsOptimizable(); // False for natives.
3367 DartPrecompilationPipeline pipeline(zone, field_type_map); 3385 DartPrecompilationPipeline pipeline(zone, field_type_map);
3368 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); 3386 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized);
3369 } 3387 }
3370 3388
3371 #endif // DART_PRECOMPILER 3389 #endif // DART_PRECOMPILER
3372 3390
3373 } // namespace dart 3391 } // namespace dart
OLDNEW
« runtime/include/dart_api.h ('K') | « runtime/vm/precompiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698