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

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

Issue 54293008: Set runtime type on list and map literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
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 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 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 2017
2018 void push(HInstruction instruction) { 2018 void push(HInstruction instruction) {
2019 add(instruction); 2019 add(instruction);
2020 stack.add(instruction); 2020 stack.add(instruction);
2021 } 2021 }
2022 2022
2023 void pushWithPosition(HInstruction instruction, Node node) { 2023 void pushWithPosition(HInstruction instruction, Node node) {
2024 push(attachPosition(instruction, node)); 2024 push(attachPosition(instruction, node));
2025 } 2025 }
2026 2026
2027 HInstruction peek() => stack.last;
2028
2027 HInstruction pop() { 2029 HInstruction pop() {
2028 return stack.removeLast(); 2030 return stack.removeLast();
2029 } 2031 }
2030 2032
2031 void dup() { 2033 void dup() {
2032 stack.add(stack.last); 2034 stack.add(stack.last);
2033 } 2035 }
2034 2036
2035 HInstruction popBoolified() { 2037 HInstruction popBoolified() {
2036 HInstruction value = pop(); 2038 HInstruction value = pop();
(...skipping 2457 matching lines...) Expand 10 before | Expand all | Expand 10 after
4494 HInstruction initialValue = graph.addConstantNull(compiler); 4496 HInstruction initialValue = graph.addConstantNull(compiler);
4495 localsHandler.updateLocal(elements[definition], initialValue); 4497 localsHandler.updateLocal(elements[definition], initialValue);
4496 } else { 4498 } else {
4497 assert(definition is SendSet); 4499 assert(definition is SendSet);
4498 visitSendSet(definition); 4500 visitSendSet(definition);
4499 pop(); // Discard value. 4501 pop(); // Discard value.
4500 } 4502 }
4501 } 4503 }
4502 } 4504 }
4503 4505
4506 void setRtiIfNeeded(HInstruction object, Node node) {
4507 InterfaceType type = elements.getType(node);
4508 if (!backend.classNeedsRti(type.element)) return;
4509 List<HInstruction> arguments = <HInstruction>[];
4510 for (DartType argument in type.typeArguments) {
4511 arguments.add(analyzeTypeArgument(argument));
4512 }
4513 print(arguments);
kasperl 2013/11/01 10:30:57 Get rid of the printing.
karlklose 2013/11/01 10:35:01 Done.
4514 callSetRuntimeTypeInfo(type.element, arguments, object);
4515 }
4516
4504 visitLiteralList(LiteralList node) { 4517 visitLiteralList(LiteralList node) {
4505 HInstruction instruction; 4518 HInstruction instruction;
4506 4519
4507 if (node.isConst()) { 4520 if (node.isConst()) {
4508 instruction = addConstant(node); 4521 instruction = addConstant(node);
4509 } else { 4522 } else {
4510 List<HInstruction> inputs = <HInstruction>[]; 4523 List<HInstruction> inputs = <HInstruction>[];
4511 for (Link<Node> link = node.elements.nodes; 4524 for (Link<Node> link = node.elements.nodes;
4512 !link.isEmpty; 4525 !link.isEmpty;
4513 link = link.tail) { 4526 link = link.tail) {
4514 visit(link.head); 4527 visit(link.head);
4515 inputs.add(pop()); 4528 inputs.add(pop());
4516 } 4529 }
4517 instruction = buildLiteralList(inputs); 4530 instruction = buildLiteralList(inputs);
4518 add(instruction); 4531 add(instruction);
4532 setRtiIfNeeded(instruction, node);
4519 } 4533 }
4520 4534
4521 HType type = new HType.inferredForNode(currentElement, node, compiler); 4535 HType type = new HType.inferredForNode(currentElement, node, compiler);
4522 if (!type.containsAll(compiler)) instruction.instructionType = type; 4536 if (!type.containsAll(compiler)) instruction.instructionType = type;
4523 stack.add(instruction); 4537 stack.add(instruction);
4524 } 4538 }
4525 4539
4526 visitConditional(Conditional node) { 4540 visitConditional(Conditional node) {
4527 SsaBranchBuilder brancher = new SsaBranchBuilder(this, node); 4541 SsaBranchBuilder brancher = new SsaBranchBuilder(this, node);
4528 brancher.handleConditional(() => visit(node.condition), 4542 brancher.handleConditional(() => visit(node.condition),
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
4710 !link.isEmpty; 4724 !link.isEmpty;
4711 link = link.tail) { 4725 link = link.tail) {
4712 visit(link.head); 4726 visit(link.head);
4713 inputs.add(pop()); 4727 inputs.add(pop());
4714 inputs.add(pop()); 4728 inputs.add(pop());
4715 } 4729 }
4716 HLiteralList keyValuePairs = buildLiteralList(inputs); 4730 HLiteralList keyValuePairs = buildLiteralList(inputs);
4717 add(keyValuePairs); 4731 add(keyValuePairs);
4718 HType mapType = new HType.nonNullSubtype(backend.mapLiteralClass, compiler); 4732 HType mapType = new HType.nonNullSubtype(backend.mapLiteralClass, compiler);
4719 pushInvokeStatic(node, backend.getMapMaker(), [keyValuePairs], mapType); 4733 pushInvokeStatic(node, backend.getMapMaker(), [keyValuePairs], mapType);
4734 setRtiIfNeeded(peek(), node);
4720 } 4735 }
4721 4736
4722 visitLiteralMapEntry(LiteralMapEntry node) { 4737 visitLiteralMapEntry(LiteralMapEntry node) {
4723 visit(node.value); 4738 visit(node.value);
4724 visit(node.key); 4739 visit(node.key);
4725 } 4740 }
4726 4741
4727 visitNamedArgument(NamedArgument node) { 4742 visitNamedArgument(NamedArgument node) {
4728 visit(node.expression); 4743 visit(node.expression);
4729 } 4744 }
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
5726 new HSubGraphBlockInformation(elseBranch.graph)); 5741 new HSubGraphBlockInformation(elseBranch.graph));
5727 5742
5728 HBasicBlock conditionStartBlock = conditionBranch.block; 5743 HBasicBlock conditionStartBlock = conditionBranch.block;
5729 conditionStartBlock.setBlockFlow(info, joinBlock); 5744 conditionStartBlock.setBlockFlow(info, joinBlock);
5730 SubGraph conditionGraph = conditionBranch.graph; 5745 SubGraph conditionGraph = conditionBranch.graph;
5731 HIf branch = conditionGraph.end.last; 5746 HIf branch = conditionGraph.end.last;
5732 assert(branch is HIf); 5747 assert(branch is HIf);
5733 branch.blockInformation = conditionStartBlock.blockFlow; 5748 branch.blockInformation = conditionStartBlock.blockFlow;
5734 } 5749 }
5735 } 5750 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698