Reviewers: Lasse Reichstein,

Message:
Lasse,

may you have a look?

If it's fine, I'd bring it to trunk.

Description:
Fix one off error.

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

Please review this at http://codereview.chromium.org/1709001/show

Affected files:
  M src/runtime.cc
  M test/mjsunit/string-search.js


Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 67d60e15693227d25f818fd0cf45403a05d97207..fb54faef129abdfed4a8d7b359248732db81380d 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -10095,8 +10095,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 + 2;
+    if (target_index == cache->length()) {
+      target_index = JSFunctionResultCache::kEntriesIndex;
+    }
     return CacheMiss(cache, target_index, key);
   }
 }
Index: test/mjsunit/string-search.js
diff --git a/test/mjsunit/string-search.js b/test/mjsunit/string-search.js
index 36891c24cb6efd23023093d7960e14f893a80848..4de17bca23af81490aedca1fbac2f04ffffc9d16 100644
--- a/test/mjsunit/string-search.js
+++ b/test/mjsunit/string-search.js
@@ -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

Reply via email to