OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/json-stringifier.h" | 5 #include "src/json-stringifier.h" |
6 | 6 |
7 #include "src/conversions.h" | 7 #include "src/conversions.h" |
8 #include "src/lookup.h" | 8 #include "src/lookup.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 void JsonStringifier::StackPop() { | 266 void JsonStringifier::StackPop() { |
267 int length = Smi::cast(stack_->length())->value(); | 267 int length = Smi::cast(stack_->length())->value(); |
268 stack_->set_length(Smi::FromInt(length - 1)); | 268 stack_->set_length(Smi::FromInt(length - 1)); |
269 } | 269 } |
270 | 270 |
271 template <bool deferred_string_key> | 271 template <bool deferred_string_key> |
272 JsonStringifier::Result JsonStringifier::Serialize_(Handle<Object> object, | 272 JsonStringifier::Result JsonStringifier::Serialize_(Handle<Object> object, |
273 bool comma, | 273 bool comma, |
274 Handle<Object> key) { | 274 Handle<Object> key) { |
| 275 StackLimitCheck interrupt_check(isolate_); |
| 276 if (interrupt_check.InterruptRequested() && |
| 277 isolate_->stack_guard()->HandleInterrupts()->IsException()) { |
| 278 return EXCEPTION; |
| 279 } |
275 if (object->IsJSReceiver()) { | 280 if (object->IsJSReceiver()) { |
276 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 281 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
277 isolate_, object, ApplyToJsonFunction(object, key), EXCEPTION); | 282 isolate_, object, ApplyToJsonFunction(object, key), EXCEPTION); |
278 } | 283 } |
279 if (!replacer_function_.is_null()) { | 284 if (!replacer_function_.is_null()) { |
280 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 285 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
281 isolate_, object, ApplyReplacerFunction(object, key), EXCEPTION); | 286 isolate_, object, ApplyReplacerFunction(object, key), EXCEPTION); |
282 } | 287 } |
283 | 288 |
284 if (object->IsSmi()) { | 289 if (object->IsSmi()) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 CHECK(object->length()->ToArrayLength(&length)); | 397 CHECK(object->length()->ToArrayLength(&length)); |
393 DCHECK(!object->IsAccessCheckNeeded()); | 398 DCHECK(!object->IsAccessCheckNeeded()); |
394 builder_.AppendCharacter('['); | 399 builder_.AppendCharacter('['); |
395 Indent(); | 400 Indent(); |
396 uint32_t i = 0; | 401 uint32_t i = 0; |
397 if (replacer_function_.is_null()) { | 402 if (replacer_function_.is_null()) { |
398 switch (object->GetElementsKind()) { | 403 switch (object->GetElementsKind()) { |
399 case FAST_SMI_ELEMENTS: { | 404 case FAST_SMI_ELEMENTS: { |
400 Handle<FixedArray> elements(FixedArray::cast(object->elements()), | 405 Handle<FixedArray> elements(FixedArray::cast(object->elements()), |
401 isolate_); | 406 isolate_); |
| 407 StackLimitCheck interrupt_check(isolate_); |
402 while (i < length) { | 408 while (i < length) { |
| 409 if (interrupt_check.InterruptRequested() && |
| 410 isolate_->stack_guard()->HandleInterrupts()->IsException()) { |
| 411 return EXCEPTION; |
| 412 } |
403 Separator(i == 0); | 413 Separator(i == 0); |
404 SerializeSmi(Smi::cast(elements->get(i))); | 414 SerializeSmi(Smi::cast(elements->get(i))); |
405 i++; | 415 i++; |
406 } | 416 } |
407 break; | 417 break; |
408 } | 418 } |
409 case FAST_DOUBLE_ELEMENTS: { | 419 case FAST_DOUBLE_ELEMENTS: { |
410 // Empty array is FixedArray but not FixedDoubleArray. | 420 // Empty array is FixedArray but not FixedDoubleArray. |
411 if (length == 0) break; | 421 if (length == 0) break; |
412 Handle<FixedDoubleArray> elements( | 422 Handle<FixedDoubleArray> elements( |
413 FixedDoubleArray::cast(object->elements()), isolate_); | 423 FixedDoubleArray::cast(object->elements()), isolate_); |
| 424 StackLimitCheck interrupt_check(isolate_); |
414 while (i < length) { | 425 while (i < length) { |
| 426 if (interrupt_check.InterruptRequested() && |
| 427 isolate_->stack_guard()->HandleInterrupts()->IsException()) { |
| 428 return EXCEPTION; |
| 429 } |
415 Separator(i == 0); | 430 Separator(i == 0); |
416 SerializeDouble(elements->get_scalar(i)); | 431 SerializeDouble(elements->get_scalar(i)); |
417 i++; | 432 i++; |
418 } | 433 } |
419 break; | 434 break; |
420 } | 435 } |
421 case FAST_ELEMENTS: { | 436 case FAST_ELEMENTS: { |
422 Handle<Object> old_length(object->length(), isolate_); | 437 Handle<Object> old_length(object->length(), isolate_); |
423 while (i < length) { | 438 while (i < length) { |
424 if (object->length() != *old_length || | 439 if (object->length() != *old_length || |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 if (object->IsOneByteRepresentationUnderneath()) { | 699 if (object->IsOneByteRepresentationUnderneath()) { |
685 SerializeString_<uint8_t, uc16>(object); | 700 SerializeString_<uint8_t, uc16>(object); |
686 } else { | 701 } else { |
687 SerializeString_<uc16, uc16>(object); | 702 SerializeString_<uc16, uc16>(object); |
688 } | 703 } |
689 } | 704 } |
690 } | 705 } |
691 | 706 |
692 } // namespace internal | 707 } // namespace internal |
693 } // namespace v8 | 708 } // namespace v8 |
OLD | NEW |