}
Map* map;
- if (length <= String::kMaxShortStringSize) {
+ if (length <= String::kMaxShortSize) {
map = is_ascii ? short_cons_ascii_string_map()
: short_cons_string_map();
- } else if (length <= String::kMaxMediumStringSize) {
+ } else if (length <= String::kMaxMediumSize) {
map = is_ascii ? medium_cons_ascii_string_map()
: medium_cons_string_map();
} else {
}
Map* map;
- if (length <= String::kMaxShortStringSize) {
+ if (length <= String::kMaxShortSize) {
map = buffer->IsAsciiRepresentation() ?
short_sliced_ascii_string_map() :
short_sliced_string_map();
- } else if (length <= String::kMaxMediumStringSize) {
+ } else if (length <= String::kMaxMediumSize) {
map = buffer->IsAsciiRepresentation() ?
medium_sliced_ascii_string_map() :
medium_sliced_string_map();
ExternalAsciiString::Resource* resource) {
Map* map;
int length = resource->length();
- if (length <= String::kMaxShortStringSize) {
+ if (length <= String::kMaxShortSize) {
map = short_external_ascii_string_map();
- } else if (length <= String::kMaxMediumStringSize) {
+ } else if (length <= String::kMaxMediumSize) {
map = medium_external_ascii_string_map();
} else {
map = long_external_ascii_string_map();
Map* map;
if (is_ascii) {
- if (chars <= String::kMaxShortStringSize) {
+ if (chars <= String::kMaxShortSize) {
map = short_ascii_symbol_map();
- } else if (chars <= String::kMaxMediumStringSize) {
+ } else if (chars <= String::kMaxMediumSize) {
map = medium_ascii_symbol_map();
} else {
map = long_ascii_symbol_map();
}
size = SeqAsciiString::SizeFor(chars);
} else {
- if (chars <= String::kMaxShortStringSize) {
+ if (chars <= String::kMaxShortSize) {
map = short_symbol_map();
- } else if (chars <= String::kMaxMediumStringSize) {
+ } else if (chars <= String::kMaxMediumSize) {
map = medium_symbol_map();
} else {
map = long_symbol_map();
// Determine the map based on the string's length.
Map* map;
- if (length <= String::kMaxShortStringSize) {
+ if (length <= String::kMaxShortSize) {
map = short_ascii_string_map();
- } else if (length <= String::kMaxMediumStringSize) {
+ } else if (length <= String::kMaxMediumSize) {
map = medium_ascii_string_map();
} else {
map = long_ascii_string_map();
// Determine the map based on the string's length.
Map* map;
- if (length <= String::kMaxShortStringSize) {
+ if (length <= String::kMaxShortSize) {
map = short_string_map();
- } else if (length <= String::kMaxMediumStringSize) {
+ } else if (length <= String::kMaxMediumSize) {
map = medium_string_map();
} else {
map = long_string_map();
Map* ExternalAsciiString::StringMap(int length) {
Map* map;
// Number of characters: determines the map.
- if (length <= String::kMaxShortStringSize) {
+ if (length <= String::kMaxShortSize) {
map = Heap::short_external_ascii_string_map();
- } else if (length <= String::kMaxMediumStringSize) {
+ } else if (length <= String::kMaxMediumSize) {
map = Heap::medium_external_ascii_string_map();
} else {
map = Heap::long_external_ascii_string_map();
Map* ExternalAsciiString::SymbolMap(int length) {
Map* map;
// Number of characters: determines the map.
- if (length <= String::kMaxShortStringSize) {
+ if (length <= String::kMaxShortSize) {
map = Heap::short_external_ascii_symbol_map();
- } else if (length <= String::kMaxMediumStringSize) {
+ } else if (length <= String::kMaxMediumSize) {
map = Heap::medium_external_ascii_symbol_map();
} else {
map = Heap::long_external_ascii_symbol_map();
Map* ExternalTwoByteString::StringMap(int length) {
Map* map;
// Number of characters: determines the map.
- if (length <= String::kMaxShortStringSize) {
+ if (length <= String::kMaxShortSize) {
map = Heap::short_external_string_map();
- } else if (length <= String::kMaxMediumStringSize) {
+ } else if (length <= String::kMaxMediumSize) {
map = Heap::medium_external_string_map();
} else {
map = Heap::long_external_string_map();
Map* ExternalTwoByteString::SymbolMap(int length) {
Map* map;
// Number of characters: determines the map.
- if (length <= String::kMaxShortStringSize) {
+ if (length <= String::kMaxShortSize) {
map = Heap::short_external_symbol_map();
- } else if (length <= String::kMaxMediumStringSize) {
+ } else if (length <= String::kMaxMediumSize) {
map = Heap::medium_external_symbol_map();
} else {
map = Heap::long_external_symbol_map();
bool StringHasher::has_trivial_hash() {
- return length_ > String::kMaxMediumStringSize;
+ return length_ > String::kMaxMediumSize;
}
void String::StringShortPrint(StringStream* accumulator) {
int len = length();
- if (len > kMaxMediumStringSize) {
+ if (len > kMaxMediumSize) {
accumulator->Add("<Very long string[%u]>", len);
return;
}
uint32_t StringHasher::GetHashField() {
ASSERT(is_valid());
- if (length_ <= String::kMaxShortStringSize) {
+ if (length_ <= String::kMaxShortSize) {
uint32_t payload;
if (is_array_index()) {
payload = v8::internal::HashField(array_index(), true);
}
return (payload & ((1 << String::kShortLengthShift) - 1)) |
(length_ << String::kShortLengthShift);
- } else if (length_ <= String::kMaxMediumStringSize) {
+ } else if (length_ <= String::kMaxMediumSize) {
uint32_t payload = v8::internal::HashField(GetHash(), false);
return (payload & ((1 << String::kMediumLengthShift) - 1)) |
(length_ << String::kMediumLengthShift);
static const int kSize = kLengthOffset + kIntSize;
// Notice: kSize is not pointer-size aligned if pointers are 64-bit.
- // Limits on sizes of different types of strings.
- static const int kMaxShortStringSize = 63;
- static const int kMaxMediumStringSize = 16383;
-
+ // Maximum number of characters to consider when trying to convert a string
+ // value into an array index.
static const int kMaxArrayIndexSize = 10;
// Max ascii char code.
// field.
static const int kMaxCachedArrayIndexLength = 7;
- // Shift constants for retriving length and hash code from
+ // Shift constants for retrieving length and hash code from
// length/hash field.
static const int kHashShift = kNofLengthBitFields;
static const int kShortLengthShift = kHashShift + kShortStringTag;
static const int kMediumLengthShift = kHashShift + kMediumStringTag;
static const int kLongLengthShift = kHashShift + kLongStringTag;
- // Maximal string length that can be stored in the hash/length field.
+
+ // Maximal string length that can be stored in the hash/length field for
+ // different types of strings.
+ static const int kMaxShortSize = (1 << (32 - kShortLengthShift)) - 1;
+ static const int kMaxMediumSize = (1 << (32 - kMediumLengthShift)) - 1;
static const int kMaxLength = (1 << (32 - kLongLengthShift)) - 1;
// Limit for truncation in short printing.
void StringStream::PrintObject(Object* o) {
o->ShortPrint(this);
if (o->IsString()) {
- if (String::cast(o)->length() <= String::kMaxMediumStringSize) {
+ if (String::cast(o)->length() <= String::kMaxMediumSize) {
return;
}
} else if (o->IsNumber() || o->IsOddball()) {
CHECK(string->map() == i::Heap::short_external_ascii_string_map() ||
string->map() == i::Heap::medium_external_ascii_string_map());
// Morph external string to be TwoByte string.
- if (string->length() <= i::String::kMaxShortStringSize) {
+ if (string->length() <= i::String::kMaxShortSize) {
string->set_map(i::Heap::short_external_string_map());
} else {
string->set_map(i::Heap::medium_external_string_map());
CHECK(string->map() == i::Heap::short_external_string_map() ||
string->map() == i::Heap::medium_external_string_map());
// Morph external string to be ASCII string.
- if (string->length() <= i::String::kMaxShortStringSize) {
+ if (string->length() <= i::String::kMaxShortSize) {
string->set_map(i::Heap::short_external_ascii_string_map());
} else {
string->set_map(i::Heap::medium_external_ascii_string_map());