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

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

Issue 2100533002: Last reference to a library may be through a top-level type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: const Created 4 years, 5 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 | « no previous file | 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 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 1713
1714 for (intptr_t i = 0; i < libraries_.Length(); i++) { 1714 for (intptr_t i = 0; i < libraries_.Length(); i++) {
1715 lib ^= libraries_.At(i); 1715 lib ^= libraries_.At(i);
1716 lib.DropDependencies(); 1716 lib.DropDependencies();
1717 intptr_t entries = 0; 1717 intptr_t entries = 0;
1718 DictionaryIterator it(lib); 1718 DictionaryIterator it(lib);
1719 while (it.HasNext()) { 1719 while (it.HasNext()) {
1720 it.GetNext(); 1720 it.GetNext();
1721 entries++; 1721 entries++;
1722 } 1722 }
1723 // The root library might have no surviving members if it only exports main 1723 bool retain = false;
1724 // from another library. It will still be referenced from the object store, 1724 if (entries > 0) {
1725 // so retain it. 1725 retain = true;
1726 bool retain = (entries > 0) || 1726 } else if (lib.is_dart_scheme()) {
1727 lib.is_dart_scheme() || 1727 // The core libraries are referenced from the object store.
1728 (lib.raw() == root_lib.raw()); 1728 retain = true;
1729 } else if (lib.raw() == root_lib.raw()) {
1730 // The root library might have no surviving members if it only exports
1731 // main from another library. It will still be referenced from the object
1732 // store, so retain it.
1733 retain = true;
1734 } else {
1735 // A type for a top-level class may be referenced from an object pool as
1736 // part of an error message.
1737 const Class& top = Class::Handle(Z, lib.toplevel_class());
1738 if (classes_to_retain_.Lookup(&top) != NULL) {
1739 retain = true;
1740 }
1741 }
1742
1729 if (retain) { 1743 if (retain) {
1730 lib.set_index(retained_libraries.Length()); 1744 lib.set_index(retained_libraries.Length());
1731 retained_libraries.Add(lib); 1745 retained_libraries.Add(lib);
1732 } else { 1746 } else {
1733 dropped_library_count_++; 1747 dropped_library_count_++;
1734 lib.set_index(-1); 1748 lib.set_index(-1);
1735 if (FLAG_trace_precompiler) { 1749 if (FLAG_trace_precompiler) {
1736 THR_Print("Dropping library %s\n", lib.ToCString()); 1750 THR_Print("Dropping library %s\n", lib.ToCString());
1737 } 1751 }
1738 } 1752 }
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 CompilationPipeline::New(thread->zone(), function); 2862 CompilationPipeline::New(thread->zone(), function);
2849 2863
2850 ASSERT(FLAG_precompiled_mode); 2864 ASSERT(FLAG_precompiled_mode);
2851 const bool optimized = function.IsOptimizable(); // False for natives. 2865 const bool optimized = function.IsOptimizable(); // False for natives.
2852 return PrecompileFunctionHelper(pipeline, function, optimized); 2866 return PrecompileFunctionHelper(pipeline, function, optimized);
2853 } 2867 }
2854 2868
2855 #endif // DART_PRECOMPILER 2869 #endif // DART_PRECOMPILER
2856 2870
2857 } // namespace dart 2871 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698