OLD | NEW |
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 import 'dart:collection'; | 5 import 'dart:collection'; |
6 | 6 |
7 import 'package:js_runtime/shared/embedded_names.dart'; | 7 import 'package:js_runtime/shared/embedded_names.dart'; |
8 | 8 |
9 import '../closure.dart'; | 9 import '../closure.dart'; |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 405 |
406 if (compiler.elementHasCompileTimeError(element)) return false; | 406 if (compiler.elementHasCompileTimeError(element)) return false; |
407 | 407 |
408 MethodElement function = element; | 408 MethodElement function = element; |
409 ResolvedAst functionResolvedAst = function.resolvedAst; | 409 ResolvedAst functionResolvedAst = function.resolvedAst; |
410 bool insideLoop = loopDepth > 0 || graph.calledInLoop; | 410 bool insideLoop = loopDepth > 0 || graph.calledInLoop; |
411 | 411 |
412 // Bail out early if the inlining decision is in the cache and we can't | 412 // Bail out early if the inlining decision is in the cache and we can't |
413 // inline (no need to check the hard constraints). | 413 // inline (no need to check the hard constraints). |
414 bool cachedCanBeInlined = | 414 bool cachedCanBeInlined = |
415 inlineCache.canInline(function, insideLoop: insideLoop); | 415 inlineCache.canInline(function.declaration, insideLoop: insideLoop); |
416 if (cachedCanBeInlined == false) return false; | 416 if (cachedCanBeInlined == false) return false; |
417 | 417 |
418 bool meetsHardConstraints() { | 418 bool meetsHardConstraints() { |
419 if (options.disableInlining) return false; | 419 if (options.disableInlining) return false; |
420 | 420 |
421 assert(invariant( | 421 assert(invariant( |
422 currentNode != null ? currentNode : function, | 422 currentNode != null ? currentNode : function, |
423 selector != null || | 423 selector != null || |
424 Elements.isStaticOrTopLevel(function) || | 424 Elements.isStaticOrTopLevel(function) || |
425 function.isGenerativeConstructorBody, | 425 function.isGenerativeConstructorBody, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 // If a method is called only once, and all the methods in the | 527 // If a method is called only once, and all the methods in the |
528 // inlining stack are called only once as well, we know we will | 528 // inlining stack are called only once as well, we know we will |
529 // save on output size by inlining this method. | 529 // save on output size by inlining this method. |
530 if (isCalledOnce(function)) { | 530 if (isCalledOnce(function)) { |
531 maxInliningNodes = null; | 531 maxInliningNodes = null; |
532 } | 532 } |
533 bool canInline = InlineWeeder.canBeInlined( | 533 bool canInline = InlineWeeder.canBeInlined( |
534 functionResolvedAst, maxInliningNodes, | 534 functionResolvedAst, maxInliningNodes, |
535 enableUserAssertions: options.enableUserAssertions); | 535 enableUserAssertions: options.enableUserAssertions); |
536 if (canInline) { | 536 if (canInline) { |
537 inlineCache.markAsInlinable(function, insideLoop: insideLoop); | 537 inlineCache.markAsInlinable(function.declaration, |
| 538 insideLoop: insideLoop); |
538 } else { | 539 } else { |
539 inlineCache.markAsNonInlinable(function, insideLoop: insideLoop); | 540 inlineCache.markAsNonInlinable(function.declaration, |
| 541 insideLoop: insideLoop); |
540 } | 542 } |
541 return canInline; | 543 return canInline; |
542 } | 544 } |
543 | 545 |
544 void doInlining() { | 546 void doInlining() { |
545 // Add an explicit null check on the receiver before doing the | 547 // Add an explicit null check on the receiver before doing the |
546 // inlining. We use [element] to get the same name in the | 548 // inlining. We use [element] to get the same name in the |
547 // NoSuchMethodError message as if we had called it. | 549 // NoSuchMethodError message as if we had called it. |
548 if (function.isInstanceMember && | 550 if (function.isInstanceMember && |
549 !function.isGenerativeConstructorBody && | 551 !function.isGenerativeConstructorBody && |
(...skipping 6191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6741 this.oldReturnLocal, | 6743 this.oldReturnLocal, |
6742 this.oldReturnType, | 6744 this.oldReturnType, |
6743 this.oldResolvedAst, | 6745 this.oldResolvedAst, |
6744 this.oldStack, | 6746 this.oldStack, |
6745 this.oldLocalsHandler, | 6747 this.oldLocalsHandler, |
6746 this.inTryStatement, | 6748 this.inTryStatement, |
6747 this.allFunctionsCalledOnce, | 6749 this.allFunctionsCalledOnce, |
6748 this.oldElementInferenceResults) | 6750 this.oldElementInferenceResults) |
6749 : super(function); | 6751 : super(function); |
6750 } | 6752 } |
OLD | NEW |