| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |