Reviewers: Jakob,
Description:
Fix unsigned comparisons.
Instead of marking the comparison instruction itself as Uint32, we
look at its arguments. This is more consistent what HChange does.
BUG=v8:3380
TEST=mjsunit/regress/regress-3380
LOG=y
Please review this at https://codereview.chromium.org/325133004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+25, -13 lines):
M src/arm/lithium-codegen-arm.cc
M src/arm64/lithium-codegen-arm64.cc
M src/hydrogen-uint32-analysis.cc
M src/ia32/lithium-codegen-ia32.cc
M src/mips/lithium-codegen-mips.cc
M src/x64/lithium-codegen-x64.cc
M src/x87/lithium-codegen-x87.cc
A + test/mjsunit/regress/regress-3380.js
Index: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index
f852f3de712c45112b351d424c9078e2a1cab2c6..800f67b7172f2eac7ae2f5354e01c4d3b6bc06bf
100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -2371,7 +2371,9 @@ Condition LCodeGen::TokenToCondition(Token::Value op,
bool is_unsigned) {
void LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) {
LOperand* left = instr->left();
LOperand* right = instr->right();
- bool is_unsigned = instr->hydrogen()->CheckFlag(HInstruction::kUint32);
+ bool is_unsigned =
+ instr->hydrogen()->left()->CheckFlag(HInstruction::kUint32) ||
+ instr->hydrogen()->right()->CheckFlag(HInstruction::kUint32);
Condition cond = TokenToCondition(instr->op(), is_unsigned);
if (left->IsConstantOperand() && right->IsConstantOperand()) {
Index: src/arm64/lithium-codegen-arm64.cc
diff --git a/src/arm64/lithium-codegen-arm64.cc
b/src/arm64/lithium-codegen-arm64.cc
index
1ac579f0f61affe622899924404f0725c5783308..f301c8b765853ccc204cd04361757f68ac65f6cd
100644
--- a/src/arm64/lithium-codegen-arm64.cc
+++ b/src/arm64/lithium-codegen-arm64.cc
@@ -2470,7 +2470,9 @@ void
LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) {
void LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) {
LOperand* left = instr->left();
LOperand* right = instr->right();
- bool is_unsigned = instr->hydrogen()->CheckFlag(HInstruction::kUint32);
+ bool is_unsigned =
+ instr->hydrogen()->left()->CheckFlag(HInstruction::kUint32) ||
+ instr->hydrogen()->right()->CheckFlag(HInstruction::kUint32);
Condition cond = TokenToCondition(instr->op(), is_unsigned);
if (left->IsConstantOperand() && right->IsConstantOperand()) {
Index: src/hydrogen-uint32-analysis.cc
diff --git a/src/hydrogen-uint32-analysis.cc
b/src/hydrogen-uint32-analysis.cc
index
ce450a1de84701d00d21294f27b1d664e6b93363..7616f3d46b61a6416a6bc6917b4ed56158b76032
100644
--- a/src/hydrogen-uint32-analysis.cc
+++ b/src/hydrogen-uint32-analysis.cc
@@ -62,7 +62,6 @@ bool HUint32AnalysisPhase::IsSafeUint32Use(HValue* val,
HValue* use) {
}
}
} else if (use->IsCompareNumericAndBranch()) {
- return false; // TODO(svenpanne/3380): Fix and re-enable!
HCompareNumericAndBranch* c = HCompareNumericAndBranch::cast(use);
return IsUint32Operation(c->left()) && IsUint32Operation(c->right());
}
Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc
b/src/ia32/lithium-codegen-ia32.cc
index
ee008a047cb6c874aa77673759a52770680f3573..791faa2660a3517911c2edb926543349408745c9
100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -2247,7 +2247,9 @@ void
LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) {
LOperand* left = instr->left();
LOperand* right = instr->right();
bool is_unsigned =
- instr->is_double() ||
instr->hydrogen()->CheckFlag(HInstruction::kUint32);
+ instr->is_double() ||
+ instr->hydrogen()->left()->CheckFlag(HInstruction::kUint32) ||
+ instr->hydrogen()->right()->CheckFlag(HInstruction::kUint32);
Condition cc = TokenToCondition(instr->op(), is_unsigned);
if (left->IsConstantOperand() && right->IsConstantOperand()) {
Index: src/mips/lithium-codegen-mips.cc
diff --git a/src/mips/lithium-codegen-mips.cc
b/src/mips/lithium-codegen-mips.cc
index
ffc5a7269e73a2aa60a6baba518a7b651e42b783..65fe1aa910f1243650e64e761524d9a8b7ede4da
100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -2279,7 +2279,9 @@ Condition LCodeGen::TokenToCondition(Token::Value op,
bool is_unsigned) {
void LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) {
LOperand* left = instr->left();
LOperand* right = instr->right();
- bool is_unsigned = instr->hydrogen()->CheckFlag(HInstruction::kUint32);
+ bool is_unsigned =
+ instr->hydrogen()->left()->CheckFlag(HInstruction::kUint32) ||
+ instr->hydrogen()->right()->CheckFlag(HInstruction::kUint32);
Condition cond = TokenToCondition(instr->op(), is_unsigned);
if (left->IsConstantOperand() && right->IsConstantOperand()) {
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index
75ba04e48170f0ed94975dc180d28f5cd9625ae3..41321340e01ca4e302e91291bc54e864e47ee647
100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -2238,7 +2238,9 @@ void
LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) {
LOperand* left = instr->left();
LOperand* right = instr->right();
bool is_unsigned =
- instr->is_double() ||
instr->hydrogen()->CheckFlag(HInstruction::kUint32);
+ instr->is_double() ||
+ instr->hydrogen()->left()->CheckFlag(HInstruction::kUint32) ||
+ instr->hydrogen()->right()->CheckFlag(HInstruction::kUint32);
Condition cc = TokenToCondition(instr->op(), is_unsigned);
if (left->IsConstantOperand() && right->IsConstantOperand()) {
Index: src/x87/lithium-codegen-x87.cc
diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc
index
3cb3fab655b0f6228772084c96293022e80eb6cf..1e9168d4bb5c7b58c6dc310dc661877f1856b127
100644
--- a/src/x87/lithium-codegen-x87.cc
+++ b/src/x87/lithium-codegen-x87.cc
@@ -2380,7 +2380,9 @@ void
LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) {
LOperand* left = instr->left();
LOperand* right = instr->right();
bool is_unsigned =
- instr->is_double() ||
instr->hydrogen()->CheckFlag(HInstruction::kUint32);
+ instr->is_double() ||
+ instr->hydrogen()->left()->CheckFlag(HInstruction::kUint32) ||
+ instr->hydrogen()->right()->CheckFlag(HInstruction::kUint32);
Condition cc = TokenToCondition(instr->op(), is_unsigned);
if (left->IsConstantOperand() && right->IsConstantOperand()) {
Index: test/mjsunit/regress/regress-3380.js
diff --git a/test/mjsunit/regress/regress-349885.js
b/test/mjsunit/regress/regress-3380.js
similarity index 62%
copy from test/mjsunit/regress/regress-349885.js
copy to test/mjsunit/regress/regress-3380.js
index
dd3e79526041b0362434608b81429d83e18ae8ef..2fae459b3b46e768e4612359bcdc964350a9d5dd
100644
--- a/test/mjsunit/regress/regress-349885.js
+++ b/test/mjsunit/regress/regress-3380.js
@@ -4,12 +4,13 @@
// Flags: --allow-natives-syntax
-// The bug 349885
-
function foo(a) {
- a[292755462] = new Object();
+ return (a[0] >>> 0) > 0;
}
-foo(new Array(5));
-foo(new Array(5));
+
+var a = new Uint32Array([4]);
+var b = new Uint32Array([0x80000000]);
+assertTrue(foo(a));
+assertTrue(foo(a));
%OptimizeFunctionOnNextCall(foo);
-foo(new Array(10));
+assertTrue(foo(b))
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.