Revision: 4460
Author: [email protected]
Date: Wed Apr 21 04:13:53 2010
Log: 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
http://code.google.com/p/v8/source/detail?r=4460
Modified:
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/mjsunit/string-search.js
=======================================
--- /branches/bleeding_edge/src/objects.h Mon Apr 19 05:39:07 2010
+++ /branches/bleeding_edge/src/objects.h Wed Apr 21 04:13:53 2010
@@ -2322,6 +2322,8 @@
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
};
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Apr 20 06:10:18 2010
+++ /branches/bleeding_edge/src/runtime.cc Wed Apr 21 04:13:53 2010
@@ -10101,8 +10101,10 @@
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);
}
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/string-search.js Tue Sep 9
13:08:45 2008
+++ /branches/bleeding_edge/test/mjsunit/string-search.js Wed Apr 21
04:13:53 2010
@@ -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);
+}
+
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev