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

Side by Side Diff: src/objects.cc

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.h ('k') | src/objects-debug.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-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 accumulator->Add("Cell for "); 1017 accumulator->Add("Cell for ");
1018 JSGlobalPropertyCell::cast(this)->value()->ShortPrint(accumulator); 1018 JSGlobalPropertyCell::cast(this)->value()->ShortPrint(accumulator);
1019 break; 1019 break;
1020 default: 1020 default:
1021 accumulator->Add("<Other heap object (%d)>", map()->instance_type()); 1021 accumulator->Add("<Other heap object (%d)>", map()->instance_type());
1022 break; 1022 break;
1023 } 1023 }
1024 } 1024 }
1025 1025
1026 1026
1027 int HeapObject::SlowSizeFromMap(Map* map) {
1028 // Avoid calling functions such as FixedArray::cast during GC, which
1029 // read map pointer of this object again.
1030 InstanceType instance_type = map->instance_type();
1031 uint32_t type = static_cast<uint32_t>(instance_type);
1032
1033 if (instance_type < FIRST_NONSTRING_TYPE
1034 && (StringShape(instance_type).IsSequential())) {
1035 if ((type & kStringEncodingMask) == kAsciiStringTag) {
1036 SeqAsciiString* seq_ascii_this = reinterpret_cast<SeqAsciiString*>(this);
1037 return seq_ascii_this->SeqAsciiStringSize(instance_type);
1038 } else {
1039 SeqTwoByteString* self = reinterpret_cast<SeqTwoByteString*>(this);
1040 return self->SeqTwoByteStringSize(instance_type);
1041 }
1042 }
1043
1044 switch (instance_type) {
1045 case FIXED_ARRAY_TYPE:
1046 return FixedArray::BodyDescriptor::SizeOf(map, this);
1047 case BYTE_ARRAY_TYPE:
1048 return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
1049 case CODE_TYPE:
1050 return reinterpret_cast<Code*>(this)->CodeSize();
1051 case MAP_TYPE:
1052 return Map::kSize;
1053 default:
1054 return map->instance_size();
1055 }
1056 }
1057
1058
1059 void HeapObject::Iterate(ObjectVisitor* v) { 1027 void HeapObject::Iterate(ObjectVisitor* v) {
1060 // Handle header 1028 // Handle header
1061 IteratePointer(v, kMapOffset); 1029 IteratePointer(v, kMapOffset);
1062 // Handle object body 1030 // Handle object body
1063 Map* m = map(); 1031 Map* m = map();
1064 IterateBody(m->instance_type(), SizeFromMap(m), v); 1032 IterateBody(m->instance_type(), SizeFromMap(m), v);
1065 } 1033 }
1066 1034
1067 1035
1068 void HeapObject::IterateBody(InstanceType type, int object_size, 1036 void HeapObject::IterateBody(InstanceType type, int object_size,
(...skipping 7704 matching lines...) Expand 10 before | Expand all | Expand 10 after
8773 if (break_point_objects()->IsUndefined()) return 0; 8741 if (break_point_objects()->IsUndefined()) return 0;
8774 // Single beak point. 8742 // Single beak point.
8775 if (!break_point_objects()->IsFixedArray()) return 1; 8743 if (!break_point_objects()->IsFixedArray()) return 1;
8776 // Multiple break points. 8744 // Multiple break points.
8777 return FixedArray::cast(break_point_objects())->length(); 8745 return FixedArray::cast(break_point_objects())->length();
8778 } 8746 }
8779 #endif 8747 #endif
8780 8748
8781 8749
8782 } } // namespace v8::internal 8750 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698