Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: lib/compiler/implementation/ssa/builder.dart

Issue 9969039: Some cleanups. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 bool isContinue() => jumpInstruction is HContinue; 622 bool isContinue() => jumpInstruction is HContinue;
623 JumpHandlerEntry(this.jumpInstruction, this.locals); 623 JumpHandlerEntry(this.jumpInstruction, this.locals);
624 } 624 }
625 625
626 626
627 interface JumpHandler default JumpHandlerImpl { 627 interface JumpHandler default JumpHandlerImpl {
628 JumpHandler(SsaBuilder builder, TargetElement target); 628 JumpHandler(SsaBuilder builder, TargetElement target);
629 void generateBreak([LabelElement label]); 629 void generateBreak([LabelElement label]);
630 void generateContinue([LabelElement label]); 630 void generateContinue([LabelElement label]);
631 void forEachBreak(void action(HBreak instruction, LocalsHandler locals)); 631 void forEachBreak(void action(HBreak instruction, LocalsHandler locals));
632 void forEachContinue(void action(HBreak instruction, LocalsHandler locals)); 632 void forEachContinue(void action(HContinue instruction,
633 LocalsHandler locals));
633 void close(); 634 void close();
634 final TargetElement target; 635 final TargetElement target;
635 List<LabelElement> labels(); 636 List<LabelElement> labels();
636 } 637 }
637 638
638 // Insert break handler used to avoid null checks when a target isn't 639 // Insert break handler used to avoid null checks when a target isn't
639 // used as the target of a break, and therefore doesn't need a break 640 // used as the target of a break, and therefore doesn't need a break
640 // handler associated with it. 641 // handler associated with it.
641 class NullJumpHandler implements JumpHandler { 642 class NullJumpHandler implements JumpHandler {
642 const NullJumpHandler(); 643 const NullJumpHandler();
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 HStatic target = new HStatic(element); 1967 HStatic target = new HStatic(element);
1967 add(target); 1968 add(target);
1968 List<HInstruction> inputs = <HInstruction>[target]; 1969 List<HInstruction> inputs = <HInstruction>[target];
1969 addGenericSendArgumentsToList(link, inputs); 1970 addGenericSendArgumentsToList(link, inputs);
1970 push(new HInvokeStatic(Selector.INVOCATION_0, inputs)); 1971 push(new HInvokeStatic(Selector.INVOCATION_0, inputs));
1971 } 1972 }
1972 } 1973 }
1973 1974
1974 void handleForeignDartClosureToJs(Send node) { 1975 void handleForeignDartClosureToJs(Send node) {
1975 if (node.arguments.isEmpty() || !node.arguments.tail.isEmpty()) { 1976 if (node.arguments.isEmpty() || !node.arguments.tail.isEmpty()) {
1976 compiler.cancel('Exactly one argument required', node: node.arguments); 1977 compiler.cancel('Exactly one argument required',
1978 node: node.argumentsNode);
1977 } 1979 }
1978 Node closure = node.arguments.head; 1980 Node closure = node.arguments.head;
1979 Element element = elements[closure]; 1981 Element element = elements[closure];
1980 if (!Elements.isStaticOrTopLevelFunction(element)) { 1982 if (!Elements.isStaticOrTopLevelFunction(element)) {
1981 compiler.cancel( 1983 compiler.cancel(
1982 'JS_TO_CLOSURE requires a static or top-level method', 1984 'JS_TO_CLOSURE requires a static or top-level method',
1983 node: closure); 1985 node: closure);
1984 } 1986 }
1985 FunctionElement function = element; 1987 FunctionElement function = element;
1986 FunctionParameters parameters = element.computeParameters(compiler); 1988 FunctionParameters parameters = function.computeParameters(compiler);
1987 if (parameters.optionalParameterCount !== 0) { 1989 if (parameters.optionalParameterCount !== 0) {
1988 compiler.cancel( 1990 compiler.cancel(
1989 'JS_TO_CLOSURE does not handle closure with optional parameters', 1991 'JS_TO_CLOSURE does not handle closure with optional parameters',
1990 node: closure); 1992 node: closure);
1991 } 1993 }
1992 visit(closure); 1994 visit(closure);
1993 List<HInstruction> inputs = <HInstruction>[pop()]; 1995 List<HInstruction> inputs = <HInstruction>[pop()];
1994 String invocationName = compiler.namer.closureInvocationName( 1996 String invocationName = compiler.namer.closureInvocationName(
1995 new Selector(SelectorKind.INVOCATION, 1997 new Selector(SelectorKind.INVOCATION,
1996 parameters.requiredParameterCount)); 1998 parameters.requiredParameterCount));
(...skipping 28 matching lines...) Expand all
2025 Element element = elements[node]; 2027 Element element = elements[node];
2026 if (element === null) { 2028 if (element === null) {
2027 ClassElement cls = work.element.getEnclosingClass(); 2029 ClassElement cls = work.element.getEnclosingClass();
2028 element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); 2030 element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD);
2029 HStatic target = new HStatic(element); 2031 HStatic target = new HStatic(element);
2030 add(target); 2032 add(target);
2031 HInstruction self = localsHandler.readThis(); 2033 HInstruction self = localsHandler.readThis();
2032 Identifier identifier = node.selector.asIdentifier(); 2034 Identifier identifier = node.selector.asIdentifier();
2033 String name = identifier.source.slowToString(); 2035 String name = identifier.source.slowToString();
2034 // TODO(ahe): Add the arguments to this list. 2036 // TODO(ahe): Add the arguments to this list.
2035 push(new HLiteralList([], true)); 2037 push(new HLiteralList([]));
2036 var inputs = <HInstruction>[ 2038 var inputs = <HInstruction>[
2037 target, 2039 target,
2038 self, 2040 self,
2039 graph.addConstantString(new DartString.literal(name)), 2041 graph.addConstantString(new DartString.literal(name)),
2040 pop()]; 2042 pop()];
2041 push(new HInvokeSuper(const Selector(SelectorKind.INVOCATION, 2), 2043 push(new HInvokeSuper(const Selector(SelectorKind.INVOCATION, 2),
2042 inputs)); 2044 inputs));
2043 return; 2045 return;
2044 } 2046 }
2045 HInstruction target = new HStatic(element); 2047 HInstruction target = new HStatic(element);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 return; 2328 return;
2327 } 2329 }
2328 2330
2329 List<HInstruction> inputs = <HInstruction>[]; 2331 List<HInstruction> inputs = <HInstruction>[];
2330 for (Link<Node> link = node.elements.nodes; 2332 for (Link<Node> link = node.elements.nodes;
2331 !link.isEmpty(); 2333 !link.isEmpty();
2332 link = link.tail) { 2334 link = link.tail) {
2333 visit(link.head); 2335 visit(link.head);
2334 inputs.add(pop()); 2336 inputs.add(pop());
2335 } 2337 }
2336 push(new HLiteralList(inputs, node.isConst())); 2338 push(new HLiteralList(inputs));
2337 } 2339 }
2338 2340
2339 visitConditional(Conditional node) { 2341 visitConditional(Conditional node) {
2340 visit(node.condition); 2342 visit(node.condition);
2341 HIf condition = new HIf(popBoolified(), true); 2343 HIf condition = new HIf(popBoolified(), true);
2342 HBasicBlock conditionBlock = close(condition); 2344 HBasicBlock conditionBlock = close(condition);
2343 LocalsHandler savedLocals = new LocalsHandler.from(localsHandler); 2345 LocalsHandler savedLocals = new LocalsHandler.from(localsHandler);
2344 2346
2345 HBasicBlock thenBlock = addNewBlock(); 2347 HBasicBlock thenBlock = addNewBlock();
2346 conditionBlock.addSuccessor(thenBlock); 2348 conditionBlock.addSuccessor(thenBlock);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 return; 2546 return;
2545 } 2547 }
2546 List<HInstruction> inputs = <HInstruction>[]; 2548 List<HInstruction> inputs = <HInstruction>[];
2547 for (Link<Node> link = node.entries.nodes; 2549 for (Link<Node> link = node.entries.nodes;
2548 !link.isEmpty(); 2550 !link.isEmpty();
2549 link = link.tail) { 2551 link = link.tail) {
2550 visit(link.head); 2552 visit(link.head);
2551 inputs.addLast(pop()); 2553 inputs.addLast(pop());
2552 inputs.addLast(pop()); 2554 inputs.addLast(pop());
2553 } 2555 }
2554 HLiteralList keyValuePairs = new HLiteralList(inputs, node.isConst()); 2556 HLiteralList keyValuePairs = new HLiteralList(inputs);
2555 HStatic mapMaker = new HStatic(interceptors.getMapMaker()); 2557 HStatic mapMaker = new HStatic(interceptors.getMapMaker());
2556 add(keyValuePairs); 2558 add(keyValuePairs);
2557 add(mapMaker); 2559 add(mapMaker);
2558 inputs = <HInstruction>[mapMaker, keyValuePairs]; 2560 inputs = <HInstruction>[mapMaker, keyValuePairs];
2559 push(new HInvokeStatic(Selector.INVOCATION_1, inputs)); 2561 push(new HInvokeStatic(Selector.INVOCATION_1, inputs));
2560 } 2562 }
2561 2563
2562 visitLiteralMapEntry(LiteralMapEntry node) { 2564 visitLiteralMapEntry(LiteralMapEntry node) {
2563 visit(node.value); 2565 visit(node.value);
2564 visit(node.key); 2566 visit(node.key);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 */ 2876 */
2875 HInstruction prefix = null; 2877 HInstruction prefix = null;
2876 2878
2877 StringBuilderVisitor(this.builder, this.offset); 2879 StringBuilderVisitor(this.builder, this.offset);
2878 2880
2879 void visit(Node node) { 2881 void visit(Node node) {
2880 node.accept(this); 2882 node.accept(this);
2881 } 2883 }
2882 2884
2883 visitNode(Node node) { 2885 visitNode(Node node) {
2884 compiler.internalError('unexpected node', node: node); 2886 builder.compiler.internalError('unexpected node', node: node);
2885 } 2887 }
2886 2888
2887 void visitExpression(Node node) { 2889 void visitExpression(Node node) {
2888 flushLiterals(); 2890 flushLiterals();
2889 node.accept(builder); 2891 node.accept(builder);
2890 HInstruction asString = buildToString(node, builder.pop()); 2892 HInstruction asString = buildToString(node, builder.pop());
2891 prefix = concat(prefix, asString); 2893 prefix = concat(prefix, asString);
2892 } 2894 }
2893 2895
2894 void visitLiteralNull(LiteralNull node) { 2896 void visitLiteralNull(LiteralNull node) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2997 false, 2999 false,
2998 <HInstruction>[target, input])); 3000 <HInstruction>[target, input]));
2999 return builder.pop(); 3001 return builder.pop();
3000 } 3002 }
3001 3003
3002 HInstruction result() { 3004 HInstruction result() {
3003 flushLiterals(); 3005 flushLiterals();
3004 return prefix; 3006 return prefix;
3005 } 3007 }
3006 } 3008 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698