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

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

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

Powered by Google App Engine
This is Rietveld 408576698