Chromium Code Reviews| Index: gin/isolate_holder.cc |
| diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc |
| index 2e707359ca70f51778e179a74c26c95060ed52a1..e996fb97c163a699ea8dd7845fc0f95a434e7846 100644 |
| --- a/gin/isolate_holder.cc |
| +++ b/gin/isolate_holder.cc |
| @@ -35,23 +35,53 @@ 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, |
| + kDefault) {} |
| IsolateHolder::IsolateHolder( |
| scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| AccessMode access_mode, |
| - AllowAtomicsWaitMode atomics_wait_mode) |
| - : access_mode_(access_mode) { |
| + AllowAtomicsWaitMode atomics_wait_mode, |
| + intptr_t* reference, |
| + V8ContextMode context_mode) |
| + : access_mode_(access_mode), v8_context_mode_(context_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(); |
| - params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), |
| - base::SysInfo::AmountOfVirtualMemory()); |
| - params.array_buffer_allocator = allocator; |
| - params.allow_atomics_wait = atomics_wait_mode == kAllowAtomicsWait; |
| - isolate_ = v8::Isolate::New(params); |
| + |
| + if (v8_context_mode_ == kTakeSnapshot) { |
| + DCHECK(reference); |
| + snapshot_creator_.reset(new v8::SnapshotCreator(reference)); |
|
haraken
2017/05/20 19:10:02
It looks strange that we have to create the snapsh
peria
2017/05/30 08:25:43
Done.
|
| + isolate_ = snapshot_creator_->GetIsolate(); |
| + isolate_->Exit(); |
|
haraken
2017/05/20 19:10:02
Just to confirm: Does "new v8::SnapshotCreator(ref
peria
2017/05/30 08:25:43
Acknowledged.
|
| + } else { |
| + 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(); |
| + params.constraints.ConfigureDefaults( |
| + base::SysInfo::AmountOfPhysicalMemory(), |
| + base::SysInfo::AmountOfVirtualMemory()); |
| + params.array_buffer_allocator = allocator; |
| + params.allow_atomics_wait = atomics_wait_mode == kAllowAtomicsWait; |
| + |
| + params.external_references = reference; |
| + if (v8_context_mode_ == kUseSnapshot) { |
| + CHECK(reference); |
| + V8Initializer::GetV8ContextData(&startup_data_.data, |
| + &startup_data_.raw_size); |
|
haraken
2017/05/20 19:10:02
Can we move this code to when LocalWindowProxy use
peria
2017/05/30 08:25:43
Function name seems wrong, but this actually loads
|
| + if (startup_data_.data) { |
| + params.snapshot_blob = &startup_data_; |
| + } else { |
| + params.snapshot_blob = nullptr; |
| + v8_context_mode_ = kDefault; |
|
haraken
2017/05/20 19:10:02
Why do we need to overwrite v8_context_mode_ here?
peria
2017/05/30 08:25:43
it is used to handle context creation (FromSnapsho
|
| + } |
| + } |
| + isolate_ = v8::Isolate::New(params); |
| + } |
| + |
| isolate_data_.reset( |
| new PerIsolateData(isolate_, allocator, access_mode, task_runner)); |
| isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this)); |
| @@ -85,7 +115,7 @@ IsolateHolder::~IsolateHolder() { |
| isolate_memory_dump_provider_.reset(); |
| isolate_data_.reset(); |
| isolate_->Dispose(); |
| - isolate_ = NULL; |
| + isolate_ = nullptr; |
| } |
| // static |