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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 * | 547 * |
548 * However, inlining can only be performed when the target function can be | 548 * However, inlining can only be performed when the target function can be |
549 * resolved statically. The defaults can therefore be included at this point. | 549 * resolved statically. The defaults can therefore be included at this point. |
550 * | 550 * |
551 * The [providedArguments] list contains first all positional arguments, then | 551 * The [providedArguments] list contains first all positional arguments, then |
552 * the provided named arguments (the named arguments that are defined in the | 552 * the provided named arguments (the named arguments that are defined in the |
553 * [selector]) in a specific order (see [addDynamicSendArgumentsToList]). | 553 * [selector]) in a specific order (see [addDynamicSendArgumentsToList]). |
554 */ | 554 */ |
555 List<HInstruction> completeDynamicSendArgumentsList(Selector selector, | 555 List<HInstruction> completeDynamicSendArgumentsList(Selector selector, |
556 FunctionElement function, List<HInstruction> providedArguments) { | 556 FunctionElement function, List<HInstruction> providedArguments) { |
557 assert(selector.applies(function, compiler.closedWorld)); | 557 assert(selector.applies(function, backend)); |
558 FunctionSignature signature = function.functionSignature; | 558 FunctionSignature signature = function.functionSignature; |
559 List<HInstruction> compiledArguments = new List<HInstruction>( | 559 List<HInstruction> compiledArguments = new List<HInstruction>( |
560 signature.parameterCount + 1); // Plus one for receiver. | 560 signature.parameterCount + 1); // Plus one for receiver. |
561 | 561 |
562 compiledArguments[0] = providedArguments[0]; // Receiver. | 562 compiledArguments[0] = providedArguments[0]; // Receiver. |
563 int index = 1; | 563 int index = 1; |
564 for (; index <= signature.requiredParameterCount; index++) { | 564 for (; index <= signature.requiredParameterCount; index++) { |
565 compiledArguments[index] = providedArguments[index]; | 565 compiledArguments[index] = providedArguments[index]; |
566 } | 566 } |
567 if (!signature.optionalParametersAreNamed) { | 567 if (!signature.optionalParametersAreNamed) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 bool meetsHardConstraints() { | 641 bool meetsHardConstraints() { |
642 if (compiler.options.disableInlining) return false; | 642 if (compiler.options.disableInlining) return false; |
643 | 643 |
644 assert(invariant( | 644 assert(invariant( |
645 currentNode != null ? currentNode : element, | 645 currentNode != null ? currentNode : element, |
646 selector != null || | 646 selector != null || |
647 Elements.isStaticOrTopLevel(element) || | 647 Elements.isStaticOrTopLevel(element) || |
648 element.isGenerativeConstructorBody, | 648 element.isGenerativeConstructorBody, |
649 message: "Missing selector for inlining of $element.")); | 649 message: "Missing selector for inlining of $element.")); |
650 if (selector != null) { | 650 if (selector != null) { |
651 if (!selector.applies(function, compiler.closedWorld)) return false; | 651 if (!selector.applies(function, backend)) return false; |
652 if (mask != null && | 652 if (mask != null && |
653 !mask.canHit(function, selector, compiler.closedWorld)) { | 653 !mask.canHit(function, selector, compiler.closedWorld)) { |
654 return false; | 654 return false; |
655 } | 655 } |
656 } | 656 } |
657 | 657 |
658 if (backend.isJsInterop(element)) return false; | 658 if (backend.isJsInterop(element)) return false; |
659 | 659 |
660 // Don't inline operator== methods if the parameter can be null. | 660 // Don't inline operator== methods if the parameter can be null. |
661 if (element.name == '==') { | 661 if (element.name == '==') { |
(...skipping 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3680 push(buildInvokeSuper(Selectors.noSuchMethod_, element, inputs)); | 3680 push(buildInvokeSuper(Selectors.noSuchMethod_, element, inputs)); |
3681 } | 3681 } |
3682 | 3682 |
3683 /// Generate a call to a super method or constructor. | 3683 /// Generate a call to a super method or constructor. |
3684 void generateSuperInvoke(ast.Send node, FunctionElement function, | 3684 void generateSuperInvoke(ast.Send node, FunctionElement function, |
3685 SourceInformation sourceInformation) { | 3685 SourceInformation sourceInformation) { |
3686 // TODO(5347): Try to avoid the need for calling [implementation] before | 3686 // TODO(5347): Try to avoid the need for calling [implementation] before |
3687 // calling [makeStaticArgumentList]. | 3687 // calling [makeStaticArgumentList]. |
3688 Selector selector = elements.getSelector(node); | 3688 Selector selector = elements.getSelector(node); |
3689 assert(invariant( | 3689 assert(invariant( |
3690 node, selector.applies(function.implementation, compiler.closedWorld), | 3690 node, selector.applies(function.implementation, backend), |
3691 message: "$selector does not apply to ${function.implementation}")); | 3691 message: "$selector does not apply to ${function.implementation}")); |
3692 List<HInstruction> inputs = makeStaticArgumentList( | 3692 List<HInstruction> inputs = makeStaticArgumentList( |
3693 selector.callStructure, node.arguments, function.implementation); | 3693 selector.callStructure, node.arguments, function.implementation); |
3694 push(buildInvokeSuper(selector, function, inputs, sourceInformation)); | 3694 push(buildInvokeSuper(selector, function, inputs, sourceInformation)); |
3695 } | 3695 } |
3696 | 3696 |
3697 /// Access the value from the super [element]. | 3697 /// Access the value from the super [element]. |
3698 void handleSuperGet(ast.Send node, Element element) { | 3698 void handleSuperGet(ast.Send node, Element element) { |
3699 Selector selector = elements.getSelector(node); | 3699 Selector selector = elements.getSelector(node); |
3700 SourceInformation sourceInformation = | 3700 SourceInformation sourceInformation = |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4936 sourceInformation: | 4936 sourceInformation: |
4937 sourceInformationBuilder.buildGeneric(node.assignmentOperator)); | 4937 sourceInformationBuilder.buildGeneric(node.assignmentOperator)); |
4938 } | 4938 } |
4939 | 4939 |
4940 void handleSuperSendSet(ast.SendSet node) { | 4940 void handleSuperSendSet(ast.SendSet node) { |
4941 Element element = elements[node]; | 4941 Element element = elements[node]; |
4942 List<HInstruction> setterInputs = <HInstruction>[]; | 4942 List<HInstruction> setterInputs = <HInstruction>[]; |
4943 void generateSuperSendSet() { | 4943 void generateSuperSendSet() { |
4944 Selector setterSelector = elements.getSelector(node); | 4944 Selector setterSelector = elements.getSelector(node); |
4945 if (Elements.isUnresolved(element) || | 4945 if (Elements.isUnresolved(element) || |
4946 !setterSelector.applies(element, compiler.closedWorld)) { | 4946 !setterSelector.applies(element, compiler.backend)) { |
4947 generateSuperNoSuchMethodSend(node, setterSelector, setterInputs); | 4947 generateSuperNoSuchMethodSend(node, setterSelector, setterInputs); |
4948 pop(); | 4948 pop(); |
4949 } else { | 4949 } else { |
4950 add(buildInvokeSuper(setterSelector, element, setterInputs)); | 4950 add(buildInvokeSuper(setterSelector, element, setterInputs)); |
4951 } | 4951 } |
4952 } | 4952 } |
4953 | 4953 |
4954 if (identical(node.assignmentOperator.source, '=')) { | 4954 if (identical(node.assignmentOperator.source, '=')) { |
4955 addDynamicSendArgumentsToList(node, setterInputs); | 4955 addDynamicSendArgumentsToList(node, setterInputs); |
4956 generateSuperSendSet(); | 4956 generateSuperSendSet(); |
(...skipping 2601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7558 const _LoopTypeVisitor(); | 7558 const _LoopTypeVisitor(); |
7559 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; | 7559 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; |
7560 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; | 7560 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; |
7561 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; | 7561 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; |
7562 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; | 7562 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; |
7563 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 7563 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
7564 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 7564 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
7565 int visitSwitchStatement(ast.SwitchStatement node) => | 7565 int visitSwitchStatement(ast.SwitchStatement node) => |
7566 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; | 7566 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; |
7567 } | 7567 } |
OLD | NEW |