Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: src/runtime.cc

Issue 4135004: Separate JSON parsing from the JavaScript parser. (Closed)
Patch Set: Rename GetSymbol. Move ZoneScope. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.h ('k') | src/scanner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 9a604a035dc9ed8662c62494cca75ad38e2e0494..084745ae74eb7960d636854d9fa32a5130aae017 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -6932,20 +6932,31 @@ static Object* Runtime_GlobalReceiver(Arguments args) {
}
+static Object* Runtime_ParseJson(Arguments args) {
+ HandleScope scope;
+ ASSERT_EQ(1, args.length());
+ CONVERT_ARG_CHECKED(String, source, 0);
+
+ Handle<Object> result = JsonParser::Parse(source);
+ if (result.is_null()) {
+ // Syntax error or stack overflow in scanner.
+ ASSERT(Top::has_pending_exception());
+ return Failure::Exception();
+ }
+ return *result;
+}
+
+
static Object* Runtime_CompileString(Arguments args) {
HandleScope scope;
- ASSERT_EQ(2, args.length());
+ ASSERT_EQ(1, args.length());
CONVERT_ARG_CHECKED(String, source, 0);
- CONVERT_ARG_CHECKED(Oddball, is_json, 1)
// Compile source string in the global context.
Handle<Context> context(Top::context()->global_context());
- Compiler::ValidationState validate = (is_json->IsTrue())
- ? Compiler::VALIDATE_JSON : Compiler::DONT_VALIDATE_JSON;
Handle<SharedFunctionInfo> shared = Compiler::CompileEval(source,
context,
- true,
- validate);
+ true);
if (shared.is_null()) return Failure::Exception();
Handle<JSFunction> fun =
Factory::NewFunctionFromSharedFunctionInfo(shared, context, NOT_TENURED);
@@ -6960,8 +6971,7 @@ static ObjectPair CompileGlobalEval(Handle<String> source,
Handle<SharedFunctionInfo> shared = Compiler::CompileEval(
source,
Handle<Context>(Top::context()),
- Top::context()->IsGlobalContext(),
- Compiler::DONT_VALIDATE_JSON);
+ Top::context()->IsGlobalContext());
if (shared.is_null()) return MakePair(Failure::Exception(), NULL);
Handle<JSFunction> compiled = Factory::NewFunctionFromSharedFunctionInfo(
shared,
@@ -9164,8 +9174,7 @@ static Object* Runtime_DebugEvaluate(Arguments args) {
Handle<SharedFunctionInfo> shared =
Compiler::CompileEval(function_source,
context,
- context->IsGlobalContext(),
- Compiler::DONT_VALIDATE_JSON);
+ context->IsGlobalContext());
if (shared.is_null()) return Failure::Exception();
Handle<JSFunction> compiled_function =
Factory::NewFunctionFromSharedFunctionInfo(shared, context);
@@ -9232,8 +9241,7 @@ static Object* Runtime_DebugEvaluateGlobal(Arguments args) {
Handle<SharedFunctionInfo> shared =
Compiler::CompileEval(source,
context,
- true,
- Compiler::DONT_VALIDATE_JSON);
+ true);
if (shared.is_null()) return Failure::Exception();
Handle<JSFunction> compiled_function =
Handle<JSFunction>(Factory::NewFunctionFromSharedFunctionInfo(shared,
« no previous file with comments | « src/runtime.h ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698