Fix one off error.

Proper condition to start eviction is when next possible index is equal
to cache length.

Review URL: http://codereview.chromium.org/1709001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4460 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
antonm@chromium.org 2010-04-21 11:13:53 +00:00
parent e9f818b242
commit 0710de75c0
3 changed files with 16 additions and 2 deletions

View File

@ -2322,6 +2322,8 @@ class JSFunctionResultCache: public FixedArray {
static const int kCacheSizeIndex = kFingerIndex + 1;
static const int kDummyIndex = kCacheSizeIndex + 1;
static const int kEntriesIndex = kDummyIndex + 1;
static const int kEntrySize = 2; // key + value
};

View File

@ -10101,8 +10101,10 @@ static Object* Runtime_GetFromCache(Arguments args) {
cache->set(JSFunctionResultCache::kCacheSizeIndex, Smi::FromInt(size + 2));
return CacheMiss(cache, size, key);
} else {
int target_index = (finger_index < cache->length()) ?
finger_index + 2 : JSFunctionResultCache::kEntriesIndex;
int target_index = finger_index + JSFunctionResultCache::kEntrySize;
if (target_index == cache->length()) {
target_index = JSFunctionResultCache::kEntriesIndex;
}
return CacheMiss(cache, target_index, key);
}
}

View File

@ -28,3 +28,13 @@
var str="ABC abc";
var r = str.search('a');
assertEquals(r, 4);
// Test for a lot of different string.
var s = "";
for (var i = 0; i < 100; i++) {
s += i;
var r = s.search(s);
assertEquals(0, r);
}