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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/model.dart

Issue 915043002: dart2js: Track holders better when they are deferred. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.new_js_emitter.model; 5 library dart2js.new_js_emitter.model;
6 6
7 import '../js/js.dart' as js show Expression, Statement; 7 import '../js/js.dart' as js show Expression, Statement;
8 import '../constants/values.dart' show ConstantValue; 8 import '../constants/values.dart' show ConstantValue;
9 9
10 import '../deferred_load.dart' show OutputUnit; 10 import '../deferred_load.dart' show OutputUnit;
11 11
12 import 'js_emitter.dart' show MetadataCollector; 12 import 'js_emitter.dart' show MetadataCollector;
13 13
14 import '../common.dart'; 14 import '../common.dart';
15 15
16 class Program { 16 class Program {
17 final List<Fragment> fragments; 17 final List<Fragment> fragments;
18 final List<Holder> holders;
18 final bool outputContainsConstantList; 19 final bool outputContainsConstantList;
19 final bool outputContainsNativeClasses; 20 final bool outputContainsNativeClasses;
20 final bool hasIsolateSupport; 21 final bool hasIsolateSupport;
21 /// A map from load id to the list of fragments that need to be loaded. 22 /// A map from load id to the list of fragments that need to be loaded.
22 final Map<String, List<Fragment>> loadMap; 23 final Map<String, List<Fragment>> loadMap;
23 24
24 // If this field is not `null` then its value must be emitted in the embedded 25 // If this field is not `null` then its value must be emitted in the embedded
25 // global `TYPE_TO_INTERCEPTOR_MAP`. The map references constants and classes. 26 // global `TYPE_TO_INTERCEPTOR_MAP`. The map references constants and classes.
26 final js.Expression typeToInterceptorMap; 27 final js.Expression typeToInterceptorMap;
27 28
28 // TODO(floitsch): we should store the metadata directly instead of storing 29 // TODO(floitsch): we should store the metadata directly instead of storing
29 // the collector. However, the old emitter still updates the data. 30 // the collector. However, the old emitter still updates the data.
30 final MetadataCollector _metadataCollector; 31 final MetadataCollector _metadataCollector;
31 32
32 Program(this.fragments, 33 Program(this.fragments,
34 this.holders,
33 this.loadMap, 35 this.loadMap,
34 this.typeToInterceptorMap, 36 this.typeToInterceptorMap,
35 this._metadataCollector, 37 this._metadataCollector,
36 {this.outputContainsNativeClasses, 38 {this.outputContainsNativeClasses,
37 this.outputContainsConstantList, 39 this.outputContainsConstantList,
38 this.hasIsolateSupport}) { 40 this.hasIsolateSupport}) {
39 assert(outputContainsNativeClasses != null); 41 assert(outputContainsNativeClasses != null);
40 assert(outputContainsConstantList != null); 42 assert(outputContainsConstantList != null);
41 assert(hasIsolateSupport != null); 43 assert(hasIsolateSupport != null);
42 } 44 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 /// Output file name without extension. 90 /// Output file name without extension.
89 final String outputFileName; 91 final String outputFileName;
90 92
91 Fragment(this.outputUnit, 93 Fragment(this.outputUnit,
92 this.outputFileName, 94 this.outputFileName,
93 this.libraries, 95 this.libraries,
94 this.staticNonFinalFields, 96 this.staticNonFinalFields,
95 this.staticLazilyInitializedFields, 97 this.staticLazilyInitializedFields,
96 this.constants); 98 this.constants);
97 99
98 bool get isMainFragment => mainFragment == this; 100 bool get isMainFragment;
99 MainFragment get mainFragment;
100 } 101 }
101 102
102 /** 103 /**
103 * The main output file. 104 * The main output file.
104 * 105 *
105 * This code emitted from this [Fragment] must be loaded first. It can then load 106 * This code emitted from this [Fragment] must be loaded first. It can then load
106 * other [DeferredFragment]s. 107 * other [DeferredFragment]s.
107 */ 108 */
108 class MainFragment extends Fragment { 109 class MainFragment extends Fragment {
109 final js.Statement invokeMain; 110 final js.Statement invokeMain;
110 final List<Holder> holders;
111 111
112 MainFragment(OutputUnit outputUnit, 112 MainFragment(OutputUnit outputUnit,
113 String outputFileName, 113 String outputFileName,
114 this.invokeMain, 114 this.invokeMain,
115 List<Library> libraries, 115 List<Library> libraries,
116 List<StaticField> staticNonFinalFields, 116 List<StaticField> staticNonFinalFields,
117 List<StaticField> staticLazilyInitializedFields, 117 List<StaticField> staticLazilyInitializedFields,
118 List<Constant> constants, 118 List<Constant> constants)
119 this.holders)
120 : super(outputUnit, 119 : super(outputUnit,
121 outputFileName, 120 outputFileName,
122 libraries, 121 libraries,
123 staticNonFinalFields, 122 staticNonFinalFields,
124 staticLazilyInitializedFields, 123 staticLazilyInitializedFields,
125 constants); 124 constants);
126 125
127 MainFragment get mainFragment => this; 126 bool get isMainFragment => true;
128 } 127 }
129 128
130 /** 129 /**
131 * An output (file) for deferred code. 130 * An output (file) for deferred code.
132 */ 131 */
133 class DeferredFragment extends Fragment { 132 class DeferredFragment extends Fragment {
134 final MainFragment mainFragment;
135 final String name; 133 final String name;
136 134
137 List<Holder> get holders => mainFragment.holders;
138
139 DeferredFragment(OutputUnit outputUnit, 135 DeferredFragment(OutputUnit outputUnit,
140 String outputFileName, 136 String outputFileName,
141 this.name, 137 this.name,
142 this.mainFragment,
143 List<Library> libraries, 138 List<Library> libraries,
144 List<StaticField> staticNonFinalFields, 139 List<StaticField> staticNonFinalFields,
145 List<StaticField> staticLazilyInitializedFields, 140 List<StaticField> staticLazilyInitializedFields,
146 List<Constant> constants) 141 List<Constant> constants)
147 : super(outputUnit, 142 : super(outputUnit,
148 outputFileName, 143 outputFileName,
149 libraries, 144 libraries,
150 staticNonFinalFields, 145 staticNonFinalFields,
151 staticLazilyInitializedFields, 146 staticLazilyInitializedFields,
152 constants); 147 constants);
148
149 bool get isMainFragment => false;
153 } 150 }
154 151
155 class Constant { 152 class Constant {
156 final String name; 153 final String name;
157 final Holder holder; 154 final Holder holder;
158 final ConstantValue value; 155 final ConstantValue value;
159 156
160 Constant(this.name, this.holder, this.value); 157 Constant(this.name, this.holder, this.value);
161 } 158 }
162 159
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 tearOffName : tearOffName, 434 tearOffName : tearOffName,
438 canBeApplied : canBeApplied, 435 canBeApplied : canBeApplied,
439 canBeReflected : canBeReflected); 436 canBeReflected : canBeReflected);
440 } 437 }
441 438
442 class StaticStubMethod extends StubMethod implements StaticMethod { 439 class StaticStubMethod extends StubMethod implements StaticMethod {
443 Holder holder; 440 Holder holder;
444 StaticStubMethod(String name, this.holder, js.Expression code) 441 StaticStubMethod(String name, this.holder, js.Expression code)
445 : super(name, code); 442 : super(name, code);
446 } 443 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698