| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 IsolateHolder::IsolateHolder() | 48 IsolateHolder::IsolateHolder() |
| 49 : isolate_owner_(true) { | 49 : isolate_owner_(true) { |
| 50 EnsureV8Initialized(true); | 50 EnsureV8Initialized(true); |
| 51 isolate_ = v8::Isolate::New(); | 51 isolate_ = v8::Isolate::New(); |
| 52 v8::ResourceConstraints constraints; | 52 v8::ResourceConstraints constraints; |
| 53 constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), | 53 constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), |
| 54 base::SysInfo::NumberOfProcessors()); | 54 base::SysInfo::NumberOfProcessors()); |
| 55 v8::SetResourceConstraints(isolate_, &constraints); | 55 v8::SetResourceConstraints(isolate_, &constraints); |
| 56 Init(); | 56 Init(ArrayBufferAllocator::SharedInstance()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 IsolateHolder::IsolateHolder(v8::Isolate* isolate) | 59 IsolateHolder::IsolateHolder(v8::Isolate* isolate) |
| 60 : isolate_owner_(false), | 60 : isolate_owner_(false), |
| 61 isolate_(isolate) { | 61 isolate_(isolate) { |
| 62 EnsureV8Initialized(false); | 62 EnsureV8Initialized(false); |
| 63 Init(); | 63 Init(NULL); |
| 64 } |
| 65 |
| 66 IsolateHolder::IsolateHolder(v8::Isolate* isolate, |
| 67 v8::ArrayBuffer::Allocator* allocator) |
| 68 : isolate_owner_(false), isolate_(isolate) { |
| 69 EnsureV8Initialized(false); |
| 70 Init(allocator); |
| 64 } | 71 } |
| 65 | 72 |
| 66 IsolateHolder::~IsolateHolder() { | 73 IsolateHolder::~IsolateHolder() { |
| 67 isolate_data_.reset(); | 74 isolate_data_.reset(); |
| 68 if (isolate_owner_) | 75 if (isolate_owner_) |
| 69 isolate_->Dispose(); | 76 isolate_->Dispose(); |
| 70 } | 77 } |
| 71 | 78 |
| 72 void IsolateHolder::Init() { | 79 void IsolateHolder::Init(v8::ArrayBuffer::Allocator* allocator) { |
| 73 v8::Isolate::Scope isolate_scope(isolate_); | 80 v8::Isolate::Scope isolate_scope(isolate_); |
| 74 v8::HandleScope handle_scope(isolate_); | 81 v8::HandleScope handle_scope(isolate_); |
| 75 isolate_data_.reset(new PerIsolateData(isolate_)); | 82 isolate_data_.reset(new PerIsolateData(isolate_, allocator)); |
| 76 } | 83 } |
| 77 | 84 |
| 78 } // namespace gin | 85 } // namespace gin |
| OLD | NEW |