Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion r12834 committed - Fix handling arrays with holes in JSON.stringify....

Received: by 10.68.226.41 with SMTP id rp9mr11047600pbc.4.1351611000902;
        Tue, 30 Oct 2012 08:30:00 -0700 (PDT)
X-BeenThere: v8-dev@googlegroups.com
Received: by 10.68.190.100 with SMTP id gp4ls2164606pbc.9.gmail; Tue, 30 Oct
 2012 08:30:00 -0700 (PDT)
Received: by 10.68.138.14 with SMTP id qm14mr11042465pbb.5.1351611000135;
        Tue, 30 Oct 2012 08:30:00 -0700 (PDT)
Received: by 10.68.138.14 with SMTP id qm14mr11042464pbb.5.1351611000124;
        Tue, 30 Oct 2012 08:30:00 -0700 (PDT)
Return-Path: <3ePKPUBAKBicFRGHVLWH-QRUHSObJRRJOH.FRPYl-GHYJRRJOHJURXSV....@codesite.bounces.google.com>
Received: from mail-pb0-f75.google.com (mail-pb0-f75.google.com [209.85.160.75])
        by gmr-mx.google.com with ESMTPS id r4si232156paz.1.2012.10.30.08.30.00
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 30 Oct 2012 08:30:00 -0700 (PDT)
Received-SPF: pass (google.com: domain of 3ePKPUBAKBicFRGHVLWH-QRUHSObJRRJOH.FRPYl-GHYJRRJOHJURXSV....@codesite.bounces.google.com designates 209.85.160.75 as permitted sender) client-ip=209.85.160.75;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of 3ePKPUBAKBicFRGHVLWH-QRUHSObJRRJOH.FRPYl-GHYJRRJOHJURXSV....@codesite.bounces.google.com designates 209.85.160.75 as permitted sender) smtp.mail=3ePKPUBAKBicFRGHVLWH-QRUHSObJRRJOH.FRPYl-GHYJRRJOHJURXSV....@codesite.bounces.google.com; dkim=pass header...@google.com
Received: by mail-pb0-f75.google.com with SMTP id rp2so33063pbb.4
        for <v8-dev@googlegroups.com>; Tue, 30 Oct 2012 08:30:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=mime-version:x-generated-by:message-id:date:subject:from:to
         :content-type;
        bh=g6Q+9TiVxhee8pW+dOqE6peOugkUQPbc90U26UMD0Wg=;
        b=WLQvAgzyQa8mbPBAdvfUhdDsDNP7YnrZ2hUWZbbGavvCZtRHkQE5kuqH6GPd7NezZt
         vHRQFZ1qJhhBjGfGDt7E0DmJLvS19ZEP60BX7q8SV6O3gD/3w3MU0E/RQjsNO4RFDTE4
         cZJNjnpgq8h2YF7/+gaNIyme1Rp0JKyuFYHmXUg8KBC5UIjQiC1VJuQXi1UMcgKu8r45
         OCtv76zKnX5bGCUow6atMDBRNukoe73mURHo1in5YXqZGFs4szteGiFo0JZFeVIcIXfx
         holg2GAKK0PlKTw8b8+2wD/UbBOroKkPxuKRufEmbbHSeCMBlCVWvtNN2Rf6CQOcgUYm
         Fndw==
MIME-Version: 1.0
Received: by 10.66.79.40 with SMTP id g8mr6076620pax.45.1351611000040; Tue, 30
 Oct 2012 08:30:00 -0700 (PDT)
X-Generated-By: Google Code
Message-ID: <f46d042e00d3882e7804cd487...@google.com>
Date: Tue, 30 Oct 2012 15:30:00 +0000
Subject: [v8] r12834 committed - Fix handling arrays with holes in JSON.stringify....
From: codesite-nore...@google.com
To: v8-dev@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes

Revision: 12834
Author:   yang...@chromium.org
Date:     Tue Oct 30 08:29:34 2012
Log:      Fix handling arrays with holes in JSON.stringify.

R=verwa...@chromium.org
BUG=

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

Added:
  /branches/bleeding_edge/test/mjsunit/json2.js
Modified:
  /branches/bleeding_edge/src/json-stringifier.h

=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/json2.js	Tue Oct 30 08:29:34 2012
@@ -0,0 +1,48 @@
+// 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:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --allow-natives-syntax
+
+var fast_smi = [1, 2, 3, 4];
+fast_smi.__proto__ = [7, 7, 7, 7];
+delete fast_smi[2];
+assertTrue(%HasFastSmiElements(fast_smi));
+assertEquals("[1,2,7,4]", JSON.stringify(fast_smi));
+
+var fast_double = [1.1, 2, 3, 4];
+fast_double.__proto__ = [7, 7, 7, 7];
+
+delete fast_double[2];
+assertTrue(%HasFastDoubleElements(fast_double));
+assertEquals("[1.1,2,7,4]", JSON.stringify(fast_double));
+
+var fast_obj = [1, 2, {}, {}];
+fast_obj.__proto__ = [7, 7, 7, 7];
+
+delete fast_obj[2];
+assertTrue(%HasFastObjectElements(fast_obj));
+assertEquals("[1,2,7,{}]", JSON.stringify(fast_obj));
=======================================
--- /branches/bleeding_edge/src/json-stringifier.h	Thu Oct 25 05:18:24 2012
+++ /branches/bleeding_edge/src/json-stringifier.h	Tue Oct 30 08:29:34 2012
@@ -413,20 +413,6 @@
        }
        break;
      }
-    case FAST_HOLEY_SMI_ELEMENTS: {
-      Handle<FixedArray> elements = Handle<FixedArray>(
-          FixedArray::cast(object->elements()));
-      for (int i = 0; i < length; i++) {
-        if (i > 0) Append(',');
-        if (elements->is_the_hole(i)) {
-          Append("null");
-        } else {
-          SerializeSmi(Smi::cast(elements->get(i)));
-        }
-      }
-      break;
-    }
-    case FAST_HOLEY_DOUBLE_ELEMENTS:
      case FAST_DOUBLE_ELEMENTS: {
        Handle<FixedDoubleArray> elements = Handle<FixedDoubleArray>(
            FixedDoubleArray::cast(object->elements()));
@@ -436,7 +422,6 @@
        }
        break;
      }
-    case FAST_HOLEY_ELEMENTS:
      case FAST_ELEMENTS: {
        Handle<FixedArray> elements = Handle<FixedArray>(
            FixedArray::cast(object->elements()));