Removing a wrong check.
A strings which represents an array index with length 8 and 9 digits do not pass this check. However generated hash is valid. Review URL: http://codereview.chromium.org/3295017 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5420 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
7368ce808e
commit
e54ad9ee86
@ -4988,17 +4988,20 @@ bool String::SlowAsArrayIndex(uint32_t* index) {
|
||||
}
|
||||
|
||||
|
||||
uint32_t StringHasher::MakeCachedArrayIndex(uint32_t value, int length) {
|
||||
value <<= String::kHashShift;
|
||||
uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
|
||||
// For array indexes mix the length into the hash as an array index could
|
||||
// be zero.
|
||||
ASSERT(length > 0);
|
||||
ASSERT(length <= String::kMaxArrayIndexSize);
|
||||
ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
|
||||
(1 << String::kArrayIndexValueBits));
|
||||
ASSERT(String::kMaxArrayIndexSize < (1 << String::kArrayIndexValueBits));
|
||||
value &= ~String::kIsNotArrayIndexMask;
|
||||
|
||||
value <<= String::kHashShift;
|
||||
value |= length << String::kArrayIndexHashLengthShift;
|
||||
|
||||
ASSERT((value & String::kIsNotArrayIndexMask) == 0);
|
||||
ASSERT((length > String::kMaxCachedArrayIndexLength) ||
|
||||
(value & String::kContainsCachedArrayIndexMask) == 0);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -5007,7 +5010,7 @@ uint32_t StringHasher::GetHashField() {
|
||||
ASSERT(is_valid());
|
||||
if (length_ <= String::kMaxHashCalcLength) {
|
||||
if (is_array_index()) {
|
||||
return MakeCachedArrayIndex(array_index(), length_);
|
||||
return MakeArrayIndexHash(array_index(), length_);
|
||||
}
|
||||
return (GetHash() << String::kHashShift) | String::kIsNotArrayIndexMask;
|
||||
} else {
|
||||
|
@ -4223,7 +4223,7 @@ class StringHasher {
|
||||
// Calculated hash value for a string consisting of 1 to
|
||||
// String::kMaxArrayIndexSize digits with no leading zeros (except "0").
|
||||
// value is represented decimal value.
|
||||
static uint32_t MakeCachedArrayIndex(uint32_t value, int length);
|
||||
static uint32_t MakeArrayIndexHash(uint32_t value, int length);
|
||||
|
||||
private:
|
||||
|
||||
@ -4467,6 +4467,7 @@ class String: public HeapObject {
|
||||
kBitsPerInt - kArrayIndexValueBits - kNofHashBitFields;
|
||||
|
||||
STATIC_CHECK((kArrayIndexLengthBits > 0));
|
||||
STATIC_CHECK(kMaxArrayIndexSize < (1 << kArrayIndexLengthBits));
|
||||
|
||||
static const int kArrayIndexHashLengthShift =
|
||||
kArrayIndexValueBits + kNofHashBitFields;
|
||||
|
@ -4677,9 +4677,8 @@ static Object* Runtime_StringToNumber(Arguments args) {
|
||||
(len == 1 || data[0] != '0')) {
|
||||
// String hash is not calculated yet but all the data are present.
|
||||
// Update the hash field to speed up sequential convertions.
|
||||
uint32_t hash = StringHasher::MakeCachedArrayIndex(d, len);
|
||||
uint32_t hash = StringHasher::MakeArrayIndexHash(d, len);
|
||||
#ifdef DEBUG
|
||||
ASSERT((hash & String::kContainsCachedArrayIndexMask) == 0);
|
||||
subject->Hash(); // Force hash calculation.
|
||||
ASSERT_EQ(static_cast<int>(subject->hash_field()),
|
||||
static_cast<int>(hash));
|
||||
|
@ -203,3 +203,7 @@ assertTrue(isNaN(toNumber("Infinity junk")), "Infinity junk");
|
||||
assertTrue(isNaN(toNumber("1e")), "1e");
|
||||
assertTrue(isNaN(toNumber("1e ")), "1e_");
|
||||
assertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk");
|
||||
|
||||
for (var i = 1; i < 12; i++) {
|
||||
assertEquals(toNumber('1' + repeat('0', i)), Math.pow(10.0, i));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user