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

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

Issue 10383062: Avoid inserting new temporaries because of HTypeConversion nodes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
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 /** 5 /**
6 * Instead of emitting each SSA instruction with a temporary variable 6 * Instead of emitting each SSA instruction with a temporary variable
7 * mark instructions that can be emitted at their use-site. 7 * mark instructions that can be emitted at their use-site.
8 * For example, in: 8 * For example, in:
9 * t0 = 4; 9 * t0 = 4;
10 * t1 = 3; 10 * t1 = 3;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 void visitIs(HIs instruction) {} 47 void visitIs(HIs instruction) {}
48 48
49 // A check method must not have its input generate at use site, 49 // A check method must not have its input generate at use site,
50 // because it's using it multiple times. 50 // because it's using it multiple times.
51 void visitCheck(HCheck instruction) {} 51 void visitCheck(HCheck instruction) {}
52 52
53 // A type guard should not generate its input at use site, otherwise 53 // A type guard should not generate its input at use site, otherwise
54 // they would not be alive. 54 // they would not be alive.
55 void visitTypeGuard(HTypeGuard instruction) {} 55 void visitTypeGuard(HTypeGuard instruction) {}
56 56
57 // TODO(ngeoffray): This should not be needed. The codegen should 57 void visitTypeConversion(HTypeConversion instruction) {
58 // cope better with this instruction. 58 if (!instruction.checked) generateAtUseSite.add(instruction);
59 void visitTypeConversion(HTypeConversion instruction) {} 59 visitInstruction(instruction);
60 }
60 61
61 void tryGenerateAtUseSite(HInstruction instruction) { 62 void tryGenerateAtUseSite(HInstruction instruction) {
62 // A type guard should never be generate at use site, otherwise we 63 if (instruction.isControlFlow()) return;
63 // cannot bailout.
64 if (instruction is HTypeGuard) return;
65
66 // A check should never be generate at use site, otherwise we
67 // cannot throw.
68 if (instruction is HCheck) return;
69
70 // TODO(ngeoffray): This should not be needed. The codegen should
71 // cope better with this instruction.
72 if (instruction is HTypeConversion) return;
73
74 generateAtUseSite.add(instruction); 64 generateAtUseSite.add(instruction);
75 } 65 }
76 66
77 bool isBlockSinglePredecessor(HBasicBlock block) { 67 bool isBlockSinglePredecessor(HBasicBlock block) {
78 return block.successors.length === 1 68 return block.successors.length === 1
79 && block.successors[0].predecessors.length === 1; 69 && block.successors[0].predecessors.length === 1;
80 } 70 }
81 71
82 void visitBasicBlock(HBasicBlock block) { 72 void visitBasicBlock(HBasicBlock block) {
83 // Compensate from not merging blocks: if the block is the 73 // Compensate from not merging blocks: if the block is the
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 // improving the performance of future lookups. 486 // improving the performance of future lookups.
497 T root = getRepresentative(parent); 487 T root = getRepresentative(parent);
498 if (root !== parent) representative[element] = root; 488 if (root !== parent) representative[element] = root;
499 return root; 489 return root;
500 } 490 }
501 491
502 bool areEquivalent(T a, T b) { 492 bool areEquivalent(T a, T b) {
503 return getRepresentative(a) === getRepresentative(b); 493 return getRepresentative(a) === getRepresentative(b);
504 } 494 }
505 } 495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698