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

Side by Side Diff: gin/isolate_holder.cc

Issue 2589363003: Use timer task runner for V8PerIsolate tasks (Closed)
Patch Set: One more fix Created 3 years, 12 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/sys_info.h" 16 #include "base/sys_info.h"
17 #include "gin/debug_impl.h" 17 #include "gin/debug_impl.h"
18 #include "gin/function_template.h" 18 #include "gin/function_template.h"
19 #include "gin/per_isolate_data.h" 19 #include "gin/per_isolate_data.h"
20 #include "gin/run_microtasks_observer.h" 20 #include "gin/run_microtasks_observer.h"
21 #include "gin/v8_initializer.h" 21 #include "gin/v8_initializer.h"
22 #include "gin/v8_isolate_memory_dump_provider.h" 22 #include "gin/v8_isolate_memory_dump_provider.h"
23 23
24 namespace gin { 24 namespace gin {
25 25
26 namespace { 26 namespace {
27 v8::ArrayBuffer::Allocator* g_array_buffer_allocator = nullptr; 27 v8::ArrayBuffer::Allocator* g_array_buffer_allocator = nullptr;
28 } // namespace 28 } // namespace
29 29
30 IsolateHolder::IsolateHolder() : IsolateHolder(AccessMode::kSingleThread) { 30 IsolateHolder::IsolateHolder(
31 } 31 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
32 : IsolateHolder(std::move(task_runner), AccessMode::kSingleThread) {}
32 33
33 IsolateHolder::IsolateHolder(AccessMode access_mode) 34 IsolateHolder::IsolateHolder(
35 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
36 AccessMode access_mode)
34 : access_mode_(access_mode) { 37 : access_mode_(access_mode) {
35 v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator; 38 v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator;
36 CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first"; 39 CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first";
37 v8::Isolate::CreateParams params; 40 v8::Isolate::CreateParams params;
38 params.entry_hook = DebugImpl::GetFunctionEntryHook(); 41 params.entry_hook = DebugImpl::GetFunctionEntryHook();
39 params.code_event_handler = DebugImpl::GetJitCodeEventHandler(); 42 params.code_event_handler = DebugImpl::GetJitCodeEventHandler();
40 params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), 43 params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
41 base::SysInfo::AmountOfVirtualMemory()); 44 base::SysInfo::AmountOfVirtualMemory());
42 params.array_buffer_allocator = allocator; 45 params.array_buffer_allocator = allocator;
43 isolate_ = v8::Isolate::New(params); 46 isolate_ = v8::Isolate::New(params);
44 isolate_data_.reset(new PerIsolateData(isolate_, allocator, access_mode)); 47 isolate_data_.reset(
48 new PerIsolateData(isolate_, allocator, access_mode, task_runner));
45 isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this)); 49 isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this));
46 #if defined(OS_WIN) 50 #if defined(OS_WIN)
47 { 51 {
48 void* code_range; 52 void* code_range;
49 size_t size; 53 size_t size;
50 isolate_->GetCodeRange(&code_range, &size); 54 isolate_->GetCodeRange(&code_range, &size);
51 Debug::CodeRangeCreatedCallback callback = 55 Debug::CodeRangeCreatedCallback callback =
52 DebugImpl::GetCodeRangeCreatedCallback(); 56 DebugImpl::GetCodeRangeCreatedCallback();
53 if (code_range && size && callback) 57 if (code_range && size && callback)
54 callback(code_range, size); 58 callback(code_range, size);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 task_observer_.reset(); 101 task_observer_.reset();
98 } 102 }
99 103
100 void IsolateHolder::EnableIdleTasks( 104 void IsolateHolder::EnableIdleTasks(
101 std::unique_ptr<V8IdleTaskRunner> idle_task_runner) { 105 std::unique_ptr<V8IdleTaskRunner> idle_task_runner) {
102 DCHECK(isolate_data_.get()); 106 DCHECK(isolate_data_.get());
103 isolate_data_->EnableIdleTasks(std::move(idle_task_runner)); 107 isolate_data_->EnableIdleTasks(std::move(idle_task_runner));
104 } 108 }
105 109
106 } // namespace gin 110 } // namespace gin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698