Reviewers: Mads Ager,

Description:
Arrays created with new Array(n) are not assumed to be sparse unless the
given
size is truly huge.  A test had to be modified slightly so as not to be
too slow.

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

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

Affected files:
   M     src/builtins.cc
   M     src/objects.h
   M     test/mjsunit/fuzz-natives.js


Index: test/mjsunit/fuzz-natives.js
===================================================================
--- test/mjsunit/fuzz-natives.js        (revision 1416)
+++ test/mjsunit/fuzz-natives.js        (working copy)
@@ -31,8 +31,8 @@
    var result = [ ];
    result.push(17);
    result.push(-31);
-  result.push(Number.MAX_VALUE);
-  result.push(new Array(5003));
+  result.push(new Array(100));
+  result.push(new Array(100003));
    result.push(Number.MIN_VALUE);
    result.push("whoops");
    result.push("x");
Index: src/objects.h
===================================================================
--- src/objects.h       (revision 1416)
+++ src/objects.h       (working copy)
@@ -1433,6 +1433,7 @@

    static const uint32_t kMaxGap = 1024;
    static const int kMaxFastElementsLength = 5000;
+  static const int kInitialMaxFastElementArray = 100000;
    static const int kMaxFastProperties = 8;
    static const int kMaxInstanceSize = 255 * kPointerSize;
    // When extending the backing storage for property values, we increase
Index: src/builtins.cc
===================================================================
--- src/builtins.cc     (revision 1416)
+++ src/builtins.cc     (working copy)
@@ -155,7 +155,7 @@
      Object* obj = BUILTIN_ARG(1);
      if (obj->IsSmi()) {
        int len = Smi::cast(obj)->value();
-      if (len >= 0 && len < JSObject::kMaxFastElementsLength) {
+      if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) {
          Object* obj = Heap::AllocateFixedArrayWithHoles(len);
          if (obj->IsFailure()) return obj;
          array->SetContent(FixedArray::cast(obj));



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

Reply via email to