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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 14015004: Remove call-indirections from type tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 addInstanceMember(member, builder); 1168 addInstanceMember(member, builder);
1169 } 1169 }
1170 } 1170 }
1171 1171
1172 classElement.implementation.forEachMember( 1172 classElement.implementation.forEachMember(
1173 visitMember, 1173 visitMember,
1174 includeBackendMembers: true, 1174 includeBackendMembers: true,
1175 includeSuperMembers: false); 1175 includeSuperMembers: false);
1176 1176
1177 void generateIsTest(Element other) { 1177 void generateIsTest(Element other) {
1178 jsAst.Expression code;
1179 if (other == compiler.objectClass && other != classElement) { 1178 if (other == compiler.objectClass && other != classElement) {
1180 // Avoid emitting [:$isObject:] on all classes but [Object]. 1179 // Avoid emitting [:$isObject:] on all classes but [Object].
1181 return; 1180 return;
1182 } 1181 }
1183 if (nativeEmitter.requiresNativeIsCheck(other)) { 1182 builder.addProperty(namer.operatorIs(other), js('true'));
1184 code = js.fun([], [js.return_(true)]);
1185 } else {
1186 code = js('true');
1187 }
1188 builder.addProperty(namer.operatorIs(other), code);
1189 } 1183 }
1190 1184
1191 void generateSubstitution(Element other, {bool emitNull: false}) { 1185 void generateSubstitution(Element other, {bool emitNull: false}) {
1192 RuntimeTypes rti = backend.rti; 1186 RuntimeTypes rti = backend.rti;
1193 // TODO(karlklose): support typedefs with variables. 1187 // TODO(karlklose): support typedefs with variables.
1194 jsAst.Expression expression; 1188 jsAst.Expression expression;
1195 bool needsNativeCheck = nativeEmitter.requiresNativeIsCheck(other); 1189 bool needsNativeCheck = nativeEmitter.requiresNativeIsCheck(other);
1196 if (other.kind == ElementKind.CLASS) { 1190 if (other.kind == ElementKind.CLASS) {
1197 String substitution = rti.getSupertypeSubstitution(classElement, other, 1191 String substitution = rti.getSupertypeSubstitution(classElement, other,
1198 alwaysGenerateFunction: true); 1192 alwaysGenerateFunction: true);
1199 if (substitution != null) { 1193 if (substitution != null) {
1200 expression = new jsAst.LiteralExpression(substitution); 1194 expression = new jsAst.LiteralExpression(substitution);
1201 } else if (emitNull || needsNativeCheck) { 1195 } else if (emitNull || needsNativeCheck) {
1202 expression = new jsAst.LiteralNull(); 1196 expression = new jsAst.LiteralNull();
1203 } 1197 }
1204 } 1198 }
1205 if (expression != null) { 1199 if (expression != null) {
1206 if (needsNativeCheck) {
1207 expression = js.fun([], js.return_(expression));
1208 }
1209 builder.addProperty(namer.substitutionName(other), expression); 1200 builder.addProperty(namer.substitutionName(other), expression);
1210 } 1201 }
1211 } 1202 }
1212 1203
1213 generateIsTestsOn(classElement, generateIsTest, generateSubstitution); 1204 generateIsTestsOn(classElement, generateIsTest, generateSubstitution);
1214 1205
1215 if (identical(classElement, compiler.objectClass) 1206 if (identical(classElement, compiler.objectClass)
1216 && compiler.enabledNoSuchMethod) { 1207 && compiler.enabledNoSuchMethod) {
1217 // Emit the noSuchMethod handlers on the Object prototype now, 1208 // Emit the noSuchMethod handlers on the Object prototype now,
1218 // so that the code in the dynamicFunction helper can find 1209 // so that the code in the dynamicFunction helper can find
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 """; 3038 """;
3048 const String HOOKS_API_USAGE = """ 3039 const String HOOKS_API_USAGE = """
3049 // The code supports the following hooks: 3040 // The code supports the following hooks:
3050 // dartPrint(message) - if this function is defined it is called 3041 // dartPrint(message) - if this function is defined it is called
3051 // instead of the Dart [print] method. 3042 // instead of the Dart [print] method.
3052 // dartMainRunner(main) - if this function is defined, the Dart [main] 3043 // dartMainRunner(main) - if this function is defined, the Dart [main]
3053 // method will not be invoked directly. 3044 // method will not be invoked directly.
3054 // Instead, a closure that will invoke [main] is 3045 // Instead, a closure that will invoke [main] is
3055 // passed to [dartMainRunner]. 3046 // passed to [dartMainRunner].
3056 """; 3047 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698