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

Side by Side Diff: runtime/vm/kernel_isolate.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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 | « runtime/vm/kernel_binary_flowgraph.cc ('k') | runtime/vm/kernel_reader.cc » ('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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/kernel_isolate.h" 5 #include "vm/kernel_isolate.h"
6 6
7 #include "bin/dartutils.h" 7 #include "bin/dartutils.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 28 matching lines...) Expand all
39 false, 39 false,
40 "Show Kernel service isolate as normal isolate."); 40 "Show Kernel service isolate as normal isolate.");
41 41
42 const char* KernelIsolate::kName = DART_KERNEL_ISOLATE_NAME; 42 const char* KernelIsolate::kName = DART_KERNEL_ISOLATE_NAME;
43 Dart_IsolateCreateCallback KernelIsolate::create_callback_ = NULL; 43 Dart_IsolateCreateCallback KernelIsolate::create_callback_ = NULL;
44 Monitor* KernelIsolate::monitor_ = new Monitor(); 44 Monitor* KernelIsolate::monitor_ = new Monitor();
45 Isolate* KernelIsolate::isolate_ = NULL; 45 Isolate* KernelIsolate::isolate_ = NULL;
46 bool KernelIsolate::initializing_ = true; 46 bool KernelIsolate::initializing_ = true;
47 Dart_Port KernelIsolate::kernel_port_ = ILLEGAL_PORT; 47 Dart_Port KernelIsolate::kernel_port_ = ILLEGAL_PORT;
48 48
49
50 class RunKernelTask : public ThreadPool::Task { 49 class RunKernelTask : public ThreadPool::Task {
51 public: 50 public:
52 virtual void Run() { 51 virtual void Run() {
53 ASSERT(Isolate::Current() == NULL); 52 ASSERT(Isolate::Current() == NULL);
54 53
55 if (!FLAG_use_dart_frontend) { 54 if (!FLAG_use_dart_frontend) {
56 ASSERT(FLAG_use_dart_frontend); 55 ASSERT(FLAG_use_dart_frontend);
57 // In release builds, make this a no-op. In debug builds, the 56 // In release builds, make this a no-op. In debug builds, the
58 // assert shows that this is not supposed to happen. 57 // assert shows that this is not supposed to happen.
59 return; 58 return;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 error.ToErrorCString()); 191 error.ToErrorCString());
193 return false; 192 return false;
194 } 193 }
195 ASSERT(result.IsReceivePort()); 194 ASSERT(result.IsReceivePort());
196 const ReceivePort& rp = ReceivePort::Cast(result); 195 const ReceivePort& rp = ReceivePort::Cast(result);
197 KernelIsolate::SetLoadPort(rp.Id()); 196 KernelIsolate::SetLoadPort(rp.Id());
198 return true; 197 return true;
199 } 198 }
200 }; 199 };
201 200
202
203 void KernelIsolate::Run() { 201 void KernelIsolate::Run() {
204 if (!FLAG_use_dart_frontend) { 202 if (!FLAG_use_dart_frontend) {
205 return; 203 return;
206 } 204 }
207 // Grab the isolate create callback here to avoid race conditions with tests 205 // Grab the isolate create callback here to avoid race conditions with tests
208 // that change this after Dart_Initialize returns. 206 // that change this after Dart_Initialize returns.
209 create_callback_ = Isolate::CreateCallback(); 207 create_callback_ = Isolate::CreateCallback();
210 Dart::thread_pool()->Run(new RunKernelTask()); 208 Dart::thread_pool()->Run(new RunKernelTask());
211 } 209 }
212 210
213
214 void KernelIsolate::InitCallback(Isolate* I) { 211 void KernelIsolate::InitCallback(Isolate* I) {
215 Thread* T = Thread::Current(); 212 Thread* T = Thread::Current();
216 ASSERT(I == T->isolate()); 213 ASSERT(I == T->isolate());
217 ASSERT(I != NULL); 214 ASSERT(I != NULL);
218 ASSERT(I->name() != NULL); 215 ASSERT(I->name() != NULL);
219 if (!FLAG_use_dart_frontend || 216 if (!FLAG_use_dart_frontend ||
220 (strstr(I->name(), DART_KERNEL_ISOLATE_NAME) == NULL)) { 217 (strstr(I->name(), DART_KERNEL_ISOLATE_NAME) == NULL)) {
221 // Not kernel isolate. 218 // Not kernel isolate.
222 return; 219 return;
223 } 220 }
224 ASSERT(!Exists()); 221 ASSERT(!Exists());
225 if (FLAG_trace_kernel) { 222 if (FLAG_trace_kernel) {
226 OS::Print(DART_KERNEL_ISOLATE_NAME ": InitCallback for %s.\n", I->name()); 223 OS::Print(DART_KERNEL_ISOLATE_NAME ": InitCallback for %s.\n", I->name());
227 } 224 }
228 SetKernelIsolate(I); 225 SetKernelIsolate(I);
229 } 226 }
230 227
231
232 bool KernelIsolate::IsKernelIsolate(const Isolate* isolate) { 228 bool KernelIsolate::IsKernelIsolate(const Isolate* isolate) {
233 MonitorLocker ml(monitor_); 229 MonitorLocker ml(monitor_);
234 return isolate == isolate_; 230 return isolate == isolate_;
235 } 231 }
236 232
237
238 bool KernelIsolate::IsRunning() { 233 bool KernelIsolate::IsRunning() {
239 MonitorLocker ml(monitor_); 234 MonitorLocker ml(monitor_);
240 return (kernel_port_ != ILLEGAL_PORT) && (isolate_ != NULL); 235 return (kernel_port_ != ILLEGAL_PORT) && (isolate_ != NULL);
241 } 236 }
242 237
243
244 bool KernelIsolate::Exists() { 238 bool KernelIsolate::Exists() {
245 MonitorLocker ml(monitor_); 239 MonitorLocker ml(monitor_);
246 return isolate_ != NULL; 240 return isolate_ != NULL;
247 } 241 }
248 242
249
250 void KernelIsolate::SetKernelIsolate(Isolate* isolate) { 243 void KernelIsolate::SetKernelIsolate(Isolate* isolate) {
251 MonitorLocker ml(monitor_); 244 MonitorLocker ml(monitor_);
252 isolate_ = isolate; 245 isolate_ = isolate;
253 } 246 }
254 247
255
256 void KernelIsolate::SetLoadPort(Dart_Port port) { 248 void KernelIsolate::SetLoadPort(Dart_Port port) {
257 MonitorLocker ml(monitor_); 249 MonitorLocker ml(monitor_);
258 kernel_port_ = port; 250 kernel_port_ = port;
259 } 251 }
260 252
261
262 void KernelIsolate::FinishedInitializing() { 253 void KernelIsolate::FinishedInitializing() {
263 MonitorLocker ml(monitor_); 254 MonitorLocker ml(monitor_);
264 initializing_ = false; 255 initializing_ = false;
265 ml.NotifyAll(); 256 ml.NotifyAll();
266 } 257 }
267 258
268
269 Dart_Port KernelIsolate::WaitForKernelPort() { 259 Dart_Port KernelIsolate::WaitForKernelPort() {
270 if (!FLAG_use_dart_frontend) { 260 if (!FLAG_use_dart_frontend) {
271 return ILLEGAL_PORT; 261 return ILLEGAL_PORT;
272 } 262 }
273 MonitorLocker ml(monitor_); 263 MonitorLocker ml(monitor_);
274 while (initializing_ && (kernel_port_ == ILLEGAL_PORT)) { 264 while (initializing_ && (kernel_port_ == ILLEGAL_PORT)) {
275 ml.Wait(); 265 ml.Wait();
276 } 266 }
277 return kernel_port_; 267 return kernel_port_;
278 } 268 }
279 269
280
281 class KernelCompilationRequest : public ValueObject { 270 class KernelCompilationRequest : public ValueObject {
282 public: 271 public:
283 KernelCompilationRequest() 272 KernelCompilationRequest()
284 : monitor_(new Monitor()), 273 : monitor_(new Monitor()),
285 port_(Dart_NewNativePort("kernel-compilation-port", 274 port_(Dart_NewNativePort("kernel-compilation-port",
286 &HandleResponse, 275 &HandleResponse,
287 false)), 276 false)),
288 next_(NULL), 277 next_(NULL),
289 prev_(NULL) { 278 prev_(NULL) {
290 ASSERT(port_ != ILLEGAL_PORT); 279 ASSERT(port_ != ILLEGAL_PORT);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 result.status = Dart_KernelCompilationStatus_Unknown; 467 result.status = Dart_KernelCompilationStatus_Unknown;
479 result.error = strdup("Error while initializing Kernel isolate"); 468 result.error = strdup("Error while initializing Kernel isolate");
480 return result; 469 return result;
481 } 470 }
482 471
483 KernelCompilationRequest request; 472 KernelCompilationRequest request;
484 return request.SendAndWaitForResponse(kernel_port, script_uri, 473 return request.SendAndWaitForResponse(kernel_port, script_uri,
485 source_file_count, source_files); 474 source_file_count, source_files);
486 } 475 }
487 476
488
489 #endif // DART_PRECOMPILED_RUNTIME 477 #endif // DART_PRECOMPILED_RUNTIME
490 478
491 } // namespace dart 479 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/kernel_binary_flowgraph.cc ('k') | runtime/vm/kernel_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698