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

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

Issue 16817002: Be smarter about when disabling tree-shaking. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 Element getInterceptorMethod; 69 Element getInterceptorMethod;
70 Element interceptedNames; 70 Element interceptedNames;
71 71
72 HType stringType; 72 HType stringType;
73 HType indexablePrimitiveType; 73 HType indexablePrimitiveType;
74 HType readableArrayType; 74 HType readableArrayType;
75 HType mutableArrayType; 75 HType mutableArrayType;
76 HType fixedArrayType; 76 HType fixedArrayType;
77 HType extendableArrayType; 77 HType extendableArrayType;
78
79 78
80 // TODO(9577): Make it so that these are not needed when there are no native 79 // TODO(9577): Make it so that these are not needed when there are no native
81 // classes. 80 // classes.
82 Element dispatchPropertyName; 81 Element dispatchPropertyName;
83 Element getNativeInterceptorMethod; 82 Element getNativeInterceptorMethod;
84 Element defineNativeMethodsFinishMethod; 83 Element defineNativeMethodsFinishMethod;
85 Element getDispatchPropertyMethod; 84 Element getDispatchPropertyMethod;
86 Element setDispatchPropertyMethod; 85 Element setDispatchPropertyMethod;
87 Element initializeDispatchPropertyMethod; 86 Element initializeDispatchPropertyMethod;
88 bool needToInitializeDispatchProperty = false; 87 bool needToInitializeDispatchProperty = false;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 * Set of classes whose `operator ==` methods handle `null` themselves. 148 * Set of classes whose `operator ==` methods handle `null` themselves.
150 */ 149 */
151 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>(); 150 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>();
152 151
153 List<CompilerTask> get tasks { 152 List<CompilerTask> get tasks {
154 return <CompilerTask>[builder, optimizer, generator, emitter]; 153 return <CompilerTask>[builder, optimizer, generator, emitter];
155 } 154 }
156 155
157 final RuntimeTypes rti; 156 final RuntimeTypes rti;
158 157
158 /// Holds the method "disableTreeShaking" in js_mirrors when
159 /// dart:mirrors has been loaded.
160 FunctionElement disableTreeShakingMarker;
161
162 /// Holds the method "preserveNames" in js_mirrors when
163 /// dart:mirrors has been loaded.
164 FunctionElement preserveNamesMarker;
165
159 JavaScriptBackend(Compiler compiler, bool generateSourceMap, bool disableEval) 166 JavaScriptBackend(Compiler compiler, bool generateSourceMap, bool disableEval)
160 : namer = determineNamer(compiler), 167 : namer = determineNamer(compiler),
161 usedInterceptors = new Set<Selector>(), 168 usedInterceptors = new Set<Selector>(),
162 oneShotInterceptors = new Map<String, Selector>(), 169 oneShotInterceptors = new Map<String, Selector>(),
163 interceptedElements = new Map<SourceString, Set<Element>>(), 170 interceptedElements = new Map<SourceString, Set<Element>>(),
164 rti = new RuntimeTypes(compiler), 171 rti = new RuntimeTypes(compiler),
165 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), 172 specializedGetInterceptors = new Map<String, Set<ClassElement>>(),
166 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) { 173 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) {
167 emitter = disableEval 174 emitter = disableEval
168 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap) 175 ? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap)
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 ClassElement get stringImplementation => jsStringClass; 1114 ClassElement get stringImplementation => jsStringClass;
1108 ClassElement get listImplementation => jsArrayClass; 1115 ClassElement get listImplementation => jsArrayClass;
1109 ClassElement get constListImplementation => jsArrayClass; 1116 ClassElement get constListImplementation => jsArrayClass;
1110 ClassElement get fixedListImplementation => jsFixedArrayClass; 1117 ClassElement get fixedListImplementation => jsFixedArrayClass;
1111 ClassElement get growableListImplementation => jsExtendableArrayClass; 1118 ClassElement get growableListImplementation => jsExtendableArrayClass;
1112 ClassElement get mapImplementation => mapLiteralClass; 1119 ClassElement get mapImplementation => mapLiteralClass;
1113 ClassElement get constMapImplementation => constMapLiteralClass; 1120 ClassElement get constMapImplementation => constMapLiteralClass;
1114 ClassElement get typeImplementation => typeLiteralClass; 1121 ClassElement get typeImplementation => typeLiteralClass;
1115 ClassElement get boolImplementation => jsBoolClass; 1122 ClassElement get boolImplementation => jsBoolClass;
1116 ClassElement get nullImplementation => jsNullClass; 1123 ClassElement get nullImplementation => jsNullClass;
1124
1125 void enableMirrors() {
1126 LibraryElement library = compiler.libraries['dart:_js_mirrors'];
1127 disableTreeShakingMarker =
1128 library.find(const SourceString('disableTreeShaking'));
1129 preserveNamesMarker =
1130 library.find(const SourceString('preserveNames'));
1131 }
1132
1133 void registerStaticUse(Element element, Enqueuer enqueuer) {
1134 if (element == disableTreeShakingMarker) {
1135 enqueuer.enqueueEverything();
1136 } else if (element == preserveNamesMarker) {
1137 }
Johnni Winther 2013/06/13 07:08:29 Something missing in this block?
ahe 2013/06/14 12:00:22 Yes. I'll fill in more stuff in future CLs.
1138 }
1117 } 1139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698