Fix for issue 95.
authorolehougaard <olehougaard@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 26 Sep 2008 09:15:02 +0000 (09:15 +0000)
committerolehougaard <olehougaard@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 26 Sep 2008 09:15:02 +0000 (09:15 +0000)
Fixed QuickSort so it doesn't overflow the stack with non-reflexsive comparison functions.
Review URL: http://codereview.chromium.org/4297

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@382 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/array.js
test/mozilla/mozilla.status

index 396e5e8..3d32c18 100644 (file)
@@ -672,8 +672,10 @@ function ArraySort(comparefn) {
     if (from >= to - 1) return;
     var pivot_index = $floor($random() * (to - from)) + from;
     var pivot = a[pivot_index];
+    a[pivot_index] = a[to - 1];
+    a[to - 1] = pivot;
     var low_end = from;   // Upper bound of the elements lower than pivot.
-    var high_start = to; // Lower bound of the elements greater than pivot.
+    var high_start = to - 1; // Lower bound of the elements greater than pivot.
     for (var i = from; i < high_start; ) {
       var element = a[i];
       var order = Compare(element, pivot);
@@ -690,6 +692,9 @@ function ArraySort(comparefn) {
         i++;
       }
     }
+    a[to - 1] = a[high_start];
+    a[high_start] = pivot;
+    high_start++;
     QuickSort(a, from, low_end);
     QuickSort(a, high_start, to);
   }
index 681b5f0..b43ea17 100644 (file)
@@ -45,8 +45,6 @@
 prefix mozilla
 def FAIL_OK = FAIL, OKAY
 
-js1_5/Array/regress-360681-01: FAIL
-
 ##################### SKIPPED TESTS #####################
 
 # This test checks that we behave properly in an out-of-memory