Reviewers: danno,

Message:
PTAL.

Description:
Initialize internal arrays with the correct map.


BUG=v8:1878
TEST=regress-1878.js


Please review this at http://codereview.chromium.org/9402009/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/builtins.cc
  M test/mjsunit/regress/regress-1878.js


Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 0d5b2b26f3f39a8917d33041261592897b504beb..7290a2cf1cef2611efc35a6943fc588bb9f70dc3 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -206,8 +206,7 @@ static MaybeObject* ArrayCodeGenericCommon(Arguments* args,
     }
   } else {
     // Allocate the JS Array
-    MaybeObject* maybe_obj =
-        heap->AllocateEmptyJSArray(FAST_SMI_ONLY_ELEMENTS);
+    MaybeObject* maybe_obj = heap->AllocateJSObject(constructor);
     if (!maybe_obj->To(&array)) return maybe_obj;
   }

Index: test/mjsunit/regress/regress-1878.js
diff --git a/test/mjsunit/regress/regress-1878.js b/test/mjsunit/regress/regress-1878.js index 1b3c63aeb1ec56d1d3d223eb5b821fcb5d221065..baa385fd7c754b338e036842bcedb3945008c678 100644
--- a/test/mjsunit/regress/regress-1878.js
+++ b/test/mjsunit/regress/regress-1878.js
@@ -1,4 +1,4 @@
-// Copyright 2009 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -30,5 +30,15 @@
 // Flags: --allow-natives-syntax --expose_natives_as=natives

 var a = Array();
-var ai = natives.InternalArray();
-assertFalse(%HaveSameMap(ai, a));
+
+for (var i = 0; i < 1000; i++) {
+  var ai = natives.InternalArray(10000);
+  assertFalse(%HaveSameMap(ai, a));
+  assertTrue(%HasFastElements(ai));
+}
+
+for (var i = 0; i < 1000; i++) {
+  var ai = new natives.InternalArray(10000);
+  assertFalse(%HaveSameMap(ai, a));
+  assertTrue(%HasFastElements(ai));
+}
\ No newline at end of file


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to