OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 "test/inspector/task-runner.h" | 5 #include "test/inspector/task-runner.h" |
6 | 6 |
7 #include "test/inspector/inspector-impl.h" | 7 #include "test/inspector/inspector-impl.h" |
8 | 8 |
9 #if !defined(_WIN32) && !defined(_WIN64) | 9 #if !defined(_WIN32) && !defined(_WIN64) |
10 #include <unistd.h> // NOLINT | 10 #include <unistd.h> // NOLINT |
(...skipping 16 matching lines...) Expand all Loading... |
27 v8::internal::Vector<uint16_t> buffer = | 27 v8::internal::Vector<uint16_t> buffer = |
28 v8::internal::Vector<uint16_t>::New(str->Length()); | 28 v8::internal::Vector<uint16_t>::New(str->Length()); |
29 str->Write(buffer.start(), 0, str->Length()); | 29 str->Write(buffer.start(), 0, str->Length()); |
30 return buffer; | 30 return buffer; |
31 } | 31 } |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 TaskRunner::TaskRunner(TaskRunner::SetupGlobalTasks setup_global_tasks, | 35 TaskRunner::TaskRunner(TaskRunner::SetupGlobalTasks setup_global_tasks, |
36 bool catch_exceptions, | 36 bool catch_exceptions, |
37 v8::base::Semaphore* ready_semaphore, | 37 v8::base::Semaphore* ready_semaphore) |
38 v8::StartupData* startup_data) | |
39 : Thread(Options("Task Runner")), | 38 : Thread(Options("Task Runner")), |
40 setup_global_tasks_(std::move(setup_global_tasks)), | 39 setup_global_tasks_(std::move(setup_global_tasks)), |
41 startup_data_(startup_data), | |
42 catch_exceptions_(catch_exceptions), | 40 catch_exceptions_(catch_exceptions), |
43 ready_semaphore_(ready_semaphore), | 41 ready_semaphore_(ready_semaphore), |
44 isolate_(nullptr), | 42 isolate_(nullptr), |
45 process_queue_semaphore_(0), | 43 process_queue_semaphore_(0), |
46 nested_loop_count_(0) { | 44 nested_loop_count_(0) { |
47 Start(); | 45 Start(); |
48 } | 46 } |
49 | 47 |
50 TaskRunner::~TaskRunner() { Join(); } | 48 TaskRunner::~TaskRunner() { Join(); } |
51 | 49 |
52 void TaskRunner::InitializeIsolate() { | 50 void TaskRunner::InitializeIsolate() { |
53 v8::Isolate::CreateParams params; | 51 v8::Isolate::CreateParams params; |
54 params.array_buffer_allocator = | 52 params.array_buffer_allocator = |
55 v8::ArrayBuffer::Allocator::NewDefaultAllocator(); | 53 v8::ArrayBuffer::Allocator::NewDefaultAllocator(); |
56 params.snapshot_blob = startup_data_; | |
57 isolate_ = v8::Isolate::New(params); | 54 isolate_ = v8::Isolate::New(params); |
58 isolate_->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); | 55 isolate_->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); |
59 v8::Isolate::Scope isolate_scope(isolate_); | 56 v8::Isolate::Scope isolate_scope(isolate_); |
60 v8::HandleScope handle_scope(isolate_); | 57 v8::HandleScope handle_scope(isolate_); |
61 NewContextGroup(setup_global_tasks_); | 58 NewContextGroup(setup_global_tasks_); |
62 if (ready_semaphore_) ready_semaphore_->Signal(); | 59 if (ready_semaphore_) ready_semaphore_->Signal(); |
63 } | 60 } |
64 | 61 |
65 v8::Local<v8::Context> TaskRunner::NewContextGroup( | 62 v8::Local<v8::Context> TaskRunner::NewContextGroup( |
66 const TaskRunner::SetupGlobalTasks& setup_global_tasks) { | 63 const TaskRunner::SetupGlobalTasks& setup_global_tasks) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 return; | 255 return; |
259 } | 256 } |
260 if (!module->Instantiate(local_context, &TaskRunner::ModuleResolveCallback)) | 257 if (!module->Instantiate(local_context, &TaskRunner::ModuleResolveCallback)) |
261 return; | 258 return; |
262 v8::Local<v8::Value> result; | 259 v8::Local<v8::Value> result; |
263 if (!module->Evaluate(local_context).ToLocal(&result)) return; | 260 if (!module->Evaluate(local_context).ToLocal(&result)) return; |
264 TaskRunner* runner = TaskRunner::FromContext(local_context); | 261 TaskRunner* runner = TaskRunner::FromContext(local_context); |
265 runner->RegisterModule(name_, module); | 262 runner->RegisterModule(name_, module); |
266 } | 263 } |
267 } | 264 } |
OLD | NEW |