| Index: gin/isolate_holder.cc
|
| diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
|
| index caea27e7a569cad1b99efef6093c0da570deb4a8..5db5a9b7d03e79b9f50217ef8ffe02e86beebe15 100644
|
| --- a/gin/isolate_holder.cc
|
| +++ b/gin/isolate_holder.cc
|
| @@ -34,23 +34,50 @@ 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));
|
| + isolate_ = snapshot_creator_->GetIsolate();
|
| + isolate_->Exit();
|
| + } 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;
|
| + v8_context_mode_ = kDefault;
|
| + if (reference) {
|
| + V8Initializer::GetV8ContextData(&startup_data_.data,
|
| + &startup_data_.raw_size);
|
| + if (startup_data_.data) {
|
| + params.snapshot_blob = &startup_data_;
|
| + params.external_references = reference;
|
| + v8_context_mode_ = kUseSnapshot;
|
| + }
|
| + }
|
| + isolate_ = v8::Isolate::New(params);
|
| + }
|
| +
|
| isolate_data_.reset(
|
| new PerIsolateData(isolate_, allocator, access_mode, task_runner));
|
| isolate_memory_dump_provider_.reset(new V8IsolateMemoryDumpProvider(this));
|
| @@ -84,7 +111,7 @@ IsolateHolder::~IsolateHolder() {
|
| isolate_memory_dump_provider_.reset();
|
| isolate_data_.reset();
|
| isolate_->Dispose();
|
| - isolate_ = NULL;
|
| + isolate_ = nullptr;
|
| }
|
|
|
| // static
|
|
|