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 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 } while (false) | 1926 } while (false) |
1927 #else | 1927 #else |
1928 #define TRACE_ISOLATE(tag) | 1928 #define TRACE_ISOLATE(tag) |
1929 #endif | 1929 #endif |
1930 | 1930 |
1931 class VerboseAccountingAllocator : public AccountingAllocator { | 1931 class VerboseAccountingAllocator : public AccountingAllocator { |
1932 public: | 1932 public: |
1933 VerboseAccountingAllocator(Heap* heap, size_t sample_bytes) | 1933 VerboseAccountingAllocator(Heap* heap, size_t sample_bytes) |
1934 : heap_(heap), last_memory_usage_(0), sample_bytes_(sample_bytes) {} | 1934 : heap_(heap), last_memory_usage_(0), sample_bytes_(sample_bytes) {} |
1935 | 1935 |
1936 v8::internal::Segment* AllocateSegment(size_t size) override { | 1936 v8::internal::Segment* GetSegment(size_t size) override { |
1937 v8::internal::Segment* memory = AccountingAllocator::AllocateSegment(size); | 1937 v8::internal::Segment* memory = AccountingAllocator::GetSegment(size); |
1938 if (memory) { | 1938 if (memory) { |
1939 size_t current = GetCurrentMemoryUsage(); | 1939 size_t current = GetCurrentMemoryUsage(); |
1940 if (last_memory_usage_.Value() + sample_bytes_ < current) { | 1940 if (last_memory_usage_.Value() + sample_bytes_ < current) { |
1941 PrintJSON(current); | 1941 PrintJSON(current); |
1942 last_memory_usage_.SetValue(current); | 1942 last_memory_usage_.SetValue(current); |
1943 } | 1943 } |
1944 } | 1944 } |
1945 return memory; | 1945 return memory; |
1946 } | 1946 } |
1947 | 1947 |
1948 void FreeSegment(v8::internal::Segment* memory) override { | 1948 void ReturnSegment(v8::internal::Segment* memory) override { |
1949 AccountingAllocator::FreeSegment(memory); | 1949 AccountingAllocator::ReturnSegment(memory); |
1950 size_t current = GetCurrentMemoryUsage(); | 1950 size_t current = GetCurrentMemoryUsage(); |
1951 if (current + sample_bytes_ < last_memory_usage_.Value()) { | 1951 if (current + sample_bytes_ < last_memory_usage_.Value()) { |
1952 PrintJSON(current); | 1952 PrintJSON(current); |
1953 last_memory_usage_.SetValue(current); | 1953 last_memory_usage_.SetValue(current); |
1954 } | 1954 } |
1955 } | 1955 } |
1956 | 1956 |
1957 private: | 1957 private: |
1958 void PrintJSON(size_t sample) { | 1958 void PrintJSON(size_t sample) { |
1959 // Note: Neither isolate, nor heap is locked, so be careful with accesses | 1959 // Note: Neither isolate, nor heap is locked, so be careful with accesses |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3310 // Then check whether this scope intercepts. | 3310 // Then check whether this scope intercepts. |
3311 if ((flag & intercept_mask_)) { | 3311 if ((flag & intercept_mask_)) { |
3312 intercepted_flags_ |= flag; | 3312 intercepted_flags_ |= flag; |
3313 return true; | 3313 return true; |
3314 } | 3314 } |
3315 return false; | 3315 return false; |
3316 } | 3316 } |
3317 | 3317 |
3318 } // namespace internal | 3318 } // namespace internal |
3319 } // namespace v8 | 3319 } // namespace v8 |
OLD | NEW |