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

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

Issue 987393002: Support @NoInline for constructor bodies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments Created 5 years, 9 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 30 matching lines...) Expand all
41 41
42 final Map<FunctionElement, int> _cachedDecisions = 42 final Map<FunctionElement, int> _cachedDecisions =
43 new Map<FunctionElement, int>(); 43 new Map<FunctionElement, int>();
44 44
45 // Returns `true`/`false` if we have a cached decision. 45 // Returns `true`/`false` if we have a cached decision.
46 // Returns `null` otherwise. 46 // Returns `null` otherwise.
47 bool canInline(FunctionElement element, {bool insideLoop}) { 47 bool canInline(FunctionElement element, {bool insideLoop}) {
48 int decision = _cachedDecisions[element]; 48 int decision = _cachedDecisions[element];
49 49
50 if (decision == null) { 50 if (decision == null) {
51 decision = _unknown; 51 // These synthetic elements are not yet present when we initially compute
52 // this cache from metadata annotations, so look for their parent.
53 if (element is ConstructorBodyElement) {
54 ConstructorBodyElement body = element;
55 decision = _cachedDecisions[body.constructor];
56 }
57 if (decision == null) {
58 decision = _unknown;
59 }
52 } 60 }
53 61
54 if (insideLoop) { 62 if (insideLoop) {
55 switch (decision) { 63 switch (decision) {
56 case _mustNotInline: 64 case _mustNotInline:
57 return false; 65 return false;
58 66
59 case _unknown: 67 case _unknown:
60 case _mayInlineInLoopMustNotOutside: 68 case _mayInlineInLoopMustNotOutside:
61 // We know we can't inline outside a loop, but don't know for the 69 // We know we can't inline outside a loop, but don't know for the
(...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 new CodegenRegistry(compiler, 2434 new CodegenRegistry(compiler,
2427 dependency.annotatedElement.analyzableElement.treeElements)); 2435 dependency.annotatedElement.analyzableElement.treeElements));
2428 } 2436 }
2429 metadataConstants.clear(); 2437 metadataConstants.clear();
2430 } 2438 }
2431 } 2439 }
2432 return true; 2440 return true;
2433 } 2441 }
2434 2442
2435 void onElementResolved(Element element, TreeElements elements) { 2443 void onElementResolved(Element element, TreeElements elements) {
2436 if (element.isFunction && annotations.noInline(element)) { 2444 if ((element.isFunction || element.isGenerativeConstructor) &&
2445 annotations.noInline(element)) {
2437 inlineCache.markAsNonInlinable(element); 2446 inlineCache.markAsNonInlinable(element);
2438 } 2447 }
2439 2448
2440 LibraryElement library = element.library; 2449 LibraryElement library = element.library;
2441 if (!library.isPlatformLibrary && !library.canUseNative) return; 2450 if (!library.isPlatformLibrary && !library.canUseNative) return;
2442 bool hasNoInline = false; 2451 bool hasNoInline = false;
2443 bool hasForceInline = false; 2452 bool hasForceInline = false;
2444 bool hasNoThrows = false; 2453 bool hasNoThrows = false;
2445 bool hasNoSideEffects = false; 2454 bool hasNoSideEffects = false;
2446 for (MetadataAnnotation metadata in element.metadata) { 2455 for (MetadataAnnotation metadata in element.metadata) {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 } 2843 }
2835 } 2844 }
2836 2845
2837 /// Records that [constant] is used by the element behind [registry]. 2846 /// Records that [constant] is used by the element behind [registry].
2838 class Dependency { 2847 class Dependency {
2839 final ConstantValue constant; 2848 final ConstantValue constant;
2840 final Element annotatedElement; 2849 final Element annotatedElement;
2841 2850
2842 const Dependency(this.constant, this.annotatedElement); 2851 const Dependency(this.constant, this.annotatedElement);
2843 } 2852 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | tests/compiler/dart2js/expect_annotations2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698