From 1bc04768a93af89717658e3f2e138b9f70b34464 Mon Sep 17 00:00:00 2001 From: "antonm@chromium.org" Date: Fri, 5 Mar 2010 15:07:53 +0000 Subject: [PATCH] An attempt to fix the tests. TBR=sgjesse@chromium.org Review URL: http://codereview.chromium.org/669162 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4042 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/builtins.cc | 19 ++++++++++--------- test/mjsunit/array-splice.js | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/builtins.cc b/src/builtins.cc index 46c3748..0004440 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -665,8 +665,6 @@ BUILTIN(ArraySplice) { // we should never hit this case. ASSERT((item_count - actual_delete_count) <= (Smi::kMaxValue - len)); - FixedArray* source_elms = elms; - // Check if array need to grow. if (new_length > elms->length()) { // New backing storage is needed. @@ -678,18 +676,21 @@ BUILTIN(ArraySplice) { AssertNoAllocation no_gc; // Copy the part before actual_start as is. CopyElements(&no_gc, new_elms, 0, elms, 0, actual_start); + CopyElements(&no_gc, + new_elms, actual_start + item_count, + elms, actual_start + actual_delete_count, + (len - actual_delete_count - actual_start)); FillWithHoles(new_elms, new_length, capacity); - source_elms = elms; elms = new_elms; array->set_elements(elms); + } else { + AssertNoAllocation no_gc; + MoveElements(&no_gc, + elms, actual_start + item_count, + elms, actual_start + actual_delete_count, + (len - actual_delete_count - actual_start)); } - - AssertNoAllocation no_gc; - MoveElements(&no_gc, - elms, actual_start + item_count, - source_elms, actual_start + actual_delete_count, - (len - actual_delete_count - actual_start)); } AssertNoAllocation no_gc; diff --git a/test/mjsunit/array-splice.js b/test/mjsunit/array-splice.js index 887097d..dda53a0 100644 --- a/test/mjsunit/array-splice.js +++ b/test/mjsunit/array-splice.js @@ -31,13 +31,13 @@ var array = new Array(10); var spliced = array.splice(1, 1, 'one', 'two'); assertEquals(1, spliced.length); - assertFalse(0 in spliced, "0 in spliced"); + assertFalse(0 in spliced, "0 in spliced: " + spliced); assertEquals(11, array.length); - assertFalse(0 in array, "0 in array"); + assertFalse(0 in array, "0 in array: " + array); assertTrue(1 in array); assertTrue(2 in array); - assertFalse(3 in array, "3 in array"); + assertFalse(3 in array, "3 in array: " + array); } })(); -- 2.7.4