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

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

Issue 1153243003: dart2js: Use frequency of occurence to sort metadata indices. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Addressed sra's comments Created 5 years, 6 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 /// This class should morph into something that makes it easy to build 7 /// This class should morph into something that makes it easy to build
8 /// JavaScript representations of libraries, class-sides, and instance-sides. 8 /// JavaScript representations of libraries, class-sides, and instance-sides.
9 /// Initially, it is just a placeholder for code that is moved from 9 /// Initially, it is just a placeholder for code that is moved from
10 /// [CodeEmitterTask]. 10 /// [CodeEmitterTask].
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 tearOffInfo.add(new jsAst.LiteralString(callSelectorString)); 123 tearOffInfo.add(new jsAst.LiteralString(callSelectorString));
124 } 124 }
125 125
126 expressions 126 expressions
127 ..addAll(tearOffInfo) 127 ..addAll(tearOffInfo)
128 ..add((tearOffName == null || member.isAccessor) 128 ..add((tearOffName == null || member.isAccessor)
129 ? js("null") : js.string(tearOffName)) 129 ? js("null") : js.string(tearOffName))
130 ..add(js.number(requiredParameterCount)) 130 ..add(js.number(requiredParameterCount))
131 ..add(js.number(optionalParameterCount)) 131 ..add(js.number(optionalParameterCount))
132 ..add(memberTypeExpression == null ? js("null") : memberTypeExpression) 132 ..add(memberTypeExpression == null ? js("null") : memberTypeExpression)
133 ..addAll(task.metadataCollector 133 ..addAll(task.metadataCollector.reifyDefaultArguments(member));
134 .reifyDefaultArguments(member).map(js.number));
135 134
136 if (canBeReflected || canBeApplied) { 135 if (canBeReflected || canBeApplied) {
137 parameters.forEachParameter((Element parameter) { 136 parameters.forEachParameter((Element parameter) {
138 expressions.add( 137 expressions.add(task.metadataCollector.reifyName(parameter.name));
139 js.number(task.metadataCollector.reifyName(parameter.name)));
140 if (backend.mustRetainMetadata) { 138 if (backend.mustRetainMetadata) {
141 Iterable<int> metadataIndices = 139 Iterable<jsAst.Expression> metadataIndices =
142 parameter.metadata.map((MetadataAnnotation annotation) { 140 parameter.metadata.map((MetadataAnnotation annotation) {
143 ConstantValue constant = 141 ConstantValue constant =
144 backend.constants.getConstantValueForMetadata(annotation); 142 backend.constants.getConstantValueForMetadata(annotation);
145 backend.constants.addCompileTimeConstantForEmission(constant); 143 backend.constants.addCompileTimeConstantForEmission(constant);
146 return task.metadataCollector.reifyMetadata(annotation); 144 return task.metadataCollector.reifyMetadata(annotation);
147 }); 145 });
148 expressions.add(new jsAst.ArrayInitializer( 146 expressions.add(new jsAst.ArrayInitializer(metadataIndices.toList()));
149 metadataIndices.map(js.number).toList()));
150 } 147 }
151 }); 148 });
152 } 149 }
153 if (canBeReflected) { 150 if (canBeReflected) {
154 jsAst.LiteralString reflectionName; 151 jsAst.LiteralString reflectionName;
155 if (member.isConstructor) { 152 if (member.isConstructor) {
156 String reflectionNameString = emitter.getReflectionName(member, name); 153 String reflectionNameString = emitter.getReflectionName(member, name);
157 reflectionName = 154 reflectionName =
158 new jsAst.LiteralString( 155 new jsAst.LiteralString(
159 '"new ${Elements.reconstructConstructorName(member)}"'); 156 '"new ${Elements.reconstructConstructorName(member)}"');
160 } else { 157 } else {
161 reflectionName = 158 reflectionName =
162 js.string(namer.privateName(member.memberName)); 159 js.string(namer.privateName(member.memberName));
163 } 160 }
164 expressions 161 expressions
165 ..add(reflectionName) 162 ..add(reflectionName)
166 ..addAll(task.metadataCollector 163 ..addAll(task.metadataCollector.computeMetadata(member));
167 .computeMetadata(member).map(js.number));
168 } else if (isClosure && canBeApplied) { 164 } else if (isClosure && canBeApplied) {
169 expressions.add(js.string(namer.privateName(member.memberName))); 165 expressions.add(js.string(namer.privateName(member.memberName)));
170 } 166 }
171 167
172 jsAst.ArrayInitializer arrayInit = 168 jsAst.ArrayInitializer arrayInit =
173 new jsAst.ArrayInitializer(expressions.toList()); 169 new jsAst.ArrayInitializer(expressions.toList());
174 compiler.dumpInfoTask.registerElementAst(member, 170 compiler.dumpInfoTask.registerElementAst(member,
175 builder.addProperty(name, arrayInit)); 171 builder.addProperty(name, arrayInit));
176 } 172 }
177 173
178 void addMemberField(Field field, ClassBuilder builder) { 174 void addMemberField(Field field, ClassBuilder builder) {
179 // For now, do nothing. 175 // For now, do nothing.
180 } 176 }
181 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698