Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: gin/isolate_holder.cc

Issue 1088683003: Adding v8_isolate_memory_dump_provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase for primiano's changes. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium 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 "gin/public/isolate_holder.h" 5 #include "gin/public/isolate_holder.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/sys_info.h" 12 #include "base/sys_info.h"
13 #include "gin/debug_impl.h" 13 #include "gin/debug_impl.h"
14 #include "gin/function_template.h" 14 #include "gin/function_template.h"
15 #include "gin/per_isolate_data.h" 15 #include "gin/per_isolate_data.h"
16 #include "gin/run_microtasks_observer.h" 16 #include "gin/run_microtasks_observer.h"
17 #include "gin/v8_initializer.h" 17 #include "gin/v8_initializer.h"
18 #include "gin/v8_isolate_memory_dump_provider.h"
18 19
19 namespace gin { 20 namespace gin {
20 21
21 namespace { 22 namespace {
22 v8::ArrayBuffer::Allocator* g_array_buffer_allocator = nullptr; 23 v8::ArrayBuffer::Allocator* g_array_buffer_allocator = nullptr;
23 } // namespace 24 } // namespace
24 25
25 IsolateHolder::IsolateHolder() { 26 IsolateHolder::IsolateHolder() {
26 v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator; 27 v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator;
27 CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first"; 28 CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first";
28 v8::Isolate::CreateParams params; 29 v8::Isolate::CreateParams params;
29 params.entry_hook = DebugImpl::GetFunctionEntryHook(); 30 params.entry_hook = DebugImpl::GetFunctionEntryHook();
30 params.code_event_handler = DebugImpl::GetJitCodeEventHandler(); 31 params.code_event_handler = DebugImpl::GetJitCodeEventHandler();
31 params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), 32 params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
32 base::SysInfo::AmountOfVirtualMemory()); 33 base::SysInfo::AmountOfVirtualMemory());
33 isolate_ = v8::Isolate::New(params); 34 isolate_ = v8::Isolate::New(params);
34 isolate_data_.reset(new PerIsolateData(isolate_, allocator)); 35 isolate_data_.reset(new PerIsolateData(isolate_, allocator));
35 #if defined(OS_WIN) 36 #if defined(OS_WIN)
36 { 37 {
37 void* code_range; 38 void* code_range;
38 size_t size; 39 size_t size;
39 isolate_->GetCodeRange(&code_range, &size); 40 isolate_->GetCodeRange(&code_range, &size);
40 Debug::CodeRangeCreatedCallback callback = 41 Debug::CodeRangeCreatedCallback callback =
41 DebugImpl::GetCodeRangeCreatedCallback(); 42 DebugImpl::GetCodeRangeCreatedCallback();
42 if (code_range && size && callback) 43 if (code_range && size && callback)
43 callback(code_range, size); 44 callback(code_range, size);
44 } 45 }
45 #endif 46 #endif
47 isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this));
46 } 48 }
47 49
48 IsolateHolder::~IsolateHolder() { 50 IsolateHolder::~IsolateHolder() {
51 isolate_memory_dump_provider_.reset();
49 if (task_observer_.get()) 52 if (task_observer_.get())
50 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); 53 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get());
51 #if defined(OS_WIN) 54 #if defined(OS_WIN)
52 { 55 {
53 void* code_range; 56 void* code_range;
54 size_t size; 57 size_t size;
55 isolate_->GetCodeRange(&code_range, &size); 58 isolate_->GetCodeRange(&code_range, &size);
56 Debug::CodeRangeDeletedCallback callback = 59 Debug::CodeRangeDeletedCallback callback =
57 DebugImpl::GetCodeRangeDeletedCallback(); 60 DebugImpl::GetCodeRangeDeletedCallback();
58 if (code_range && callback) 61 if (code_range && callback)
(...skipping 19 matching lines...) Expand all
78 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); 81 base::MessageLoop::current()->AddTaskObserver(task_observer_.get());
79 } 82 }
80 83
81 void IsolateHolder::RemoveRunMicrotasksObserver() { 84 void IsolateHolder::RemoveRunMicrotasksObserver() {
82 DCHECK(task_observer_.get()); 85 DCHECK(task_observer_.get());
83 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); 86 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get());
84 task_observer_.reset(); 87 task_observer_.reset();
85 } 88 }
86 89
87 } // namespace gin 90 } // namespace gin
OLDNEW
« no previous file with comments | « gin/gin.gyp ('k') | gin/public/isolate_holder.h » ('j') | gin/v8_isolate_memory_dump_provider.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698