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/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 } while (false) | 1927 } while (false) |
1928 #else | 1928 #else |
1929 #define TRACE_ISOLATE(tag) | 1929 #define TRACE_ISOLATE(tag) |
1930 #endif | 1930 #endif |
1931 | 1931 |
1932 class VerboseAccountingAllocator : public AccountingAllocator { | 1932 class VerboseAccountingAllocator : public AccountingAllocator { |
1933 public: | 1933 public: |
1934 VerboseAccountingAllocator(Heap* heap, size_t sample_bytes) | 1934 VerboseAccountingAllocator(Heap* heap, size_t sample_bytes) |
1935 : heap_(heap), last_memory_usage_(0), sample_bytes_(sample_bytes) {} | 1935 : heap_(heap), last_memory_usage_(0), sample_bytes_(sample_bytes) {} |
1936 | 1936 |
1937 v8::internal::Segment* AllocateSegment(size_t size) override { | 1937 v8::internal::Segment* GetSegment(size_t size) override { |
1938 v8::internal::Segment* memory = AccountingAllocator::AllocateSegment(size); | 1938 v8::internal::Segment* memory = AccountingAllocator::GetSegment(size); |
1939 if (memory) { | 1939 if (memory) { |
1940 size_t current = GetCurrentMemoryUsage(); | 1940 size_t current = GetCurrentMemoryUsage(); |
1941 if (last_memory_usage_.Value() + sample_bytes_ < current) { | 1941 if (last_memory_usage_.Value() + sample_bytes_ < current) { |
1942 PrintJSON(current); | 1942 PrintJSON(current); |
1943 last_memory_usage_.SetValue(current); | 1943 last_memory_usage_.SetValue(current); |
1944 } | 1944 } |
1945 } | 1945 } |
1946 return memory; | 1946 return memory; |
1947 } | 1947 } |
1948 | 1948 |
1949 void FreeSegment(v8::internal::Segment* memory) override { | 1949 void ReturnSegment(v8::internal::Segment* memory) override { |
1950 AccountingAllocator::FreeSegment(memory); | 1950 AccountingAllocator::ReturnSegment(memory); |
1951 size_t current = GetCurrentMemoryUsage(); | 1951 size_t current = GetCurrentMemoryUsage(); |
1952 if (current + sample_bytes_ < last_memory_usage_.Value()) { | 1952 if (current + sample_bytes_ < last_memory_usage_.Value()) { |
1953 PrintJSON(current); | 1953 PrintJSON(current); |
1954 last_memory_usage_.SetValue(current); | 1954 last_memory_usage_.SetValue(current); |
1955 } | 1955 } |
1956 } | 1956 } |
1957 | 1957 |
1958 private: | 1958 private: |
1959 void PrintJSON(size_t sample) { | 1959 void PrintJSON(size_t sample) { |
1960 // Note: Neither isolate, nor heap is locked, so be careful with accesses | 1960 // Note: Neither isolate, nor heap is locked, so be careful with accesses |
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3323 // Then check whether this scope intercepts. | 3323 // Then check whether this scope intercepts. |
3324 if ((flag & intercept_mask_)) { | 3324 if ((flag & intercept_mask_)) { |
3325 intercepted_flags_ |= flag; | 3325 intercepted_flags_ |= flag; |
3326 return true; | 3326 return true; |
3327 } | 3327 } |
3328 return false; | 3328 return false; |
3329 } | 3329 } |
3330 | 3330 |
3331 } // namespace internal | 3331 } // namespace internal |
3332 } // namespace v8 | 3332 } // namespace v8 |
OLD | NEW |