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

Unified Diff: src/json-stringifier.h

Issue 13782002: Fix slow path of JSON.stringifier when GC strikes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-json-stringify-gc.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/json-stringifier.h
diff --git a/src/json-stringifier.h b/src/json-stringifier.h
index bcdd64ce7643e57bb3732c51cfe2fb5d9a7b3217..a154a4e99a3db613a6ddf555cec9a1762773fff4 100644
--- a/src/json-stringifier.h
+++ b/src/json-stringifier.h
@@ -295,19 +295,30 @@ MaybeObject* BasicJsonStringifier::StringifyString(Isolate* isolate,
return stringifier.Stringify(object);
}
- FlattenString(object);
- String::FlatContent flat = object->GetFlatContent();
- if (flat.IsAscii()) {
+ object = FlattenGetString(object);
+ ASSERT(object->IsFlat());
+ if (object->IsOneByteRepresentation()) {
+ Handle<String> result =
+ isolate->factory()->NewRawOneByteString(worst_case_length);
+ AssertNoAllocation no_alloc;
+ const uint8_t* start = object->IsSeqOneByteString()
+ ? SeqOneByteString::cast(*object)->GetChars()
+ : ExternalAsciiString::cast(*object)->GetChars();
return StringifyString_<SeqOneByteString>(
isolate,
- flat.ToOneByteVector(),
- isolate->factory()->NewRawOneByteString(worst_case_length));
+ Vector<const uint8_t>(start, object->length()),
+ result);
} else {
- ASSERT(flat.IsTwoByte());
+ Handle<String> result =
+ isolate->factory()->NewRawTwoByteString(worst_case_length);
+ AssertNoAllocation no_alloc;
+ const uc16* start = object->IsSeqTwoByteString()
+ ? SeqTwoByteString::cast(*object)->GetChars()
+ : ExternalTwoByteString::cast(*object)->GetChars();
return StringifyString_<SeqTwoByteString>(
isolate,
- flat.ToUC16Vector(),
- isolate->factory()->NewRawTwoByteString(worst_case_length));
+ Vector<const uc16>(start, object->length()),
+ result);
}
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-json-stringify-gc.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698