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

Unified Diff: pkg/compiler/lib/src/js_emitter/registry.dart

Issue 838643002: dart2js: Register constants in the model builder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/registry.dart
diff --git a/pkg/compiler/lib/src/js_emitter/registry.dart b/pkg/compiler/lib/src/js_emitter/registry.dart
index 0c036b3e3179a0b5b7b179753682de6c19fda0bb..801372b232ed0418081d39f24f6740013a725dac 100644
--- a/pkg/compiler/lib/src/js_emitter/registry.dart
+++ b/pkg/compiler/lib/src/js_emitter/registry.dart
@@ -54,6 +54,10 @@ class Registry {
final Map<OutputUnit, Fragment> _deferredFragmentsMap =
<OutputUnit, Fragment>{};
+ /// Cache for the last seen output unit.
+ OutputUnit _lastOutputUnit;
+ Fragment _lastFragment;
+
DeferredLoadTask get _deferredLoadTask => _compiler.deferredLoadTask;
Iterable<Holder> get holders => _holdersMap.values;
Iterable<Fragment> get deferredFragments => _deferredFragmentsMap.values;
@@ -68,17 +72,24 @@ class Registry {
OutputUnit get _mainOutputUnit => _deferredLoadTask.mainOutputUnit;
Fragment _mapUnitToFragment(OutputUnit targetUnit) {
+ if (targetUnit == _lastOutputUnit) return _lastFragment;
+
if (mainFragment == null) {
mainFragment = new Fragment.main(_deferredLoadTask.mainOutputUnit);
}
+ Fragment result;
if (!_isProgramSplit) {
assert(targetUnit == _deferredLoadTask.mainOutputUnit);
- return mainFragment;
+ result = mainFragment;
+ } else {
+ if (targetUnit == _mainOutputUnit) return mainFragment;
zarah 2015/01/09 08:39:19 Shouldn't _lastOutputUnit and _lastFragment be set
floitsch 2015/01/09 17:21:50 done and simplified.
+ String name = targetUnit.name;
+ result = _deferredFragmentsMap.putIfAbsent(
+ targetUnit, () => new Fragment.deferred(targetUnit, name));
}
- if (targetUnit == _mainOutputUnit) return mainFragment;
- String name = targetUnit.name;
- return _deferredFragmentsMap.putIfAbsent(
- targetUnit, () => new Fragment.deferred(targetUnit, name));
+ _lastOutputUnit = targetUnit;
+ _lastFragment = result;
+ return result;
}
/// Adds all elements to their respective libraries in the correct fragment.
@@ -89,6 +100,12 @@ class Registry {
}
}
+ void registerConstant(OutputUnit outputUnit, ConstantValue constantValue) {
+ // We just need to make sure that the target fragment is registered.
+ // Otherwise a fragment that contains only constants is not built.
+ _mapUnitToFragment(outputUnit);
+ }
+
Holder registerHolder(String name) {
return _holdersMap.putIfAbsent(
name,
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698