Chromium Code Reviews| 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 5437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5448 | 5448 |
| 5449 bool v8::V8::Dispose() { | 5449 bool v8::V8::Dispose() { |
| 5450 i::V8::TearDown(); | 5450 i::V8::TearDown(); |
| 5451 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 5451 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 5452 i::DisposeNatives(); | 5452 i::DisposeNatives(); |
| 5453 #endif | 5453 #endif |
| 5454 return true; | 5454 return true; |
| 5455 } | 5455 } |
| 5456 | 5456 |
| 5457 | 5457 |
| 5458 class HeapSpacesStatistics { | |
| 5459 public: | |
| 5460 std::vector<HeapStatistics::SpaceStatistics>* SpacesStatistics() { | |
| 5461 return &spaces_statistics_; | |
| 5462 } | |
| 5463 | |
| 5464 private: | |
| 5465 std::vector<HeapStatistics::SpaceStatistics> spaces_statistics_; | |
| 5466 }; | |
| 5467 | |
| 5468 | |
| 5458 HeapStatistics::HeapStatistics(): total_heap_size_(0), | 5469 HeapStatistics::HeapStatistics(): total_heap_size_(0), |
| 5459 total_heap_size_executable_(0), | 5470 total_heap_size_executable_(0), |
| 5460 total_physical_size_(0), | 5471 total_physical_size_(0), |
| 5461 used_heap_size_(0), | 5472 used_heap_size_(0), |
| 5462 heap_size_limit_(0) { } | 5473 heap_size_limit_(0) { |
| 5474 spaces_statistics_ = new HeapSpacesStatistics(); | |
| 5475 } | |
| 5476 | |
| 5477 | |
| 5478 HeapStatistics::~HeapStatistics() { free(spaces_statistics_); } | |
|
rmcilroy
2015/04/14 17:25:53
You are using 'new' and 'free' which is wrong - yo
| |
| 5479 | |
| 5480 | |
| 5481 std::vector<HeapStatistics::SpaceStatistics>* | |
| 5482 HeapStatistics::SpacesStatistics() { | |
| 5483 return spaces_statistics_->SpacesStatistics(); | |
| 5484 } | |
| 5463 | 5485 |
| 5464 | 5486 |
| 5465 bool v8::V8::InitializeICU(const char* icu_data_file) { | 5487 bool v8::V8::InitializeICU(const char* icu_data_file) { |
| 5466 return i::InitializeICU(icu_data_file); | 5488 return i::InitializeICU(icu_data_file); |
| 5467 } | 5489 } |
| 5468 | 5490 |
| 5469 | 5491 |
| 5470 const char* v8::V8::GetVersion() { | 5492 const char* v8::V8::GetVersion() { |
| 5471 return i::Version::GetVersion(); | 5493 return i::Version::GetVersion(); |
| 5472 } | 5494 } |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6989 | 7011 |
| 6990 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { | 7012 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { |
| 6991 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7013 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 6992 i::Heap* heap = isolate->heap(); | 7014 i::Heap* heap = isolate->heap(); |
| 6993 heap_statistics->total_heap_size_ = heap->CommittedMemory(); | 7015 heap_statistics->total_heap_size_ = heap->CommittedMemory(); |
| 6994 heap_statistics->total_heap_size_executable_ = | 7016 heap_statistics->total_heap_size_executable_ = |
| 6995 heap->CommittedMemoryExecutable(); | 7017 heap->CommittedMemoryExecutable(); |
| 6996 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); | 7018 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); |
| 6997 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); | 7019 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); |
| 6998 heap_statistics->heap_size_limit_ = heap->MaxReserved(); | 7020 heap_statistics->heap_size_limit_ = heap->MaxReserved(); |
| 7021 | |
| 7022 HeapStatistics::SpaceStatistics new_space_stats( | |
| 7023 heap->GetSpaceName(i::NEW_SPACE), | |
| 7024 heap->new_space()->CommittedMemory(), | |
| 7025 heap->new_space()->Size(), | |
| 7026 heap->new_space()->Available(), | |
| 7027 heap->new_space()->CommittedPhysicalMemory()); | |
| 7028 heap_statistics->SpacesStatistics()->push_back(new_space_stats); | |
| 7029 | |
| 7030 for (int space = i::FIRST_PAGED_SPACE; space < i::LAST_PAGED_SPACE; space++) { | |
| 7031 HeapStatistics::SpaceStatistics space_stats( | |
| 7032 heap->GetSpaceName(space), | |
| 7033 heap->paged_space(space)->CommittedMemory(), | |
| 7034 heap->paged_space(space)->SizeOfObjects(), | |
| 7035 heap->paged_space(space)->Available(), | |
| 7036 heap->paged_space(space)->CommittedPhysicalMemory()); | |
| 7037 heap_statistics->SpacesStatistics()->push_back(space_stats); | |
| 7038 } | |
| 7039 | |
| 7040 HeapStatistics::SpaceStatistics lo_space_stats( | |
| 7041 heap->GetSpaceName(i::LO_SPACE), | |
| 7042 heap->lo_space()->CommittedMemory(), | |
| 7043 heap->lo_space()->SizeOfObjects(), | |
| 7044 heap->lo_space()->Available(), | |
| 7045 heap->lo_space()->CommittedPhysicalMemory()); | |
| 7046 heap_statistics->SpacesStatistics()->push_back(lo_space_stats); | |
| 6999 } | 7047 } |
| 7000 | 7048 |
| 7001 | 7049 |
| 7002 void Isolate::GetStackSample(const RegisterState& state, void** frames, | 7050 void Isolate::GetStackSample(const RegisterState& state, void** frames, |
| 7003 size_t frames_limit, SampleInfo* sample_info) { | 7051 size_t frames_limit, SampleInfo* sample_info) { |
| 7004 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7052 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 7005 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame, | 7053 i::TickSample::GetStackSample(isolate, state, i::TickSample::kSkipCEntryFrame, |
| 7006 frames, frames_limit, sample_info); | 7054 frames, frames_limit, sample_info); |
| 7007 } | 7055 } |
| 7008 | 7056 |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8109 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8157 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8110 Address callback_address = | 8158 Address callback_address = |
| 8111 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8159 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8112 VMState<EXTERNAL> state(isolate); | 8160 VMState<EXTERNAL> state(isolate); |
| 8113 ExternalCallbackScope call_scope(isolate, callback_address); | 8161 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8114 callback(info); | 8162 callback(info); |
| 8115 } | 8163 } |
| 8116 | 8164 |
| 8117 | 8165 |
| 8118 } } // namespace v8::internal | 8166 } } // namespace v8::internal |
| OLD | NEW |