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

Unified Diff: src/objects-inl.h

Issue 17895002: The check for internalized strings relied on the fact that we had less (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: More comments Created 7 years, 6 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.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index f3d2a661ae171b64fd658ad2fc35205a6bba37c6..5920679f6ab9b70360f151512257092ca81ffefc 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -221,12 +221,9 @@ bool Object::IsSpecFunction() {
bool Object::IsInternalizedString() {
if (!this->IsHeapObject()) return false;
uint32_t type = HeapObject::cast(this)->map()->instance_type();
- // Because the internalized tag is non-zero and no non-string types have the
- // internalized bit set we can test for internalized strings with a very
- // simple test operation.
STATIC_ASSERT(kInternalizedTag != 0);
- ASSERT(kNotStringTag + kIsInternalizedMask > LAST_TYPE);
- return (type & kIsInternalizedMask) != 0;
+ return (type & (kIsNotStringMask | kIsInternalizedMask)) ==
+ (kInternalizedTag | kStringTag);
}
@@ -323,7 +320,8 @@ StringShape::StringShape(InstanceType t)
bool StringShape::IsInternalized() {
ASSERT(valid());
STATIC_ASSERT(kInternalizedTag != 0);
- return (type_ & kIsInternalizedMask) != 0;
+ return (type_ & (kIsNotStringMask | kIsInternalizedMask)) ==
+ (kInternalizedTag | kStringTag);
}
@@ -3388,15 +3386,13 @@ int Map::pre_allocated_property_fields() {
int HeapObject::SizeFromMap(Map* map) {
int instance_size = map->instance_size();
if (instance_size != kVariableSizeSentinel) return instance_size;
- // We can ignore the "internalized" bit because it is only set for strings
- // and thus implies a string type.
- int instance_type =
- static_cast<int>(map->instance_type()) & ~kIsInternalizedMask;
// Only inline the most frequent cases.
+ int instance_type = static_cast<int>(map->instance_type());
if (instance_type == FIXED_ARRAY_TYPE) {
return FixedArray::BodyDescriptor::SizeOf(map, this);
}
- if (instance_type == ASCII_STRING_TYPE) {
+ if (instance_type == ASCII_STRING_TYPE ||
+ instance_type == ASCII_INTERNALIZED_STRING_TYPE) {
return SeqOneByteString::SizeFor(
reinterpret_cast<SeqOneByteString*>(this)->length());
}
@@ -3406,7 +3402,8 @@ int HeapObject::SizeFromMap(Map* map) {
if (instance_type == FREE_SPACE_TYPE) {
return reinterpret_cast<FreeSpace*>(this)->size();
}
- if (instance_type == STRING_TYPE) {
+ if (instance_type == STRING_TYPE ||
+ instance_type == INTERNALIZED_STRING_TYPE) {
return SeqTwoByteString::SizeFor(
reinterpret_cast<SeqTwoByteString*>(this)->length());
}
« no previous file with comments | « src/objects.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698