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

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

Issue 12210142: Implement is-checks against type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix computation of classes that need rti. Created 7 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
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 typedef void Recompile(Element element); 7 typedef void Recompile(Element element);
8 8
9 class ReturnInfo { 9 class ReturnInfo {
10 HType returnType; 10 HType returnType;
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 655
656 /** 656 /**
657 * Interface used to determine if an object has the JavaScript 657 * Interface used to determine if an object has the JavaScript
658 * indexing behavior. The interface is only visible to specific 658 * indexing behavior. The interface is only visible to specific
659 * libraries. 659 * libraries.
660 */ 660 */
661 ClassElement jsIndexingBehaviorInterface; 661 ClassElement jsIndexingBehaviorInterface;
662 662
663 final Map<Element, ReturnInfo> returnInfo; 663 final Map<Element, ReturnInfo> returnInfo;
664 664
665 Iterable<ClassElement> cachedClassesUsingTypeVariableTests;
ngeoffray 2013/02/21 10:26:18 Should that be in the emitter instead? It would li
karlklose 2013/02/21 14:48:44 Done.
666
667 Iterable<ClassElement> get classesUsingTypeVariableTests {
668 if (cachedClassesUsingTypeVariableTests == null) {
669 cachedClassesUsingTypeVariableTests = rti.isChecks
670 .where((DartType t) => t is TypeVariableType)
671 .map((TypeVariableType v) => v.element.getEnclosingClass());
672 }
673 return cachedClassesUsingTypeVariableTests;
674 }
675
665 /** 676 /**
666 * Documentation wanted -- johnniwinther 677 * Documentation wanted -- johnniwinther
667 * 678 *
668 * Invariant: Elements must be declaration elements. 679 * Invariant: Elements must be declaration elements.
669 */ 680 */
670 final List<Element> invalidateAfterCodegen; 681 final List<Element> invalidateAfterCodegen;
671 ArgumentTypesRegistry argumentTypes; 682 ArgumentTypesRegistry argumentTypes;
672 FieldTypesRegistry fieldTypes; 683 FieldTypesRegistry fieldTypes;
673 684
674 /** 685 /**
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 enqueueInResolution(getTraceFromException()); 999 enqueueInResolution(getTraceFromException());
989 } 1000 }
990 1001
991 void registerRuntimeType() { 1002 void registerRuntimeType() {
992 enqueueInResolution(getSetRuntimeTypeInfo()); 1003 enqueueInResolution(getSetRuntimeTypeInfo());
993 enqueueInResolution(getGetRuntimeTypeInfo()); 1004 enqueueInResolution(getGetRuntimeTypeInfo());
994 enqueueInResolution(getGetRuntimeTypeArgument()); 1005 enqueueInResolution(getGetRuntimeTypeArgument());
995 } 1006 }
996 1007
997 void registerIsCheck(DartType type, Enqueuer world) { 1008 void registerIsCheck(DartType type, Enqueuer world) {
998 if (!type.isRaw) { 1009 if (!type.isRaw || type is TypeVariableType) {
ngeoffray 2013/02/21 10:26:18 use type.kind instead?
karlklose 2013/02/21 14:48:44 Done.
999 enqueueInResolution(getSetRuntimeTypeInfo()); 1010 enqueueInResolution(getSetRuntimeTypeInfo());
1000 enqueueInResolution(getGetRuntimeTypeInfo()); 1011 enqueueInResolution(getGetRuntimeTypeInfo());
1001 enqueueInResolution(getGetRuntimeTypeArgument()); 1012 enqueueInResolution(getGetRuntimeTypeArgument());
1002 enqueueInResolution(getCheckArguments()); 1013 enqueueInResolution(getCheckArguments());
1014 enqueueInResolution(getGetObjectIsSubtype());
ngeoffray 2013/02/21 10:26:18 Isn't that one just requires by TypeVariableType?
karlklose 2013/02/21 14:48:44 Done.
1003 } 1015 }
1004 // [registerIsCheck] is also called for checked mode checks, so we 1016 // [registerIsCheck] is also called for checked mode checks, so we
1005 // need to register checked mode helpers. 1017 // need to register checked mode helpers.
1006 if (compiler.enableTypeAssertions) { 1018 if (compiler.enableTypeAssertions) {
1007 Element e = getCheckedModeHelper(type, typeCast: false); 1019 Element e = getCheckedModeHelper(type, typeCast: false);
1008 if (e != null) world.addToWorkList(e); 1020 if (e != null) world.addToWorkList(e);
1009 // We also need the native variant of the check (for DOM types). 1021 // We also need the native variant of the check (for DOM types).
1010 e = getNativeCheckedModeHelper(type, typeCast: false); 1022 e = getNativeCheckedModeHelper(type, typeCast: false);
1011 if (e != null) world.addToWorkList(e); 1023 if (e != null) world.addToWorkList(e);
1012 } 1024 }
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 } 1449 }
1438 1450
1439 Element getGetRuntimeTypeArgument() { 1451 Element getGetRuntimeTypeArgument() {
1440 return compiler.findHelper(const SourceString('getRuntimeTypeArgument')); 1452 return compiler.findHelper(const SourceString('getRuntimeTypeArgument'));
1441 } 1453 }
1442 1454
1443 Element getCheckArguments() { 1455 Element getCheckArguments() {
1444 return compiler.findHelper(const SourceString('checkArguments')); 1456 return compiler.findHelper(const SourceString('checkArguments'));
1445 } 1457 }
1446 1458
1459 Element getGetObjectIsSubtype() {
1460 return compiler.findHelper(const SourceString('objectIsSubtype'));
1461 }
1462
1447 Element getThrowNoSuchMethod() { 1463 Element getThrowNoSuchMethod() {
1448 return compiler.findHelper(const SourceString('throwNoSuchMethod')); 1464 return compiler.findHelper(const SourceString('throwNoSuchMethod'));
1449 } 1465 }
1450 1466
1451 Element getCreateRuntimeType() { 1467 Element getCreateRuntimeType() {
1452 return compiler.findHelper(const SourceString('createRuntimeType')); 1468 return compiler.findHelper(const SourceString('createRuntimeType'));
1453 } 1469 }
1454 1470
1455 Element getFallThroughError() { 1471 Element getFallThroughError() {
1456 return compiler.findHelper(const SourceString("getFallThroughError")); 1472 return compiler.findHelper(const SourceString("getFallThroughError"));
(...skipping 13 matching lines...) Expand all
1470 * 1486 *
1471 * Invariant: [element] must be a declaration element. 1487 * Invariant: [element] must be a declaration element.
1472 */ 1488 */
1473 void eagerRecompile(Element element) { 1489 void eagerRecompile(Element element) {
1474 assert(invariant(element, element.isDeclaration)); 1490 assert(invariant(element, element.isDeclaration));
1475 generatedCode.remove(element); 1491 generatedCode.remove(element);
1476 generatedBailoutCode.remove(element); 1492 generatedBailoutCode.remove(element);
1477 compiler.enqueuer.codegen.addToWorkList(element); 1493 compiler.enqueuer.codegen.addToWorkList(element);
1478 } 1494 }
1479 } 1495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698