| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 * | 325 * |
| 326 * However, inlining can only be performed when the target function can be | 326 * However, inlining can only be performed when the target function can be |
| 327 * resolved statically. The defaults can therefore be included at this point. | 327 * resolved statically. The defaults can therefore be included at this point. |
| 328 * | 328 * |
| 329 * The [providedArguments] list contains first all positional arguments, then | 329 * The [providedArguments] list contains first all positional arguments, then |
| 330 * the provided named arguments (the named arguments that are defined in the | 330 * the provided named arguments (the named arguments that are defined in the |
| 331 * [selector]) in a specific order (see [addDynamicSendArgumentsToList]). | 331 * [selector]) in a specific order (see [addDynamicSendArgumentsToList]). |
| 332 */ | 332 */ |
| 333 List<HInstruction> completeDynamicSendArgumentsList(Selector selector, | 333 List<HInstruction> completeDynamicSendArgumentsList(Selector selector, |
| 334 FunctionElement function, List<HInstruction> providedArguments) { | 334 FunctionElement function, List<HInstruction> providedArguments) { |
| 335 assert(selector.applies(function, backend)); | 335 assert(selector.applies(function)); |
| 336 FunctionSignature signature = function.functionSignature; | 336 FunctionSignature signature = function.functionSignature; |
| 337 List<HInstruction> compiledArguments = new List<HInstruction>( | 337 List<HInstruction> compiledArguments = new List<HInstruction>( |
| 338 signature.parameterCount + 1); // Plus one for receiver. | 338 signature.parameterCount + 1); // Plus one for receiver. |
| 339 | 339 |
| 340 compiledArguments[0] = providedArguments[0]; // Receiver. | 340 compiledArguments[0] = providedArguments[0]; // Receiver. |
| 341 int index = 1; | 341 int index = 1; |
| 342 for (; index <= signature.requiredParameterCount; index++) { | 342 for (; index <= signature.requiredParameterCount; index++) { |
| 343 compiledArguments[index] = providedArguments[index]; | 343 compiledArguments[index] = providedArguments[index]; |
| 344 } | 344 } |
| 345 if (!signature.optionalParametersAreNamed) { | 345 if (!signature.optionalParametersAreNamed) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 bool meetsHardConstraints() { | 419 bool meetsHardConstraints() { |
| 420 if (compiler.options.disableInlining) return false; | 420 if (compiler.options.disableInlining) return false; |
| 421 | 421 |
| 422 assert(invariant( | 422 assert(invariant( |
| 423 currentNode != null ? currentNode : element, | 423 currentNode != null ? currentNode : element, |
| 424 selector != null || | 424 selector != null || |
| 425 Elements.isStaticOrTopLevel(element) || | 425 Elements.isStaticOrTopLevel(element) || |
| 426 element.isGenerativeConstructorBody, | 426 element.isGenerativeConstructorBody, |
| 427 message: "Missing selector for inlining of $element.")); | 427 message: "Missing selector for inlining of $element.")); |
| 428 if (selector != null) { | 428 if (selector != null) { |
| 429 if (!selector.applies(function, backend)) return false; | 429 if (!selector.applies(function)) return false; |
| 430 if (mask != null && | 430 if (mask != null && |
| 431 !mask.canHit(function, selector, compiler.closedWorld)) { | 431 !mask.canHit(function, selector, compiler.closedWorld)) { |
| 432 return false; | 432 return false; |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 | 435 |
| 436 if (backend.isJsInterop(element)) return false; | 436 if (backend.isJsInterop(element)) return false; |
| 437 | 437 |
| 438 // Don't inline operator== methods if the parameter can be null. | 438 // Don't inline operator== methods if the parameter can be null. |
| 439 if (element.name == '==') { | 439 if (element.name == '==') { |
| (...skipping 2754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3194 var inputs = <HInstruction>[pop()]; | 3194 var inputs = <HInstruction>[pop()]; |
| 3195 push(buildInvokeSuper(Selectors.noSuchMethod_, element, inputs)); | 3195 push(buildInvokeSuper(Selectors.noSuchMethod_, element, inputs)); |
| 3196 } | 3196 } |
| 3197 | 3197 |
| 3198 /// Generate a call to a super method or constructor. | 3198 /// Generate a call to a super method or constructor. |
| 3199 void generateSuperInvoke(ast.Send node, FunctionElement function, | 3199 void generateSuperInvoke(ast.Send node, FunctionElement function, |
| 3200 SourceInformation sourceInformation) { | 3200 SourceInformation sourceInformation) { |
| 3201 // TODO(5347): Try to avoid the need for calling [implementation] before | 3201 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 3202 // calling [makeStaticArgumentList]. | 3202 // calling [makeStaticArgumentList]. |
| 3203 Selector selector = elements.getSelector(node); | 3203 Selector selector = elements.getSelector(node); |
| 3204 assert(invariant(node, selector.applies(function.implementation, backend), | 3204 assert(invariant(node, selector.applies(function.implementation), |
| 3205 message: "$selector does not apply to ${function.implementation}")); | 3205 message: "$selector does not apply to ${function.implementation}")); |
| 3206 List<HInstruction> inputs = makeStaticArgumentList( | 3206 List<HInstruction> inputs = makeStaticArgumentList( |
| 3207 selector.callStructure, node.arguments, function.implementation); | 3207 selector.callStructure, node.arguments, function.implementation); |
| 3208 push(buildInvokeSuper(selector, function, inputs, sourceInformation)); | 3208 push(buildInvokeSuper(selector, function, inputs, sourceInformation)); |
| 3209 } | 3209 } |
| 3210 | 3210 |
| 3211 /// Access the value from the super [element]. | 3211 /// Access the value from the super [element]. |
| 3212 void handleSuperGet(ast.Send node, Element element) { | 3212 void handleSuperGet(ast.Send node, Element element) { |
| 3213 Selector selector = elements.getSelector(node); | 3213 Selector selector = elements.getSelector(node); |
| 3214 SourceInformation sourceInformation = | 3214 SourceInformation sourceInformation = |
| (...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4446 node, | 4446 node, |
| 4447 sourceInformation: | 4447 sourceInformation: |
| 4448 sourceInformationBuilder.buildGeneric(node.assignmentOperator)); | 4448 sourceInformationBuilder.buildGeneric(node.assignmentOperator)); |
| 4449 } | 4449 } |
| 4450 | 4450 |
| 4451 void handleSuperSendSet(ast.SendSet node) { | 4451 void handleSuperSendSet(ast.SendSet node) { |
| 4452 Element element = elements[node]; | 4452 Element element = elements[node]; |
| 4453 List<HInstruction> setterInputs = <HInstruction>[]; | 4453 List<HInstruction> setterInputs = <HInstruction>[]; |
| 4454 void generateSuperSendSet() { | 4454 void generateSuperSendSet() { |
| 4455 Selector setterSelector = elements.getSelector(node); | 4455 Selector setterSelector = elements.getSelector(node); |
| 4456 if (Elements.isUnresolved(element) || | 4456 if (Elements.isUnresolved(element) || !setterSelector.applies(element)) { |
| 4457 !setterSelector.applies(element, compiler.backend)) { | |
| 4458 generateSuperNoSuchMethodSend(node, setterSelector, setterInputs); | 4457 generateSuperNoSuchMethodSend(node, setterSelector, setterInputs); |
| 4459 pop(); | 4458 pop(); |
| 4460 } else { | 4459 } else { |
| 4461 add(buildInvokeSuper(setterSelector, element, setterInputs)); | 4460 add(buildInvokeSuper(setterSelector, element, setterInputs)); |
| 4462 } | 4461 } |
| 4463 } | 4462 } |
| 4464 | 4463 |
| 4465 if (identical(node.assignmentOperator.source, '=')) { | 4464 if (identical(node.assignmentOperator.source, '=')) { |
| 4466 addDynamicSendArgumentsToList(node, setterInputs); | 4465 addDynamicSendArgumentsToList(node, setterInputs); |
| 4467 generateSuperSendSet(); | 4466 generateSuperSendSet(); |
| (...skipping 2596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7064 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 7063 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
| 7065 unaliased.accept(this, builder); | 7064 unaliased.accept(this, builder); |
| 7066 } | 7065 } |
| 7067 | 7066 |
| 7068 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 7067 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
| 7069 JavaScriptBackend backend = builder.compiler.backend; | 7068 JavaScriptBackend backend = builder.compiler.backend; |
| 7070 ClassElement cls = backend.helpers.DynamicRuntimeType; | 7069 ClassElement cls = backend.helpers.DynamicRuntimeType; |
| 7071 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld))); | 7070 builder.push(new HDynamicType(type, new TypeMask.exact(cls, closedWorld))); |
| 7072 } | 7071 } |
| 7073 } | 7072 } |
| OLD | NEW |