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> |
11 | 11 |
12 #include "src/ast/context-slot-cache.h" | 12 #include "src/ast/context-slot-cache.h" |
13 #include "src/base/accounting-allocator.h" | |
14 #include "src/base/hashmap.h" | 13 #include "src/base/hashmap.h" |
15 #include "src/base/platform/platform.h" | 14 #include "src/base/platform/platform.h" |
16 #include "src/base/sys-info.h" | 15 #include "src/base/sys-info.h" |
17 #include "src/base/utils/random-number-generator.h" | 16 #include "src/base/utils/random-number-generator.h" |
18 #include "src/basic-block-profiler.h" | 17 #include "src/basic-block-profiler.h" |
19 #include "src/bootstrapper.h" | 18 #include "src/bootstrapper.h" |
20 #include "src/cancelable-task.h" | 19 #include "src/cancelable-task.h" |
21 #include "src/codegen.h" | 20 #include "src/codegen.h" |
22 #include "src/compilation-cache.h" | 21 #include "src/compilation-cache.h" |
23 #include "src/compilation-statistics.h" | 22 #include "src/compilation-statistics.h" |
(...skipping 12 matching lines...) Expand all Loading... |
36 #include "src/profiler/cpu-profiler.h" | 35 #include "src/profiler/cpu-profiler.h" |
37 #include "src/prototype.h" | 36 #include "src/prototype.h" |
38 #include "src/regexp/regexp-stack.h" | 37 #include "src/regexp/regexp-stack.h" |
39 #include "src/runtime-profiler.h" | 38 #include "src/runtime-profiler.h" |
40 #include "src/simulator.h" | 39 #include "src/simulator.h" |
41 #include "src/snapshot/deserializer.h" | 40 #include "src/snapshot/deserializer.h" |
42 #include "src/v8.h" | 41 #include "src/v8.h" |
43 #include "src/version.h" | 42 #include "src/version.h" |
44 #include "src/vm-state-inl.h" | 43 #include "src/vm-state-inl.h" |
45 #include "src/wasm/wasm-module.h" | 44 #include "src/wasm/wasm-module.h" |
| 45 #include "src/zone/accounting-allocator.h" |
46 | 46 |
47 namespace v8 { | 47 namespace v8 { |
48 namespace internal { | 48 namespace internal { |
49 | 49 |
50 base::Atomic32 ThreadId::highest_thread_id_ = 0; | 50 base::Atomic32 ThreadId::highest_thread_id_ = 0; |
51 | 51 |
52 int ThreadId::AllocateThreadId() { | 52 int ThreadId::AllocateThreadId() { |
53 int new_id = base::NoBarrier_AtomicIncrement(&highest_thread_id_, 1); | 53 int new_id = base::NoBarrier_AtomicIncrement(&highest_thread_id_, 1); |
54 return new_id; | 54 return new_id; |
55 } | 55 } |
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 do { \ | 1891 do { \ |
1892 if (FLAG_trace_isolates) { \ | 1892 if (FLAG_trace_isolates) { \ |
1893 PrintF("Isolate %p (id %d)" #tag "\n", \ | 1893 PrintF("Isolate %p (id %d)" #tag "\n", \ |
1894 reinterpret_cast<void*>(this), id()); \ | 1894 reinterpret_cast<void*>(this), id()); \ |
1895 } \ | 1895 } \ |
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 base::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 void* Allocate(size_t size) override { | 1906 v8::internal::Segment* AllocateSegment(size_t size) override { |
1907 void* memory = base::AccountingAllocator::Allocate(size); | 1907 v8::internal::Segment* memory = AccountingAllocator::AllocateSegment(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 Free(void* memory, size_t bytes) override { | 1918 void FreeSegment(v8::internal::Segment* memory) override { |
1919 base::AccountingAllocator::Free(memory, bytes); | 1919 AccountingAllocator::FreeSegment(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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1964 capture_stack_trace_for_uncaught_exceptions_(false), | 1964 capture_stack_trace_for_uncaught_exceptions_(false), |
1965 stack_trace_for_uncaught_exceptions_frame_limit_(0), | 1965 stack_trace_for_uncaught_exceptions_frame_limit_(0), |
1966 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), | 1966 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), |
1967 keyed_lookup_cache_(NULL), | 1967 keyed_lookup_cache_(NULL), |
1968 context_slot_cache_(NULL), | 1968 context_slot_cache_(NULL), |
1969 descriptor_lookup_cache_(NULL), | 1969 descriptor_lookup_cache_(NULL), |
1970 handle_scope_implementer_(NULL), | 1970 handle_scope_implementer_(NULL), |
1971 unicode_cache_(NULL), | 1971 unicode_cache_(NULL), |
1972 allocator_(FLAG_trace_gc_object_stats | 1972 allocator_(FLAG_trace_gc_object_stats |
1973 ? new VerboseAccountingAllocator(&heap_, 256 * KB) | 1973 ? new VerboseAccountingAllocator(&heap_, 256 * KB) |
1974 : new base::AccountingAllocator()), | 1974 : new AccountingAllocator()), |
1975 runtime_zone_(new Zone(allocator_)), | 1975 runtime_zone_(new Zone(allocator_)), |
1976 inner_pointer_to_code_cache_(NULL), | 1976 inner_pointer_to_code_cache_(NULL), |
1977 global_handles_(NULL), | 1977 global_handles_(NULL), |
1978 eternal_handles_(NULL), | 1978 eternal_handles_(NULL), |
1979 thread_manager_(NULL), | 1979 thread_manager_(NULL), |
1980 has_installed_extensions_(false), | 1980 has_installed_extensions_(false), |
1981 regexp_stack_(NULL), | 1981 regexp_stack_(NULL), |
1982 date_cache_(NULL), | 1982 date_cache_(NULL), |
1983 call_descriptor_data_(NULL), | 1983 call_descriptor_data_(NULL), |
1984 // TODO(bmeurer) Initialized lazily because it depends on flags; can | 1984 // TODO(bmeurer) Initialized lazily because it depends on flags; can |
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3217 // Then check whether this scope intercepts. | 3217 // Then check whether this scope intercepts. |
3218 if ((flag & intercept_mask_)) { | 3218 if ((flag & intercept_mask_)) { |
3219 intercepted_flags_ |= flag; | 3219 intercepted_flags_ |= flag; |
3220 return true; | 3220 return true; |
3221 } | 3221 } |
3222 return false; | 3222 return false; |
3223 } | 3223 } |
3224 | 3224 |
3225 } // namespace internal | 3225 } // namespace internal |
3226 } // namespace v8 | 3226 } // namespace v8 |
OLD | NEW |