OLD | NEW |
---|---|
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 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 7 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
8 final Set<HInstruction> boundsChecked; | 8 final Set<HInstruction> boundsChecked; |
9 | 9 |
10 JavaScriptItemCompilationContext() | 10 JavaScriptItemCompilationContext() |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 Set<ClassElement> classes = getInterceptedClassesOn(selector.name); | 470 Set<ClassElement> classes = getInterceptedClassesOn(selector.name); |
471 String name = namer.getOneShotInterceptorName(selector, classes); | 471 String name = namer.getOneShotInterceptorName(selector, classes); |
472 if (!oneShotInterceptors.containsKey(name)) { | 472 if (!oneShotInterceptors.containsKey(name)) { |
473 registerSpecializedGetInterceptor(classes); | 473 registerSpecializedGetInterceptor(classes); |
474 oneShotInterceptors[name] = selector; | 474 oneShotInterceptors[name] = selector; |
475 } | 475 } |
476 return name; | 476 return name; |
477 } | 477 } |
478 | 478 |
479 bool isInterceptedMethod(Element element) { | 479 bool isInterceptedMethod(Element element) { |
480 return element.isInstanceMember() | 480 if (!element.isInstanceMember()) return false; |
481 && !element.isGenerativeConstructorBody() | 481 if (element.isGenerativeConstructorBody()) { |
482 && interceptedElements[element.name] != null; | 482 return Elements.isNativeOrExtendsNative(element.getEnclosingClass()); |
483 } | |
484 return interceptedElements[element.name] != null; | |
483 } | 485 } |
484 | 486 |
485 bool fieldHasInterceptedGetter(Element element) { | 487 bool fieldHasInterceptedGetter(Element element) { |
486 assert(element.isField()); | 488 assert(element.isField()); |
487 return interceptedElements[element.name] != null; | 489 return interceptedElements[element.name] != null; |
488 } | 490 } |
489 | 491 |
490 bool fieldHasInterceptedSetter(Element element) { | 492 bool fieldHasInterceptedSetter(Element element) { |
491 assert(element.isField()); | 493 assert(element.isField()); |
492 return interceptedElements[element.name] != null; | 494 return interceptedElements[element.name] != null; |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
945 Enqueuer enqueuer, | 947 Enqueuer enqueuer, |
946 TreeElements elements) { | 948 TreeElements elements) { |
947 enqueuer.registerInstantiatedClass(typeImplementation, elements); | 949 enqueuer.registerInstantiatedClass(typeImplementation, elements); |
948 enqueueInResolution(getCreateRuntimeType(), elements); | 950 enqueueInResolution(getCreateRuntimeType(), elements); |
949 // TODO(ahe): Might want to register [element] as an instantiated class | 951 // TODO(ahe): Might want to register [element] as an instantiated class |
950 // when reflection is used. However, as long as we disable tree-shaking | 952 // when reflection is used. However, as long as we disable tree-shaking |
951 // eagerly it doesn't matter. | 953 // eagerly it doesn't matter. |
952 if (element.isTypedef()) { | 954 if (element.isTypedef()) { |
953 typedefTypeLiterals.add(element); | 955 typedefTypeLiterals.add(element); |
954 } | 956 } |
957 registerEscapingConstructorsOfClass(element, enqueuer); | |
955 } | 958 } |
956 | 959 |
960 | |
961 void registerEscapingConstructorsOfClass(ClassElement classElement, | |
962 Enqueuer enqueuer) { | |
963 // Web component classes have constructors that are escaped to the host | |
964 // environment. | |
965 classElement.ensureResolved(compiler); | |
kasperl
2013/10/04 11:08:43
You may want to consider if you can avoid the stat
sra1
2013/10/04 20:21:28
I'll TODO it for now.
It would be nice if there w
| |
966 if (Elements.isNativeOrExtendsNative(classElement)) { | |
kasperl
2013/10/04 11:08:43
I guess we are sure that we're only calling Elemen
sra1
2013/10/04 20:21:28
Added assertion in isNativeOrExtendsNative.
| |
967 classElement.forEachMember( | |
968 (ClassElement enclosingClass, Element member) { | |
kasperl
2013/10/04 11:08:43
Maybe this would be more readable if you introduce
sra1
2013/10/04 20:21:28
Done.
| |
969 if (member.isGenerativeConstructor()) { | |
970 enqueuer.registerStaticUse(member); | |
971 } | |
972 }, | |
973 includeBackendMembers: false, | |
974 includeSuperAndInjectedMembers: false); | |
975 } | |
976 } | |
977 | |
978 | |
979 | |
957 void registerStackTraceInCatch(TreeElements elements) { | 980 void registerStackTraceInCatch(TreeElements elements) { |
958 enqueueInResolution(getTraceFromException(), elements); | 981 enqueueInResolution(getTraceFromException(), elements); |
959 } | 982 } |
960 | 983 |
961 void registerSetRuntimeType(TreeElements elements) { | 984 void registerSetRuntimeType(TreeElements elements) { |
962 enqueueInResolution(getSetRuntimeTypeInfo(), elements); | 985 enqueueInResolution(getSetRuntimeTypeInfo(), elements); |
963 } | 986 } |
964 | 987 |
965 void registerGetRuntimeTypeArgument(TreeElements elements) { | 988 void registerGetRuntimeTypeArgument(TreeElements elements) { |
966 enqueueInResolution(getGetRuntimeTypeArgument(), elements); | 989 enqueueInResolution(getGetRuntimeTypeArgument(), elements); |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1858 copy(constant.values); | 1881 copy(constant.values); |
1859 copy(constant.protoValue); | 1882 copy(constant.protoValue); |
1860 copy(constant); | 1883 copy(constant); |
1861 } | 1884 } |
1862 | 1885 |
1863 void visitConstructed(ConstructedConstant constant) { | 1886 void visitConstructed(ConstructedConstant constant) { |
1864 copy(constant.fields); | 1887 copy(constant.fields); |
1865 copy(constant); | 1888 copy(constant); |
1866 } | 1889 } |
1867 } | 1890 } |
OLD | NEW |