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

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

Issue 12334070: Support runtime check of function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Register dependency Created 7 years, 9 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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 } 1063 }
1064 1064
1065 void registerSetRuntimeType(TreeElements elements) { 1065 void registerSetRuntimeType(TreeElements elements) {
1066 enqueueInResolution(getSetRuntimeTypeInfo(), elements); 1066 enqueueInResolution(getSetRuntimeTypeInfo(), elements);
1067 } 1067 }
1068 1068
1069 void registerGetRuntimeTypeArgument(TreeElements elements) { 1069 void registerGetRuntimeTypeArgument(TreeElements elements) {
1070 enqueueInResolution(getGetRuntimeTypeArgument(), elements); 1070 enqueueInResolution(getGetRuntimeTypeArgument(), elements);
1071 } 1071 }
1072 1072
1073 void registerGenericClosure(Enqueuer enqueuer, TreeElements elements) {
1074 enqueue(enqueuer, getSetRuntimeTypeInfo(), elements);
1075 enqueue(enqueuer, getGetRuntimeTypeInfo(), elements);
1076 enqueue(enqueuer, getForwardRuntimeTypeInfo(), elements);
1077 enqueuer.registerInstantiatedClass(compiler.listClass, elements);
1078 }
1079
1073 void registerRuntimeType(TreeElements elements) { 1080 void registerRuntimeType(TreeElements elements) {
1074 enqueueInResolution(getSetRuntimeTypeInfo(), elements); 1081 enqueueInResolution(getSetRuntimeTypeInfo(), elements);
1075 enqueueInResolution(getGetRuntimeTypeInfo(), elements); 1082 enqueueInResolution(getGetRuntimeTypeInfo(), elements);
1076 enqueueInResolution(getGetRuntimeTypeArgument(), elements); 1083 enqueueInResolution(getGetRuntimeTypeArgument(), elements);
1077 compiler.enqueuer.resolution.registerInstantiatedClass( 1084 compiler.enqueuer.resolution.registerInstantiatedClass(
1078 compiler.listClass, elements); 1085 compiler.listClass, elements);
1079 } 1086 }
1080 1087
1081 void registerTypeVariableExpression(TreeElements elements) { 1088 void registerTypeVariableExpression(TreeElements elements) {
1082 registerRuntimeType(elements); 1089 registerRuntimeType(elements);
1083 enqueueInResolution(getRuntimeTypeToString(), elements); 1090 enqueueInResolution(getRuntimeTypeToString(), elements);
1084 enqueueInResolution(getCreateRuntimeType(), elements); 1091 enqueueInResolution(getCreateRuntimeType(), elements);
1085 } 1092 }
1086 1093
1087 void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) { 1094 void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) {
1095 if (type.isMalformed) {
1096 registerThrowRuntimeError(elements);
1097 return;
1098 }
1088 world.registerInstantiatedClass(compiler.boolClass, elements); 1099 world.registerInstantiatedClass(compiler.boolClass, elements);
1089 bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE; 1100 bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE;
1090 if (!type.isRaw || isTypeVariable) { 1101 if (!type.isRaw || type.containsTypeVariables) {
1091 enqueueInResolution(getSetRuntimeTypeInfo(), elements); 1102 enqueueInResolution(getSetRuntimeTypeInfo(), elements);
1092 enqueueInResolution(getGetRuntimeTypeInfo(), elements); 1103 enqueueInResolution(getGetRuntimeTypeInfo(), elements);
1093 enqueueInResolution(getGetRuntimeTypeArgument(), elements); 1104 enqueueInResolution(getGetRuntimeTypeArgument(), elements);
1094 enqueueInResolution(getCheckArguments(), elements); 1105 enqueueInResolution(getCheckArguments(), elements);
1095 if (isTypeVariable) { 1106 if (isTypeVariable) {
1096 enqueueInResolution(getGetObjectIsSubtype(), elements); 1107 enqueueInResolution(getGetObjectIsSubtype(), elements);
1097 } 1108 }
1098 world.registerInstantiatedClass(compiler.listClass, elements); 1109 world.registerInstantiatedClass(compiler.listClass, elements);
1099 } 1110 }
1111 if (type is FunctionType) {
1112 enqueueInResolution(getCheckFunctionSubtype(), elements);
1113 }
1100 // [registerIsCheck] is also called for checked mode checks, so we 1114 // [registerIsCheck] is also called for checked mode checks, so we
1101 // need to register checked mode helpers. 1115 // need to register checked mode helpers.
1102 if (compiler.enableTypeAssertions) { 1116 if (compiler.enableTypeAssertions) {
1103 Element e = getCheckedModeHelper(type, typeCast: false); 1117 Element e = getCheckedModeHelper(type, typeCast: false);
1104 if (e != null) world.addToWorkList(e); 1118 if (e != null) world.addToWorkList(e);
1105 // We also need the native variant of the check (for DOM types). 1119 // We also need the native variant of the check (for DOM types).
1106 e = getNativeCheckedModeHelper(type, typeCast: false); 1120 e = getNativeCheckedModeHelper(type, typeCast: false);
1107 if (e != null) world.addToWorkList(e); 1121 if (e != null) world.addToWorkList(e);
1108 } 1122 }
1109 if (type.element.isNative()) { 1123 if (type.element.isNative()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 1155
1142 void registerSuperNoSuchMethod(TreeElements elements) { 1156 void registerSuperNoSuchMethod(TreeElements elements) {
1143 enqueueInResolution(getCreateInvocationMirror(), elements); 1157 enqueueInResolution(getCreateInvocationMirror(), elements);
1144 enqueueInResolution( 1158 enqueueInResolution(
1145 compiler.objectClass.lookupLocalMember(Compiler.NO_SUCH_METHOD), 1159 compiler.objectClass.lookupLocalMember(Compiler.NO_SUCH_METHOD),
1146 elements); 1160 elements);
1147 compiler.enqueuer.resolution.registerInstantiatedClass( 1161 compiler.enqueuer.resolution.registerInstantiatedClass(
1148 compiler.listClass, elements); 1162 compiler.listClass, elements);
1149 } 1163 }
1150 1164
1165 void enqueue(Enqueuer enqueuer, Element e, TreeElements elements) {
1166 enqueuer.addToWorkList(e);
1167 elements.registerDependency(e);
1168 }
1169
1151 void enqueueInResolution(Element e, TreeElements elements) { 1170 void enqueueInResolution(Element e, TreeElements elements) {
1152 if (e == null) return; 1171 if (e == null) return;
1153 ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution; 1172 ResolutionEnqueuer enqueuer = compiler.enqueuer.resolution;
1154 enqueuer.addToWorkList(e); 1173 enqueue(enqueuer, e, elements);
1155 elements.registerDependency(e);
1156 } 1174 }
1157 1175
1158 void registerConstantMap(TreeElements elements) { 1176 void registerConstantMap(TreeElements elements) {
1159 Element e = compiler.findHelper(const SourceString('ConstantMap')); 1177 Element e = compiler.findHelper(const SourceString('ConstantMap'));
1160 if (e != null) { 1178 if (e != null) {
1161 compiler.enqueuer.resolution.registerInstantiatedClass(e, elements); 1179 compiler.enqueuer.resolution.registerInstantiatedClass(e, elements);
1162 } 1180 }
1163 e = compiler.findHelper(const SourceString('ConstantProtoMap')); 1181 e = compiler.findHelper(const SourceString('ConstantProtoMap'));
1164 if (e != null) { 1182 if (e != null) {
1165 compiler.enqueuer.resolution.registerInstantiatedClass(e, elements); 1183 compiler.enqueuer.resolution.registerInstantiatedClass(e, elements);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 } 1558 }
1541 1559
1542 Element getMapMaker() { 1560 Element getMapMaker() {
1543 return compiler.findHelper(const SourceString('makeLiteralMap')); 1561 return compiler.findHelper(const SourceString('makeLiteralMap'));
1544 } 1562 }
1545 1563
1546 Element getSetRuntimeTypeInfo() { 1564 Element getSetRuntimeTypeInfo() {
1547 return compiler.findHelper(const SourceString('setRuntimeTypeInfo')); 1565 return compiler.findHelper(const SourceString('setRuntimeTypeInfo'));
1548 } 1566 }
1549 1567
1568 Element getForwardRuntimeTypeInfo() {
1569 return compiler.findHelper(const SourceString('forwardRuntimeTypeInfo'));
1570 }
1571
1550 Element getGetRuntimeTypeInfo() { 1572 Element getGetRuntimeTypeInfo() {
1551 return compiler.findHelper(const SourceString('getRuntimeTypeInfo')); 1573 return compiler.findHelper(const SourceString('getRuntimeTypeInfo'));
1552 } 1574 }
1553 1575
1554 Element getGetRuntimeTypeArgument() { 1576 Element getGetRuntimeTypeArgument() {
1555 return compiler.findHelper(const SourceString('getRuntimeTypeArgument')); 1577 return compiler.findHelper(const SourceString('getRuntimeTypeArgument'));
1556 } 1578 }
1557 1579
1558 Element getRuntimeTypeToString() { 1580 Element getRuntimeTypeToString() {
1559 return compiler.findHelper(const SourceString('runtimeTypeToString')); 1581 return compiler.findHelper(const SourceString('runtimeTypeToString'));
1560 } 1582 }
1561 1583
1562 Element getCheckArguments() { 1584 Element getCheckArguments() {
1563 return compiler.findHelper(const SourceString('checkArguments')); 1585 return compiler.findHelper(const SourceString('checkArguments'));
1564 } 1586 }
1565 1587
1566 Element getGetObjectIsSubtype() { 1588 Element getGetObjectIsSubtype() {
1567 return compiler.findHelper(const SourceString('objectIsSubtype')); 1589 return compiler.findHelper(const SourceString('objectIsSubtype'));
1568 } 1590 }
1569 1591
1592 Element getCheckFunctionSubtype() {
1593 return compiler.findHelper(const SourceString('checkFunctionSubtype'));
1594 }
1595
1570 Element getThrowNoSuchMethod() { 1596 Element getThrowNoSuchMethod() {
1571 return compiler.findHelper(const SourceString('throwNoSuchMethod')); 1597 return compiler.findHelper(const SourceString('throwNoSuchMethod'));
1572 } 1598 }
1573 1599
1574 Element getCreateRuntimeType() { 1600 Element getCreateRuntimeType() {
1575 return compiler.findHelper(const SourceString('createRuntimeType')); 1601 return compiler.findHelper(const SourceString('createRuntimeType'));
1576 } 1602 }
1577 1603
1578 Element getFallThroughError() { 1604 Element getFallThroughError() {
1579 return compiler.findHelper(const SourceString("getFallThroughError")); 1605 return compiler.findHelper(const SourceString("getFallThroughError"));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 ClassElement get constListImplementation => jsArrayClass; 1638 ClassElement get constListImplementation => jsArrayClass;
1613 ClassElement get fixedListImplementation => jsFixedArrayClass; 1639 ClassElement get fixedListImplementation => jsFixedArrayClass;
1614 ClassElement get growableListImplementation => jsExtendableArrayClass; 1640 ClassElement get growableListImplementation => jsExtendableArrayClass;
1615 ClassElement get mapImplementation => mapLiteralClass; 1641 ClassElement get mapImplementation => mapLiteralClass;
1616 ClassElement get constMapImplementation => constMapLiteralClass; 1642 ClassElement get constMapImplementation => constMapLiteralClass;
1617 ClassElement get functionImplementation => jsFunctionClass; 1643 ClassElement get functionImplementation => jsFunctionClass;
1618 ClassElement get typeImplementation => typeLiteralClass; 1644 ClassElement get typeImplementation => typeLiteralClass;
1619 ClassElement get boolImplementation => jsBoolClass; 1645 ClassElement get boolImplementation => jsBoolClass;
1620 ClassElement get nullImplementation => jsNullClass; 1646 ClassElement get nullImplementation => jsNullClass;
1621 } 1647 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698