Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index d3d472d79947cd208684db88d98cc633a551f48c..495df09848ce426ae99d12ac0f0429316a7dfe11 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -4399,31 +4399,29 @@ bool v8::V8::Dispose() { |
| } |
| -HeapStatistics::HeapStatistics(): total_heap_size_(0), |
| - total_heap_size_executable_(0), |
| - total_physical_size_(0), |
| - used_heap_size_(0), |
| - heap_size_limit_(0) { } |
| +HeapStatistics::HeapStatistics() { |
| + Clear(); |
| +} |
| + |
| + |
| +void HeapStatistics::Clear() { |
| + total_heap_size_ = 0; |
| + total_heap_size_executable_ = 0; |
| + total_physical_size_ = 0; |
| + used_heap_size_ = 0; |
| + heap_size_limit_ = 0; |
| +} |
| void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) { |
| - if (!i::Isolate::Current()->IsInitialized()) { |
| + i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| + if (isolate == NULL || !isolate->IsInitialized()) { |
| // Isolate is unitialized thus heap is not configured yet. |
| - heap_statistics->set_total_heap_size(0); |
| - heap_statistics->set_total_heap_size_executable(0); |
| - heap_statistics->set_total_physical_size(0); |
| - heap_statistics->set_used_heap_size(0); |
| - heap_statistics->set_heap_size_limit(0); |
| + heap_statistics->Clear(); |
|
Michael Starzinger
2013/02/08 12:30:11
Since there is only one use of the Clear() method
Sven Panne
2013/02/08 12:41:37
Good point, leaving the duplication as it is until
|
| return; |
| } |
| - |
| - i::Heap* heap = i::Isolate::Current()->heap(); |
| - heap_statistics->set_total_heap_size(heap->CommittedMemory()); |
| - heap_statistics->set_total_heap_size_executable( |
| - heap->CommittedMemoryExecutable()); |
| - heap_statistics->set_total_physical_size(heap->CommittedPhysicalMemory()); |
| - heap_statistics->set_used_heap_size(heap->SizeOfObjects()); |
| - heap_statistics->set_heap_size_limit(heap->MaxReserved()); |
| + Isolate* ext_isolate = reinterpret_cast<Isolate*>(isolate); |
| + return ext_isolate->GetHeapStatistics(heap_statistics); |
| } |
| @@ -5609,6 +5607,18 @@ void Isolate::Exit() { |
| } |
| +void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| + i::Heap* heap = isolate->heap(); |
| + heap_statistics->total_heap_size_ = heap->CommittedMemory(); |
| + heap_statistics->total_heap_size_executable_ = |
| + heap->CommittedMemoryExecutable(); |
| + heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); |
| + heap_statistics->used_heap_size_ = heap->SizeOfObjects(); |
| + heap_statistics->heap_size_limit_ = heap->MaxReserved(); |
| +} |
| + |
| + |
| String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
| : str_(NULL), length_(0) { |
| i::Isolate* isolate = i::Isolate::Current(); |