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

Unified Diff: src/objects-inl.h

Issue 3127016: Make instance_size immediately useful for all fixed size objects. (Closed)
Patch Set: Comment fix. Created 10 years, 4 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-debug.cc ('k') | test/cctest/test-heap.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 c70ab022c6c4b3adccf285ea2365ae602e731b98..7bd4514ed025edf7e112bada0f53f08a819ed09b 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2111,20 +2111,28 @@ int Map::pre_allocated_property_fields() {
int HeapObject::SizeFromMap(Map* map) {
- InstanceType instance_type = map->instance_type();
+ int instance_size = map->instance_size();
+ if (instance_size != kVariableSizeSentinel) return instance_size;
+ // We can ignore the "symbol" bit becase it is only set for symbols
+ // and implies a string type.
+ int instance_type = static_cast<int>(map->instance_type()) & ~kIsSymbolMask;
// Only inline the most frequent cases.
- if (instance_type == JS_OBJECT_TYPE ||
- (instance_type & (kIsNotStringMask | kStringRepresentationMask)) ==
- (kStringTag | kConsStringTag) ||
- instance_type == JS_ARRAY_TYPE) return map->instance_size();
if (instance_type == FIXED_ARRAY_TYPE) {
return FixedArray::BodyDescriptor::SizeOf(map, this);
}
+ if (instance_type == ASCII_STRING_TYPE) {
+ return SeqAsciiString::SizeFor(
+ reinterpret_cast<SeqAsciiString*>(this)->length());
+ }
if (instance_type == BYTE_ARRAY_TYPE) {
return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
}
- // Otherwise do the general size computation.
- return SlowSizeFromMap(map);
+ if (instance_type == STRING_TYPE) {
+ return SeqTwoByteString::SizeFor(
+ reinterpret_cast<SeqTwoByteString*>(this)->length());
+ }
+ ASSERT(instance_type == CODE_TYPE);
+ return reinterpret_cast<Code*>(this)->CodeSize();
}
« no previous file with comments | « src/objects-debug.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698