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

Unified Diff: lib/compiler/implementation/ssa/bailout.dart

Issue 10534109: Use simple loop tracking instead of size to determine if (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comment. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/ssa/bailout.dart
diff --git a/lib/compiler/implementation/ssa/bailout.dart b/lib/compiler/implementation/ssa/bailout.dart
index 94975e54acac68de545b01b9f3b57bf27baadfc3..ace3724dafde7c7d6eda2c6739966543aac88d86 100644
--- a/lib/compiler/implementation/ssa/bailout.dart
+++ b/lib/compiler/implementation/ssa/bailout.dart
@@ -81,12 +81,10 @@ class Environment {
* inconsistent way. No further analysis should rely on them.
*/
class SsaTypeGuardInserter extends HGraphVisitor implements OptimizationPhase {
- static final int SMALL_METHOD_BLOCK_LIMIT = 5;
-
final Compiler compiler;
final String name = 'SsaTypeGuardInserter';
final WorkItem work;
- bool smallMethodNoLoops = false;
+ bool calledInLoop = false;
bool isRecursiveMethod = false;
int stateId = 1;
@@ -94,15 +92,7 @@ class SsaTypeGuardInserter extends HGraphVisitor implements OptimizationPhase {
void visitGraph(HGraph graph) {
isRecursiveMethod = graph.isRecursiveMethod;
- var blocks = graph.blocks;
- if (blocks.length < SMALL_METHOD_BLOCK_LIMIT) {
- smallMethodNoLoops = true;
- for (var i = 0; i < blocks.length; i++) {
- if (blocks[i].enclosingLoopHeader !== null) {
- smallMethodNoLoops = false;
- }
- }
- }
+ calledInLoop = graph.calledInLoop;
work.guards = <HTypeGuard>[];
visitDominatorTree(graph);
}
@@ -163,14 +153,9 @@ class SsaTypeGuardInserter extends HGraphVisitor implements OptimizationPhase {
if (isNested(userLoopHeader, currentLoopHeader)) return true;
}
- // Insert type guards for small methods with no loops and multiple
- // uses. These are expected to be helper methods that could
- // benefit from type guards. If there is a loop, we expect the
- // loop to take most of the time and that inserting a type guard
- // for something not used in the loop will not be valuable.
- if (smallMethodNoLoops && instruction.usedBy.length > 2) return true;
-
- return false;
+ // Insert type guards if the method is likely to be called in a
+ // loop.
+ return calledInLoop;
}
bool shouldInsertTypeGuard(HInstruction instruction) {

Powered by Google App Engine
This is Rietveld 408576698