| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A special element for the extra parameter taken by intercepted | 8 * A special element for the extra parameter taken by intercepted |
| 9 * methods. We need to override [Element.computeType] because our | 9 * methods. We need to override [Element.computeType] because our |
| 10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
| (...skipping 3115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3126 handleForeignJsCallInIsolate(node); | 3126 handleForeignJsCallInIsolate(node); |
| 3127 } else if (name == const SourceString('DART_CLOSURE_TO_JS')) { | 3127 } else if (name == const SourceString('DART_CLOSURE_TO_JS')) { |
| 3128 handleForeignDartClosureToJs(node); | 3128 handleForeignDartClosureToJs(node); |
| 3129 } else { | 3129 } else { |
| 3130 throw "Unknown foreign: ${selector}"; | 3130 throw "Unknown foreign: ${selector}"; |
| 3131 } | 3131 } |
| 3132 } | 3132 } |
| 3133 | 3133 |
| 3134 generateSuperNoSuchMethodSend(Send node) { | 3134 generateSuperNoSuchMethodSend(Send node) { |
| 3135 Selector selector = elements.getSelector(node); | 3135 Selector selector = elements.getSelector(node); |
| 3136 String name = selector.invocationMirrorMemberName; | 3136 SourceString name = selector.name; |
| 3137 |
| 3137 ClassElement cls = work.element.getEnclosingClass(); | 3138 ClassElement cls = work.element.getEnclosingClass(); |
| 3138 if (cls is ClosureClassElement) { | |
| 3139 ClosureClassElement closureClass = cls; | |
| 3140 cls = closureClass.methodElement.getEnclosingClass(); | |
| 3141 } | |
| 3142 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); | 3139 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); |
| 3143 if (element.enclosingElement.declaration != compiler.objectClass) { | 3140 if (element.enclosingElement.declaration != compiler.objectClass) { |
| 3144 // Register the call as dynamic if [:noSuchMethod:] on the super class | 3141 // Register the call as dynamic if [:noSuchMethod:] on the super class |
| 3145 // is _not_ the default implementation from [:Object:]. | 3142 // is _not_ the default implementation from [:Object:]. |
| 3146 compiler.enqueuer.codegen.registerDynamicInvocation(selector.name, | 3143 compiler.enqueuer.codegen.registerDynamicInvocation(name, selector); |
| 3147 selector); | |
| 3148 } | 3144 } |
| 3149 HStatic target = new HStatic(element); | 3145 HStatic target = new HStatic(element); |
| 3150 add(target); | 3146 add(target); |
| 3151 HInstruction self = localsHandler.readThis(); | 3147 HInstruction self = localsHandler.readThis(); |
| 3152 Constant nameConstant = constantSystem.createString( | 3148 Constant nameConstant = constantSystem.createString( |
| 3153 new DartString.literal(name), node); | 3149 new DartString.literal(name.slowToString()), node); |
| 3154 | 3150 |
| 3155 String internalName = backend.namer.invocationMirrorInternalName(selector); | 3151 String internalName = backend.namer.instanceMethodInvocationName( |
| 3152 currentLibrary, name, selector); |
| 3156 Constant internalNameConstant = | 3153 Constant internalNameConstant = |
| 3157 constantSystem.createString(new DartString.literal(internalName), node); | 3154 constantSystem.createString(new DartString.literal(internalName), node); |
| 3158 | 3155 |
| 3159 Element createInvocationMirror = | 3156 Element createInvocationMirror = |
| 3160 compiler.findHelper(Compiler.CREATE_INVOCATION_MIRROR); | 3157 compiler.findHelper(Compiler.CREATE_INVOCATION_MIRROR); |
| 3161 | 3158 |
| 3162 var arguments = new List<HInstruction>(); | 3159 var arguments = new List<HInstruction>(); |
| 3163 if (node.argumentsNode != null) { | 3160 if (node.argumentsNode != null) { |
| 3164 addGenericSendArgumentsToList(node.arguments, arguments); | 3161 addGenericSendArgumentsToList(node.arguments, arguments); |
| 3165 } | 3162 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3205 Selector selector = elements.getSelector(node); | 3202 Selector selector = elements.getSelector(node); |
| 3206 Element element = elements[node]; | 3203 Element element = elements[node]; |
| 3207 if (element == null) return generateSuperNoSuchMethodSend(node); | 3204 if (element == null) return generateSuperNoSuchMethodSend(node); |
| 3208 // TODO(5346): Try to avoid the need for calling [declaration] before | 3205 // TODO(5346): Try to avoid the need for calling [declaration] before |
| 3209 // creating an [HStatic]. | 3206 // creating an [HStatic]. |
| 3210 HInstruction target = new HStatic(element.declaration); | 3207 HInstruction target = new HStatic(element.declaration); |
| 3211 HInstruction context = localsHandler.readThis(); | 3208 HInstruction context = localsHandler.readThis(); |
| 3212 add(target); | 3209 add(target); |
| 3213 var inputs = <HInstruction>[target, context]; | 3210 var inputs = <HInstruction>[target, context]; |
| 3214 if (node.isPropertyAccess) { | 3211 if (node.isPropertyAccess) { |
| 3215 push(new HInvokeSuper(inputs, isPropertyAccess: true)); | 3212 push(new HInvokeSuper(inputs)); |
| 3216 } else if (element.isFunction() || element.isGenerativeConstructor()) { | 3213 } else if (element.isFunction() || element.isGenerativeConstructor()) { |
| 3217 // TODO(5347): Try to avoid the need for calling [implementation] before | 3214 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 3218 // calling [addStaticSendArgumentsToList]. | 3215 // calling [addStaticSendArgumentsToList]. |
| 3219 FunctionElement function = element.implementation; | 3216 FunctionElement function = element.implementation; |
| 3220 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, | 3217 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, |
| 3221 function, inputs); | 3218 function, inputs); |
| 3222 if (!succeeded) { | 3219 if (!succeeded) { |
| 3223 generateSuperNoSuchMethodSend(node); | 3220 generateWrongArgumentCountError(node, element, node.arguments); |
| 3224 } else { | 3221 } else { |
| 3225 push(new HInvokeSuper(inputs)); | 3222 push(new HInvokeSuper(inputs)); |
| 3226 } | 3223 } |
| 3227 } else { | 3224 } else { |
| 3228 target = new HInvokeSuper(inputs); | 3225 target = new HInvokeSuper(inputs); |
| 3229 add(target); | 3226 add(target); |
| 3230 inputs = <HInstruction>[target]; | 3227 inputs = <HInstruction>[target]; |
| 3231 addDynamicSendArgumentsToList(node, inputs); | 3228 addDynamicSendArgumentsToList(node, inputs); |
| 3232 push(new HInvokeClosure(selector, inputs)); | 3229 push(new HInvokeClosure(selector, inputs)); |
| 3233 } | 3230 } |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3640 visitSendSet(SendSet node) { | 3637 visitSendSet(SendSet node) { |
| 3641 Element element = elements[node]; | 3638 Element element = elements[node]; |
| 3642 if (!Elements.isUnresolved(element) && element.impliesType()) { | 3639 if (!Elements.isUnresolved(element) && element.impliesType()) { |
| 3643 Identifier selector = node.selector; | 3640 Identifier selector = node.selector; |
| 3644 generateThrowNoSuchMethod(node, selector.source.slowToString(), | 3641 generateThrowNoSuchMethod(node, selector.source.slowToString(), |
| 3645 argumentNodes: node.arguments); | 3642 argumentNodes: node.arguments); |
| 3646 return; | 3643 return; |
| 3647 } | 3644 } |
| 3648 Operator op = node.assignmentOperator; | 3645 Operator op = node.assignmentOperator; |
| 3649 if (node.isSuperCall) { | 3646 if (node.isSuperCall) { |
| 3650 if (Elements.isUnresolved(element) || !Elements.isAssignable(element)) { | 3647 if (element == null) return generateSuperNoSuchMethodSend(node); |
| 3651 return generateSuperNoSuchMethodSend(node); | |
| 3652 } | |
| 3653 HInstruction target = new HStatic(element); | 3648 HInstruction target = new HStatic(element); |
| 3654 HInstruction context = localsHandler.readThis(); | 3649 HInstruction context = localsHandler.readThis(); |
| 3655 add(target); | 3650 add(target); |
| 3656 var inputs = <HInstruction>[target, context]; | 3651 var inputs = <HInstruction>[target, context]; |
| 3657 addDynamicSendArgumentsToList(node, inputs); | 3652 addDynamicSendArgumentsToList(node, inputs); |
| 3658 if (!identical(node.assignmentOperator.source.stringValue, '=')) { | 3653 if (!identical(node.assignmentOperator.source.stringValue, '=')) { |
| 3659 compiler.unimplemented('complex super assignment', | 3654 compiler.unimplemented('complex super assignment', |
| 3660 node: node.assignmentOperator); | 3655 node: node.assignmentOperator); |
| 3661 } | 3656 } |
| 3662 push(new HInvokeSuper(inputs, isSendSet: true)); | 3657 push(new HInvokeSuper(inputs, isSetter: true)); |
| 3663 } else if (node.isIndex) { | 3658 } else if (node.isIndex) { |
| 3664 if (!methodInterceptionEnabled) { | 3659 if (!methodInterceptionEnabled) { |
| 3665 assert(identical(op.source.stringValue, '=')); | 3660 assert(identical(op.source.stringValue, '=')); |
| 3666 visitDynamicSend(node); | 3661 visitDynamicSend(node); |
| 3667 } else { | 3662 } else { |
| 3668 HStatic target = new HStatic( | 3663 HStatic target = new HStatic( |
| 3669 interceptors.getIndexAssignmentInterceptor()); | 3664 interceptors.getIndexAssignmentInterceptor()); |
| 3670 add(target); | 3665 add(target); |
| 3671 visit(node.receiver); | 3666 visit(node.receiver); |
| 3672 HInstruction receiver = pop(); | 3667 HInstruction receiver = pop(); |
| (...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5079 new HSubGraphBlockInformation(elseBranch.graph)); | 5074 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5080 | 5075 |
| 5081 HBasicBlock conditionStartBlock = conditionBranch.block; | 5076 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5082 conditionStartBlock.setBlockFlow(info, joinBlock); | 5077 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5083 SubGraph conditionGraph = conditionBranch.graph; | 5078 SubGraph conditionGraph = conditionBranch.graph; |
| 5084 HIf branch = conditionGraph.end.last; | 5079 HIf branch = conditionGraph.end.last; |
| 5085 assert(branch is HIf); | 5080 assert(branch is HIf); |
| 5086 branch.blockInformation = conditionStartBlock.blockFlow; | 5081 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5087 } | 5082 } |
| 5088 } | 5083 } |
| OLD | NEW |