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

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: 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
floitsch 2015/03/10 17:42:27 missing ".".
herhut 2015/03/11 14:01:56 Done.
53 if (element is ConstructorBodyElement) {
54 ConstructorBodyElement body = element;
55 decision = _cachedDecisions[body.constructor];
56 print("checked for $element as $decision via ${body.constructor}");
floitsch 2015/03/10 17:42:27 remove print.
herhut 2015/03/11 14:01:56 Done.
57 }
58 if (decision == null) {
59 decision = _unknown;
60 }
52 } 61 }
53 62
54 if (insideLoop) { 63 if (insideLoop) {
55 switch (decision) { 64 switch (decision) {
56 case _mustNotInline: 65 case _mustNotInline:
57 return false; 66 return false;
58 67
59 case _unknown: 68 case _unknown:
60 case _mayInlineInLoopMustNotOutside: 69 case _mayInlineInLoopMustNotOutside:
61 // We know we can't inline outside a loop, but don't know for the 70 // 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, 2435 new CodegenRegistry(compiler,
2427 dependency.annotatedElement.analyzableElement.treeElements)); 2436 dependency.annotatedElement.analyzableElement.treeElements));
2428 } 2437 }
2429 metadataConstants.clear(); 2438 metadataConstants.clear();
2430 } 2439 }
2431 } 2440 }
2432 return true; 2441 return true;
2433 } 2442 }
2434 2443
2435 void onElementResolved(Element element, TreeElements elements) { 2444 void onElementResolved(Element element, TreeElements elements) {
2436 if (element.isFunction && annotations.noInline(element)) { 2445 if ((element.isFunction || element.isGenerativeConstructor) &&
2446 annotations.noInline(element)) {
2437 inlineCache.markAsNonInlinable(element); 2447 inlineCache.markAsNonInlinable(element);
2438 } 2448 }
2439 2449
2440 LibraryElement library = element.library; 2450 LibraryElement library = element.library;
2441 if (!library.isPlatformLibrary && !library.canUseNative) return; 2451 if (!library.isPlatformLibrary && !library.canUseNative) return;
2442 bool hasNoInline = false; 2452 bool hasNoInline = false;
2443 bool hasForceInline = false; 2453 bool hasForceInline = false;
2444 bool hasNoThrows = false; 2454 bool hasNoThrows = false;
2445 bool hasNoSideEffects = false; 2455 bool hasNoSideEffects = false;
2446 for (MetadataAnnotation metadata in element.metadata) { 2456 for (MetadataAnnotation metadata in element.metadata) {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 } 2844 }
2835 } 2845 }
2836 2846
2837 /// Records that [constant] is used by the element behind [registry]. 2847 /// Records that [constant] is used by the element behind [registry].
2838 class Dependency { 2848 class Dependency {
2839 final ConstantValue constant; 2849 final ConstantValue constant;
2840 final Element annotatedElement; 2850 final Element annotatedElement;
2841 2851
2842 const Dependency(this.constant, this.annotatedElement); 2852 const Dependency(this.constant, this.annotatedElement);
2843 } 2853 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698