Revision: 20485
Author: [email protected]
Date: Thu Apr 3 14:25:59 2014 UTC
Log: Return MaybeHandle from JsonParser.
[email protected]
Review URL: https://codereview.chromium.org/223553003
http://code.google.com/p/v8/source/detail?r=20485
Modified:
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/json-parser.h
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/api.cc Thu Apr 3 12:41:37 2014 UTC
+++ /branches/bleeding_edge/src/api.cc Thu Apr 3 14:25:59 2014 UTC
@@ -2315,13 +2315,11 @@
i::Handle<i::String> source = i::Handle<i::String>(
FlattenGetString(Utils::OpenHandle(*json_string)));
EXCEPTION_PREAMBLE(isolate);
+ i::MaybeHandle<i::Object> maybe_result =
+ source->IsSeqOneByteString() ? i::JsonParser<true>::Parse(source)
+ : i::JsonParser<false>::Parse(source);
i::Handle<i::Object> result;
- if (source->IsSeqOneByteString()) {
- result = i::JsonParser<true>::Parse(source);
- } else {
- result = i::JsonParser<false>::Parse(source);
- }
- has_pending_exception = result.is_null();
+ has_pending_exception = !maybe_result.ToHandle(&result);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
return Utils::ToLocal(
i::Handle<i::Object>::cast(scope.CloseAndEscape(result)));
=======================================
--- /branches/bleeding_edge/src/json-parser.h Thu Apr 3 12:30:08 2014 UTC
+++ /branches/bleeding_edge/src/json-parser.h Thu Apr 3 14:25:59 2014 UTC
@@ -43,7 +43,7 @@
template <bool seq_ascii>
class JsonParser BASE_EMBEDDED {
public:
- static Handle<Object> Parse(Handle<String> source) {
+ static MaybeHandle<Object> Parse(Handle<String> source) {
return JsonParser(source).ParseJson();
}
@@ -69,7 +69,7 @@
}
// Parse a string containing a single JSON value.
- Handle<Object> ParseJson();
+ MaybeHandle<Object> ParseJson();
inline void Advance() {
position_++;
@@ -219,7 +219,7 @@
};
template <bool seq_ascii>
-Handle<Object> JsonParser<seq_ascii>::ParseJson() {
+MaybeHandle<Object> JsonParser<seq_ascii>::ParseJson() {
// Advance to the first character (possibly EOS)
AdvanceSkipWhitespace();
Handle<Object> result = ParseJsonValue();
@@ -268,9 +268,8 @@
MessageLocation location(factory->NewScript(source_),
position_,
position_ + 1);
- Handle<Object> result = factory->NewSyntaxError(message, array);
- isolate()->Throw(*result, &location);
- return Handle<Object>::null();
+ Handle<Object> error = factory->NewSyntaxError(message, array);
+ return isolate()->template Throw<Object>(error, &location);
}
return result;
}
=======================================
--- /branches/bleeding_edge/src/runtime.cc Thu Apr 3 12:30:37 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Thu Apr 3 14:25:59 2014 UTC
@@ -9769,16 +9769,10 @@
source = Handle<String>(FlattenGetString(source));
// Optimized fast case where we only have ASCII characters.
Handle<Object> result;
- if (source->IsSeqOneByteString()) {
- result = JsonParser<true>::Parse(source);
- } else {
- result = JsonParser<false>::Parse(source);
- }
- if (result.is_null()) {
- // Syntax error or stack overflow in scanner.
- ASSERT(isolate->has_pending_exception());
- return Failure::Exception();
- }
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ source->IsSeqOneByteString() ? JsonParser<true>::Parse(source)
+ : JsonParser<false>::Parse(source));
return *result;
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.