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

Side by Side Diff: gin/isolate_holder.cc

Issue 567343002: Move setup of code event handlers to gin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 | « gin/gin.gyp ('k') | gin/public/debug.h » ('j') | 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"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "base/sys_info.h" 12 #include "base/sys_info.h"
13 #include "gin/array_buffer.h" 13 #include "gin/array_buffer.h"
14 #include "gin/debug_impl.h"
14 #include "gin/function_template.h" 15 #include "gin/function_template.h"
15 #include "gin/per_isolate_data.h" 16 #include "gin/per_isolate_data.h"
16 #include "gin/public/v8_platform.h" 17 #include "gin/public/v8_platform.h"
17 18
18 namespace gin { 19 namespace gin {
19 20
20 namespace { 21 namespace {
21 22
22 v8::ArrayBuffer::Allocator* g_array_buffer_allocator = NULL; 23 v8::ArrayBuffer::Allocator* g_array_buffer_allocator = NULL;
23 24
24 bool GenerateEntropy(unsigned char* buffer, size_t amount) { 25 bool GenerateEntropy(unsigned char* buffer, size_t amount) {
25 base::RandBytes(buffer, amount); 26 base::RandBytes(buffer, amount);
26 return true; 27 return true;
27 } 28 }
28 29
29 } // namespace 30 } // namespace
30 31
31 IsolateHolder::IsolateHolder() { 32 IsolateHolder::IsolateHolder() {
32 CHECK(g_array_buffer_allocator) 33 CHECK(g_array_buffer_allocator)
33 << "You need to invoke gin::IsolateHolder::Initialize first"; 34 << "You need to invoke gin::IsolateHolder::Initialize first";
34 isolate_ = v8::Isolate::New(); 35 v8::Isolate::CreateParams params;
36 params.entry_hook = DebugImpl::GetFunctionEntryHook();
37 params.code_event_handler = DebugImpl::GetJitCodeEventHandler();
38 isolate_ = v8::Isolate::New(params);
35 v8::ResourceConstraints constraints; 39 v8::ResourceConstraints constraints;
36 constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(), 40 constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
37 base::SysInfo::AmountOfVirtualMemory(), 41 base::SysInfo::AmountOfVirtualMemory(),
38 base::SysInfo::NumberOfProcessors()); 42 base::SysInfo::NumberOfProcessors());
39 v8::SetResourceConstraints(isolate_, &constraints); 43 v8::SetResourceConstraints(isolate_, &constraints);
40 isolate_data_.reset(new PerIsolateData(isolate_, g_array_buffer_allocator)); 44 isolate_data_.reset(new PerIsolateData(isolate_, g_array_buffer_allocator));
41 } 45 }
42 46
43 IsolateHolder::~IsolateHolder() { 47 IsolateHolder::~IsolateHolder() {
44 isolate_data_.reset(); 48 isolate_data_.reset();
(...skipping 13 matching lines...) Expand all
58 if (mode == gin::IsolateHolder::kStrictMode) { 62 if (mode == gin::IsolateHolder::kStrictMode) {
59 static const char v8_flags[] = "--use_strict"; 63 static const char v8_flags[] = "--use_strict";
60 v8::V8::SetFlagsFromString(v8_flags, sizeof(v8_flags) - 1); 64 v8::V8::SetFlagsFromString(v8_flags, sizeof(v8_flags) - 1);
61 } 65 }
62 v8::V8::SetEntropySource(&GenerateEntropy); 66 v8::V8::SetEntropySource(&GenerateEntropy);
63 v8::V8::Initialize(); 67 v8::V8::Initialize();
64 v8_is_initialized = true; 68 v8_is_initialized = true;
65 } 69 }
66 70
67 } // namespace gin 71 } // namespace gin
OLDNEW
« no previous file with comments | « gin/gin.gyp ('k') | gin/public/debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698