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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 } | 596 } |
597 | 597 |
598 | 598 |
599 void BasicJsonStringifier::ShrinkCurrentPart() { | 599 void BasicJsonStringifier::ShrinkCurrentPart() { |
600 ASSERT(current_index_ < part_length_); | 600 ASSERT(current_index_ < part_length_); |
601 if (current_index_ == 0) { | 601 if (current_index_ == 0) { |
602 current_part_ = factory_->empty_string(); | 602 current_part_ = factory_->empty_string(); |
603 return; | 603 return; |
604 } | 604 } |
605 | 605 |
606 int string_size, allocated_string_size; | 606 SeqString::cast(*current_part_)->Truncate(current_index_); |
Toon Verwaest
2012/12/05 14:29:12
Runtime_Truncate returns the resulting string; and
| |
607 if (is_ascii_) { | |
608 allocated_string_size = SeqOneByteString::SizeFor(part_length_); | |
609 string_size = SeqOneByteString::SizeFor(current_index_); | |
610 } else { | |
611 allocated_string_size = SeqTwoByteString::SizeFor(part_length_); | |
612 string_size = SeqTwoByteString::SizeFor(current_index_); | |
613 } | |
614 | |
615 int delta = allocated_string_size - string_size; | |
616 current_part_->set_length(current_index_); | |
617 | |
618 // String sizes are pointer size aligned, so that we can use filler objects | |
619 // that are a multiple of pointer size. | |
620 Address end_of_string = current_part_->address() + string_size; | |
621 isolate_->heap()->CreateFillerObjectAt(end_of_string, delta); | |
622 if (Marking::IsBlack(Marking::MarkBitFrom(*current_part_))) { | |
623 MemoryChunk::IncrementLiveBytesFromMutator( | |
624 current_part_->address(), -delta); | |
625 } | |
626 } | 607 } |
627 | 608 |
628 | 609 |
629 void BasicJsonStringifier::Extend() { | 610 void BasicJsonStringifier::Extend() { |
630 set_accumulator(factory_->NewConsString(accumulator(), current_part_)); | 611 set_accumulator(factory_->NewConsString(accumulator(), current_part_)); |
631 if (part_length_ <= kMaxPartLength / kPartLengthGrowthFactor) { | 612 if (part_length_ <= kMaxPartLength / kPartLengthGrowthFactor) { |
632 part_length_ *= kPartLengthGrowthFactor; | 613 part_length_ *= kPartLengthGrowthFactor; |
633 } | 614 } |
634 if (is_ascii_) { | 615 if (is_ascii_) { |
635 current_part_ = factory_->NewRawOneByteString(part_length_); | 616 current_part_ = factory_->NewRawOneByteString(part_length_); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
761 SerializeString_<false, char>(flat.ToAsciiVector(), object); | 742 SerializeString_<false, char>(flat.ToAsciiVector(), object); |
762 } else { | 743 } else { |
763 SerializeString_<false, uc16>(flat.ToUC16Vector(), object); | 744 SerializeString_<false, uc16>(flat.ToUC16Vector(), object); |
764 } | 745 } |
765 } | 746 } |
766 } | 747 } |
767 | 748 |
768 } } // namespace v8::internal | 749 } } // namespace v8::internal |
769 | 750 |
770 #endif // V8_JSON_STRINGIFIER_H_ | 751 #endif // V8_JSON_STRINGIFIER_H_ |
OLD | NEW |