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

Unified Diff: pkg/compiler/lib/src/serialization/system.dart

Issue 2024783003: Support references to unserialized libraries. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/serialization/system.dart
diff --git a/pkg/compiler/lib/src/serialization/system.dart b/pkg/compiler/lib/src/serialization/system.dart
index 8b54e98d5754d6af2c62bce641f9d0502aff6b15..ce8831326c905f5fbf55e9250cac5560d8de4e9b 100644
--- a/pkg/compiler/lib/src/serialization/system.dart
+++ b/pkg/compiler/lib/src/serialization/system.dart
@@ -37,7 +37,8 @@ class DeserializerSystemImpl extends DeserializerSystem {
factory DeserializerSystemImpl(
Compiler compiler, ImpactTransformer impactTransformer) {
DeserializationContext context =
- new DeserializationContext(compiler.reporter);
+ new DeserializationContext(
+ compiler.reporter, compiler.resolution, compiler.libraryLoader);
DeserializerPlugin backendDeserializer =
compiler.backend.serialization.deserializer;
context.plugins.add(backendDeserializer);
@@ -96,7 +97,7 @@ class DeserializerSystemImpl extends DeserializerSystem {
element.enclosingClass.isUnnamedMixinApplication) {
return true;
}
- return _resolutionImpactDeserializer.impactMap.containsKey(element);
+ return _resolutionImpactDeserializer.hasResolutionImpact(element);
}
@override
@@ -111,14 +112,15 @@ class DeserializerSystemImpl extends DeserializerSystem {
"${element} not found in ${superclass}."));
// TODO(johnniwinther): Compute callStructure. Currently not used.
CallStructure callStructure;
- return _resolutionImpactDeserializer.impactMap.putIfAbsent(element, () {
+ return _resolutionImpactDeserializer.registerResolutionImpact(element,
+ () {
return new DeserializedResolutionImpact(staticUses: <StaticUse>[
new StaticUse.superConstructorInvoke(
superclassConstructor, callStructure)
]);
});
}
- return _resolutionImpactDeserializer.impactMap[element];
+ return _resolutionImpactDeserializer.getResolutionImpact(element);
}
@override
@@ -158,7 +160,8 @@ class ResolutionImpactSerializer extends SerializerPlugin {
}
class ResolutionImpactDeserializer extends DeserializerPlugin {
- Map<Element, ResolutionImpact> impactMap = <Element, ResolutionImpact>{};
+ Map<Element, ObjectDecoder> _decoderMap = <Element, ObjectDecoder>{};
+ Map<Element, ResolutionImpact> _impactMap = <Element, ResolutionImpact>{};
final DeserializerPlugin nativeDataDeserializer;
ResolutionImpactDeserializer(this.nativeDataDeserializer);
@@ -167,10 +170,31 @@ class ResolutionImpactDeserializer extends DeserializerPlugin {
void onElement(Element element, ObjectDecoder getDecoder(String tag)) {
ObjectDecoder decoder = getDecoder(WORLD_IMPACT_TAG);
if (decoder != null) {
- impactMap[element] = ImpactDeserializer.deserializeImpact(
- element, decoder, nativeDataDeserializer);
+ _decoderMap[element] = decoder;
}
}
+
+ bool hasResolutionImpact(Element element) {
+ return _impactMap.containsKey(element) || _decoderMap.containsKey(element);
+ }
+
+ ResolutionImpact registerResolutionImpact(
+ Element element, ResolutionImpact ifAbsent()) {
+ return _impactMap.putIfAbsent(element, ifAbsent);
+ }
+
+ ResolutionImpact getResolutionImpact(Element element) {
+ return registerResolutionImpact(element, () {
+ ObjectDecoder decoder = _decoderMap[element];
+ if (decoder != null) {
+ _decoderMap.remove(element);
+ return ImpactDeserializer.deserializeImpact(
+ element, decoder, nativeDataDeserializer);
+ }
+ return null;
+ });
+
+ }
}
const String RESOLVED_AST_TAG = 'resolvedAst';
« no previous file with comments | « pkg/compiler/lib/src/serialization/serialization.dart ('k') | tests/compiler/dart2js/serialization/equivalence_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698