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

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

Issue 27524003: Generate tear-off closures dynamically. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r30954 Created 7 years 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 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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 } else if (cls == compiler.boundClosureClass) { 804 } else if (cls == compiler.boundClosureClass) {
805 // TODO(ngeoffray): Move the bound closure class in the 805 // TODO(ngeoffray): Move the bound closure class in the
806 // backend. 806 // backend.
807 enqueueClass(enqueuer, compiler.boundClosureClass, elements); 807 enqueueClass(enqueuer, compiler.boundClosureClass, elements);
808 } else if (Elements.isNativeOrExtendsNative(cls)) { 808 } else if (Elements.isNativeOrExtendsNative(cls)) {
809 enqueue(enqueuer, getNativeInterceptorMethod, elements); 809 enqueue(enqueuer, getNativeInterceptorMethod, elements);
810 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies); 810 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies);
811 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, elements); 811 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, elements);
812 } 812 }
813 } 813 }
814 if (cls == compiler.closureClass) {
815 enqueue(enqueuer,
816 compiler.findHelper('closureFromTearOff'),
817 elements);
818 }
814 ClassElement result = null; 819 ClassElement result = null;
815 if (cls == compiler.stringClass || cls == jsStringClass) { 820 if (cls == compiler.stringClass || cls == jsStringClass) {
816 addInterceptors(jsStringClass, enqueuer, elements); 821 addInterceptors(jsStringClass, enqueuer, elements);
817 } else if (cls == compiler.listClass 822 } else if (cls == compiler.listClass
818 || cls == jsArrayClass 823 || cls == jsArrayClass
819 || cls == jsFixedArrayClass 824 || cls == jsFixedArrayClass
820 || cls == jsExtendableArrayClass) { 825 || cls == jsExtendableArrayClass) {
821 addInterceptors(jsArrayClass, enqueuer, elements); 826 addInterceptors(jsArrayClass, enqueuer, elements);
822 addInterceptors(jsMutableArrayClass, enqueuer, elements); 827 addInterceptors(jsMutableArrayClass, enqueuer, elements);
823 addInterceptors(jsFixedArrayClass, enqueuer, elements); 828 addInterceptors(jsFixedArrayClass, enqueuer, elements);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 void registerTypeVariableExpression(TreeElements elements) { 989 void registerTypeVariableExpression(TreeElements elements) {
985 enqueueInResolution(getSetRuntimeTypeInfo(), elements); 990 enqueueInResolution(getSetRuntimeTypeInfo(), elements);
986 enqueueInResolution(getGetRuntimeTypeInfo(), elements); 991 enqueueInResolution(getGetRuntimeTypeInfo(), elements);
987 registerGetRuntimeTypeArgument(elements); 992 registerGetRuntimeTypeArgument(elements);
988 enqueueClass(compiler.enqueuer.resolution, compiler.listClass, elements); 993 enqueueClass(compiler.enqueuer.resolution, compiler.listClass, elements);
989 enqueueInResolution(getRuntimeTypeToString(), elements); 994 enqueueInResolution(getRuntimeTypeToString(), elements);
990 enqueueInResolution(getCreateRuntimeType(), elements); 995 enqueueInResolution(getCreateRuntimeType(), elements);
991 } 996 }
992 997
993 void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) { 998 void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) {
999 enqueueInResolution(getThrowRuntimeError(), elements);
994 type = type.unalias(compiler); 1000 type = type.unalias(compiler);
995 enqueueClass(world, compiler.boolClass, elements); 1001 enqueueClass(world, compiler.boolClass, elements);
996 bool inCheckedMode = compiler.enableTypeAssertions; 1002 bool inCheckedMode = compiler.enableTypeAssertions;
997 // [registerIsCheck] is also called for checked mode checks, so we 1003 // [registerIsCheck] is also called for checked mode checks, so we
998 // need to register checked mode helpers. 1004 // need to register checked mode helpers.
999 if (inCheckedMode) { 1005 if (inCheckedMode) {
1000 if (!world.isResolutionQueue) { 1006 if (!world.isResolutionQueue) {
1001 // All helpers are added to resolution queue in enqueueHelpers. These 1007 // All helpers are added to resolution queue in enqueueHelpers. These
1002 // calls to enqueueInResolution serve as assertions that the helper was 1008 // calls to enqueueInResolution serve as assertions that the helper was
1003 // in fact added. 1009 // in fact added.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 // We will neeed to add the "$is" and "$as" properties on the 1047 // We will neeed to add the "$is" and "$as" properties on the
1042 // JavaScript object prototype, so we make sure 1048 // JavaScript object prototype, so we make sure
1043 // [:defineProperty:] is compiled. 1049 // [:defineProperty:] is compiled.
1044 enqueue(world, 1050 enqueue(world,
1045 compiler.findHelper('defineProperty'), 1051 compiler.findHelper('defineProperty'),
1046 elements); 1052 elements);
1047 } 1053 }
1048 } 1054 }
1049 1055
1050 void registerAsCheck(DartType type, Enqueuer world, TreeElements elements) { 1056 void registerAsCheck(DartType type, Enqueuer world, TreeElements elements) {
1057 enqueueInResolution(getThrowRuntimeError(), elements);
1051 type = type.unalias(compiler); 1058 type = type.unalias(compiler);
1052 if (!world.isResolutionQueue) { 1059 if (!world.isResolutionQueue) {
1053 // All helpers are added to resolution queue in enqueueHelpers. These 1060 // All helpers are added to resolution queue in enqueueHelpers. These
1054 // calls to enqueueInResolution serve as assertions that the helper was in 1061 // calls to enqueueInResolution serve as assertions that the helper was in
1055 // fact added. 1062 // fact added.
1056 // TODO(13155): Find a way to enqueue helpers lazily. 1063 // TODO(13155): Find a way to enqueue helpers lazily.
1057 CheckedModeHelper helper = getCheckedModeHelper(type, typeCast: true); 1064 CheckedModeHelper helper = getCheckedModeHelper(type, typeCast: true);
1058 enqueueInResolution(helper.getElement(compiler), elements); 1065 enqueueInResolution(helper.getElement(compiler), elements);
1059 // We also need the native variant of the check (for DOM types). 1066 // We also need the native variant of the check (for DOM types).
1060 helper = getNativeCheckedModeHelper(type, typeCast: true); 1067 helper = getNativeCheckedModeHelper(type, typeCast: true);
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 /** 1736 /**
1730 * Returns `true` if [element] can be accessed through reflection, that is, 1737 * Returns `true` if [element] can be accessed through reflection, that is,
1731 * is in the set of elements covered by a `MirrorsUsed` annotation. 1738 * is in the set of elements covered by a `MirrorsUsed` annotation.
1732 * 1739 *
1733 * This property is used to tag emitted elements with a marker which is 1740 * This property is used to tag emitted elements with a marker which is
1734 * checked by the runtime system to throw an exception if an element is 1741 * checked by the runtime system to throw an exception if an element is
1735 * accessed (invoked, get, set) that is not accessible for the reflective 1742 * accessed (invoked, get, set) that is not accessible for the reflective
1736 * system. 1743 * system.
1737 */ 1744 */
1738 bool isAccessibleByReflection(Element element) { 1745 bool isAccessibleByReflection(Element element) {
1746 // TODO(ahe): This isn't sufficient: simply importing dart:mirrors
1747 // causes hasInsufficientMirrorsUsed to become true.
1739 if (hasInsufficientMirrorsUsed) return true; 1748 if (hasInsufficientMirrorsUsed) return true;
1740 return isNeededForReflection(element); 1749 return isNeededForReflection(element);
1741 } 1750 }
1742 1751
1743 /** 1752 /**
1744 * Returns `true` if the emitter must emit the element even though there 1753 * Returns `true` if the emitter must emit the element even though there
1745 * is no direct use in the program, but because the reflective system may 1754 * is no direct use in the program, but because the reflective system may
1746 * need to access it. 1755 * need to access it.
1747 */ 1756 */
1748 bool isNeededForReflection(Element element) { 1757 bool isNeededForReflection(Element element) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 copy(constant.values); 1968 copy(constant.values);
1960 copy(constant.protoValue); 1969 copy(constant.protoValue);
1961 copy(constant); 1970 copy(constant);
1962 } 1971 }
1963 1972
1964 void visitConstructed(ConstructedConstant constant) { 1973 void visitConstructed(ConstructedConstant constant) {
1965 copy(constant.fields); 1974 copy(constant.fields);
1966 copy(constant); 1975 copy(constant);
1967 } 1976 }
1968 } 1977 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698