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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/objects-debug.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); 2104 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset);
2105 } 2105 }
2106 2106
2107 2107
2108 int Map::pre_allocated_property_fields() { 2108 int Map::pre_allocated_property_fields() {
2109 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); 2109 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset);
2110 } 2110 }
2111 2111
2112 2112
2113 int HeapObject::SizeFromMap(Map* map) { 2113 int HeapObject::SizeFromMap(Map* map) {
2114 InstanceType instance_type = map->instance_type(); 2114 int instance_size = map->instance_size();
2115 if (instance_size != kVariableSizeSentinel) return instance_size;
2116 // We can ignore the "symbol" bit becase it is only set for symbols
2117 // and implies a string type.
2118 int instance_type = static_cast<int>(map->instance_type()) & ~kIsSymbolMask;
2115 // Only inline the most frequent cases. 2119 // Only inline the most frequent cases.
2116 if (instance_type == JS_OBJECT_TYPE ||
2117 (instance_type & (kIsNotStringMask | kStringRepresentationMask)) ==
2118 (kStringTag | kConsStringTag) ||
2119 instance_type == JS_ARRAY_TYPE) return map->instance_size();
2120 if (instance_type == FIXED_ARRAY_TYPE) { 2120 if (instance_type == FIXED_ARRAY_TYPE) {
2121 return FixedArray::BodyDescriptor::SizeOf(map, this); 2121 return FixedArray::BodyDescriptor::SizeOf(map, this);
2122 } 2122 }
2123 if (instance_type == ASCII_STRING_TYPE) {
2124 return SeqAsciiString::SizeFor(
2125 reinterpret_cast<SeqAsciiString*>(this)->length());
2126 }
2123 if (instance_type == BYTE_ARRAY_TYPE) { 2127 if (instance_type == BYTE_ARRAY_TYPE) {
2124 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); 2128 return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
2125 } 2129 }
2126 // Otherwise do the general size computation. 2130 if (instance_type == STRING_TYPE) {
2127 return SlowSizeFromMap(map); 2131 return SeqTwoByteString::SizeFor(
2132 reinterpret_cast<SeqTwoByteString*>(this)->length());
2133 }
2134 ASSERT(instance_type == CODE_TYPE);
2135 return reinterpret_cast<Code*>(this)->CodeSize();
2128 } 2136 }
2129 2137
2130 2138
2131 void Map::set_instance_size(int value) { 2139 void Map::set_instance_size(int value) {
2132 ASSERT_EQ(0, value & (kPointerSize - 1)); 2140 ASSERT_EQ(0, value & (kPointerSize - 1));
2133 value >>= kPointerSizeLog2; 2141 value >>= kPointerSizeLog2;
2134 ASSERT(0 <= value && value < 256); 2142 ASSERT(0 <= value && value < 256);
2135 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); 2143 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value));
2136 } 2144 }
2137 2145
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
3449 #undef WRITE_INT_FIELD 3457 #undef WRITE_INT_FIELD
3450 #undef READ_SHORT_FIELD 3458 #undef READ_SHORT_FIELD
3451 #undef WRITE_SHORT_FIELD 3459 #undef WRITE_SHORT_FIELD
3452 #undef READ_BYTE_FIELD 3460 #undef READ_BYTE_FIELD
3453 #undef WRITE_BYTE_FIELD 3461 #undef WRITE_BYTE_FIELD
3454 3462
3455 3463
3456 } } // namespace v8::internal 3464 } } // namespace v8::internal
3457 3465
3458 #endif // V8_OBJECTS_INL_H_ 3466 #endif // V8_OBJECTS_INL_H_
OLDNEW
« 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