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

Side by Side Diff: pkg/compiler/lib/src/serialization/task.dart

Issue 1873573004: Serialize TreeElements (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Check only the last test to avoid timeout. Created 4 years, 8 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 library dart2js.serialization.task; 5 library dart2js.serialization.task;
6 6
7 import 'dart:async' show Future;
7 import '../common/resolution.dart' show ResolutionImpact, ResolutionWorkItem; 8 import '../common/resolution.dart' show ResolutionImpact, ResolutionWorkItem;
8 import '../common/tasks.dart' show CompilerTask; 9 import '../common/tasks.dart' show CompilerTask;
9 import '../common/work.dart' show ItemCompilationContext; 10 import '../common/work.dart' show ItemCompilationContext;
10 import '../compiler.dart' show Compiler; 11 import '../compiler.dart' show Compiler;
11 import '../elements/elements.dart'; 12 import '../elements/elements.dart';
12 import '../enqueue.dart' show ResolutionEnqueuer; 13 import '../enqueue.dart' show ResolutionEnqueuer;
13 import '../universe/world_impact.dart' show WorldImpact; 14 import '../universe/world_impact.dart' show WorldImpact;
14 15
15 /// A deserializer that can load a library element by reading it's information 16 /// A deserializer that can load a library element by reading it's information
16 /// from a serialized form. 17 /// from a serialized form.
17 abstract class LibraryDeserializer { 18 abstract class LibraryDeserializer {
18 /// Loads the [LibraryElement] associated with a library under [uri], or null 19 /// Loads the [LibraryElement] associated with a library under [uri], or null
19 /// if no serialized information is available for the given library. 20 /// if no serialized information is available for the given library.
20 LibraryElement readLibrary(Uri uri); 21 Future<LibraryElement> readLibrary(Uri uri);
21 } 22 }
22 23
23 /// Task that supports deserialization of elements. 24 /// Task that supports deserialization of elements.
24 class SerializationTask extends CompilerTask implements LibraryDeserializer { 25 class SerializationTask extends CompilerTask implements LibraryDeserializer {
25 SerializationTask(Compiler compiler) : super(compiler); 26 SerializationTask(Compiler compiler) : super(compiler);
26 27
27 DeserializerSystem deserializer; 28 DeserializerSystem deserializer;
28 29
29 String get name => 'Serialization'; 30 String get name => 'Serialization';
30 31
31 /// If `true`, data must be retained to support serialization. 32 /// If `true`, data must be retained to support serialization.
32 // TODO(johnniwinther): Make this more precise in terms of what needs to be 33 // TODO(johnniwinther): Make this more precise in terms of what needs to be
33 // retained, for instance impacts, resolution data etc. 34 // retained, for instance impacts, resolution data etc.
34 bool supportSerialization = false; 35 bool supportSerialization = false;
35 36
36 /// Returns the [LibraryElement] for [resolvedUri] if available from 37 /// Returns the [LibraryElement] for [resolvedUri] if available from
37 /// serialization. 38 /// serialization.
38 LibraryElement readLibrary(Uri resolvedUri) { 39 Future<LibraryElement> readLibrary(Uri resolvedUri) {
39 if (deserializer == null) return null; 40 if (deserializer == null) return new Future<LibraryElement>.value();
40 return deserializer.readLibrary(resolvedUri); 41 return deserializer.readLibrary(resolvedUri);
41 } 42 }
42 43
43 /// Returns `true` if [element] has been deserialized. 44 /// Returns `true` if [element] has been deserialized.
44 bool isDeserialized(Element element) { 45 bool isDeserialized(Element element) {
45 return deserializer != null && deserializer.isDeserialized(element); 46 return deserializer != null && deserializer.isDeserialized(element);
46 } 47 }
47 48
48 /// Creates the [ResolutionWorkItem] for the deserialized [element]. 49 /// Creates the [ResolutionWorkItem] for the deserialized [element].
49 ResolutionWorkItem createResolutionWorkItem( 50 ResolutionWorkItem createResolutionWorkItem(
(...skipping 24 matching lines...) Expand all
74 WorldImpact run(Compiler compiler, ResolutionEnqueuer world) { 75 WorldImpact run(Compiler compiler, ResolutionEnqueuer world) {
75 _isAnalyzed = true; 76 _isAnalyzed = true;
76 world.registerProcessedElement(element); 77 world.registerProcessedElement(element);
77 return worldImpact; 78 return worldImpact;
78 } 79 }
79 } 80 }
80 81
81 /// The interface for a system that supports deserialization of libraries and 82 /// The interface for a system that supports deserialization of libraries and
82 /// elements. 83 /// elements.
83 abstract class DeserializerSystem { 84 abstract class DeserializerSystem {
84 LibraryElement readLibrary(Uri resolvedUri); 85 Future<LibraryElement> readLibrary(Uri resolvedUri);
85 bool isDeserialized(Element element); 86 bool isDeserialized(Element element);
87 ResolvedAst getResolvedAst(Element element);
86 ResolutionImpact getResolutionImpact(Element element); 88 ResolutionImpact getResolutionImpact(Element element);
87 WorldImpact computeWorldImpact(Element element); 89 WorldImpact computeWorldImpact(Element element);
88 } 90 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/serialization_util.dart ('k') | tests/compiler/dart2js/serialization_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698