| 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 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 } while (false) | 1896 } while (false) |
| 1897 #else | 1897 #else |
| 1898 #define TRACE_ISOLATE(tag) | 1898 #define TRACE_ISOLATE(tag) |
| 1899 #endif | 1899 #endif |
| 1900 | 1900 |
| 1901 class VerboseAccountingAllocator : public AccountingAllocator { | 1901 class VerboseAccountingAllocator : public AccountingAllocator { |
| 1902 public: | 1902 public: |
| 1903 VerboseAccountingAllocator(Heap* heap, size_t sample_bytes) | 1903 VerboseAccountingAllocator(Heap* heap, size_t sample_bytes) |
| 1904 : heap_(heap), last_memory_usage_(0), sample_bytes_(sample_bytes) {} | 1904 : heap_(heap), last_memory_usage_(0), sample_bytes_(sample_bytes) {} |
| 1905 | 1905 |
| 1906 v8::internal::Segment* AllocateSegment(size_t size) override { | 1906 v8::internal::Segment* GetSegment(size_t size) override { |
| 1907 v8::internal::Segment* memory = AccountingAllocator::AllocateSegment(size); | 1907 v8::internal::Segment* memory = AccountingAllocator::GetSegment(size); |
| 1908 if (memory) { | 1908 if (memory) { |
| 1909 size_t current = GetCurrentMemoryUsage(); | 1909 size_t current = GetCurrentMemoryUsage(); |
| 1910 if (last_memory_usage_.Value() + sample_bytes_ < current) { | 1910 if (last_memory_usage_.Value() + sample_bytes_ < current) { |
| 1911 PrintJSON(current); | 1911 PrintJSON(current); |
| 1912 last_memory_usage_.SetValue(current); | 1912 last_memory_usage_.SetValue(current); |
| 1913 } | 1913 } |
| 1914 } | 1914 } |
| 1915 return memory; | 1915 return memory; |
| 1916 } | 1916 } |
| 1917 | 1917 |
| 1918 void FreeSegment(v8::internal::Segment* memory) override { | 1918 void ReturnSegment(v8::internal::Segment* memory) override { |
| 1919 AccountingAllocator::FreeSegment(memory); | 1919 AccountingAllocator::ReturnSegment(memory); |
| 1920 size_t current = GetCurrentMemoryUsage(); | 1920 size_t current = GetCurrentMemoryUsage(); |
| 1921 if (current + sample_bytes_ < last_memory_usage_.Value()) { | 1921 if (current + sample_bytes_ < last_memory_usage_.Value()) { |
| 1922 PrintJSON(current); | 1922 PrintJSON(current); |
| 1923 last_memory_usage_.SetValue(current); | 1923 last_memory_usage_.SetValue(current); |
| 1924 } | 1924 } |
| 1925 } | 1925 } |
| 1926 | 1926 |
| 1927 private: | 1927 private: |
| 1928 void PrintJSON(size_t sample) { | 1928 void PrintJSON(size_t sample) { |
| 1929 // Note: Neither isolate, nor heap is locked, so be careful with accesses | 1929 // Note: Neither isolate, nor heap is locked, so be careful with accesses |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 void Isolate::SetIsolateThreadLocals(Isolate* isolate, | 2162 void Isolate::SetIsolateThreadLocals(Isolate* isolate, |
| 2163 PerIsolateThreadData* data) { | 2163 PerIsolateThreadData* data) { |
| 2164 base::Thread::SetThreadLocal(isolate_key_, isolate); | 2164 base::Thread::SetThreadLocal(isolate_key_, isolate); |
| 2165 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); | 2165 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); |
| 2166 } | 2166 } |
| 2167 | 2167 |
| 2168 | 2168 |
| 2169 Isolate::~Isolate() { | 2169 Isolate::~Isolate() { |
| 2170 TRACE_ISOLATE(destructor); | 2170 TRACE_ISOLATE(destructor); |
| 2171 | 2171 |
| 2172 // Has to be called while counters_ are still alive | |
| 2173 runtime_zone_->DeleteKeptSegment(); | |
| 2174 | |
| 2175 // The entry stack must be empty when we get here. | 2172 // The entry stack must be empty when we get here. |
| 2176 DCHECK(entry_stack_ == NULL || entry_stack_->previous_item == NULL); | 2173 DCHECK(entry_stack_ == NULL || entry_stack_->previous_item == NULL); |
| 2177 | 2174 |
| 2178 delete entry_stack_; | 2175 delete entry_stack_; |
| 2179 entry_stack_ = NULL; | 2176 entry_stack_ = NULL; |
| 2180 | 2177 |
| 2181 delete unicode_cache_; | 2178 delete unicode_cache_; |
| 2182 unicode_cache_ = NULL; | 2179 unicode_cache_ = NULL; |
| 2183 | 2180 |
| 2184 delete date_cache_; | 2181 delete date_cache_; |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 // Then check whether this scope intercepts. | 3214 // Then check whether this scope intercepts. |
| 3218 if ((flag & intercept_mask_)) { | 3215 if ((flag & intercept_mask_)) { |
| 3219 intercepted_flags_ |= flag; | 3216 intercepted_flags_ |= flag; |
| 3220 return true; | 3217 return true; |
| 3221 } | 3218 } |
| 3222 return false; | 3219 return false; |
| 3223 } | 3220 } |
| 3224 | 3221 |
| 3225 } // namespace internal | 3222 } // namespace internal |
| 3226 } // namespace v8 | 3223 } // namespace v8 |
| OLD | NEW |