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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/nodes.dart

Issue 15917017: Don't let HCheck instructions prevent GVN. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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: sdk/lib/_internal/compiler/implementation/ssa/nodes.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/nodes.dart (revision 23842)
+++ sdk/lib/_internal/compiler/implementation/ssa/nodes.dart (working copy)
@@ -621,7 +621,9 @@
void rewriteWithBetterUser(HInstruction from, HInstruction to) {
Link<HCheck> better = const Link<HCheck>();
for (HInstruction user in to.usedBy) {
- if (user is HCheck && identical((user as HCheck).checkedInput, to)) {
+ if (user == from || user is! HCheck) continue;
+ HCheck check = user;
+ if (check.checkedInput == to) {
better = better.prepend(user);
}
}
@@ -819,6 +821,10 @@
&& !canThrow();
}
+ // Overridden by [HCheck] to return the actual non-[HCheck]
+ // instruction it checks against.
+ HInstruction nonCheck() => this;
+
// Can this node throw an exception?
bool canThrow() => false;
@@ -901,7 +907,9 @@
final List<HInstruction> otherInputs = other.inputs;
if (inputsLength != otherInputs.length) return false;
for (int i = 0; i < inputsLength; i++) {
- if (!identical(inputs[i], otherInputs[i])) return false;
+ if (!identical(inputs[i].nonCheck(), otherInputs[i].nonCheck())) {
+ return false;
+ }
}
// Check that the data in the instruction matches.
return dataEquals(other);
@@ -911,7 +919,7 @@
int result = typeCode();
int length = inputs.length;
for (int i = 0; i < length; i++) {
- result = (result * 19) + (inputs[i].id) + (result >> 7);
+ result = (result * 19) + (inputs[i].nonCheck().id) + (result >> 7);
}
return result;
}
@@ -1158,11 +1166,7 @@
bool isJsStatement() => true;
bool canThrow() => true;
- HInstruction unwrap() {
- var checked = checkedInput;
- while (checked is HCheck) checked = checked.checkedInput;
- return checked;
- }
+ HInstruction nonCheck() => checkedInput.nonCheck();
}
class HBailoutTarget extends HInstruction {
@@ -1320,7 +1324,11 @@
int typeCode() => HInstruction.INVOKE_DYNAMIC_TYPECODE;
bool typeEquals(other) => other is HInvokeDynamic;
bool dataEquals(HInvokeDynamic other) {
- return selector == other.selector && element == other.element;
+ // Use the name and the kind instead of [Selector.operator==]
+ // because we don't need to check the arity (already checked in
+ // [gvnEquals]), and the receiver types may not be in sync.
+ return selector.name == other.selector.name
+ && selector.kind == other.selector.kind;
}
}

Powered by Google App Engine
This is Rietveld 408576698