Chromium Code Reviews| Index: gin/isolate_holder.cc |
| diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc |
| index 2e707359ca70f51778e179a74c26c95060ed52a1..1d9b0d8c49c423ddfa4aefef1474410fc6de2ce2 100644 |
| --- a/gin/isolate_holder.cc |
| +++ b/gin/isolate_holder.cc |
| @@ -35,15 +35,22 @@ IsolateHolder::IsolateHolder( |
| IsolateHolder::IsolateHolder( |
| scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| AccessMode access_mode) |
| - : IsolateHolder(std::move(task_runner), access_mode, kAllowAtomicsWait) {} |
| + : IsolateHolder(std::move(task_runner), |
| + access_mode, |
| + kAllowAtomicsWait, |
| + nullptr, |
| + nullptr) {} |
| IsolateHolder::IsolateHolder( |
| scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| AccessMode access_mode, |
| - AllowAtomicsWaitMode atomics_wait_mode) |
| + AllowAtomicsWaitMode atomics_wait_mode, |
| + intptr_t* reference, |
| + v8::StartupData* startup_data) |
| : access_mode_(access_mode) { |
| v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator; |
| CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first"; |
| + |
| v8::Isolate::CreateParams params; |
| params.entry_hook = DebugImpl::GetFunctionEntryHook(); |
| params.code_event_handler = DebugImpl::GetJitCodeEventHandler(); |
| @@ -51,7 +58,18 @@ IsolateHolder::IsolateHolder( |
| base::SysInfo::AmountOfVirtualMemory()); |
| params.array_buffer_allocator = allocator; |
| params.allow_atomics_wait = atomics_wait_mode == kAllowAtomicsWait; |
| + params.external_references = reference; |
| + |
| + if (startup_data) { |
| + CHECK(reference); |
| + V8Initializer::GetV8ContextData(&startup_data->data, |
| + &startup_data->raw_size); |
| + if (startup_data->data) { |
| + params.snapshot_blob = startup_data; |
| + } |
|
Yuki
2017/05/30 14:35:56
What happens if GetV8ContextData fails to load the
peria
2017/06/01 08:33:32
I can't agree to make it an error. Even if Chrome
|
| + } |
| isolate_ = v8::Isolate::New(params); |
| + |
| isolate_data_.reset( |
| new PerIsolateData(isolate_, allocator, access_mode, task_runner)); |
| isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this)); |
| @@ -68,6 +86,26 @@ IsolateHolder::IsolateHolder( |
| #endif |
| } |
| +IsolateHolder::IsolateHolder(v8::Isolate* isolate) |
| + : isolate_(isolate), access_mode_(kSingleThread) { |
|
Yuki
2017/05/30 14:35:56
Could you avoid copy&pasting? Can we have a helpe
peria
2017/06/01 08:33:32
Done.
Will move to another CL.
|
| + v8::ArrayBuffer::Allocator* allocator = g_array_buffer_allocator; |
| + CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first"; |
| + isolate_data_.reset( |
| + new PerIsolateData(isolate_, allocator, access_mode_, nullptr)); |
| + isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this)); |
| +#if defined(OS_WIN) |
| + { |
| + void* code_range; |
| + size_t size; |
| + isolate_->GetCodeRange(&code_range, &size); |
| + Debug::CodeRangeCreatedCallback callback = |
| + DebugImpl::GetCodeRangeCreatedCallback(); |
| + if (code_range && size && callback) |
| + callback(code_range, size); |
| + } |
| +#endif |
| +} |
| + |
| IsolateHolder::~IsolateHolder() { |
| if (task_observer_.get()) |
| base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get()); |
| @@ -85,7 +123,7 @@ IsolateHolder::~IsolateHolder() { |
| isolate_memory_dump_provider_.reset(); |
| isolate_data_.reset(); |
| isolate_->Dispose(); |
| - isolate_ = NULL; |
| + isolate_ = nullptr; |
| } |
| // static |