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

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

Issue 1342213003: Add optional message to assert in Dart2js - continued (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add --assert-message flag 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 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 Element element = find(isolateHelperLibrary, name); 1352 Element element = find(isolateHelperLibrary, name);
1351 enqueuer.addToWorkList(element); 1353 enqueuer.addToWorkList(element);
1352 compiler.globalDependencies.registerDependency(element); 1354 compiler.globalDependencies.registerDependency(element);
1353 helpersUsed.add(element.declaration); 1355 helpersUsed.add(element.declaration);
1354 } 1356 }
1355 } else { 1357 } else {
1356 enqueuer.addToWorkList(find(isolateHelperLibrary, START_ROOT_ISOLATE)); 1358 enqueuer.addToWorkList(find(isolateHelperLibrary, START_ROOT_ISOLATE));
1357 } 1359 }
1358 } 1360 }
1359 1361
1360 bool isAssertMethod(Element element) => element == assertMethod;
1361
1362 void registerRequiredType(DartType type, Element enclosingElement) { 1362 void registerRequiredType(DartType type, Element enclosingElement) {
1363 // If [argument] has type variables or is a type variable, this method 1363 // If [argument] has type variables or is a type variable, this method
1364 // registers a RTI dependency between the class where the type variable is 1364 // registers a RTI dependency between the class where the type variable is
1365 // defined (that is the enclosing class of the current element being 1365 // defined (that is the enclosing class of the current element being
1366 // resolved) and the class of [type]. If the class of [type] requires RTI, 1366 // resolved) and the class of [type]. If the class of [type] requires RTI,
1367 // then the class of the type variable does too. 1367 // then the class of the type variable does too.
1368 ClassElement contextClass = Types.getClassContext(type); 1368 ClassElement contextClass = Types.getClassContext(type);
1369 if (contextClass != null) { 1369 if (contextClass != null) {
1370 assert(contextClass == enclosingElement.enclosingClass.declaration); 1370 assert(contextClass == enclosingElement.enclosingClass.declaration);
1371 rti.registerRtiDependency(type.element, contextClass); 1371 rti.registerRtiDependency(type.element, contextClass);
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 jsMutableArrayClass = findClass('JSMutableArray'); 2114 jsMutableArrayClass = findClass('JSMutableArray');
2115 jsFixedArrayClass = findClass('JSFixedArray'); 2115 jsFixedArrayClass = findClass('JSFixedArray');
2116 jsExtendableArrayClass = findClass('JSExtendableArray'); 2116 jsExtendableArrayClass = findClass('JSExtendableArray');
2117 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); 2117 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray');
2118 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); 2118 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject');
2119 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); 2119 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject');
2120 jsIndexableClass = findClass('JSIndexable'); 2120 jsIndexableClass = findClass('JSIndexable');
2121 jsMutableIndexableClass = findClass('JSMutableIndexable'); 2121 jsMutableIndexableClass = findClass('JSMutableIndexable');
2122 } else if (uri == DART_JS_HELPER) { 2122 } else if (uri == DART_JS_HELPER) {
2123 initializeHelperClasses(); 2123 initializeHelperClasses();
2124 assertMethod = findHelper('assertHelper'); 2124 assertTestMethod = findHelper('assertTest');
2125 assertThrowMethod = findHelper('assertThrow');
2126 assertHelperMethod = findHelper('assertHelper');
2125 2127
2126 typeLiteralClass = findClass('TypeImpl'); 2128 typeLiteralClass = findClass('TypeImpl');
2127 constMapLiteralClass = findClass('ConstantMap'); 2129 constMapLiteralClass = findClass('ConstantMap');
2128 typeVariableClass = findClass('TypeVariable'); 2130 typeVariableClass = findClass('TypeVariable');
2129 2131
2130 jsIndexingBehaviorInterface = findClass('JavaScriptIndexingBehavior'); 2132 jsIndexingBehaviorInterface = findClass('JavaScriptIndexingBehavior');
2131 2133
2132 noSideEffectsClass = findClass('NoSideEffects'); 2134 noSideEffectsClass = findClass('NoSideEffects');
2133 noThrowsClass = findClass('NoThrows'); 2135 noThrowsClass = findClass('NoThrows');
2134 noInlineClass = findClass('NoInline'); 2136 noInlineClass = findClass('NoInline');
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 void registerBackendStaticInvocation(Element element, Registry registry) { 2916 void registerBackendStaticInvocation(Element element, Registry registry) {
2915 registry.registerStaticInvocation(backend.registerBackendUse(element)); 2917 registry.registerStaticInvocation(backend.registerBackendUse(element));
2916 } 2918 }
2917 2919
2918 void registerBackendInstantiation(ClassElement element, Registry registry) { 2920 void registerBackendInstantiation(ClassElement element, Registry registry) {
2919 backend.registerBackendUse(element); 2921 backend.registerBackendUse(element);
2920 element.ensureResolved(backend.compiler); 2922 element.ensureResolved(backend.compiler);
2921 registry.registerInstantiation(element.rawType); 2923 registry.registerInstantiation(element.rawType);
2922 } 2924 }
2923 2925
2924 void onAssert(Send node, Registry registry) { 2926 void onAssert(bool hasMessage, Registry registry) {
2925 registerBackendStaticInvocation(backend.assertMethod, registry); 2927 if (hasMessage) {
2928 registerBackendStaticInvocation(backend.assertTestMethod, registry);
2929 registerBackendStaticInvocation(backend.assertThrowMethod, registry);
2930 } else {
2931 registerBackendStaticInvocation(backend.assertHelperMethod, registry);
2932 }
2926 } 2933 }
2927 2934
2928 void onAsyncForIn(AsyncForIn node, Registry registry) { 2935 void onAsyncForIn(AsyncForIn node, Registry registry) {
2929 registerBackendStaticInvocation(backend.getStreamIteratorConstructor(), 2936 registerBackendStaticInvocation(backend.getStreamIteratorConstructor(),
2930 registry); 2937 registry);
2931 } 2938 }
2932 2939
2933 void onStringInterpolation(Registry registry) { 2940 void onStringInterpolation(Registry registry) {
2934 assert(registry.isForResolution); 2941 assert(registry.isForResolution);
2935 registerBackendStaticInvocation( 2942 registerBackendStaticInvocation(
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
3163 } 3170 }
3164 } 3171 }
3165 3172
3166 /// Records that [constant] is used by the element behind [registry]. 3173 /// Records that [constant] is used by the element behind [registry].
3167 class Dependency { 3174 class Dependency {
3168 final ConstantValue constant; 3175 final ConstantValue constant;
3169 final Element annotatedElement; 3176 final Element annotatedElement;
3170 3177
3171 const Dependency(this.constant, this.annotatedElement); 3178 const Dependency(this.constant, this.annotatedElement);
3172 } 3179 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart ('k') | pkg/compiler/lib/src/parser/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698