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

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

Issue 1686773002: Precompilation: drop unused types and type arguments and empty classes and libraries. (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 | « runtime/vm/object.cc ('k') | runtime/vm/precompiler.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) 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 #ifndef VM_PRECOMPILER_H_ 5 #ifndef VM_PRECOMPILER_H_
6 #define VM_PRECOMPILER_H_ 6 #define VM_PRECOMPILER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/hash_map.h" 9 #include "vm/hash_map.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 160
161 static inline bool IsKeyEqual(Pair pair, Key key) { 161 static inline bool IsKeyEqual(Pair pair, Key key) {
162 return pair->raw() == key->raw(); 162 return pair->raw() == key->raw();
163 } 163 }
164 }; 164 };
165 165
166 typedef DirectChainedHashMap<FieldKeyValueTrait> FieldSet; 166 typedef DirectChainedHashMap<FieldKeyValueTrait> FieldSet;
167 167
168 168
169 class ClassKeyValueTrait {
170 public:
171 // Typedefs needed for the DirectChainedHashMap template.
172 typedef const Class* Key;
173 typedef const Class* Value;
174 typedef const Class* Pair;
175
176 static Key KeyOf(Pair kv) { return kv; }
177
178 static Value ValueOf(Pair kv) { return kv; }
179
180 static inline intptr_t Hashcode(Key key) {
181 return key->token_pos().value();
182 }
183
184 static inline bool IsKeyEqual(Pair pair, Key key) {
185 return pair->raw() == key->raw();
186 }
187 };
188
189 typedef DirectChainedHashMap<ClassKeyValueTrait> ClassSet;
190
191
192 class AbstractTypeKeyValueTrait {
193 public:
194 // Typedefs needed for the DirectChainedHashMap template.
195 typedef const AbstractType* Key;
196 typedef const AbstractType* Value;
197 typedef const AbstractType* Pair;
198
199 static Key KeyOf(Pair kv) { return kv; }
200
201 static Value ValueOf(Pair kv) { return kv; }
202
203 static inline intptr_t Hashcode(Key key) {
204 return key->token_pos().value();
regis 2016/02/22 15:44:03 So the hash does not work?
rmacnak 2016/02/22 22:03:46 Forgot. Switched to ->Hash().
205 }
206
207 static inline bool IsKeyEqual(Pair pair, Key key) {
208 return pair->raw() == key->raw();
209 }
210 };
211
212 typedef DirectChainedHashMap<AbstractTypeKeyValueTrait> AbstractTypeSet;
213
214
215 class TypeArgumentsKeyValueTrait {
216 public:
217 // Typedefs needed for the DirectChainedHashMap template.
218 typedef const TypeArguments* Key;
219 typedef const TypeArguments* Value;
220 typedef const TypeArguments* Pair;
221
222 static Key KeyOf(Pair kv) { return kv; }
223
224 static Value ValueOf(Pair kv) { return kv; }
225
226 static inline intptr_t Hashcode(Key key) {
227 return key->Hash();
228 }
229
230 static inline bool IsKeyEqual(Pair pair, Key key) {
231 return pair->raw() == key->raw();
232 }
233 };
234
235 typedef DirectChainedHashMap<TypeArgumentsKeyValueTrait> TypeArgumentsSet;
236
237
169 class Precompiler : public ValueObject { 238 class Precompiler : public ValueObject {
170 public: 239 public:
171 static RawError* CompileAll( 240 static RawError* CompileAll(
172 Dart_QualifiedFunctionName embedder_entry_points[], 241 Dart_QualifiedFunctionName embedder_entry_points[],
173 bool reset_fields); 242 bool reset_fields);
174 243
175 // Returns named function that is a unique dynamic target, i.e., 244 // Returns named function that is a unique dynamic target, i.e.,
176 // - the target is identified by its name alone, since it occurs only once. 245 // - the target is identified by its name alone, since it occurs only once.
177 // - target's class has no subclasses, and neither is subclassed, i.e., 246 // - target's class has no subclasses, and neither is subclassed, i.e.,
178 // the receiver type can be only the function's class. 247 // the receiver type can be only the function's class.
(...skipping 13 matching lines...) Expand all
192 261
193 262
194 static RawFunction* CompileStaticInitializer(const Field& field); 263 static RawFunction* CompileStaticInitializer(const Field& field);
195 264
196 void DoCompileAll(Dart_QualifiedFunctionName embedder_entry_points[]); 265 void DoCompileAll(Dart_QualifiedFunctionName embedder_entry_points[]);
197 void ClearAllCode(); 266 void ClearAllCode();
198 void AddRoots(Dart_QualifiedFunctionName embedder_entry_points[]); 267 void AddRoots(Dart_QualifiedFunctionName embedder_entry_points[]);
199 void AddEntryPoints(Dart_QualifiedFunctionName entry_points[]); 268 void AddEntryPoints(Dart_QualifiedFunctionName entry_points[]);
200 void Iterate(); 269 void Iterate();
201 270
271 void AddType(const AbstractType& type);
272 void AddTypesOf(const Class& cls);
273 void AddTypesOf(const Function& function);
274 void AddTypeArguments(const TypeArguments& args);
202 void AddCalleesOf(const Function& function); 275 void AddCalleesOf(const Function& function);
203 void AddConstObject(const Instance& instance); 276 void AddConstObject(const Instance& instance);
204 void AddClosureCall(const ICData& call_site); 277 void AddClosureCall(const ICData& call_site);
205 void AddField(const Field& field); 278 void AddField(const Field& field);
206 void AddFunction(const Function& function); 279 void AddFunction(const Function& function);
207 void AddInstantiatedClass(const Class& cls); 280 void AddInstantiatedClass(const Class& cls);
208 void AddSelector(const String& selector); 281 void AddSelector(const String& selector);
209 bool IsSent(const String& selector); 282 bool IsSent(const String& selector);
210 283
211 void ProcessFunction(const Function& function); 284 void ProcessFunction(const Function& function);
212 void CheckForNewDynamicFunctions(); 285 void CheckForNewDynamicFunctions();
213 286
214 void DropFunctions(); 287 void DropFunctions();
215 void DropFields(); 288 void DropFields();
289 void TraceTypesFromRetainedClasses();
290 void DropTypes();
291 void DropTypeArguments();
292 void DropClasses();
293 void DropLibraries();
294
216 void BindStaticCalls(); 295 void BindStaticCalls();
217 void DedupStackmaps(); 296 void DedupStackmaps();
218 void DedupStackmapLists(); 297 void DedupStackmapLists();
219 void DedupInstructions(); 298 void DedupInstructions();
220 void ResetPrecompilerState(); 299 void ResetPrecompilerState();
221 300
222 void CollectDynamicFunctionNames(); 301 void CollectDynamicFunctionNames();
223 302
224 class FunctionVisitor : public ValueObject { 303 class FunctionVisitor : public ValueObject {
225 public: 304 public:
(...skipping 14 matching lines...) Expand all
240 Isolate* isolate_; 319 Isolate* isolate_;
241 320
242 const bool reset_fields_; 321 const bool reset_fields_;
243 322
244 bool changed_; 323 bool changed_;
245 intptr_t function_count_; 324 intptr_t function_count_;
246 intptr_t class_count_; 325 intptr_t class_count_;
247 intptr_t selector_count_; 326 intptr_t selector_count_;
248 intptr_t dropped_function_count_; 327 intptr_t dropped_function_count_;
249 intptr_t dropped_field_count_; 328 intptr_t dropped_field_count_;
329 intptr_t dropped_class_count_;
330 intptr_t dropped_typearg_count_;
331 intptr_t dropped_type_count_;
332 intptr_t dropped_library_count_;
250 333
251 const GrowableObjectArray& libraries_; 334 GrowableObjectArray& libraries_;
252 const GrowableObjectArray& pending_functions_; 335 const GrowableObjectArray& pending_functions_;
253 SymbolSet sent_selectors_; 336 SymbolSet sent_selectors_;
254 FunctionSet enqueued_functions_; 337 FunctionSet enqueued_functions_;
255 FieldSet fields_to_retain_; 338 FieldSet fields_to_retain_;
339 ClassSet classes_to_retain_;
340 TypeArgumentsSet typeargs_to_retain_;
341 AbstractTypeSet types_to_retain_;
256 Error& error_; 342 Error& error_;
257 }; 343 };
258 344
259 } // namespace dart 345 } // namespace dart
260 346
261 #endif // VM_PRECOMPILER_H_ 347 #endif // VM_PRECOMPILER_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698