| 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 494     SerializeDeferredKey(deferred_comma, key); | 494     SerializeDeferredKey(deferred_comma, key); | 
| 495   } | 495   } | 
| 496 | 496 | 
| 497   Handle<String> result_string = Handle<String>::cast(result); | 497   Handle<String> result_string = Handle<String>::cast(result); | 
| 498   // Shrink current part, attach it to the accumulator, also attach the result | 498   // Shrink current part, attach it to the accumulator, also attach the result | 
| 499   // string to the accumulator, and allocate a new part. | 499   // string to the accumulator, and allocate a new part. | 
| 500   ShrinkCurrentPart();  // Shrink. | 500   ShrinkCurrentPart();  // Shrink. | 
| 501   part_length_ = kInitialPartLength;  // Allocate conservatively. | 501   part_length_ = kInitialPartLength;  // Allocate conservatively. | 
| 502   Extend();             // Attach current part and allocate new part. | 502   Extend();             // Attach current part and allocate new part. | 
| 503   // Attach result string to the accumulator. | 503   // Attach result string to the accumulator. | 
| 504   Handle<String> cons; | 504   Handle<String> cons = factory_->NewConsString(accumulator(), result_string); | 
| 505   ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 505   RETURN_IF_EMPTY_HANDLE_VALUE(isolate_, cons, EXCEPTION); | 
| 506       isolate_, cons, |  | 
| 507       factory_->NewConsString(accumulator(), result_string), |  | 
| 508       EXCEPTION); |  | 
| 509   set_accumulator(cons); | 506   set_accumulator(cons); | 
| 510   return SUCCESS; | 507   return SUCCESS; | 
| 511 } | 508 } | 
| 512 | 509 | 
| 513 | 510 | 
| 514 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue( | 511 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue( | 
| 515     Handle<JSValue> object) { | 512     Handle<JSValue> object) { | 
| 516   bool has_exception = false; | 513   bool has_exception = false; | 
| 517   String* class_name = object->class_name(); | 514   String* class_name = object->class_name(); | 
| 518   if (class_name == isolate_->heap()->String_string()) { | 515   if (class_name == isolate_->heap()->String_string()) { | 
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 727                                       current_index_); | 724                                       current_index_); | 
| 728 } | 725 } | 
| 729 | 726 | 
| 730 | 727 | 
| 731 void BasicJsonStringifier::Accumulate() { | 728 void BasicJsonStringifier::Accumulate() { | 
| 732   if (accumulator()->length() + current_part_->length() > String::kMaxLength) { | 729   if (accumulator()->length() + current_part_->length() > String::kMaxLength) { | 
| 733     // Screw it.  Simply set the flag and carry on.  Throw exception at the end. | 730     // Screw it.  Simply set the flag and carry on.  Throw exception at the end. | 
| 734     set_accumulator(factory_->empty_string()); | 731     set_accumulator(factory_->empty_string()); | 
| 735     overflowed_ = true; | 732     overflowed_ = true; | 
| 736   } else { | 733   } else { | 
| 737     set_accumulator(factory_->NewConsString(accumulator(), | 734     set_accumulator(factory_->NewConsString(accumulator(), current_part_)); | 
| 738                                             current_part_).ToHandleChecked()); |  | 
| 739   } | 735   } | 
| 740 } | 736 } | 
| 741 | 737 | 
| 742 | 738 | 
| 743 void BasicJsonStringifier::Extend() { | 739 void BasicJsonStringifier::Extend() { | 
| 744   Accumulate(); | 740   Accumulate(); | 
| 745   if (part_length_ <= kMaxPartLength / kPartLengthGrowthFactor) { | 741   if (part_length_ <= kMaxPartLength / kPartLengthGrowthFactor) { | 
| 746     part_length_ *= kPartLengthGrowthFactor; | 742     part_length_ *= kPartLengthGrowthFactor; | 
| 747   } | 743   } | 
| 748   if (is_ascii_) { | 744   if (is_ascii_) { | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 881       SerializeString_<false, uint8_t>(object); | 877       SerializeString_<false, uint8_t>(object); | 
| 882     } else { | 878     } else { | 
| 883       SerializeString_<false, uc16>(object); | 879       SerializeString_<false, uc16>(object); | 
| 884     } | 880     } | 
| 885   } | 881   } | 
| 886 } | 882 } | 
| 887 | 883 | 
| 888 } }  // namespace v8::internal | 884 } }  // namespace v8::internal | 
| 889 | 885 | 
| 890 #endif  // V8_JSON_STRINGIFIER_H_ | 886 #endif  // V8_JSON_STRINGIFIER_H_ | 
| OLD | NEW | 
|---|