OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 return scope.CloseAndEscape(object); | 383 return scope.CloseAndEscape(object); |
384 } | 384 } |
385 | 385 |
386 | 386 |
387 BasicJsonStringifier::Result BasicJsonStringifier::StackPush( | 387 BasicJsonStringifier::Result BasicJsonStringifier::StackPush( |
388 Handle<Object> object) { | 388 Handle<Object> object) { |
389 StackLimitCheck check(isolate_); | 389 StackLimitCheck check(isolate_); |
390 if (check.HasOverflowed()) return STACK_OVERFLOW; | 390 if (check.HasOverflowed()) return STACK_OVERFLOW; |
391 | 391 |
392 int length = Smi::cast(stack_->length())->value(); | 392 int length = Smi::cast(stack_->length())->value(); |
393 FixedArray* elements = FixedArray::cast(stack_->elements()); | 393 { |
394 for (int i = 0; i < length; i++) { | 394 DisallowHeapAllocation no_allocation; |
395 if (elements->get(i) == *object) { | 395 FixedArray* elements = FixedArray::cast(stack_->elements()); |
396 return CIRCULAR; | 396 for (int i = 0; i < length; i++) { |
| 397 if (elements->get(i) == *object) { |
| 398 return CIRCULAR; |
| 399 } |
397 } | 400 } |
398 } | 401 } |
399 stack_->EnsureSize(length + 1); | 402 JSArray::EnsureSize(stack_, length + 1); |
400 FixedArray::cast(stack_->elements())->set(length, *object); | 403 FixedArray::cast(stack_->elements())->set(length, *object); |
401 stack_->set_length(Smi::FromInt(length + 1)); | 404 stack_->set_length(Smi::FromInt(length + 1)); |
402 return SUCCESS; | 405 return SUCCESS; |
403 } | 406 } |
404 | 407 |
405 | 408 |
406 void BasicJsonStringifier::StackPop() { | 409 void BasicJsonStringifier::StackPop() { |
407 int length = Smi::cast(stack_->length())->value(); | 410 int length = Smi::cast(stack_->length())->value(); |
408 stack_->set_length(Smi::FromInt(length - 1)); | 411 stack_->set_length(Smi::FromInt(length - 1)); |
409 } | 412 } |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 SerializeString_<false, uint8_t>(object); | 873 SerializeString_<false, uint8_t>(object); |
871 } else { | 874 } else { |
872 SerializeString_<false, uc16>(object); | 875 SerializeString_<false, uc16>(object); |
873 } | 876 } |
874 } | 877 } |
875 } | 878 } |
876 | 879 |
877 } } // namespace v8::internal | 880 } } // namespace v8::internal |
878 | 881 |
879 #endif // V8_JSON_STRINGIFIER_H_ | 882 #endif // V8_JSON_STRINGIFIER_H_ |
OLD | NEW |