| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index 0ecc2867ac0b4706c209f3fa57b5fec1754caaa2..0aa0806b866349aa64750c184a6b7e1d5d27e746 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -3007,7 +3007,12 @@ MaybeObject* Heap::AllocateExternalStringFromAscii(
|
| return Failure::OutOfMemoryException();
|
| }
|
|
|
| - Map* map = external_ascii_string_map();
|
| + Map* map;
|
| + if (length < static_cast<size_t>(ExternalString::kMinBufferedStringLength)) {
|
| + map = external_ascii_string_map();
|
| + } else {
|
| + map = external_buffered_ascii_string_map();
|
| + }
|
| Object* result;
|
| { MaybeObject* maybe_result = Allocate(map, NEW_SPACE);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| @@ -3017,7 +3022,9 @@ MaybeObject* Heap::AllocateExternalStringFromAscii(
|
| external_string->set_length(static_cast<int>(length));
|
| external_string->set_hash_field(String::kEmptyHashField);
|
| external_string->set_resource(resource);
|
| -
|
| + if (external_string->IsBuffered()) {
|
| + external_string->set_buffer_index(ExternalString::kInvalidBufferIndex);
|
| + }
|
| return result;
|
| }
|
|
|
| @@ -3035,8 +3042,14 @@ MaybeObject* Heap::AllocateExternalStringFromTwoByte(
|
| static const size_t kAsciiCheckLengthLimit = 32;
|
| bool is_ascii = length <= kAsciiCheckLengthLimit &&
|
| String::IsAscii(resource->data(), static_cast<int>(length));
|
| - Map* map = is_ascii ?
|
| - external_string_with_ascii_data_map() : external_string_map();
|
| + Map* map;
|
| + if (length < static_cast<size_t>(ExternalString::kMinBufferedStringLength)) {
|
| + map = is_ascii ? external_string_with_ascii_data_map()
|
| + : external_string_map();
|
| + } else {
|
| + map = is_ascii ? external_buffered_string_with_ascii_data_map()
|
| + : external_buffered_string_map();
|
| + }
|
| Object* result;
|
| { MaybeObject* maybe_result = Allocate(map, NEW_SPACE);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| @@ -3046,7 +3059,9 @@ MaybeObject* Heap::AllocateExternalStringFromTwoByte(
|
| external_string->set_length(static_cast<int>(length));
|
| external_string->set_hash_field(String::kEmptyHashField);
|
| external_string->set_resource(resource);
|
| -
|
| + if (external_string->IsBuffered()) {
|
| + external_string->set_buffer_index(ExternalString::kInvalidBufferIndex);
|
| + }
|
| return result;
|
| }
|
|
|
|
|