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

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

Issue 912223003: Support @NoInlining in the ssa-builder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: move TODO Created 5 years, 10 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 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 const bool USE_CPS_IR = const bool.fromEnvironment("USE_CPS_IR"); 9 const bool USE_CPS_IR = const bool.fromEnvironment("USE_CPS_IR");
10 10
(...skipping 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 new CodegenRegistry(compiler, 2298 new CodegenRegistry(compiler,
2299 dependency.annotatedElement.analyzableElement.treeElements)); 2299 dependency.annotatedElement.analyzableElement.treeElements));
2300 } 2300 }
2301 metadataConstants.clear(); 2301 metadataConstants.clear();
2302 } 2302 }
2303 } 2303 }
2304 return true; 2304 return true;
2305 } 2305 }
2306 2306
2307 void onElementResolved(Element element, TreeElements elements) { 2307 void onElementResolved(Element element, TreeElements elements) {
2308 if (element.isFunction && annotations.noInline(element)) {
2309 inlineCache.markAsNonInlinable(element);
2310 }
2311
2308 LibraryElement library = element.library; 2312 LibraryElement library = element.library;
2309 if (!library.isPlatformLibrary && !library.canUseNative) return; 2313 if (!library.isPlatformLibrary && !library.canUseNative) return;
2310 bool hasNoInline = false; 2314 bool hasNoInline = false;
2311 bool hasNoThrows = false; 2315 bool hasNoThrows = false;
2312 bool hasNoSideEffects = false; 2316 bool hasNoSideEffects = false;
2313 for (MetadataAnnotation metadata in element.metadata) { 2317 for (MetadataAnnotation metadata in element.metadata) {
2314 metadata.ensureResolved(compiler); 2318 metadata.ensureResolved(compiler);
2315 if (!metadata.constant.value.isConstructedObject) continue; 2319 if (!metadata.constant.value.isConstructedObject) continue;
2316 ObjectConstantValue value = metadata.constant.value; 2320 ObjectConstantValue value = metadata.constant.value;
2317 ClassElement cls = value.type.element; 2321 ClassElement cls = value.type.element;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 enqueue(enqueuer, getStreamIteratorConstructor(), registry); 2427 enqueue(enqueuer, getStreamIteratorConstructor(), registry);
2424 } 2428 }
2425 } 2429 }
2426 } 2430 }
2427 2431
2428 /// Handling of special annotations for tests. 2432 /// Handling of special annotations for tests.
2429 class Annotations { 2433 class Annotations {
2430 static final Uri PACKAGE_EXPECT = 2434 static final Uri PACKAGE_EXPECT =
2431 new Uri(scheme: 'package', path: 'expect/expect.dart'); 2435 new Uri(scheme: 'package', path: 'expect/expect.dart');
2432 2436
2433 ClassElement expectNoInliningClass; 2437 ClassElement expectNoInlineClass;
2434 ClassElement expectTrustTypeAnnotationsClass; 2438 ClassElement expectTrustTypeAnnotationsClass;
2435 ClassElement expectAssumeDynamicClass; 2439 ClassElement expectAssumeDynamicClass;
2436 2440
2437 void onLibraryScanned(LibraryElement library) { 2441 void onLibraryScanned(LibraryElement library) {
2438 if (library.canonicalUri == PACKAGE_EXPECT) { 2442 if (library.canonicalUri == PACKAGE_EXPECT) {
2439 expectNoInliningClass = library.find('NoInlining'); 2443 expectNoInlineClass = library.find('NoInline');
2440 expectTrustTypeAnnotationsClass = library.find('TrustTypeAnnotations'); 2444 expectTrustTypeAnnotationsClass = library.find('TrustTypeAnnotations');
2441 expectAssumeDynamicClass = library.find('AssumeDynamic'); 2445 expectAssumeDynamicClass = library.find('AssumeDynamic');
2442 if (expectNoInliningClass == null || 2446 if (expectNoInlineClass == null ||
2443 expectTrustTypeAnnotationsClass == null || 2447 expectTrustTypeAnnotationsClass == null ||
2444 expectAssumeDynamicClass == null) { 2448 expectAssumeDynamicClass == null) {
2445 // This is not the package you're looking for. 2449 // This is not the package you're looking for.
2446 expectNoInliningClass = null; 2450 expectNoInlineClass = null;
2447 expectTrustTypeAnnotationsClass = null; 2451 expectTrustTypeAnnotationsClass = null;
2448 expectAssumeDynamicClass = null; 2452 expectAssumeDynamicClass = null;
2449 } 2453 }
2450 } 2454 }
2451 } 2455 }
2452 2456
2453 /// Returns `true` if inlining is disabled for [element]. 2457 /// Returns `true` if inlining is disabled for [element].
2454 bool noInlining(Element element) { 2458 bool noInline(Element element) {
2455 return _hasAnnotation(element, expectNoInliningClass); 2459 // TODO(floitsch): restrict to test directory.
2460 return _hasAnnotation(element, expectNoInlineClass);
2456 } 2461 }
2457 2462
2458 /// Returns `true` if parameter and returns types should be trusted for 2463 /// Returns `true` if parameter and returns types should be trusted for
2459 /// [element]. 2464 /// [element].
2460 bool trustTypeAnnotations(Element element) { 2465 bool trustTypeAnnotations(Element element) {
2461 return _hasAnnotation(element, expectTrustTypeAnnotationsClass); 2466 return _hasAnnotation(element, expectTrustTypeAnnotationsClass);
2462 } 2467 }
2463 2468
2464 /// Returns `true` if inference of parameter types is disabled for [element]. 2469 /// Returns `true` if inference of parameter types is disabled for [element].
2465 bool assumeDynamic(Element element) { 2470 bool assumeDynamic(Element element) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 } 2686 }
2682 } 2687 }
2683 2688
2684 /// Records that [constant] is used by the element behind [registry]. 2689 /// Records that [constant] is used by the element behind [registry].
2685 class Dependency { 2690 class Dependency {
2686 final ConstantValue constant; 2691 final ConstantValue constant;
2687 final Element annotatedElement; 2692 final Element annotatedElement;
2688 2693
2689 const Dependency(this.constant, this.annotatedElement); 2694 const Dependency(this.constant, this.annotatedElement);
2690 } 2695 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/builder.dart » ('j') | tests/compiler/dart2js/expect_annotations2_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698