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

Side by Side Diff: gin/isolate_holder.cc

Issue 570423002: Pass ResourceConstraints to V8 via the Isolate constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 17 matching lines...) Expand all
28 } 28 }
29 29
30 } // namespace 30 } // namespace
31 31
32 IsolateHolder::IsolateHolder() { 32 IsolateHolder::IsolateHolder() {
33 CHECK(g_array_buffer_allocator) 33 CHECK(g_array_buffer_allocator)
34 << "You need to invoke gin::IsolateHolder::Initialize first"; 34 << "You need to invoke gin::IsolateHolder::Initialize first";
35 v8::Isolate::CreateParams params; 35 v8::Isolate::CreateParams params;
36 params.entry_hook = DebugImpl::GetFunctionEntryHook(); 36 params.entry_hook = DebugImpl::GetFunctionEntryHook();
37 params.code_event_handler = DebugImpl::GetJitCodeEventHandler(); 37 params.code_event_handler = DebugImpl::GetJitCodeEventHandler();
38 params.constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
39 base::SysInfo::AmountOfVirtualMemory(),
40 base::SysInfo::NumberOfProcessors());
38 isolate_ = v8::Isolate::New(params); 41 isolate_ = v8::Isolate::New(params);
39 v8::ResourceConstraints constraints;
40 constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
41 base::SysInfo::AmountOfVirtualMemory(),
42 base::SysInfo::NumberOfProcessors());
43 v8::SetResourceConstraints(isolate_, &constraints);
44 isolate_data_.reset(new PerIsolateData(isolate_, g_array_buffer_allocator)); 42 isolate_data_.reset(new PerIsolateData(isolate_, g_array_buffer_allocator));
45 } 43 }
46 44
47 IsolateHolder::~IsolateHolder() { 45 IsolateHolder::~IsolateHolder() {
48 isolate_data_.reset(); 46 isolate_data_.reset();
49 isolate_->Dispose(); 47 isolate_->Dispose();
50 } 48 }
51 49
52 // static 50 // static
53 void IsolateHolder::Initialize(ScriptMode mode, 51 void IsolateHolder::Initialize(ScriptMode mode,
54 v8::ArrayBuffer::Allocator* allocator) { 52 v8::ArrayBuffer::Allocator* allocator) {
55 CHECK(allocator); 53 CHECK(allocator);
56 static bool v8_is_initialized = false; 54 static bool v8_is_initialized = false;
57 if (v8_is_initialized) 55 if (v8_is_initialized)
58 return; 56 return;
59 v8::V8::InitializePlatform(V8Platform::Get()); 57 v8::V8::InitializePlatform(V8Platform::Get());
60 v8::V8::SetArrayBufferAllocator(allocator); 58 v8::V8::SetArrayBufferAllocator(allocator);
61 g_array_buffer_allocator = allocator; 59 g_array_buffer_allocator = allocator;
62 if (mode == gin::IsolateHolder::kStrictMode) { 60 if (mode == gin::IsolateHolder::kStrictMode) {
63 static const char v8_flags[] = "--use_strict"; 61 static const char v8_flags[] = "--use_strict";
64 v8::V8::SetFlagsFromString(v8_flags, sizeof(v8_flags) - 1); 62 v8::V8::SetFlagsFromString(v8_flags, sizeof(v8_flags) - 1);
65 } 63 }
66 v8::V8::SetEntropySource(&GenerateEntropy); 64 v8::V8::SetEntropySource(&GenerateEntropy);
67 v8::V8::Initialize(); 65 v8::V8::Initialize();
68 v8_is_initialized = true; 66 v8_is_initialized = true;
69 } 67 }
70 68
71 } // namespace gin 69 } // namespace gin
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698