Reviewers: Jakob,
Message:
PTAL.
Description:
Fix HConstant's hash function for smis on x64.
BUG=
TEST=
Please review this at http://codereview.chromium.org/9466003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen-instructions.h
M test/mjsunit/mjsunit.status
M test/mjsunit/regress/regress-1969.js
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
011529d6cdfd94f85f2029b93e93ee07333d6e19..1ad3e0cb4834467a9743312d59993cc91d980880
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -2457,7 +2457,11 @@ class HConstant: public HTemplateInstruction<0> {
virtual intptr_t Hashcode() {
ASSERT(!HEAP->allow_allocation(false));
- return reinterpret_cast<intptr_t>(*handle());
+ intptr_t hash = reinterpret_cast<intptr_t>(*handle());
+ // Prevent smis from having fewer hash values when truncated to
+ // the least significant bits.
+ const int kShiftSize = kSmiShiftSize + kSmiTagSize;
+ return hash ^ (hash >> kShiftSize);
}
#ifdef DEBUG
Index: test/mjsunit/mjsunit.status
diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status
index
60310bba2eb75c20276fff45d968a21fb8deadfe..a1b927097a0d171154baa4c8c526b3e0c5a530c3
100644
--- a/test/mjsunit/mjsunit.status
+++ b/test/mjsunit/mjsunit.status
@@ -66,7 +66,7 @@ debug-liveedit-check-stack: SKIP
debug-liveedit-patch-positions-replace: SKIP
# Test Crankshaft compilation time. Expected to take too long in debug
mode.
-regress/regress-1969: PASS, SKIP if ($mode == debug || $arch == x64)
+regress/regress-1969: PASS, SKIP if $mode == debug
##############################################################################
[ $isolates ]
Index: test/mjsunit/regress/regress-1969.js
diff --git a/test/mjsunit/regress/regress-1969.js
b/test/mjsunit/regress/regress-1969.js
index
ea836ea29a449ca390d8d39f4d6232019e1cb033..2728c2cae76901207e716681fb84e468ae2220fa
100644
--- a/test/mjsunit/regress/regress-1969.js
+++ b/test/mjsunit/regress/regress-1969.js
@@ -31,12 +31,14 @@ f();
f();
%OptimizeFunctionOnNextCall(f);
var start = (new Date()).getTime();
-f();
+var array = f();
var end = (new Date()).getTime();
// Assert that recompiling and executing f() takes less than a second.
assertTrue((end - start) < 1000);
+for (var i = 0; i < 5000; i++) assertEquals(0, array[i]);
+
function f() {
var a = new Array(5000);
a[0]=0;
@@ -162,7 +164,7 @@ function f() {
a[120]=0;
a[121]=0;
a[122]=0;
- a[0]=0;
+ a[123]=0;
a[124]=0;
a[125]=0;
a[126]=0;
@@ -1162,7 +1164,7 @@ function f() {
a[1120]=0;
a[1121]=0;
a[1122]=0;
- a[10]=0;
+ a[1123]=0;
a[1124]=0;
a[1125]=0;
a[1126]=0;
@@ -1269,16 +1271,16 @@ function f() {
a[1227]=0;
a[1228]=0;
a[1229]=0;
- a[00]=0;
- a[01]=0;
- a[02]=0;
- a[03]=0;
- a[04]=0;
- a[05]=0;
- a[06]=0;
- a[07]=0;
- a[08]=0;
- a[09]=0;
+ a[1230]=0;
+ a[1231]=0;
+ a[1232]=0;
+ a[1233]=0;
+ a[1234]=0;
+ a[1235]=0;
+ a[1236]=0;
+ a[1237]=0;
+ a[1238]=0;
+ a[1239]=0;
a[1240]=0;
a[1241]=0;
a[1242]=0;
@@ -2162,7 +2164,7 @@ function f() {
a[2120]=0;
a[2121]=0;
a[2122]=0;
- a[20]=0;
+ a[2123]=0;
a[2124]=0;
a[2125]=0;
a[2126]=0;
@@ -3162,7 +3164,7 @@ function f() {
a[3120]=0;
a[3121]=0;
a[3122]=0;
- a[30]=0;
+ a[3123]=0;
a[3124]=0;
a[3125]=0;
a[3126]=0;
@@ -4162,7 +4164,7 @@ function f() {
a[4120]=0;
a[4121]=0;
a[4122]=0;
- a[40]=0;
+ a[4123]=0;
a[4124]=0;
a[4125]=0;
a[4126]=0;
@@ -5039,4 +5041,5 @@ function f() {
a[4997]=0;
a[4998]=0;
a[4999]=0;
+ return a;
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev