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

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

Issue 236313012: Don't hide interceptors in mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 7 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
« no previous file with comments | « pkg/pkg.status ('k') | sdk/lib/_internal/compiler/implementation/js_backend/namer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { 9 class JavaScriptItemCompilationContext extends ItemCompilationContext {
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 551
552 jsIndexingBehaviorInterface = 552 jsIndexingBehaviorInterface =
553 compiler.findHelper('JavaScriptIndexingBehavior'); 553 compiler.findHelper('JavaScriptIndexingBehavior');
554 554
555 specialOperatorEqClasses 555 specialOperatorEqClasses
556 ..add(compiler.objectClass) 556 ..add(compiler.objectClass)
557 ..add(jsInterceptorClass) 557 ..add(jsInterceptorClass)
558 ..add(jsNullClass); 558 ..add(jsNullClass);
559 559
560 validateInterceptorImplementsAllObjectMethods(jsInterceptorClass); 560 validateInterceptorImplementsAllObjectMethods(jsInterceptorClass);
561 // The null-interceptor must also implement *all* methods.
562 validateInterceptorImplementsAllObjectMethods(jsNullClass);
561 563
562 typeVariableClass = compiler.findHelper('TypeVariable'); 564 typeVariableClass = compiler.findHelper('TypeVariable');
563 565
564 indexablePrimitiveType = new TypeMask.nonNullSubtype(jsIndexableClass); 566 indexablePrimitiveType = new TypeMask.nonNullSubtype(jsIndexableClass);
565 readableArrayType = new TypeMask.nonNullSubclass(jsArrayClass); 567 readableArrayType = new TypeMask.nonNullSubclass(jsArrayClass);
566 mutableArrayType = new TypeMask.nonNullSubclass(jsMutableArrayClass); 568 mutableArrayType = new TypeMask.nonNullSubclass(jsMutableArrayClass);
567 fixedArrayType = new TypeMask.nonNullExact(jsFixedArrayClass); 569 fixedArrayType = new TypeMask.nonNullExact(jsFixedArrayClass);
568 extendableArrayType = new TypeMask.nonNullExact(jsExtendableArrayClass); 570 extendableArrayType = new TypeMask.nonNullExact(jsExtendableArrayClass);
569 nonNullType = compiler.typesTask.dynamicType.nonNullable(); 571 nonNullType = compiler.typesTask.dynamicType.nonNullable();
570 572
571 noSideEffectsClass = compiler.findHelper('NoSideEffects'); 573 noSideEffectsClass = compiler.findHelper('NoSideEffects');
572 noThrowsClass = compiler.findHelper('NoThrows'); 574 noThrowsClass = compiler.findHelper('NoThrows');
573 noInlineClass = compiler.findHelper('NoInline'); 575 noInlineClass = compiler.findHelper('NoInline');
574 irRepresentationClass = compiler.findHelper('IrRepresentation'); 576 irRepresentationClass = compiler.findHelper('IrRepresentation');
575 } 577 }
576 578
577 void validateInterceptorImplementsAllObjectMethods( 579 void validateInterceptorImplementsAllObjectMethods(
578 ClassElement interceptorClass) { 580 ClassElement interceptorClass) {
579 if (interceptorClass == null) return; 581 if (interceptorClass == null) return;
580 interceptorClass.ensureResolved(compiler); 582 interceptorClass.ensureResolved(compiler);
581 compiler.objectClass.forEachMember((_, Element member) { 583 compiler.objectClass.forEachMember((_, Element member) {
582 if (member.isGenerativeConstructor()) return; 584 if (member.isGenerativeConstructor()) return;
583 Element interceptorMember = interceptorClass.lookupMember(member.name); 585 Element interceptorMember = interceptorClass.lookupMember(member.name);
584 // Interceptors must override all Object methods due to calling convention 586 // Interceptors must override all Object methods due to calling convention
585 // differences. 587 // differences.
586 assert(interceptorMember.getEnclosingClass() != compiler.objectClass); 588 assert(interceptorMember.getEnclosingClass() == interceptorClass);
587 }); 589 });
588 } 590 }
589 591
590 void addInterceptorsForNativeClassMembers( 592 void addInterceptorsForNativeClassMembers(
591 ClassElement cls, Enqueuer enqueuer) { 593 ClassElement cls, Enqueuer enqueuer) {
592 if (enqueuer.isResolutionQueue) { 594 if (enqueuer.isResolutionQueue) {
593 cls.ensureResolved(compiler); 595 cls.ensureResolved(compiler);
594 cls.forEachMember((ClassElement classElement, Element member) { 596 cls.forEachMember((ClassElement classElement, Element member) {
595 if (member.name == Compiler.CALL_OPERATOR_NAME) { 597 if (member.name == Compiler.CALL_OPERATOR_NAME) {
596 compiler.reportError( 598 compiler.reportError(
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 1105
1104 bool classNeedsRti(ClassElement cls) { 1106 bool classNeedsRti(ClassElement cls) {
1105 return rti.classesNeedingRti.contains(cls.declaration) || 1107 return rti.classesNeedingRti.contains(cls.declaration) ||
1106 compiler.enabledRuntimeType; 1108 compiler.enabledRuntimeType;
1107 } 1109 }
1108 1110
1109 bool isDefaultNoSuchMethodImplementation(Element element) { 1111 bool isDefaultNoSuchMethodImplementation(Element element) {
1110 assert(element.name == Compiler.NO_SUCH_METHOD); 1112 assert(element.name == Compiler.NO_SUCH_METHOD);
1111 ClassElement classElement = element.getEnclosingClass(); 1113 ClassElement classElement = element.getEnclosingClass();
1112 return classElement == compiler.objectClass 1114 return classElement == compiler.objectClass
1113 || classElement == jsInterceptorClass; 1115 || classElement == jsInterceptorClass
1116 || classElement == jsNullClass;
1114 } 1117 }
1115 1118
1116 bool isDefaultEqualityImplementation(Element element) { 1119 bool isDefaultEqualityImplementation(Element element) {
1117 assert(element.name == '=='); 1120 assert(element.name == '==');
1118 ClassElement classElement = element.getEnclosingClass(); 1121 ClassElement classElement = element.getEnclosingClass();
1119 return classElement == compiler.objectClass 1122 return classElement == compiler.objectClass
1120 || classElement == jsInterceptorClass 1123 || classElement == jsInterceptorClass
1121 || classElement == jsNullClass; 1124 || classElement == jsNullClass;
1122 } 1125 }
1123 1126
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 1260
1258 Element getDartClass(Element element) { 1261 Element getDartClass(Element element) {
1259 for (ClassElement dartClass in implementationClasses.keys) { 1262 for (ClassElement dartClass in implementationClasses.keys) {
1260 if (element == implementationClasses[dartClass]) { 1263 if (element == implementationClasses[dartClass]) {
1261 return dartClass; 1264 return dartClass;
1262 } 1265 }
1263 } 1266 }
1264 return element; 1267 return element;
1265 } 1268 }
1266 1269
1267 Element getImplementationClass(Element element) {
1268 for (ClassElement dartClass in implementationClasses.keys) {
1269 if (element == dartClass) {
1270 return implementationClasses[dartClass];
1271 }
1272 }
1273 return element;
1274 }
1275
1276 /** 1270 /**
1277 * Returns the checked mode helper that will be needed to do a type check/type 1271 * Returns the checked mode helper that will be needed to do a type check/type
1278 * cast on [type] at runtime. Note that this method is being called both by 1272 * cast on [type] at runtime. Note that this method is being called both by
1279 * the resolver with interface types (int, String, ...), and by the SSA 1273 * the resolver with interface types (int, String, ...), and by the SSA
1280 * backend with implementation types (JSInt, JSString, ...). 1274 * backend with implementation types (JSInt, JSString, ...).
1281 */ 1275 */
1282 CheckedModeHelper getCheckedModeHelper(DartType type, {bool typeCast}) { 1276 CheckedModeHelper getCheckedModeHelper(DartType type, {bool typeCast}) {
1283 return getCheckedModeHelperInternal( 1277 return getCheckedModeHelperInternal(
1284 type, typeCast: typeCast, nativeCheckOnly: false); 1278 type, typeCast: typeCast, nativeCheckOnly: false);
1285 } 1279 }
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 } 1908 }
1915 } 1909 }
1916 1910
1917 /// Records that [constant] is used by [user.element]. 1911 /// Records that [constant] is used by [user.element].
1918 class Dependency { 1912 class Dependency {
1919 final Constant constant; 1913 final Constant constant;
1920 final TreeElements user; 1914 final TreeElements user;
1921 1915
1922 const Dependency(this.constant, this.user); 1916 const Dependency(this.constant, this.user);
1923 } 1917 }
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | sdk/lib/_internal/compiler/implementation/js_backend/namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698