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

Unified Diff: src/heap.cc

Issue 8568013: Introduce read buffer for external strings when using charAt (ia32). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 9 years, 1 month 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 | « src/heap.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « src/heap.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698