summaryrefslogtreecommitdiff
path: root/deps/v8/src/json-stringifier.h
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-06-11 23:45:46 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-06-11 23:46:00 +0200
commit6dd78074a3c0a7579ca5e919021587c22ff763ae (patch)
treee225460f8e76126f4e4b2e1809dbd4c9c2ba511b /deps/v8/src/json-stringifier.h
parent9ae1d182ba98629ac7c7b9100022ac93133494b7 (diff)
downloadnode-new-6dd78074a3c0a7579ca5e919021587c22ff763ae.tar.gz
v8: upgrade to v3.19.13
Diffstat (limited to 'deps/v8/src/json-stringifier.h')
-rw-r--r--deps/v8/src/json-stringifier.h33
1 files changed, 17 insertions, 16 deletions
diff --git a/deps/v8/src/json-stringifier.h b/deps/v8/src/json-stringifier.h
index b67a9f6b6a..31aebd6ddb 100644
--- a/deps/v8/src/json-stringifier.h
+++ b/deps/v8/src/json-stringifier.h
@@ -300,7 +300,7 @@ MaybeObject* BasicJsonStringifier::StringifyString(Isolate* isolate,
if (object->IsOneByteRepresentationUnderneath()) {
Handle<String> result =
isolate->factory()->NewRawOneByteString(worst_case_length);
- AssertNoAllocation no_alloc;
+ DisallowHeapAllocation no_gc;
return StringifyString_<SeqOneByteString>(
isolate,
object->GetFlatContent().ToOneByteVector(),
@@ -308,7 +308,7 @@ MaybeObject* BasicJsonStringifier::StringifyString(Isolate* isolate,
} else {
Handle<String> result =
isolate->factory()->NewRawTwoByteString(worst_case_length);
- AssertNoAllocation no_alloc;
+ DisallowHeapAllocation no_gc;
return StringifyString_<SeqTwoByteString>(
isolate,
object->GetFlatContent().ToUC16Vector(),
@@ -321,7 +321,7 @@ template <typename ResultType, typename Char>
MaybeObject* BasicJsonStringifier::StringifyString_(Isolate* isolate,
Vector<Char> vector,
Handle<String> result) {
- AssertNoAllocation no_allocation;
+ DisallowHeapAllocation no_gc;
int final_size = 0;
ResultType* dest = ResultType::cast(*result);
dest->Set(final_size++, '\"');
@@ -640,7 +640,7 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSObject(
if (!name->IsString()) continue;
Handle<String> key = Handle<String>::cast(name);
PropertyDetails details = map->instance_descriptors()->GetDetails(i);
- if (details.IsDontEnum() || details.IsDeleted()) continue;
+ if (details.IsDontEnum()) continue;
Handle<Object> property;
if (details.type() == FIELD && *map == object->map()) {
property = Handle<Object>(
@@ -759,7 +759,7 @@ void BasicJsonStringifier::SerializeString_(Handle<String> string) {
// is a more pessimistic estimate, but faster to calculate.
if (((part_length_ - current_index_) >> 3) > length) {
- AssertNoAllocation no_allocation;
+ DisallowHeapAllocation no_gc;
Vector<const Char> vector = GetCharVector<Char>(string);
if (is_ascii) {
current_index_ += SerializeStringUnchecked_(
@@ -773,9 +773,16 @@ void BasicJsonStringifier::SerializeString_(Handle<String> string) {
length);
}
} else {
- String* string_location = *string;
- Vector<const Char> vector = GetCharVector<Char>(string);
+ String* string_location = NULL;
+ Vector<const Char> vector(NULL, 0);
for (int i = 0; i < length; i++) {
+ // If GC moved the string, we need to refresh the vector.
+ if (*string != string_location) {
+ DisallowHeapAllocation no_gc;
+ // This does not actually prevent the string from being relocated later.
+ vector = GetCharVector<Char>(string);
+ string_location = *string;
+ }
Char c = vector[i];
if (DoNotEscape(c)) {
Append_<is_ascii, Char>(c);
@@ -783,11 +790,6 @@ void BasicJsonStringifier::SerializeString_(Handle<String> string) {
Append_<is_ascii, uint8_t>(reinterpret_cast<const uint8_t*>(
&JsonEscapeTable[c * kJsonEscapeTableEntrySize]));
}
- // If GC moved the string, we need to refresh the vector.
- if (*string != string_location) {
- vector = GetCharVector<Char>(string);
- string_location = *string;
- }
}
}
@@ -825,17 +827,16 @@ Vector<const uc16> BasicJsonStringifier::GetCharVector(Handle<String> string) {
void BasicJsonStringifier::SerializeString(Handle<String> object) {
- FlattenString(object);
- String::FlatContent flat = object->GetFlatContent();
+ object = FlattenGetString(object);
if (is_ascii_) {
- if (flat.IsAscii()) {
+ if (object->IsOneByteRepresentation()) {
SerializeString_<true, uint8_t>(object);
} else {
ChangeEncoding();
SerializeString(object);
}
} else {
- if (flat.IsAscii()) {
+ if (object->IsOneByteRepresentation()) {
SerializeString_<false, uint8_t>(object);
} else {
SerializeString_<false, uc16>(object);