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) |
38 : Thread(Options("Task Runner")), | 39 : Thread(Options("Task Runner")), |
39 setup_global_tasks_(std::move(setup_global_tasks)), | 40 setup_global_tasks_(std::move(setup_global_tasks)), |
| 41 startup_data_(startup_data), |
40 catch_exceptions_(catch_exceptions), | 42 catch_exceptions_(catch_exceptions), |
41 ready_semaphore_(ready_semaphore), | 43 ready_semaphore_(ready_semaphore), |
42 isolate_(nullptr), | 44 isolate_(nullptr), |
43 process_queue_semaphore_(0), | 45 process_queue_semaphore_(0), |
44 nested_loop_count_(0) { | 46 nested_loop_count_(0) { |
45 Start(); | 47 Start(); |
46 } | 48 } |
47 | 49 |
48 TaskRunner::~TaskRunner() { Join(); } | 50 TaskRunner::~TaskRunner() { Join(); } |
49 | 51 |
50 void TaskRunner::InitializeIsolate() { | 52 void TaskRunner::InitializeIsolate() { |
51 v8::Isolate::CreateParams params; | 53 v8::Isolate::CreateParams params; |
52 params.array_buffer_allocator = | 54 params.array_buffer_allocator = |
53 v8::ArrayBuffer::Allocator::NewDefaultAllocator(); | 55 v8::ArrayBuffer::Allocator::NewDefaultAllocator(); |
| 56 params.snapshot_blob = startup_data_; |
54 isolate_ = v8::Isolate::New(params); | 57 isolate_ = v8::Isolate::New(params); |
55 isolate_->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); | 58 isolate_->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); |
56 v8::Isolate::Scope isolate_scope(isolate_); | 59 v8::Isolate::Scope isolate_scope(isolate_); |
57 v8::HandleScope handle_scope(isolate_); | 60 v8::HandleScope handle_scope(isolate_); |
58 NewContextGroup(setup_global_tasks_); | 61 NewContextGroup(setup_global_tasks_); |
59 if (ready_semaphore_) ready_semaphore_->Signal(); | 62 if (ready_semaphore_) ready_semaphore_->Signal(); |
60 } | 63 } |
61 | 64 |
62 v8::Local<v8::Context> TaskRunner::NewContextGroup( | 65 v8::Local<v8::Context> TaskRunner::NewContextGroup( |
63 const TaskRunner::SetupGlobalTasks& setup_global_tasks) { | 66 const TaskRunner::SetupGlobalTasks& setup_global_tasks) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 return; | 258 return; |
256 } | 259 } |
257 if (!module->Instantiate(local_context, &TaskRunner::ModuleResolveCallback)) | 260 if (!module->Instantiate(local_context, &TaskRunner::ModuleResolveCallback)) |
258 return; | 261 return; |
259 v8::Local<v8::Value> result; | 262 v8::Local<v8::Value> result; |
260 if (!module->Evaluate(local_context).ToLocal(&result)) return; | 263 if (!module->Evaluate(local_context).ToLocal(&result)) return; |
261 TaskRunner* runner = TaskRunner::FromContext(local_context); | 264 TaskRunner* runner = TaskRunner::FromContext(local_context); |
262 runner->RegisterModule(name_, module); | 265 runner->RegisterModule(name_, module); |
263 } | 266 } |
264 } | 267 } |
OLD | NEW |