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

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

Issue 1638143002: Precompilation: compact the symbol table. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 | « no previous file | runtime/vm/raw_object.h » ('j') | runtime/vm/symbols.h » ('J')
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/cha.h" 7 #include "vm/cha.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/hash_table.h" 10 #include "vm/hash_table.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 Isolate* isolate = Isolate::Current(); 48 Isolate* isolate = Isolate::Current();
49 const Error& error = Error::Handle(isolate->object_store()->sticky_error()); 49 const Error& error = Error::Handle(isolate->object_store()->sticky_error());
50 isolate->object_store()->clear_sticky_error(); 50 isolate->object_store()->clear_sticky_error();
51 return error.raw(); 51 return error.raw();
52 } 52 }
53 } 53 }
54 54
55 55
56 Precompiler::Precompiler(Thread* thread, bool reset_fields) : 56 Precompiler::Precompiler(Thread* thread, bool reset_fields) :
57 thread_(thread), 57 thread_(thread),
58 zone_(thread->zone()), 58 zone_(NULL),
59 isolate_(thread->isolate()), 59 isolate_(thread->isolate()),
60 reset_fields_(reset_fields), 60 reset_fields_(reset_fields),
61 changed_(false), 61 changed_(false),
62 function_count_(0), 62 function_count_(0),
63 class_count_(0), 63 class_count_(0),
64 selector_count_(0), 64 selector_count_(0),
65 dropped_function_count_(0), 65 dropped_function_count_(0),
66 dropped_field_count_(0), 66 dropped_field_count_(0),
67 libraries_(GrowableObjectArray::Handle(Z, I->object_store()->libraries())), 67 libraries_(GrowableObjectArray::Handle(I->object_store()->libraries())),
68 pending_functions_( 68 pending_functions_(
69 GrowableObjectArray::Handle(Z, GrowableObjectArray::New())), 69 GrowableObjectArray::Handle(GrowableObjectArray::New())),
70 sent_selectors_(), 70 sent_selectors_(),
71 enqueued_functions_(), 71 enqueued_functions_(),
72 error_(Error::Handle(Z)) { 72 error_(Error::Handle()) {
73 } 73 }
74 74
75 75
76 void Precompiler::DoCompileAll( 76 void Precompiler::DoCompileAll(
77 Dart_QualifiedFunctionName embedder_entry_points[]) { 77 Dart_QualifiedFunctionName embedder_entry_points[]) {
78 ASSERT(I->compilation_allowed()); 78 ASSERT(I->compilation_allowed());
79 79
80 // Make sure class hierarchy is stable before compilation so that CHA 80 {
81 // can be used. Also ensures lookup of entry points won't miss functions 81 StackZone stack_zone(T);
82 // because their class hasn't been finalized yet. 82 zone_ = stack_zone.GetZone();
83 FinalizeAllClasses();
84 83
85 const intptr_t kPrecompilerRounds = 1; 84 // Make sure class hierarchy is stable before compilation so that CHA
86 for (intptr_t round = 0; round < kPrecompilerRounds; round++) { 85 // can be used. Also ensures lookup of entry points won't miss functions
87 if (FLAG_trace_precompiler) { 86 // because their class hasn't been finalized yet.
88 OS::Print("Precompiler round %" Pd "\n", round); 87 FinalizeAllClasses();
88
89 const intptr_t kPrecompilerRounds = 1;
90 for (intptr_t round = 0; round < kPrecompilerRounds; round++) {
91 if (FLAG_trace_precompiler) {
92 OS::Print("Precompiler round %" Pd "\n", round);
93 }
94
95 if (round > 0) {
96 ResetPrecompilerState();
97 }
98
99 // TODO(rmacnak): We should be able to do a more thorough job and drop
100 // some
101 // - implicit static closures
102 // - field initializers
103 // - invoke-field-dispatchers
104 // - method-extractors
105 // that are needed in early iterations but optimized away in later
106 // iterations.
107 ClearAllCode();
108
109 CollectDynamicFunctionNames();
110
111 // Start with the allocations and invocations that happen from C++.
112 AddRoots(embedder_entry_points);
113
114 // Compile newly found targets and add their callees until we reach a
115 // fixed point.
116 Iterate();
89 } 117 }
90 118
91 if (round > 0) { 119 I->set_compilation_allowed(false);
92 ResetPrecompilerState();
93 }
94 120
95 // TODO(rmacnak): We should be able to do a more thorough job and drop some 121 DropUncompiledFunctions();
96 // - implicit static closures 122 DropFields();
97 // - field initializers
98 // - invoke-field-dispatchers
99 // - method-extractors
100 // that are needed in early iterations but optimized away in later
101 // iterations.
102 ClearAllCode();
103 123
104 CollectDynamicFunctionNames(); 124 // TODO(rmacnak): DropEmptyClasses();
105 125
106 // Start with the allocations and invocations that happen from C++. 126 BindStaticCalls();
107 AddRoots(embedder_entry_points);
108 127
109 // Compile newly found targets and add their callees until we reach a fixed 128 DedupStackmaps();
110 // point. 129
111 Iterate(); 130 I->object_store()->set_compile_time_constants(Array::null_array());
131 I->object_store()->set_unique_dynamic_targets(Array::null_array());
132
133 zone_ = NULL;
112 } 134 }
113 135
114 DropUncompiledFunctions(); 136 intptr_t dropped_symbols_count = Symbols::Compact(I);
115 DropFields();
116
117 // TODO(rmacnak): DropEmptyClasses();
118
119 BindStaticCalls();
120
121 DedupStackmaps();
122 137
123 if (FLAG_trace_precompiler) { 138 if (FLAG_trace_precompiler) {
124 THR_Print("Precompiled %" Pd " functions, %" Pd " dynamic types," 139 THR_Print("Precompiled %" Pd " functions, %" Pd " dynamic types,"
125 " %" Pd " dynamic selectors.\n Dropped %" Pd " functions, %" Pd 140 " %" Pd " dynamic selectors.\n Dropped %" Pd " functions, %" Pd
126 " fields.\n", 141 " fields, %" Pd " symbols.\n",
127 function_count_, 142 function_count_,
128 class_count_, 143 class_count_,
129 selector_count_, 144 selector_count_,
130 dropped_function_count_, 145 dropped_function_count_,
131 dropped_field_count_); 146 dropped_field_count_,
147 dropped_symbols_count);
132 } 148 }
133
134 I->set_compilation_allowed(false);
135 I->object_store()->set_compile_time_constants(Array::null_array());
136 I->object_store()->set_unique_dynamic_targets(Array::null_array());
137 } 149 }
138 150
139 151
140 void Precompiler::ClearAllCode() { 152 void Precompiler::ClearAllCode() {
141 class ClearCodeFunctionVisitor : public FunctionVisitor { 153 class ClearCodeFunctionVisitor : public FunctionVisitor {
142 void VisitFunction(const Function& function) { 154 void VisitFunction(const Function& function) {
143 function.ClearCode(); 155 function.ClearCode();
144 } 156 }
145 }; 157 };
146 ClearCodeFunctionVisitor visitor; 158 ClearCodeFunctionVisitor visitor;
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 cls = it.GetNextClass(); 1216 cls = it.GetNextClass();
1205 if (cls.IsDynamicClass()) { 1217 if (cls.IsDynamicClass()) {
1206 continue; // class 'dynamic' is in the read-only VM isolate. 1218 continue; // class 'dynamic' is in the read-only VM isolate.
1207 } 1219 }
1208 cls.set_is_allocated(false); 1220 cls.set_is_allocated(false);
1209 } 1221 }
1210 } 1222 }
1211 } 1223 }
1212 1224
1213 } // namespace dart 1225 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/raw_object.h » ('j') | runtime/vm/symbols.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698