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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1325843003: Add optional message to assert in Dart2js. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Reintroduce assertHelper for asserts without messages. Created 5 years, 3 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
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 FunctionInlineCache inlineCache = new FunctionInlineCache(); 271 FunctionInlineCache inlineCache = new FunctionInlineCache();
272 272
273 LibraryElement jsHelperLibrary; 273 LibraryElement jsHelperLibrary;
274 LibraryElement asyncLibrary; 274 LibraryElement asyncLibrary;
275 LibraryElement interceptorsLibrary; 275 LibraryElement interceptorsLibrary;
276 LibraryElement foreignLibrary; 276 LibraryElement foreignLibrary;
277 LibraryElement isolateHelperLibrary; 277 LibraryElement isolateHelperLibrary;
278 278
279 ClassElement closureClass; 279 ClassElement closureClass;
280 ClassElement boundClosureClass; 280 ClassElement boundClosureClass;
281 Element assertMethod; 281 Element assertTestMethod;
282 Element assertThrowMethod;
283 Element assertHelperMethod;
282 Element invokeOnMethod; 284 Element invokeOnMethod;
283 285
284 ClassElement jsInterceptorClass; 286 ClassElement jsInterceptorClass;
285 ClassElement jsStringClass; 287 ClassElement jsStringClass;
286 ClassElement jsArrayClass; 288 ClassElement jsArrayClass;
287 ClassElement jsNumberClass; 289 ClassElement jsNumberClass;
288 ClassElement jsIntClass; 290 ClassElement jsIntClass;
289 ClassElement jsDoubleClass; 291 ClassElement jsDoubleClass;
290 ClassElement jsNullClass; 292 ClassElement jsNullClass;
291 ClassElement jsBoolClass; 293 ClassElement jsBoolClass;
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 Element element = find(isolateHelperLibrary, name); 1349 Element element = find(isolateHelperLibrary, name);
1348 enqueuer.addToWorkList(element); 1350 enqueuer.addToWorkList(element);
1349 compiler.globalDependencies.registerDependency(element); 1351 compiler.globalDependencies.registerDependency(element);
1350 helpersUsed.add(element.declaration); 1352 helpersUsed.add(element.declaration);
1351 } 1353 }
1352 } else { 1354 } else {
1353 enqueuer.addToWorkList(find(isolateHelperLibrary, START_ROOT_ISOLATE)); 1355 enqueuer.addToWorkList(find(isolateHelperLibrary, START_ROOT_ISOLATE));
1354 } 1356 }
1355 } 1357 }
1356 1358
1357 bool isAssertMethod(Element element) => element == assertMethod;
1358
1359 void registerRequiredType(DartType type, Element enclosingElement) { 1359 void registerRequiredType(DartType type, Element enclosingElement) {
1360 // If [argument] has type variables or is a type variable, this method 1360 // If [argument] has type variables or is a type variable, this method
1361 // registers a RTI dependency between the class where the type variable is 1361 // registers a RTI dependency between the class where the type variable is
1362 // defined (that is the enclosing class of the current element being 1362 // defined (that is the enclosing class of the current element being
1363 // resolved) and the class of [type]. If the class of [type] requires RTI, 1363 // resolved) and the class of [type]. If the class of [type] requires RTI,
1364 // then the class of the type variable does too. 1364 // then the class of the type variable does too.
1365 ClassElement contextClass = Types.getClassContext(type); 1365 ClassElement contextClass = Types.getClassContext(type);
1366 if (contextClass != null) { 1366 if (contextClass != null) {
1367 assert(contextClass == enclosingElement.enclosingClass.declaration); 1367 assert(contextClass == enclosingElement.enclosingClass.declaration);
1368 rti.registerRtiDependency(type.element, contextClass); 1368 rti.registerRtiDependency(type.element, contextClass);
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 jsMutableArrayClass = findClass('JSMutableArray'); 2122 jsMutableArrayClass = findClass('JSMutableArray');
2123 jsFixedArrayClass = findClass('JSFixedArray'); 2123 jsFixedArrayClass = findClass('JSFixedArray');
2124 jsExtendableArrayClass = findClass('JSExtendableArray'); 2124 jsExtendableArrayClass = findClass('JSExtendableArray');
2125 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); 2125 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray');
2126 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); 2126 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject');
2127 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); 2127 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject');
2128 jsIndexableClass = findClass('JSIndexable'); 2128 jsIndexableClass = findClass('JSIndexable');
2129 jsMutableIndexableClass = findClass('JSMutableIndexable'); 2129 jsMutableIndexableClass = findClass('JSMutableIndexable');
2130 } else if (uri == DART_JS_HELPER) { 2130 } else if (uri == DART_JS_HELPER) {
2131 initializeHelperClasses(); 2131 initializeHelperClasses();
2132 assertMethod = findHelper('assertHelper'); 2132 assertTestMethod = findHelper('assertTest');
2133 assertThrowMethod = findHelper('assertThrow');
2134 assertHelperMethod = findHelper('assertHelper');
2133 2135
2134 typeLiteralClass = findClass('TypeImpl'); 2136 typeLiteralClass = findClass('TypeImpl');
2135 constMapLiteralClass = findClass('ConstantMap'); 2137 constMapLiteralClass = findClass('ConstantMap');
2136 typeVariableClass = findClass('TypeVariable'); 2138 typeVariableClass = findClass('TypeVariable');
2137 2139
2138 jsIndexingBehaviorInterface = findClass('JavaScriptIndexingBehavior'); 2140 jsIndexingBehaviorInterface = findClass('JavaScriptIndexingBehavior');
2139 2141
2140 noSideEffectsClass = findClass('NoSideEffects'); 2142 noSideEffectsClass = findClass('NoSideEffects');
2141 noThrowsClass = findClass('NoThrows'); 2143 noThrowsClass = findClass('NoThrows');
2142 noInlineClass = findClass('NoInline'); 2144 noInlineClass = findClass('NoInline');
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 void registerBackendStaticInvocation(Element element, Registry registry) { 2921 void registerBackendStaticInvocation(Element element, Registry registry) {
2920 registry.registerStaticInvocation(backend.registerBackendUse(element)); 2922 registry.registerStaticInvocation(backend.registerBackendUse(element));
2921 } 2923 }
2922 2924
2923 void registerBackendInstantiation(ClassElement element, Registry registry) { 2925 void registerBackendInstantiation(ClassElement element, Registry registry) {
2924 backend.registerBackendUse(element); 2926 backend.registerBackendUse(element);
2925 element.ensureResolved(backend.compiler); 2927 element.ensureResolved(backend.compiler);
2926 registry.registerInstantiation(element.rawType); 2928 registry.registerInstantiation(element.rawType);
2927 } 2929 }
2928 2930
2929 void onAssert(Send node, Registry registry) { 2931 void onAssert(bool hasMessage, Registry registry) {
2930 registerBackendStaticInvocation(backend.assertMethod, registry); 2932 if (hasMessage) {
2933 registerBackendStaticInvocation(backend.assertTestMethod, registry);
2934 registerBackendStaticInvocation(backend.assertThrowMethod, registry);
2935 } else {
2936 registerBackendStaticInvocation(backend.assertHelperMethod, registry);
2937 }
2931 } 2938 }
2932 2939
2933 void onAsyncForIn(AsyncForIn node, Registry registry) { 2940 void onAsyncForIn(AsyncForIn node, Registry registry) {
2934 registerBackendStaticInvocation(backend.getStreamIteratorConstructor(), 2941 registerBackendStaticInvocation(backend.getStreamIteratorConstructor(),
2935 registry); 2942 registry);
2936 } 2943 }
2937 2944
2938 void onStringInterpolation(Registry registry) { 2945 void onStringInterpolation(Registry registry) {
2939 assert(registry.isForResolution); 2946 assert(registry.isForResolution);
2940 registerBackendStaticInvocation( 2947 registerBackendStaticInvocation(
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3135 } 3142 }
3136 } 3143 }
3137 3144
3138 /// Records that [constant] is used by the element behind [registry]. 3145 /// Records that [constant] is used by the element behind [registry].
3139 class Dependency { 3146 class Dependency {
3140 final ConstantValue constant; 3147 final ConstantValue constant;
3141 final Element annotatedElement; 3148 final Element annotatedElement;
3142 3149
3143 const Dependency(this.constant, this.annotatedElement); 3150 const Dependency(this.constant, this.annotatedElement);
3144 } 3151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698