Commit bf705f0f authored by yangguo's avatar yangguo Committed by Commit bot

[json] move json parser and stringifier into own compilation units.

This is a pure refactoring.

R=cbruni@chromium.org

Review-Url: https://codereview.chromium.org/2002933002
Cr-Commit-Position: refs/heads/master@{#36435}
parent 726d3be8
...@@ -1264,7 +1264,9 @@ v8_source_set("v8_base") { ...@@ -1264,7 +1264,9 @@ v8_source_set("v8_base") {
"src/isolate-inl.h", "src/isolate-inl.h",
"src/isolate.cc", "src/isolate.cc",
"src/isolate.h", "src/isolate.h",
"src/json-parser.cc",
"src/json-parser.h", "src/json-parser.h",
"src/json-stringifier.cc",
"src/json-stringifier.h", "src/json-stringifier.h",
"src/keys.cc", "src/keys.cc",
"src/keys.h", "src/keys.h",
...@@ -2102,7 +2104,10 @@ executable("d8") { ...@@ -2102,7 +2104,10 @@ executable("d8") {
} }
} }
if ((current_toolchain == host_toolchain && v8_toolset_for_shell == "host") || (current_toolchain == v8_snapshot_toolchain && v8_toolset_for_shell == "host") || (current_toolchain != host_toolchain && v8_toolset_for_shell == "target")) { if ((current_toolchain == host_toolchain && v8_toolset_for_shell == "host") ||
(current_toolchain == v8_snapshot_toolchain &&
v8_toolset_for_shell == "host") ||
(current_toolchain != host_toolchain && v8_toolset_for_shell == "target")) {
executable("v8_shell") { executable("v8_shell") {
sources = [ sources = [
"samples/shell.cc", "samples/shell.cc",
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "src/icu_util.h" #include "src/icu_util.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/json-parser.h" #include "src/json-parser.h"
#include "src/json-stringifier.h"
#include "src/messages.h" #include "src/messages.h"
#include "src/parsing/parser.h" #include "src/parsing/parser.h"
#include "src/parsing/scanner-character-streams.h" #include "src/parsing/scanner-character-streams.h"
...@@ -2777,8 +2778,8 @@ MaybeLocal<String> JSON::Stringify(Local<Context> context, ...@@ -2777,8 +2778,8 @@ MaybeLocal<String> JSON::Stringify(Local<Context> context,
? isolate->factory()->empty_string() ? isolate->factory()->empty_string()
: Utils::OpenHandle(*gap); : Utils::OpenHandle(*gap);
i::Handle<i::Object> maybe; i::Handle<i::Object> maybe;
has_pending_exception = has_pending_exception = !i::BasicJsonStringifier(isolate, gap_string)
!i::Runtime::BasicJsonStringify(isolate, object, gap_string) .Stringify(object)
.ToHandle(&maybe); .ToHandle(&maybe);
RETURN_ON_FAILED_EXECUTION(String); RETURN_ON_FAILED_EXECUTION(String);
Local<String> result; Local<String> result;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "src/char-predicates-inl.h" #include "src/char-predicates-inl.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/json-parser.h" #include "src/json-parser.h"
#include "src/json-stringifier.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
namespace v8 { namespace v8 {
...@@ -19,7 +20,7 @@ RUNTIME_FUNCTION(Runtime_QuoteJSONString) { ...@@ -19,7 +20,7 @@ RUNTIME_FUNCTION(Runtime_QuoteJSONString) {
DCHECK(args.length() == 1); DCHECK(args.length() == 1);
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, Runtime::BasicJsonStringifyString(isolate, string)); isolate, result, BasicJsonStringifier::StringifyString(isolate, string));
return *result; return *result;
} }
...@@ -30,7 +31,7 @@ RUNTIME_FUNCTION(Runtime_BasicJSONStringify) { ...@@ -30,7 +31,7 @@ RUNTIME_FUNCTION(Runtime_BasicJSONStringify) {
CONVERT_ARG_HANDLE_CHECKED(String, gap, 1); CONVERT_ARG_HANDLE_CHECKED(String, gap, 1);
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, Runtime::BasicJsonStringify(isolate, object, gap)); isolate, result, BasicJsonStringifier(isolate, gap).Stringify(object));
return *result; return *result;
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "src/bootstrapper.h" #include "src/bootstrapper.h"
#include "src/debug/debug.h" #include "src/debug/debug.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/json-stringifier.h"
#include "src/messages.h" #include "src/messages.h"
#include "src/property-descriptor.h" #include "src/property-descriptor.h"
#include "src/runtime/runtime.h" #include "src/runtime/runtime.h"
...@@ -226,16 +225,6 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, ...@@ -226,16 +225,6 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
return value; return value;
} }
MaybeHandle<Object> Runtime::BasicJsonStringify(Isolate* isolate,
Handle<Object> object,
Handle<String> gap) {
return BasicJsonStringifier(isolate, gap).Stringify(object);
}
MaybeHandle<Object> Runtime::BasicJsonStringifyString(Isolate* isolate,
Handle<String> string) {
return BasicJsonStringifier::StringifyString(isolate, string);
}
RUNTIME_FUNCTION(Runtime_GetPrototype) { RUNTIME_FUNCTION(Runtime_GetPrototype) {
HandleScope scope(isolate); HandleScope scope(isolate);
......
...@@ -1089,12 +1089,6 @@ class Runtime : public AllStatic { ...@@ -1089,12 +1089,6 @@ class Runtime : public AllStatic {
MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty( MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key); Isolate* isolate, Handle<Object> object, Handle<Object> key);
MUST_USE_RESULT static MaybeHandle<Object> BasicJsonStringify(
Isolate* isolate, Handle<Object> object, Handle<String> gap);
MUST_USE_RESULT static MaybeHandle<Object> BasicJsonStringifyString(
Isolate* isolate, Handle<String> string);
enum TypedArrayId { enum TypedArrayId {
// arrayIds below should be synchronized with typedarray.js natives. // arrayIds below should be synchronized with typedarray.js natives.
ARRAY_ID_UINT8 = 1, ARRAY_ID_UINT8 = 1,
......
...@@ -923,7 +923,9 @@ ...@@ -923,7 +923,9 @@
'isolate-inl.h', 'isolate-inl.h',
'isolate.cc', 'isolate.cc',
'isolate.h', 'isolate.h',
'json-parser.cc',
'json-parser.h', 'json-parser.h',
'json-stringifier.cc',
'json-stringifier.h', 'json-stringifier.h',
'keys.h', 'keys.h',
'keys.cc', 'keys.cc',
......
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