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

Unified Diff: src/objects-inl.h

Issue 21117: Allow the morphing of strings to external strings to avoid having to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 10 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 | « src/objects.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
===================================================================
--- src/objects-inl.h (revision 1251)
+++ src/objects-inl.h (working copy)
@@ -1639,6 +1639,34 @@
}
+Map* ExternalAsciiString::StringMap(int length) {
+ Map* map;
+ // Number of characters: determines the map.
+ if (length <= String::kMaxShortStringSize) {
+ map = Heap::short_external_ascii_string_map();
+ } else if (length <= String::kMaxMediumStringSize) {
+ map = Heap::medium_external_ascii_string_map();
+ } else {
+ map = Heap::long_external_ascii_string_map();
+ }
+ return map;
+}
+
+
+Map* ExternalAsciiString::SymbolMap(int length) {
+ Map* map;
+ // Number of characters: determines the map.
+ if (length <= String::kMaxShortStringSize) {
+ map = Heap::short_external_ascii_symbol_map();
+ } else if (length <= String::kMaxMediumStringSize) {
+ map = Heap::medium_external_ascii_symbol_map();
+ } else {
+ map = Heap::long_external_ascii_symbol_map();
+ }
+ return map;
+}
+
+
ExternalTwoByteString::Resource* ExternalTwoByteString::resource() {
return *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset));
}
@@ -1650,6 +1678,34 @@
}
+Map* ExternalTwoByteString::StringMap(int length) {
+ Map* map;
+ // Number of characters: determines the map.
+ if (length <= String::kMaxShortStringSize) {
+ map = Heap::short_external_string_map();
+ } else if (length <= String::kMaxMediumStringSize) {
+ map = Heap::medium_external_string_map();
+ } else {
+ map = Heap::long_external_string_map();
+ }
+ return map;
+}
+
+
+Map* ExternalTwoByteString::SymbolMap(int length) {
+ Map* map;
+ // Number of characters: determines the map.
+ if (length <= String::kMaxShortStringSize) {
+ map = Heap::short_external_symbol_map();
+ } else if (length <= String::kMaxMediumStringSize) {
+ map = Heap::medium_external_symbol_map();
+ } else {
+ map = Heap::long_external_symbol_map();
+ }
+ return map;
+}
+
+
byte ByteArray::get(int index) {
ASSERT(index >= 0 && index < this->length());
return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698