Commit 0c77912a authored by antonm@chromium.org's avatar antonm@chromium.org

Return length passed instead of receiver to allow chained assignments like

foo = a.length = 7

BUG=crbug.com/36854

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3979 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b299c619
...@@ -1365,7 +1365,9 @@ Object* StoreIC_ArrayLength(Arguments args) { ...@@ -1365,7 +1365,9 @@ Object* StoreIC_ArrayLength(Arguments args) {
JSObject* receiver = JSObject::cast(args[0]); JSObject* receiver = JSObject::cast(args[0]);
Object* len = args[1]; Object* len = args[1];
return receiver->SetElementsLength(len); Object* result = receiver->SetElementsLength(len);
if (result->IsFailure()) return result;
return len;
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var a = [0,1,2,3]; var a = [0,1,2,3];
a.length = 0; assertEquals(0, a.length = 0);
assertEquals('undefined', typeof a[0]); assertEquals('undefined', typeof a[0]);
assertEquals('undefined', typeof a[1]); assertEquals('undefined', typeof a[1]);
...@@ -35,7 +35,7 @@ assertEquals('undefined', typeof a[3]); ...@@ -35,7 +35,7 @@ assertEquals('undefined', typeof a[3]);
var a = [0,1,2,3]; var a = [0,1,2,3];
a.length = 2; assertEquals(2, a.length = 2);
assertEquals(0, a[0]); assertEquals(0, a[0]);
assertEquals(1, a[1]); assertEquals(1, a[1]);
...@@ -50,7 +50,7 @@ a[1000000] = 1000000; ...@@ -50,7 +50,7 @@ a[1000000] = 1000000;
a[2000000] = 2000000; a[2000000] = 2000000;
assertEquals(2000001, a.length); assertEquals(2000001, a.length);
a.length = 0; assertEquals(0, a.length = 0);
assertEquals(0, a.length); assertEquals(0, a.length);
assertEquals('undefined', typeof a[0]); assertEquals('undefined', typeof a[0]);
assertEquals('undefined', typeof a[1000]); assertEquals('undefined', typeof a[1000]);
...@@ -65,7 +65,7 @@ a[1000000] = 1000000; ...@@ -65,7 +65,7 @@ a[1000000] = 1000000;
a[2000000] = 2000000; a[2000000] = 2000000;
assertEquals(2000001, a.length); assertEquals(2000001, a.length);
a.length = 2000; assertEquals(2000, a.length = 2000);
assertEquals(2000, a.length); assertEquals(2000, a.length);
assertEquals(0, a[0]); assertEquals(0, a[0]);
assertEquals(1000, a[1000]); assertEquals(1000, a[1000]);
...@@ -91,7 +91,7 @@ assertEquals(Math.pow(2,31)-1, a[Math.pow(2,31)-1]); ...@@ -91,7 +91,7 @@ assertEquals(Math.pow(2,31)-1, a[Math.pow(2,31)-1]);
assertEquals(Math.pow(2,32)-2, a[Math.pow(2,32)-2]); assertEquals(Math.pow(2,32)-2, a[Math.pow(2,32)-2]);
assertEquals(Math.pow(2,32)-1, a.length); assertEquals(Math.pow(2,32)-1, a.length);
a.length = Math.pow(2,30)+1; // not a smi! assertEquals(Math.pow(2,30) + 1, a.length = Math.pow(2,30)+1); // not a smi!
assertEquals(Math.pow(2,30)+1, a.length); assertEquals(Math.pow(2,30)+1, a.length);
assertEquals(0, a[0]); assertEquals(0, a[0]);
...@@ -102,10 +102,20 @@ assertEquals('undefined', typeof a[Math.pow(2,32)-2], "top"); ...@@ -102,10 +102,20 @@ assertEquals('undefined', typeof a[Math.pow(2,32)-2], "top");
var a = new Array(); var a = new Array();
a.length = new Number(12); assertEquals(12, a.length = new Number(12));
assertEquals(12, a.length); assertEquals(12, a.length);
var o = { length: -23 }; var o = { length: -23 };
Array.prototype.pop.apply(o); Array.prototype.pop.apply(o);
assertEquals(4294967272, o.length); assertEquals(4294967272, o.length);
// Check case of compiled stubs.
var a = [];
for (var i = 0; i < 7; i++) {
assertEquals(3, a.length = 3);
var t = 239;
t = a.length = 7;
assertEquals(7, t);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment