OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 7234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7245 space_statistics->space_name_ = heap->GetSpaceName(static_cast<int>(index)); | 7245 space_statistics->space_name_ = heap->GetSpaceName(static_cast<int>(index)); |
7246 space_statistics->space_size_ = space->CommittedMemory(); | 7246 space_statistics->space_size_ = space->CommittedMemory(); |
7247 space_statistics->space_used_size_ = space->SizeOfObjects(); | 7247 space_statistics->space_used_size_ = space->SizeOfObjects(); |
7248 space_statistics->space_available_size_ = space->Available(); | 7248 space_statistics->space_available_size_ = space->Available(); |
7249 space_statistics->physical_space_size_ = space->CommittedPhysicalMemory(); | 7249 space_statistics->physical_space_size_ = space->CommittedPhysicalMemory(); |
7250 return true; | 7250 return true; |
7251 } | 7251 } |
7252 | 7252 |
7253 | 7253 |
7254 size_t Isolate::NumberOfTrackedHeapObjectTypes() { | 7254 size_t Isolate::NumberOfTrackedHeapObjectTypes() { |
7255 return i::Heap::OBJECT_STATS_COUNT; | 7255 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7256 i::Heap* heap = isolate->heap(); |
| 7257 return heap->NumberOfTrackedHeapObjectTypes(); |
7256 } | 7258 } |
7257 | 7259 |
7258 | 7260 |
7259 bool Isolate::GetHeapObjectStatisticsAtLastGC( | 7261 bool Isolate::GetHeapObjectStatisticsAtLastGC( |
7260 HeapObjectStatistics* object_statistics, size_t type_index) { | 7262 HeapObjectStatistics* object_statistics, size_t type_index) { |
7261 if (!object_statistics) return false; | 7263 if (!object_statistics) return false; |
7262 if (type_index >= i::Heap::OBJECT_STATS_COUNT) return false; | |
7263 if (!i::FLAG_track_gc_object_stats) return false; | 7264 if (!i::FLAG_track_gc_object_stats) return false; |
7264 | 7265 |
7265 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7266 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
7266 i::Heap* heap = isolate->heap(); | 7267 i::Heap* heap = isolate->heap(); |
| 7268 if (type_index >= heap->NumberOfTrackedHeapObjectTypes()) return false; |
| 7269 |
7267 const char* object_type; | 7270 const char* object_type; |
7268 const char* object_sub_type; | 7271 const char* object_sub_type; |
7269 size_t object_count = heap->object_count_last_gc(type_index); | 7272 size_t object_count = heap->ObjectCountAtLastGC(type_index); |
7270 size_t object_size = heap->object_size_last_gc(type_index); | 7273 size_t object_size = heap->ObjectSizeAtLastGC(type_index); |
7271 if (!heap->GetObjectTypeName(type_index, &object_type, &object_sub_type)) { | 7274 if (!heap->GetObjectTypeName(type_index, &object_type, &object_sub_type)) { |
7272 // There should be no objects counted when the type is unknown. | 7275 // There should be no objects counted when the type is unknown. |
7273 DCHECK_EQ(object_count, 0U); | 7276 DCHECK_EQ(object_count, 0U); |
7274 DCHECK_EQ(object_size, 0U); | 7277 DCHECK_EQ(object_size, 0U); |
7275 return false; | 7278 return false; |
7276 } | 7279 } |
7277 | 7280 |
7278 object_statistics->object_type_ = object_type; | 7281 object_statistics->object_type_ = object_type; |
7279 object_statistics->object_sub_type_ = object_sub_type; | 7282 object_statistics->object_sub_type_ = object_sub_type; |
7280 object_statistics->object_count_ = object_count; | 7283 object_statistics->object_count_ = object_count; |
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8410 Address callback_address = | 8413 Address callback_address = |
8411 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8414 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8412 VMState<EXTERNAL> state(isolate); | 8415 VMState<EXTERNAL> state(isolate); |
8413 ExternalCallbackScope call_scope(isolate, callback_address); | 8416 ExternalCallbackScope call_scope(isolate, callback_address); |
8414 callback(info); | 8417 callback(info); |
8415 } | 8418 } |
8416 | 8419 |
8417 | 8420 |
8418 } // namespace internal | 8421 } // namespace internal |
8419 } // namespace v8 | 8422 } // namespace v8 |
OLD | NEW |