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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 return compiledArguments; | 424 return compiledArguments; |
425 } | 425 } |
426 | 426 |
427 /** | 427 /** |
428 * Try to inline [element] within the correct context of the builder. The | 428 * Try to inline [element] within the correct context of the builder. The |
429 * insertion point is the state of the builder. | 429 * insertion point is the state of the builder. |
430 */ | 430 */ |
431 bool tryInlineMethod(MethodElement element, Selector selector, TypeMask mask, | 431 bool tryInlineMethod(MethodElement element, Selector selector, TypeMask mask, |
432 List<HInstruction> providedArguments, ast.Node currentNode, | 432 List<HInstruction> providedArguments, ast.Node currentNode, |
433 {ResolutionInterfaceType instanceType}) { | 433 {ResolutionInterfaceType instanceType}) { |
434 registry.registerStaticUse(new StaticUse.inlining(element)); | |
435 | |
436 if (nativeData.isJsInteropMember(element) && | 434 if (nativeData.isJsInteropMember(element) && |
437 !element.isFactoryConstructor) { | 435 !element.isFactoryConstructor) { |
438 // We only inline factory JavaScript interop constructors. | 436 // We only inline factory JavaScript interop constructors. |
439 return false; | 437 return false; |
440 } | 438 } |
441 | 439 |
442 // Ensure that [element] is an implementation element. | 440 // Ensure that [element] is an implementation element. |
443 element = element.implementation; | 441 element = element.implementation; |
444 | 442 |
445 if (compiler.elementHasCompileTimeError(element)) return false; | 443 if (compiler.elementHasCompileTimeError(element)) return false; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 enableUserAssertions: options.enableUserAssertions); | 573 enableUserAssertions: options.enableUserAssertions); |
576 if (canInline) { | 574 if (canInline) { |
577 inlineCache.markAsInlinable(declaration, insideLoop: insideLoop); | 575 inlineCache.markAsInlinable(declaration, insideLoop: insideLoop); |
578 } else { | 576 } else { |
579 inlineCache.markAsNonInlinable(declaration, insideLoop: insideLoop); | 577 inlineCache.markAsNonInlinable(declaration, insideLoop: insideLoop); |
580 } | 578 } |
581 return canInline; | 579 return canInline; |
582 } | 580 } |
583 | 581 |
584 void doInlining() { | 582 void doInlining() { |
| 583 registry.registerStaticUse(new StaticUse.inlining(declaration)); |
| 584 |
585 // Add an explicit null check on the receiver before doing the | 585 // Add an explicit null check on the receiver before doing the |
586 // inlining. We use [element] to get the same name in the | 586 // inlining. We use [element] to get the same name in the |
587 // NoSuchMethodError message as if we had called it. | 587 // NoSuchMethodError message as if we had called it. |
588 if (function.isInstanceMember && | 588 if (function.isInstanceMember && |
589 !function.isGenerativeConstructorBody && | 589 !function.isGenerativeConstructorBody && |
590 (mask == null || mask.isNullable)) { | 590 (mask == null || mask.isNullable)) { |
591 addWithPosition( | 591 addWithPosition( |
592 new HFieldGet(null, providedArguments[0], commonMasks.dynamicType, | 592 new HFieldGet(null, providedArguments[0], commonMasks.dynamicType, |
593 isAssignable: false), | 593 isAssignable: false), |
594 currentNode); | 594 currentNode); |
(...skipping 6248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6843 this.oldReturnLocal, | 6843 this.oldReturnLocal, |
6844 this.oldReturnType, | 6844 this.oldReturnType, |
6845 this.oldResolvedAst, | 6845 this.oldResolvedAst, |
6846 this.oldStack, | 6846 this.oldStack, |
6847 this.oldLocalsHandler, | 6847 this.oldLocalsHandler, |
6848 this.inTryStatement, | 6848 this.inTryStatement, |
6849 this.allFunctionsCalledOnce, | 6849 this.allFunctionsCalledOnce, |
6850 this.oldElementInferenceResults) | 6850 this.oldElementInferenceResults) |
6851 : super(function); | 6851 : super(function); |
6852 } | 6852 } |
OLD | NEW |