Index: src/objects-inl.h |
=================================================================== |
--- src/objects-inl.h (revision 3336) |
+++ src/objects-inl.h (working copy) |
@@ -280,11 +280,6 @@ |
Internals::kFullStringRepresentationMask); |
-uint32_t StringShape::size_tag() { |
- return (type_ & kStringSizeMask); |
-} |
- |
- |
bool StringShape::IsSequentialAscii() { |
return full_representation_tag() == (kSeqStringTag | kAsciiStringTag); |
} |
@@ -1635,47 +1630,28 @@ |
INT_ACCESSORS(Array, length, kLengthOffset) |
-bool String::Equals(String* other) { |
- if (other == this) return true; |
- if (StringShape(this).IsSymbol() && StringShape(other).IsSymbol()) { |
- return false; |
- } |
- return SlowEquals(other); |
-} |
+INT_ACCESSORS(String, length, kLengthOffset) |
-int String::length() { |
- uint32_t len = READ_INT_FIELD(this, kLengthOffset); |
- |
- ASSERT(kShortStringTag + kLongLengthShift == kShortLengthShift); |
- ASSERT(kMediumStringTag + kLongLengthShift == kMediumLengthShift); |
- ASSERT(kLongStringTag == 0); |
- |
- return len >> (StringShape(this).size_tag() + kLongLengthShift); |
+uint32_t String::hash_field() { |
+ return READ_UINT32_FIELD(this, kHashFieldOffset); |
} |
-void String::set_length(int value) { |
- ASSERT(kShortStringTag + kLongLengthShift == kShortLengthShift); |
- ASSERT(kMediumStringTag + kLongLengthShift == kMediumLengthShift); |
- ASSERT(kLongStringTag == 0); |
- |
- WRITE_INT_FIELD(this, |
- kLengthOffset, |
- value << (StringShape(this).size_tag() + kLongLengthShift)); |
+void String::set_hash_field(uint32_t value) { |
+ WRITE_UINT32_FIELD(this, kHashFieldOffset, value); |
} |
-uint32_t String::length_field() { |
- return READ_UINT32_FIELD(this, kLengthOffset); |
+bool String::Equals(String* other) { |
+ if (other == this) return true; |
+ if (StringShape(this).IsSymbol() && StringShape(other).IsSymbol()) { |
+ return false; |
+ } |
+ return SlowEquals(other); |
} |
-void String::set_length_field(uint32_t value) { |
- WRITE_UINT32_FIELD(this, kLengthOffset, value); |
-} |
- |
- |
Object* String::TryFlattenIfNotFlat() { |
// We don't need to flatten strings that are already flat. Since this code |
// is inlined, it can be helpful in the flat case to not call out to Flatten. |
@@ -1779,30 +1755,12 @@ |
int SeqTwoByteString::SeqTwoByteStringSize(InstanceType instance_type) { |
uint32_t length = READ_INT_FIELD(this, kLengthOffset); |
- |
- ASSERT(kShortStringTag + kLongLengthShift == kShortLengthShift); |
- ASSERT(kMediumStringTag + kLongLengthShift == kMediumLengthShift); |
- ASSERT(kLongStringTag == 0); |
- |
- // Use the map (and not 'this') to compute the size tag, since |
- // TwoByteStringSize is called during GC when maps are encoded. |
- length >>= StringShape(instance_type).size_tag() + kLongLengthShift; |
- |
return SizeFor(length); |
} |
int SeqAsciiString::SeqAsciiStringSize(InstanceType instance_type) { |
uint32_t length = READ_INT_FIELD(this, kLengthOffset); |
- |
- ASSERT(kShortStringTag + kLongLengthShift == kShortLengthShift); |
- ASSERT(kMediumStringTag + kLongLengthShift == kMediumLengthShift); |
- ASSERT(kLongStringTag == 0); |
- |
- // Use the map (and not 'this') to compute the size tag, since |
- // AsciiStringSize is called during GC when maps are encoded. |
- length >>= StringShape(instance_type).size_tag() + kLongLengthShift; |
- |
return SizeFor(length); |
} |
@@ -1850,34 +1808,6 @@ |
} |
-Map* ExternalAsciiString::StringMap(int length) { |
- Map* map; |
- // Number of characters: determines the map. |
- if (length <= String::kMaxShortSize) { |
- map = Heap::short_external_ascii_string_map(); |
- } else if (length <= String::kMaxMediumSize) { |
- 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::kMaxShortSize) { |
- map = Heap::short_external_ascii_symbol_map(); |
- } else if (length <= String::kMaxMediumSize) { |
- 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)); |
} |
@@ -1889,34 +1819,6 @@ |
} |
-Map* ExternalTwoByteString::StringMap(int length) { |
- Map* map; |
- // Number of characters: determines the map. |
- if (length <= String::kMaxShortSize) { |
- map = Heap::short_external_string_map(); |
- } else if (length <= String::kMaxMediumSize) { |
- 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::kMaxShortSize) { |
- map = Heap::short_external_symbol_map(); |
- } else if (length <= String::kMaxMediumSize) { |
- 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); |
@@ -2900,13 +2802,13 @@ |
bool String::HasHashCode() { |
- return (length_field() & kHashComputedMask) != 0; |
+ return (hash_field() & kHashComputedMask) != 0; |
} |
uint32_t String::Hash() { |
// Fast case: has hash code already been computed? |
- uint32_t field = length_field(); |
+ uint32_t field = hash_field(); |
if (field & kHashComputedMask) return field >> kHashShift; |
// Slow case: compute hash code and set it. |
return ComputeAndSetHash(); |
@@ -2923,7 +2825,7 @@ |
bool StringHasher::has_trivial_hash() { |
- return length_ > String::kMaxMediumSize; |
+ return length_ > String::kMaxHashCalcLength; |
} |
@@ -2979,7 +2881,7 @@ |
bool String::AsArrayIndex(uint32_t* index) { |
- uint32_t field = length_field(); |
+ uint32_t field = hash_field(); |
if ((field & kHashComputedMask) && !(field & kIsArrayIndexMask)) return false; |
return SlowAsArrayIndex(index); |
} |