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

Unified Diff: src/json-stringifier.cc

Issue 2037363002: [json] check and handle interrupts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 6 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/json-parser.cc ('k') | test/cctest/test-thread-termination.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/json-stringifier.cc
diff --git a/src/json-stringifier.cc b/src/json-stringifier.cc
index 9d19110d10d945e35783a3d9e9142d60601e3116..51899a9c8bc765a4a7587416a4643ac19af0edab 100644
--- a/src/json-stringifier.cc
+++ b/src/json-stringifier.cc
@@ -272,6 +272,11 @@ template <bool deferred_string_key>
JsonStringifier::Result JsonStringifier::Serialize_(Handle<Object> object,
bool comma,
Handle<Object> key) {
+ StackLimitCheck interrupt_check(isolate_);
+ if (interrupt_check.InterruptRequested() &&
+ isolate_->stack_guard()->HandleInterrupts()->IsException()) {
+ return EXCEPTION;
+ }
if (object->IsJSReceiver()) {
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate_, object, ApplyToJsonFunction(object, key), EXCEPTION);
@@ -399,7 +404,12 @@ JsonStringifier::Result JsonStringifier::SerializeJSArray(
case FAST_SMI_ELEMENTS: {
Handle<FixedArray> elements(FixedArray::cast(object->elements()),
isolate_);
+ StackLimitCheck interrupt_check(isolate_);
while (i < length) {
+ if (interrupt_check.InterruptRequested() &&
+ isolate_->stack_guard()->HandleInterrupts()->IsException()) {
+ return EXCEPTION;
+ }
Separator(i == 0);
SerializeSmi(Smi::cast(elements->get(i)));
i++;
@@ -411,7 +421,12 @@ JsonStringifier::Result JsonStringifier::SerializeJSArray(
if (length == 0) break;
Handle<FixedDoubleArray> elements(
FixedDoubleArray::cast(object->elements()), isolate_);
+ StackLimitCheck interrupt_check(isolate_);
while (i < length) {
+ if (interrupt_check.InterruptRequested() &&
+ isolate_->stack_guard()->HandleInterrupts()->IsException()) {
+ return EXCEPTION;
+ }
Separator(i == 0);
SerializeDouble(elements->get_scalar(i));
i++;
« no previous file with comments | « src/json-parser.cc ('k') | test/cctest/test-thread-termination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698