OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/heap/spaces.h" | 5 #include "src/heap/spaces.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
10 #include "src/heap/slot-set.h" | 10 #include "src/heap/slot-set.h" |
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 HeapObject* object = HeapObject::FromAddress(current); | 1639 HeapObject* object = HeapObject::FromAddress(current); |
1640 | 1640 |
1641 // The first word should be a map, and we expect all map pointers to | 1641 // The first word should be a map, and we expect all map pointers to |
1642 // be in map space. | 1642 // be in map space. |
1643 Map* map = object->map(); | 1643 Map* map = object->map(); |
1644 CHECK(map->IsMap()); | 1644 CHECK(map->IsMap()); |
1645 CHECK(heap()->map_space()->Contains(map)); | 1645 CHECK(heap()->map_space()->Contains(map)); |
1646 | 1646 |
1647 // The object should not be code or a map. | 1647 // The object should not be code or a map. |
1648 CHECK(!object->IsMap()); | 1648 CHECK(!object->IsMap()); |
1649 CHECK(!object->IsCode()); | 1649 CHECK(!object->IsAbstractCode()); |
1650 | 1650 |
1651 // The object itself should look OK. | 1651 // The object itself should look OK. |
1652 object->ObjectVerify(); | 1652 object->ObjectVerify(); |
1653 | 1653 |
1654 // All the interior pointers should be contained in the heap. | 1654 // All the interior pointers should be contained in the heap. |
1655 VerifyPointersVisitor visitor; | 1655 VerifyPointersVisitor visitor; |
1656 int size = object->Size(); | 1656 int size = object->Size(); |
1657 object->IterateBody(map->instance_type(), size, &visitor); | 1657 object->IterateBody(map->instance_type(), size, &visitor); |
1658 | 1658 |
1659 current += size; | 1659 current += size; |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2773 } | 2773 } |
2774 | 2774 |
2775 | 2775 |
2776 // Collects code size statistics: | 2776 // Collects code size statistics: |
2777 // - by code kind | 2777 // - by code kind |
2778 // - by code comment | 2778 // - by code comment |
2779 void PagedSpace::CollectCodeStatistics() { | 2779 void PagedSpace::CollectCodeStatistics() { |
2780 Isolate* isolate = heap()->isolate(); | 2780 Isolate* isolate = heap()->isolate(); |
2781 HeapObjectIterator obj_it(this); | 2781 HeapObjectIterator obj_it(this); |
2782 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { | 2782 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { |
| 2783 if (obj->IsAbstractCode()) { |
| 2784 AbstractCode* code = AbstractCode::cast(obj); |
| 2785 isolate->code_kind_statistics()[code->kind()] += code->Size(); |
| 2786 } |
2783 if (obj->IsCode()) { | 2787 if (obj->IsCode()) { |
| 2788 // TODO(mythria): Also enable this for BytecodeArray when it supports |
| 2789 // RelocInformation. |
2784 Code* code = Code::cast(obj); | 2790 Code* code = Code::cast(obj); |
2785 isolate->code_kind_statistics()[code->kind()] += code->Size(); | |
2786 RelocIterator it(code); | 2791 RelocIterator it(code); |
2787 int delta = 0; | 2792 int delta = 0; |
2788 const byte* prev_pc = code->instruction_start(); | 2793 const byte* prev_pc = code->instruction_start(); |
2789 while (!it.done()) { | 2794 while (!it.done()) { |
2790 if (it.rinfo()->rmode() == RelocInfo::COMMENT) { | 2795 if (it.rinfo()->rmode() == RelocInfo::COMMENT) { |
2791 delta += static_cast<int>(it.rinfo()->pc() - prev_pc); | 2796 delta += static_cast<int>(it.rinfo()->pc() - prev_pc); |
2792 CollectCommentStatistics(isolate, &it); | 2797 CollectCommentStatistics(isolate, &it); |
2793 prev_pc = it.rinfo()->pc(); | 2798 prev_pc = it.rinfo()->pc(); |
2794 } | 2799 } |
2795 it.next(); | 2800 it.next(); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3066 // The first word should be a map, and we expect all map pointers to be | 3071 // The first word should be a map, and we expect all map pointers to be |
3067 // in map space. | 3072 // in map space. |
3068 Map* map = object->map(); | 3073 Map* map = object->map(); |
3069 CHECK(map->IsMap()); | 3074 CHECK(map->IsMap()); |
3070 CHECK(heap()->map_space()->Contains(map)); | 3075 CHECK(heap()->map_space()->Contains(map)); |
3071 | 3076 |
3072 // We have only code, sequential strings, external strings | 3077 // We have only code, sequential strings, external strings |
3073 // (sequential strings that have been morphed into external | 3078 // (sequential strings that have been morphed into external |
3074 // strings), fixed arrays, byte arrays, and constant pool arrays in the | 3079 // strings), fixed arrays, byte arrays, and constant pool arrays in the |
3075 // large object space. | 3080 // large object space. |
3076 CHECK(object->IsCode() || object->IsSeqString() || | 3081 CHECK(object->IsAbstractCode() || object->IsSeqString() || |
3077 object->IsExternalString() || object->IsFixedArray() || | 3082 object->IsExternalString() || object->IsFixedArray() || |
3078 object->IsFixedDoubleArray() || object->IsByteArray()); | 3083 object->IsFixedDoubleArray() || object->IsByteArray()); |
3079 | 3084 |
3080 // The object itself should look OK. | 3085 // The object itself should look OK. |
3081 object->ObjectVerify(); | 3086 object->ObjectVerify(); |
3082 | 3087 |
3083 // Byte arrays and strings don't have interior pointers. | 3088 // Byte arrays and strings don't have interior pointers. |
3084 if (object->IsCode()) { | 3089 if (object->IsAbstractCode()) { |
3085 VerifyPointersVisitor code_visitor; | 3090 VerifyPointersVisitor code_visitor; |
3086 object->IterateBody(map->instance_type(), object->Size(), &code_visitor); | 3091 object->IterateBody(map->instance_type(), object->Size(), &code_visitor); |
3087 } else if (object->IsFixedArray()) { | 3092 } else if (object->IsFixedArray()) { |
3088 FixedArray* array = FixedArray::cast(object); | 3093 FixedArray* array = FixedArray::cast(object); |
3089 for (int j = 0; j < array->length(); j++) { | 3094 for (int j = 0; j < array->length(); j++) { |
3090 Object* element = array->get(j); | 3095 Object* element = array->get(j); |
3091 if (element->IsHeapObject()) { | 3096 if (element->IsHeapObject()) { |
3092 HeapObject* element_object = HeapObject::cast(element); | 3097 HeapObject* element_object = HeapObject::cast(element); |
3093 CHECK(heap()->Contains(element_object)); | 3098 CHECK(heap()->Contains(element_object)); |
3094 CHECK(element_object->map()->IsMap()); | 3099 CHECK(element_object->map()->IsMap()); |
(...skipping 30 matching lines...) Expand all Loading... |
3125 "size of objects %" V8_PTR_PREFIX "d\n", | 3130 "size of objects %" V8_PTR_PREFIX "d\n", |
3126 num_objects, objects_size_); | 3131 num_objects, objects_size_); |
3127 if (num_objects > 0) ReportHistogram(heap()->isolate(), false); | 3132 if (num_objects > 0) ReportHistogram(heap()->isolate(), false); |
3128 } | 3133 } |
3129 | 3134 |
3130 | 3135 |
3131 void LargeObjectSpace::CollectCodeStatistics() { | 3136 void LargeObjectSpace::CollectCodeStatistics() { |
3132 Isolate* isolate = heap()->isolate(); | 3137 Isolate* isolate = heap()->isolate(); |
3133 LargeObjectIterator obj_it(this); | 3138 LargeObjectIterator obj_it(this); |
3134 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { | 3139 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { |
3135 if (obj->IsCode()) { | 3140 if (obj->IsAbstractCode()) { |
3136 Code* code = Code::cast(obj); | 3141 AbstractCode* code = AbstractCode::cast(obj); |
3137 isolate->code_kind_statistics()[code->kind()] += code->Size(); | 3142 isolate->code_kind_statistics()[code->kind()] += code->Size(); |
3138 } | 3143 } |
3139 } | 3144 } |
3140 } | 3145 } |
3141 | 3146 |
3142 | 3147 |
3143 void Page::Print() { | 3148 void Page::Print() { |
3144 // Make a best-effort to print the objects in the page. | 3149 // Make a best-effort to print the objects in the page. |
3145 PrintF("Page@%p in %s\n", this->address(), | 3150 PrintF("Page@%p in %s\n", this->address(), |
3146 AllocationSpaceName(this->owner()->identity())); | 3151 AllocationSpaceName(this->owner()->identity())); |
(...skipping 10 matching lines...) Expand all Loading... |
3157 object->ShortPrint(); | 3162 object->ShortPrint(); |
3158 PrintF("\n"); | 3163 PrintF("\n"); |
3159 } | 3164 } |
3160 printf(" --------------------------------------\n"); | 3165 printf(" --------------------------------------\n"); |
3161 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3166 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3162 } | 3167 } |
3163 | 3168 |
3164 #endif // DEBUG | 3169 #endif // DEBUG |
3165 } // namespace internal | 3170 } // namespace internal |
3166 } // namespace v8 | 3171 } // namespace v8 |
OLD | NEW |