Commit e41250a3 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Revert r12760 (JSON.stringify).

R=verwaest@chromium.org
BUG=

Review URL: https://chromiumcodereview.appspot.com/11225026

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12783 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3c5e8993
This diff is collapsed.
......@@ -307,12 +307,10 @@ function BasicJSONSerialize(key, value, stack, builder) {
function JSONStringify(value, replacer, space) {
if (%_ArgumentsLength() == 1) {
var result = %BasicJSONStringify(value);
if (result != 0) return result;
var builder = new InternalArray();
BasicJSONSerialize('', value, new InternalArray(), builder);
if (builder.length == 0) return;
result = %_FastAsciiArrayJoin(builder, "");
var result = %_FastAsciiArrayJoin(builder, "");
if (!IS_UNDEFINED(result)) return result;
return %StringBuilderConcat(builder, builder.length, "");
}
......
......@@ -46,7 +46,6 @@
#include "isolate-inl.h"
#include "jsregexp.h"
#include "json-parser.h"
#include "json-stringifier.h"
#include "liveedit.h"
#include "liveobjectlist-inl.h"
#include "misc-intrinsics.h"
......@@ -5761,14 +5760,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringArray) {
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) {
ASSERT(args.length() == 1);
HandleScope scope(isolate);
BasicJsonStringifier stringifier(isolate);
return stringifier.Stringify(Handle<Object>(args[0]));
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) {
NoHandleAllocation ha;
......
......@@ -120,7 +120,6 @@ namespace internal {
F(CharFromCode, 1, 1) \
F(URIEscape, 1, 1) \
F(URIUnescape, 1, 1) \
F(BasicJSONStringify, 1, 1) \
F(QuoteJSONString, 1, 1) \
F(QuoteJSONStringComma, 1, 1) \
F(QuoteJSONStringArray, 1, 1) \
......
// 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.
var a = {};
for (i = 0; i < 10000; i++) {
var current = {};
current.a = a;
a = current;
}
function rec(a,b,c,d,e,f,g,h,i,j,k,l,m,n) {
JSON.stringify(a);
rec(a,b,c,d,e,f,g,h,i,j,k,l,m,n);
}
assertThrows(
function() { rec(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4) },
RangeError);
......@@ -257,42 +257,6 @@ assertEquals("[1,2,[3,[4],5],6,7]",
assertEquals("[2,4,[6,[8],10],12,14]",
JSON.stringify([1, 2, [3, [4], 5], 6, 7], DoubleNumbers));
assertEquals('["a","ab","abc"]', JSON.stringify(["a","ab","abc"]));
assertEquals('{"a":1,"c":true}',
JSON.stringify({ a : 1,
b : function() { 1 },
c : true,
d : function() { 2 } }));
assertEquals('[1,null,true,null]',
JSON.stringify([1, function() { 1 }, true, function() { 2 }]));
assertEquals('"toJSON 123"',
JSON.stringify({ toJSON : function() { return 'toJSON 123'; } }));
assertEquals('{"a":321}',
JSON.stringify({ a : { toJSON : function() { return 321; } } }));
var counter = 0;
assertEquals('{"getter":123}',
JSON.stringify({ get getter() { counter++; return 123; } }));
assertEquals(1, counter);
assertEquals('{"a":"abc","b":"\u1234bc"}',
JSON.stringify({ a : "abc", b : "\u1234bc" }));
var a = { a : 1, b : 2 };
delete a.a;
assertEquals('{"b":2}', JSON.stringify(a));
var b = {};
b.__proto__ = { toJSON : function() { return 321;} };
assertEquals("321", JSON.stringify(b));
var array = [""];
var expected = '""';
for (var i = 0; i < 10000; i++) {
array.push("");
expected = '"",' + expected;
}
expected = '[' + expected + ']';
assertEquals(expected, JSON.stringify(array));
var circular = [1, 2, 3];
circular[2] = circular;
......@@ -464,6 +428,5 @@ var o = JSON.parse('{"__proto__":5}');
assertEquals(Object.prototype, o.__proto__); // __proto__ isn't changed.
assertEquals(0, Object.keys(o).length); // __proto__ isn't added as enumerable.
var json = '{"stuff before slash\\\\stuff after slash":"whatever"}';
assertEquals(json, JSON.stringify(JSON.parse(json)));
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