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

Side by Side Diff: src/json-stringifier.h

Issue 223383002: Return MaybeHandle from NewConsString. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/isolate.h ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = factory_->NewConsString(accumulator(), result_string); 504 Handle<String> cons;
505 RETURN_IF_EMPTY_HANDLE_VALUE(isolate_, cons, EXCEPTION); 505 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
506 isolate_, cons,
507 factory_->NewConsString(accumulator(), result_string),
508 EXCEPTION);
506 set_accumulator(cons); 509 set_accumulator(cons);
507 return SUCCESS; 510 return SUCCESS;
508 } 511 }
509 512
510 513
511 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue( 514 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSValue(
512 Handle<JSValue> object) { 515 Handle<JSValue> object) {
513 bool has_exception = false; 516 bool has_exception = false;
514 String* class_name = object->class_name(); 517 String* class_name = object->class_name();
515 if (class_name == isolate_->heap()->String_string()) { 518 if (class_name == isolate_->heap()->String_string()) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 current_index_); 727 current_index_);
725 } 728 }
726 729
727 730
728 void BasicJsonStringifier::Accumulate() { 731 void BasicJsonStringifier::Accumulate() {
729 if (accumulator()->length() + current_part_->length() > String::kMaxLength) { 732 if (accumulator()->length() + current_part_->length() > String::kMaxLength) {
730 // Screw it. Simply set the flag and carry on. Throw exception at the end. 733 // Screw it. Simply set the flag and carry on. Throw exception at the end.
731 set_accumulator(factory_->empty_string()); 734 set_accumulator(factory_->empty_string());
732 overflowed_ = true; 735 overflowed_ = true;
733 } else { 736 } else {
734 set_accumulator(factory_->NewConsString(accumulator(), current_part_)); 737 set_accumulator(factory_->NewConsString(accumulator(),
738 current_part_).ToHandleChecked());
735 } 739 }
736 } 740 }
737 741
738 742
739 void BasicJsonStringifier::Extend() { 743 void BasicJsonStringifier::Extend() {
740 Accumulate(); 744 Accumulate();
741 if (part_length_ <= kMaxPartLength / kPartLengthGrowthFactor) { 745 if (part_length_ <= kMaxPartLength / kPartLengthGrowthFactor) {
742 part_length_ *= kPartLengthGrowthFactor; 746 part_length_ *= kPartLengthGrowthFactor;
743 } 747 }
744 if (is_ascii_) { 748 if (is_ascii_) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 SerializeString_<false, uint8_t>(object); 881 SerializeString_<false, uint8_t>(object);
878 } else { 882 } else {
879 SerializeString_<false, uc16>(object); 883 SerializeString_<false, uc16>(object);
880 } 884 }
881 } 885 }
882 } 886 }
883 887
884 } } // namespace v8::internal 888 } } // namespace v8::internal
885 889
886 #endif // V8_JSON_STRINGIFIER_H_ 890 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698