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

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

Issue 22903036: Use predicates to check simple function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Small updates. Created 7 years, 4 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 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 FunctionType methodType, 2169 FunctionType methodType,
2170 Map<FunctionType, bool> functionTypeChecks, 2170 Map<FunctionType, bool> functionTypeChecks,
2171 FunctionTypeSignatureEmitter emitFunctionTypeSignature, 2171 FunctionTypeSignatureEmitter emitFunctionTypeSignature,
2172 FunctionTypeTestEmitter emitIsFunctionTypeTest) { 2172 FunctionTypeTestEmitter emitIsFunctionTypeTest) {
2173 bool hasDynamicFunctionTypeCheck = false; 2173 bool hasDynamicFunctionTypeCheck = false;
2174 int neededPredicates = 0; 2174 int neededPredicates = 0;
2175 functionTypeChecks.forEach((FunctionType functionType, bool knownSubtype) { 2175 functionTypeChecks.forEach((FunctionType functionType, bool knownSubtype) {
2176 if (!knownSubtype) { 2176 if (!knownSubtype) {
2177 registerDynamicFunctionTypeCheck(functionType); 2177 registerDynamicFunctionTypeCheck(functionType);
2178 hasDynamicFunctionTypeCheck = true; 2178 hasDynamicFunctionTypeCheck = true;
2179 } else { 2179 } else if (!functionType.isSimple) {
karlklose 2013/08/23 09:13:50 Perhaps add a comment why these do not count as pr
Johnni Winther 2013/08/23 10:06:57 Done.
2180 neededPredicates++; 2180 neededPredicates++;
2181 } 2181 }
2182 }); 2182 });
2183 bool alwaysUseSignature = false; 2183 bool alwaysUseSignature = false;
2184 if (hasDynamicFunctionTypeCheck || 2184 if (hasDynamicFunctionTypeCheck ||
2185 neededPredicates > MAX_FUNCTION_TYPE_PREDICATES) { 2185 neededPredicates > MAX_FUNCTION_TYPE_PREDICATES) {
2186 emitFunctionTypeSignature(method, methodType); 2186 emitFunctionTypeSignature(method, methodType);
2187 alwaysUseSignature = true; 2187 alwaysUseSignature = true;
2188 } 2188 }
2189 functionTypeChecks.forEach((FunctionType functionType, bool knownSubtype) { 2189 functionTypeChecks.forEach((FunctionType functionType, bool knownSubtype) {
2190 if (knownSubtype) { 2190 if (knownSubtype) {
2191 if (alwaysUseSignature) { 2191 if (functionType.isSimple) {
2192 emitIsFunctionTypeTest(functionType);
2193 } else if (alwaysUseSignature) {
2192 registerDynamicFunctionTypeCheck(functionType); 2194 registerDynamicFunctionTypeCheck(functionType);
2193 } else { 2195 } else {
2194 emitIsFunctionTypeTest(functionType); 2196 emitIsFunctionTypeTest(functionType);
2195 } 2197 }
2196 } 2198 }
2197 }); 2199 });
2198 } 2200 }
2199 2201
2200 /** 2202 /**
2201 * Return a function that returns true if its argument is a class 2203 * Return a function that returns true if its argument is a class
(...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after
4152 4154
4153 const String HOOKS_API_USAGE = """ 4155 const String HOOKS_API_USAGE = """
4154 // The code supports the following hooks: 4156 // The code supports the following hooks:
4155 // dartPrint(message) - if this function is defined it is called 4157 // dartPrint(message) - if this function is defined it is called
4156 // instead of the Dart [print] method. 4158 // instead of the Dart [print] method.
4157 // dartMainRunner(main) - if this function is defined, the Dart [main] 4159 // dartMainRunner(main) - if this function is defined, the Dart [main]
4158 // method will not be invoked directly. 4160 // method will not be invoked directly.
4159 // Instead, a closure that will invoke [main] is 4161 // Instead, a closure that will invoke [main] is
4160 // passed to [dartMainRunner]. 4162 // passed to [dartMainRunner].
4161 """; 4163 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698