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

Unified Diff: sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart

Issue 14362026: Make mock_compiler initialize the identical function, and use the identical function element direct… (Closed) Base URL: http://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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart_backend_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart (revision 21723)
+++ sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart (working copy)
@@ -288,11 +288,21 @@
* position will be typed as dynamic.
*/
// TODO(erikcorry): Autogenerate the alphanumeric names in this set.
- Set<String> PREDICATES = ['moveNext',
- 'identicalImplementation',
- 'identical',
- '==', '<=', '>=', '<', '>'].toSet();
+ Set<SourceString> PREDICATES = new Set<SourceString>.from([
+ const SourceString('=='),
+ const SourceString('<='),
+ const SourceString('>='),
+ const SourceString('>'),
+ const SourceString('<'),
+ const SourceString('moveNext')]);
+ bool shouldOptimisticallyOptimizeToBool(Element element) {
+ return element == compiler.identicalFunction.implementation
+ || (element.isFunction()
+ && element.isInstanceMember()
+ && PREDICATES.contains(element.name));
+ }
+
final Compiler compiler;
// Times the computation of re-analysis of methods.
@@ -437,9 +447,9 @@
// mapping.
if (mapping == null) return;
if (element.isAbstract(compiler)) return;
- if (element.isFunction() &&
- PREDICATES.contains(element.name.slowToString())) {
- // Add the relational operators, ==, !=, <, etc., before any others.
+ // Add the relational operators, ==, !=, <, etc., before any
+ // others, as well as the identical function.
+ if (shouldOptimisticallyOptimizeToBool(element)) {
workSet.add(element);
// Optimistically assume that they return bool. We may need to back
// out of this.
@@ -607,11 +617,12 @@
* [analyzedElement].
*/
bool recordReturnType(Element analyzedElement, TypeMask returnType) {
- if (optimismState == OPTIMISTIC &&
- returnType != boolType &&
- PREDICATES.contains(analyzedElement.name.slowToString())) {
- // One of the relational operators (==, <, ...) turned out not to return
- // boolean. This means we need to restart the analysis.
+ assert(analyzedElement.implementation == analyzedElement);
+ if (optimismState == OPTIMISTIC
+ && shouldOptimisticallyOptimizeToBool(analyzedElement)
+ && returnType != returnTypeOf[analyzedElement]) {
+ // One of the functions turned out not to return what we expected.
+ // This means we need to restart the analysis.
optimismState = RETRY;
}
return internalRecordType(analyzedElement, returnType, returnTypeOf);
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart_backend_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698