Revision: 10712
Author:   [email protected]
Date:     Wed Feb 15 05:45:42 2012
Log:      Initialize internal arrays with the correct map.

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

Review URL: https://chromiumcodereview.appspot.com/9402009
http://code.google.com/p/v8/source/detail?r=10712

Modified:
 /branches/bleeding_edge/src/builtins.cc
 /branches/bleeding_edge/test/mjsunit/regress/regress-1878.js

=======================================
--- /branches/bleeding_edge/src/builtins.cc     Wed Feb 15 04:13:55 2012
+++ /branches/bleeding_edge/src/builtins.cc     Wed Feb 15 05:45:42 2012
@@ -206,8 +206,7 @@
     }
   } 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;
   }

=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-1878.js Tue Dec 27 07:12:12 2011 +++ /branches/bleeding_edge/test/mjsunit/regress/regress-1878.js Wed Feb 15 05:45:42 2012
@@ -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));
+}

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

Reply via email to