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 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 do { \ | 1889 do { \ |
1890 if (FLAG_trace_isolates) { \ | 1890 if (FLAG_trace_isolates) { \ |
1891 PrintF("Isolate %p (id %d)" #tag "\n", \ | 1891 PrintF("Isolate %p (id %d)" #tag "\n", \ |
1892 reinterpret_cast<void*>(this), id()); \ | 1892 reinterpret_cast<void*>(this), id()); \ |
1893 } \ | 1893 } \ |
1894 } while (false) | 1894 } while (false) |
1895 #else | 1895 #else |
1896 #define TRACE_ISOLATE(tag) | 1896 #define TRACE_ISOLATE(tag) |
1897 #endif | 1897 #endif |
1898 | 1898 |
1899 class VerboseAccountingAllocator : public base::AccountingAllocator { | 1899 class VerboseAccountingAllocator : public AccountingAllocator { |
1900 public: | 1900 public: |
1901 VerboseAccountingAllocator(Heap* heap, size_t sample_bytes) | 1901 VerboseAccountingAllocator(Heap* heap, size_t sample_bytes) |
1902 : heap_(heap), last_memory_usage_(0), sample_bytes_(sample_bytes) {} | 1902 : heap_(heap), last_memory_usage_(0), sample_bytes_(sample_bytes) {} |
1903 | 1903 |
1904 void* Allocate(size_t size) override { | 1904 v8::internal::Segment* AllocateSegment(size_t size) override { |
1905 void* memory = base::AccountingAllocator::Allocate(size); | 1905 v8::internal::Segment* memory = AccountingAllocator::AllocateSegment(size); |
1906 if (memory) { | 1906 if (memory) { |
1907 size_t current = GetCurrentMemoryUsage(); | 1907 size_t current = GetCurrentMemoryUsage(); |
1908 if (last_memory_usage_.Value() + sample_bytes_ < current) { | 1908 if (last_memory_usage_.Value() + sample_bytes_ < current) { |
1909 PrintJSON(current); | 1909 PrintJSON(current); |
1910 last_memory_usage_.SetValue(current); | 1910 last_memory_usage_.SetValue(current); |
1911 } | 1911 } |
1912 } | 1912 } |
1913 return memory; | 1913 return memory; |
1914 } | 1914 } |
1915 | 1915 |
1916 void Free(void* memory, size_t bytes) override { | 1916 void FreeSegment(v8::internal::Segment* memory) override { |
1917 base::AccountingAllocator::Free(memory, bytes); | 1917 AccountingAllocator::FreeSegment(memory); |
1918 size_t current = GetCurrentMemoryUsage(); | 1918 size_t current = GetCurrentMemoryUsage(); |
1919 if (current + sample_bytes_ < last_memory_usage_.Value()) { | 1919 if (current + sample_bytes_ < last_memory_usage_.Value()) { |
1920 PrintJSON(current); | 1920 PrintJSON(current); |
1921 last_memory_usage_.SetValue(current); | 1921 last_memory_usage_.SetValue(current); |
1922 } | 1922 } |
1923 } | 1923 } |
1924 | 1924 |
1925 private: | 1925 private: |
1926 void PrintJSON(size_t sample) { | 1926 void PrintJSON(size_t sample) { |
1927 // Note: Neither isolate, nor heap is locked, so be careful with accesses | 1927 // 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... |
1962 capture_stack_trace_for_uncaught_exceptions_(false), | 1962 capture_stack_trace_for_uncaught_exceptions_(false), |
1963 stack_trace_for_uncaught_exceptions_frame_limit_(0), | 1963 stack_trace_for_uncaught_exceptions_frame_limit_(0), |
1964 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), | 1964 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), |
1965 keyed_lookup_cache_(NULL), | 1965 keyed_lookup_cache_(NULL), |
1966 context_slot_cache_(NULL), | 1966 context_slot_cache_(NULL), |
1967 descriptor_lookup_cache_(NULL), | 1967 descriptor_lookup_cache_(NULL), |
1968 handle_scope_implementer_(NULL), | 1968 handle_scope_implementer_(NULL), |
1969 unicode_cache_(NULL), | 1969 unicode_cache_(NULL), |
1970 allocator_(FLAG_trace_gc_object_stats | 1970 allocator_(FLAG_trace_gc_object_stats |
1971 ? new VerboseAccountingAllocator(&heap_, 256 * KB) | 1971 ? new VerboseAccountingAllocator(&heap_, 256 * KB) |
1972 : new base::AccountingAllocator()), | 1972 : new AccountingAllocator()), |
1973 runtime_zone_(new Zone(allocator_)), | 1973 runtime_zone_(new Zone(allocator_)), |
1974 inner_pointer_to_code_cache_(NULL), | 1974 inner_pointer_to_code_cache_(NULL), |
1975 global_handles_(NULL), | 1975 global_handles_(NULL), |
1976 eternal_handles_(NULL), | 1976 eternal_handles_(NULL), |
1977 thread_manager_(NULL), | 1977 thread_manager_(NULL), |
1978 has_installed_extensions_(false), | 1978 has_installed_extensions_(false), |
1979 regexp_stack_(NULL), | 1979 regexp_stack_(NULL), |
1980 date_cache_(NULL), | 1980 date_cache_(NULL), |
1981 call_descriptor_data_(NULL), | 1981 call_descriptor_data_(NULL), |
1982 // TODO(bmeurer) Initialized lazily because it depends on flags; can | 1982 // TODO(bmeurer) Initialized lazily because it depends on flags; can |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3206 // Then check whether this scope intercepts. | 3206 // Then check whether this scope intercepts. |
3207 if ((flag & intercept_mask_)) { | 3207 if ((flag & intercept_mask_)) { |
3208 intercepted_flags_ |= flag; | 3208 intercepted_flags_ |= flag; |
3209 return true; | 3209 return true; |
3210 } | 3210 } |
3211 return false; | 3211 return false; |
3212 } | 3212 } |
3213 | 3213 |
3214 } // namespace internal | 3214 } // namespace internal |
3215 } // namespace v8 | 3215 } // namespace v8 |
OLD | NEW |