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

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

Issue 3001013002: Pass path to platform kernel binary to kernel-service. (Closed)
Patch Set: Add TODO to switch to outline.dill Created 3 years, 4 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
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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 ~KernelCompilationRequest() { 293 ~KernelCompilationRequest() {
294 UnregisterRequest(this); 294 UnregisterRequest(this);
295 Dart_CloseNativePort(port_); 295 Dart_CloseNativePort(port_);
296 delete monitor_; 296 delete monitor_;
297 } 297 }
298 298
299 Dart_KernelCompilationResult SendAndWaitForResponse( 299 Dart_KernelCompilationResult SendAndWaitForResponse(
300 Dart_Port kernel_port, 300 Dart_Port kernel_port,
301 const char* script_uri, 301 const char* script_uri,
302 const char* platform_kernel,
302 int source_files_count, 303 int source_files_count,
303 Dart_SourceFile source_files[], 304 Dart_SourceFile source_files[],
304 bool incremental_compile) { 305 bool incremental_compile) {
305 // Build the [null, send_port, script_uri, incremental_compile, isolate_id, 306 // Build the [null, send_port, script_uri, platform_kernel,
306 // [files]] message for the Kernel isolate: null tag tells it that request 307 // incremental_compile, isolate_id, [files]] message for the Kernel isolate.
307 // came from this code, instead of Loader so that it can given a more 308 // null tag tells it that request came from this code, instead of Loader
308 // informative response. 309 // so that it can given a more informative response.
309 Dart_CObject tag; 310 Dart_CObject tag;
310 tag.type = Dart_CObject_kNull; 311 tag.type = Dart_CObject_kNull;
311 312
312 Dart_CObject send_port; 313 Dart_CObject send_port;
313 send_port.type = Dart_CObject_kSendPort; 314 send_port.type = Dart_CObject_kSendPort;
314 send_port.value.as_send_port.id = port_; 315 send_port.value.as_send_port.id = port_;
315 send_port.value.as_send_port.origin_id = ILLEGAL_PORT; 316 send_port.value.as_send_port.origin_id = ILLEGAL_PORT;
316 317
317 Dart_CObject uri; 318 Dart_CObject uri;
318 uri.type = Dart_CObject_kString; 319 uri.type = Dart_CObject_kString;
319 uri.value.as_string = const_cast<char*>(script_uri); 320 uri.value.as_string = const_cast<char*>(script_uri);
320 321
322 Dart_CObject dart_platform_kernel;
323 if (platform_kernel != NULL) {
324 dart_platform_kernel.type = Dart_CObject_kString;
325 dart_platform_kernel.value.as_string = const_cast<char*>(platform_kernel);
326 } else {
327 dart_platform_kernel.type = Dart_CObject_kNull;
328 }
329
321 Dart_CObject dart_incremental; 330 Dart_CObject dart_incremental;
322 dart_incremental.type = Dart_CObject_kBool; 331 dart_incremental.type = Dart_CObject_kBool;
323 dart_incremental.value.as_bool = incremental_compile; 332 dart_incremental.value.as_bool = incremental_compile;
324 333
325 // TODO(aam): Assert that isolate exists once we move CompileAndReadScript 334 // TODO(aam): Assert that isolate exists once we move CompileAndReadScript
326 // compilation logic out of CreateIsolateAndSetupHelper and into 335 // compilation logic out of CreateIsolateAndSetupHelper and into
327 // IsolateSetupHelper in main.cc. 336 // IsolateSetupHelper in main.cc.
328 Isolate* isolate = 337 Isolate* isolate =
329 Thread::Current() != NULL ? Thread::Current()->isolate() : NULL; 338 Thread::Current() != NULL ? Thread::Current()->isolate() : NULL;
330 if (incremental_compile) { 339 if (incremental_compile) {
331 ASSERT(isolate != NULL); 340 ASSERT(isolate != NULL);
332 } 341 }
333 Dart_CObject isolate_id; 342 Dart_CObject isolate_id;
334 isolate_id.type = Dart_CObject_kInt64; 343 isolate_id.type = Dart_CObject_kInt64;
335 isolate_id.value.as_int64 = 344 isolate_id.value.as_int64 =
336 isolate != NULL ? static_cast<int64_t>(isolate->main_port()) : 0; 345 isolate != NULL ? static_cast<int64_t>(isolate->main_port()) : 0;
337 346
338 Dart_CObject message; 347 Dart_CObject message;
339 message.type = Dart_CObject_kArray; 348 message.type = Dart_CObject_kArray;
340 349
341 intptr_t message_len = 5; 350 intptr_t message_len = 6;
342 Dart_CObject files; 351 Dart_CObject files;
343 if (source_files_count != 0) { 352 if (source_files_count != 0) {
344 files = BuildFilesPairs(source_files_count, source_files); 353 files = BuildFilesPairs(source_files_count, source_files);
345 message_len++; 354 message_len++;
346 } 355 }
347 Dart_CObject* message_arr[] = { 356 Dart_CObject* message_arr[] = {
348 &tag, &send_port, &uri, &dart_incremental, &isolate_id, &files}; 357 &tag, &send_port, &uri, &dart_platform_kernel, &dart_incremental,
358 &isolate_id, &files};
349 message.value.as_array.values = message_arr; 359 message.value.as_array.values = message_arr;
350 message.value.as_array.length = message_len; 360 message.value.as_array.length = message_len;
351 // Send the message. 361 // Send the message.
352 Dart_PostCObject(kernel_port, &message); 362 Dart_PostCObject(kernel_port, &message);
353 363
354 // Wait for reply to arrive. 364 // Wait for reply to arrive.
355 MonitorLocker ml(monitor_); 365 MonitorLocker ml(monitor_);
356 while (result_.status == Dart_KernelCompilationStatus_Unknown) { 366 while (result_.status == Dart_KernelCompilationStatus_Unknown) {
357 ml.Wait(); 367 ml.Wait();
358 } 368 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 KernelCompilationRequest* prev_; 462 KernelCompilationRequest* prev_;
453 463
454 Dart_KernelCompilationResult result_; 464 Dart_KernelCompilationResult result_;
455 }; 465 };
456 466
457 Monitor* KernelCompilationRequest::requests_monitor_ = new Monitor(); 467 Monitor* KernelCompilationRequest::requests_monitor_ = new Monitor();
458 KernelCompilationRequest* KernelCompilationRequest::requests_ = NULL; 468 KernelCompilationRequest* KernelCompilationRequest::requests_ = NULL;
459 469
460 Dart_KernelCompilationResult KernelIsolate::CompileToKernel( 470 Dart_KernelCompilationResult KernelIsolate::CompileToKernel(
461 const char* script_uri, 471 const char* script_uri,
472 const char* platform_kernel,
462 int source_file_count, 473 int source_file_count,
463 Dart_SourceFile source_files[], 474 Dart_SourceFile source_files[],
464 bool incremental_compile) { 475 bool incremental_compile) {
465 // This must be the main script to be loaded. Wait for Kernel isolate 476 // This must be the main script to be loaded. Wait for Kernel isolate
466 // to finish initialization. 477 // to finish initialization.
467 Dart_Port kernel_port = WaitForKernelPort(); 478 Dart_Port kernel_port = WaitForKernelPort();
468 if (kernel_port == ILLEGAL_PORT) { 479 if (kernel_port == ILLEGAL_PORT) {
469 Dart_KernelCompilationResult result; 480 Dart_KernelCompilationResult result;
470 result.status = Dart_KernelCompilationStatus_Unknown; 481 result.status = Dart_KernelCompilationStatus_Unknown;
471 result.error = strdup("Error while initializing Kernel isolate"); 482 result.error = strdup("Error while initializing Kernel isolate");
472 return result; 483 return result;
473 } 484 }
474 485
475 KernelCompilationRequest request; 486 KernelCompilationRequest request;
476 return request.SendAndWaitForResponse(kernel_port, script_uri, 487 return request.SendAndWaitForResponse(kernel_port, script_uri,
477 source_file_count, source_files, 488 platform_kernel, source_file_count,
478 incremental_compile); 489 source_files, incremental_compile);
479 } 490 }
480 491
481 #endif // DART_PRECOMPILED_RUNTIME 492 #endif // DART_PRECOMPILED_RUNTIME
482 493
483 } // namespace dart 494 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698