Commit e3c3be36 authored by bmeurer's avatar bmeurer Committed by Commit bot

[json] Repair JSON.parse regression with non-sequential strings.

Make sure to flatten strings first in JSON.parse() builtins, otherwise
we always hit the slow path for non-sequential strings, i.e. for cons
strings.

Also don't create any arguments adaptor frames for JSON.parse() as the
C++ builtin can handle any number of inputs properly.

R=yangguo@chromium.org

Review-Url: https://codereview.chromium.org/2039553002
Cr-Commit-Position: refs/heads/master@{#36722}
parent 611257fb
......@@ -1603,7 +1603,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
DCHECK(json_object->IsJSObject());
JSObject::AddProperty(global, name, json_object, DONT_ENUM);
SimpleInstallFunction(json_object, "parse", Builtins::kJsonParse, 2, true);
SimpleInstallFunction(json_object, "parse", Builtins::kJsonParse, 2, false);
SimpleInstallFunction(json_object, "stringify", Builtins::kJsonStringify, 3,
true);
JSObject::AddProperty(
......
......@@ -2251,6 +2251,7 @@ BUILTIN(JsonParse) {
Handle<String> string;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string,
Object::ToString(isolate, source));
string = String::Flatten(string);
RETURN_RESULT_OR_FAILURE(
isolate, string->IsSeqOneByteString()
? JsonParser<true>::Parse(isolate, string, reviver)
......
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