Skip to content

Commit d8f5970

Browse files
rakudramacommit-bot@chromium.org
authored andcommitted
[dart2js] prepare validator for k-limiting
A few tests have huge methods where an instruction is used tens of thousands of times. We can probably k-limit the validation in assertion mode to a few thousand and greatly speed up those tests. When I added k-limiting for an infeasibly large k, the program got faster for no good reason, so I'm making this change as a baseline for filing an issue on the VM optimizer. Change-Id: I708d08be20652820b6ba878919ffcc6947a53b3d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112490 Reviewed-by: Nicholas Shahan <[email protected]> Commit-Queue: Stephen Adams <[email protected]>
1 parent 15a3bf8 commit d8f5970

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pkg/compiler/lib/src/ssa/validate.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ class HValidator extends HInstructionVisitor {
133133
super.visitBasicBlock(block);
134134
}
135135

136-
/// Returns how often [instruction] is contained in [instructions].
137-
static int countInstruction(
138-
List<HInstruction> instructions, HInstruction instruction) {
136+
/// Verifies [instruction] is contained in [instructions] [count] times.
137+
static bool checkInstructionCount(
138+
List<HInstruction> instructions, HInstruction instruction, int count) {
139139
int result = 0;
140140
for (int i = 0; i < instructions.length; i++) {
141141
if (identical(instructions[i], instruction)) result++;
142142
}
143-
return result;
143+
return result == count;
144144
}
145145

146146
/// Returns true if the predicate returns true for every instruction in the
@@ -173,9 +173,9 @@ class HValidator extends HInstructionVisitor {
173173
return everyInstruction(instruction.inputs, (input, count) {
174174
if (inBasicBlock) {
175175
return input.isInBasicBlock() &&
176-
countInstruction(input.usedBy, instruction) == count;
176+
checkInstructionCount(input.usedBy, instruction, count);
177177
} else {
178-
return countInstruction(input.usedBy, instruction) == 0;
178+
return checkInstructionCount(input.usedBy, instruction, 0);
179179
}
180180
});
181181
}
@@ -185,7 +185,7 @@ class HValidator extends HInstructionVisitor {
185185
if (!instruction.isInBasicBlock()) return true;
186186
return everyInstruction(instruction.usedBy, (use, count) {
187187
return use.isInBasicBlock() &&
188-
countInstruction(use.inputs, instruction) == count;
188+
checkInstructionCount(use.inputs, instruction, count);
189189
});
190190
}
191191

0 commit comments

Comments
 (0)