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 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 this.work = work, | 970 this.work = work, |
971 interceptors = builder.interceptors, | 971 interceptors = builder.interceptors, |
972 methodInterceptionEnabled = true, | 972 methodInterceptionEnabled = true, |
973 graph = new HGraph(), | 973 graph = new HGraph(), |
974 stack = new List<HInstruction>(), | 974 stack = new List<HInstruction>(), |
975 activationVariables = new Map<Element, HLocalValue>(), | 975 activationVariables = new Map<Element, HLocalValue>(), |
976 jumpTargets = new Map<TargetElement, JumpHandler>(), | 976 jumpTargets = new Map<TargetElement, JumpHandler>(), |
977 parameters = new Map<Element, HInstruction>(), | 977 parameters = new Map<Element, HInstruction>(), |
978 sourceElementStack = <Element>[work.element], | 978 sourceElementStack = <Element>[work.element], |
979 inliningStack = <InliningState>[], | 979 inliningStack = <InliningState>[], |
980 rti = builder.compiler.codegenWorld.rti, | 980 rti = builder.backend.rti, |
981 super(work.resolutionTree) { | 981 super(work.resolutionTree) { |
982 localsHandler = new LocalsHandler(this); | 982 localsHandler = new LocalsHandler(this); |
983 } | 983 } |
984 | 984 |
985 static const MAX_INLINING_DEPTH = 3; | 985 static const MAX_INLINING_DEPTH = 3; |
986 static const MAX_INLINING_SOURCE_SIZE = 128; | 986 static const MAX_INLINING_SOURCE_SIZE = 128; |
987 List<InliningState> inliningStack; | 987 List<InliningState> inliningStack; |
988 Element returnElement; | 988 Element returnElement; |
989 DartType returnType; | 989 DartType returnType; |
990 bool inTryStatement = false; | 990 bool inTryStatement = false; |
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2639 bool isNot = false; | 2639 bool isNot = false; |
2640 // TODO(ngeoffray): Duplicating pattern in resolver. We should | 2640 // TODO(ngeoffray): Duplicating pattern in resolver. We should |
2641 // add a new kind of node. | 2641 // add a new kind of node. |
2642 if (typeAnnotation == null) { | 2642 if (typeAnnotation == null) { |
2643 typeAnnotation = argument.asSend().receiver; | 2643 typeAnnotation = argument.asSend().receiver; |
2644 isNot = true; | 2644 isNot = true; |
2645 } | 2645 } |
2646 | 2646 |
2647 DartType type = elements.getType(typeAnnotation); | 2647 DartType type = elements.getType(typeAnnotation); |
2648 HInstruction typeInfo = null; | 2648 HInstruction typeInfo = null; |
2649 if (compiler.codegenWorld.rti.hasTypeArguments(type)) { | 2649 if (rti.hasTypeArguments(type)) { |
2650 pushInvokeHelper1(interceptors.getGetRuntimeTypeInfo(), expression); | 2650 pushInvokeHelper1(interceptors.getGetRuntimeTypeInfo(), expression); |
2651 typeInfo = pop(); | 2651 typeInfo = pop(); |
2652 } | 2652 } |
2653 if (type.element.isTypeVariable()) { | 2653 if (type.element.isTypeVariable()) { |
2654 // TODO(karlklose): We currently answer true to any is check | 2654 // TODO(karlklose): We currently answer true to any is check |
2655 // involving a type variable -- both is T and is !T -- until | 2655 // involving a type variable -- both is T and is !T -- until |
2656 // we have a proper implementation of reified generics. | 2656 // we have a proper implementation of reified generics. |
2657 stack.add(graph.addConstantBool(true, constantSystem)); | 2657 stack.add(graph.addConstantBool(true, constantSystem)); |
2658 } else { | 2658 } else { |
2659 HInstruction instruction; | 2659 HInstruction instruction; |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3374 } | 3374 } |
3375 | 3375 |
3376 HConstant addConstantString(Node node, String string) { | 3376 HConstant addConstantString(Node node, String string) { |
3377 DartString dartString = new DartString.literal(string); | 3377 DartString dartString = new DartString.literal(string); |
3378 Constant constant = constantSystem.createString(dartString, node); | 3378 Constant constant = constantSystem.createString(dartString, node); |
3379 return graph.addConstant(constant); | 3379 return graph.addConstant(constant); |
3380 } | 3380 } |
3381 | 3381 |
3382 visitTypeReferenceSend(Send node) { | 3382 visitTypeReferenceSend(Send node) { |
3383 Element element = elements[node]; | 3383 Element element = elements[node]; |
3384 HInstruction name; | 3384 if (element.isClass() || element.isTypedef()) { |
3385 Element helper = | 3385 // TODO(karlklose): add type representation |
3386 compiler.findHelper(const SourceString('createRuntimeType')); | 3386 ConstantHandler handler = compiler.constantHandler; |
3387 if (element.isClass()) { | 3387 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
3388 String string = rti.generateRuntimeTypeString(element, 0); | 3388 stack.add(graph.addConstant(constant)); |
3389 name = addConstantString(node.selector, string); | |
3390 } else if (element.isTypedef()) { | |
3391 // TODO(karlklose): implement support for type variables in typedefs. | |
3392 name = addConstantString(node.selector, rti.getName(element)); | |
3393 } else if (element.isTypeVariable()) { | 3389 } else if (element.isTypeVariable()) { |
3394 // TODO(6248): implement support for type variables. | 3390 // TODO(6248): implement support for type variables. |
3395 compiler.unimplemented('first class type for type variable', node: node); | 3391 compiler.unimplemented('first class type for type variable', node: node); |
3396 } else { | 3392 } else { |
3397 internalError('unexpected element $element', node: node); | 3393 internalError('unexpected element kind $element', node: node); |
3398 } | 3394 } |
3399 pushInvokeHelper1(helper, name); | |
3400 if (node.isCall) { | 3395 if (node.isCall) { |
3401 // This send is of the form 'e(...)', where e is resolved to a type | 3396 // This send is of the form 'e(...)', where e is resolved to a type |
3402 // reference. We create a regular closure call on the result of the type | 3397 // reference. We create a regular closure call on the result of the type |
3403 // reference instead of creating a NoSuchMethodError to avoid pulling it | 3398 // reference instead of creating a NoSuchMethodError to avoid pulling it |
3404 // in if it is not used (e.g., in a try/catch). | 3399 // in if it is not used (e.g., in a try/catch). |
3405 HInstruction target = pop(); | 3400 HInstruction target = pop(); |
3406 Selector selector = elements.getSelector(node); | 3401 Selector selector = elements.getSelector(node); |
3407 List<HInstruction> inputs = <HInstruction>[target]; | 3402 List<HInstruction> inputs = <HInstruction>[target]; |
3408 addDynamicSendArgumentsToList(node, inputs); | 3403 addDynamicSendArgumentsToList(node, inputs); |
3409 push(new HInvokeClosure(selector, inputs)); | 3404 push(new HInvokeClosure(selector, inputs)); |
(...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4958 new HSubGraphBlockInformation(elseBranch.graph)); | 4953 new HSubGraphBlockInformation(elseBranch.graph)); |
4959 | 4954 |
4960 HBasicBlock conditionStartBlock = conditionBranch.block; | 4955 HBasicBlock conditionStartBlock = conditionBranch.block; |
4961 conditionStartBlock.setBlockFlow(info, joinBlock); | 4956 conditionStartBlock.setBlockFlow(info, joinBlock); |
4962 SubGraph conditionGraph = conditionBranch.graph; | 4957 SubGraph conditionGraph = conditionBranch.graph; |
4963 HIf branch = conditionGraph.end.last; | 4958 HIf branch = conditionGraph.end.last; |
4964 assert(branch is HIf); | 4959 assert(branch is HIf); |
4965 branch.blockInformation = conditionStartBlock.blockFlow; | 4960 branch.blockInformation = conditionStartBlock.blockFlow; |
4966 } | 4961 } |
4967 } | 4962 } |
OLD | NEW |