OLD | NEW |
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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 CHECK(g_array_buffer_allocator) | 35 CHECK(g_array_buffer_allocator) |
36 << "You need to invoke gin::IsolateHolder::Initialize first"; | 36 << "You need to invoke gin::IsolateHolder::Initialize first"; |
37 v8::Isolate::CreateParams params; | 37 v8::Isolate::CreateParams params; |
38 params.entry_hook = DebugImpl::GetFunctionEntryHook(); | 38 params.entry_hook = DebugImpl::GetFunctionEntryHook(); |
39 params.code_event_handler = DebugImpl::GetJitCodeEventHandler(); | 39 params.code_event_handler = DebugImpl::GetJitCodeEventHandler(); |
40 params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), | 40 params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), |
41 base::SysInfo::AmountOfVirtualMemory(), | 41 base::SysInfo::AmountOfVirtualMemory(), |
42 base::SysInfo::NumberOfProcessors()); | 42 base::SysInfo::NumberOfProcessors()); |
43 isolate_ = v8::Isolate::New(params); | 43 isolate_ = v8::Isolate::New(params); |
44 isolate_data_.reset(new PerIsolateData(isolate_, g_array_buffer_allocator)); | 44 isolate_data_.reset(new PerIsolateData(isolate_, g_array_buffer_allocator)); |
| 45 #if defined(OS_WIN) |
| 46 { |
| 47 void* code_range; |
| 48 size_t size; |
| 49 isolate_->GetCodeRange(&code_range, &size); |
| 50 Debug::CodeRangeCreatedCallback callback = |
| 51 DebugImpl::GetCodeRangeCreatedCallback(); |
| 52 if (code_range && size && callback) |
| 53 callback(code_range, size); |
| 54 } |
| 55 #endif |
45 } | 56 } |
46 | 57 |
47 IsolateHolder::~IsolateHolder() { | 58 IsolateHolder::~IsolateHolder() { |
48 if (task_observer_.get()) | 59 if (task_observer_.get()) |
49 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); | 60 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); |
| 61 #if defined(OS_WIN) |
| 62 { |
| 63 void* code_range; |
| 64 size_t size; |
| 65 isolate_->GetCodeRange(&code_range, &size); |
| 66 Debug::CodeRangeDeletedCallback callback = |
| 67 DebugImpl::GetCodeRangeDeletedCallback(); |
| 68 if (code_range && callback) |
| 69 callback(code_range); |
| 70 } |
| 71 #endif |
50 isolate_data_.reset(); | 72 isolate_data_.reset(); |
51 isolate_->Dispose(); | 73 isolate_->Dispose(); |
52 } | 74 } |
53 | 75 |
54 // static | 76 // static |
55 void IsolateHolder::Initialize(ScriptMode mode, | 77 void IsolateHolder::Initialize(ScriptMode mode, |
56 v8::ArrayBuffer::Allocator* allocator) { | 78 v8::ArrayBuffer::Allocator* allocator) { |
57 CHECK(allocator); | 79 CHECK(allocator); |
58 static bool v8_is_initialized = false; | 80 static bool v8_is_initialized = false; |
59 if (v8_is_initialized) | 81 if (v8_is_initialized) |
(...skipping 16 matching lines...) Expand all Loading... |
76 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); | 98 base::MessageLoop::current()->AddTaskObserver(task_observer_.get()); |
77 } | 99 } |
78 | 100 |
79 void IsolateHolder::RemoveRunMicrotasksObserver() { | 101 void IsolateHolder::RemoveRunMicrotasksObserver() { |
80 DCHECK(task_observer_.get()); | 102 DCHECK(task_observer_.get()); |
81 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); | 103 base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); |
82 task_observer_.reset(); | 104 task_observer_.reset(); |
83 } | 105 } |
84 | 106 |
85 } // namespace gin | 107 } // namespace gin |
OLD | NEW |