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

Unified Diff: runtime/vm/kernel_isolate.cc

Issue 2998963002: Revert "Revert "Introduce IKG into kernel-service to support incremental compilation."" (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/kernel_isolate.h ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_isolate.cc
diff --git a/runtime/vm/kernel_isolate.cc b/runtime/vm/kernel_isolate.cc
index 6020a27f8b7540576314d5519515afbaa7d6ad8c..75d52b9b5708f249d398bc15b2e59fc46ea8181d 100644
--- a/runtime/vm/kernel_isolate.cc
+++ b/runtime/vm/kernel_isolate.cc
@@ -248,6 +248,31 @@ Dart_Port KernelIsolate::WaitForKernelPort() {
return kernel_port_;
}
+static Dart_CObject BuildFilesPairs(int source_files_count,
+ Dart_SourceFile source_files[]) {
+ Dart_CObject files;
+ files.type = Dart_CObject_kArray;
+ files.value.as_array.length = source_files_count * 2;
+ // typedef Dart_CObject* Dart_CObjectPtr;
+ Dart_CObject** fileNamePairs = new Dart_CObject*[source_files_count * 2];
+ for (int i = 0; i < source_files_count; i++) {
+ Dart_CObject* source_uri = new Dart_CObject();
+ source_uri->type = Dart_CObject_kString;
+ source_uri->value.as_string = const_cast<char*>(source_files[i].uri);
+ fileNamePairs[i * 2] = source_uri;
+
+ Dart_CObject* source_code = new Dart_CObject();
+ source_code->type = Dart_CObject_kTypedData;
+ source_code->value.as_typed_data.type = Dart_TypedData_kUint8;
+ source_code->value.as_typed_data.length = strlen(source_files[i].source);
+ source_code->value.as_typed_data.values =
+ reinterpret_cast<uint8_t*>(const_cast<char*>(source_files[i].source));
+ fileNamePairs[(i * 2) + 1] = source_code;
+ }
+ files.value.as_array.values = fileNamePairs;
+ return files;
+}
+
class KernelCompilationRequest : public ValueObject {
public:
KernelCompilationRequest()
@@ -275,10 +300,12 @@ class KernelCompilationRequest : public ValueObject {
Dart_Port kernel_port,
const char* script_uri,
int source_files_count,
- Dart_SourceFile source_files[]) {
- // Build the [null, send_port, script_uri] message for the Kernel isolate:
- // null tag tells it that request came from this code, instead of Loader
- // so that it can given a more informative response.
+ Dart_SourceFile source_files[],
+ bool incremental_compile) {
+ // Build the [null, send_port, script_uri, incremental_compile, isolate_id,
+ // [files]] message for the Kernel isolate: null tag tells it that request
+ // came from this code, instead of Loader so that it can given a more
+ // informative response.
Dart_CObject tag;
tag.type = Dart_CObject_kNull;
@@ -291,44 +318,38 @@ class KernelCompilationRequest : public ValueObject {
uri.type = Dart_CObject_kString;
uri.value.as_string = const_cast<char*>(script_uri);
+ Dart_CObject dart_incremental;
+ dart_incremental.type = Dart_CObject_kBool;
+ dart_incremental.value.as_bool = incremental_compile;
+
+ // TODO(aam): Assert that isolate exists once we move CompileAndReadScript
+ // compilation logic out of CreateIsolateAndSetupHelper and into
+ // IsolateSetupHelper in main.cc.
+ Isolate* isolate =
+ Thread::Current() != NULL ? Thread::Current()->isolate() : NULL;
+ if (incremental_compile) {
+ ASSERT(isolate != NULL);
+ }
+ Dart_CObject isolate_id;
+ isolate_id.type = Dart_CObject_kInt64;
+ isolate_id.value.as_int64 =
+ isolate != NULL ? static_cast<int64_t>(isolate->main_port()) : 0;
+
Dart_CObject message;
message.type = Dart_CObject_kArray;
- if (source_files_count == 0) {
- static const intptr_t message_len = 3;
- Dart_CObject* message_arr[] = {&tag, &send_port, &uri};
- message.value.as_array.values = message_arr;
- message.value.as_array.length = message_len;
- // Send the message.
- Dart_PostCObject(kernel_port, &message);
- } else {
- Dart_CObject files;
- files.type = Dart_CObject_kArray;
- files.value.as_array.length = source_files_count * 2;
- // typedef Dart_CObject* Dart_CObjectPtr;
- Dart_CObject** fileNamePairs = new Dart_CObject*[source_files_count * 2];
- for (int i = 0; i < source_files_count; i++) {
- Dart_CObject* source_uri = new Dart_CObject();
- source_uri->type = Dart_CObject_kString;
- source_uri->value.as_string = const_cast<char*>(source_files[i].uri);
- fileNamePairs[i * 2] = source_uri;
-
- Dart_CObject* source_code = new Dart_CObject();
- source_code->type = Dart_CObject_kTypedData;
- source_code->value.as_typed_data.type = Dart_TypedData_kUint8;
- source_code->value.as_typed_data.length =
- strlen(source_files[i].source);
- source_code->value.as_typed_data.values = reinterpret_cast<uint8_t*>(
- const_cast<char*>(source_files[i].source));
- fileNamePairs[(i * 2) + 1] = source_code;
- }
- files.value.as_array.values = fileNamePairs;
- static const intptr_t message_len = 4;
- Dart_CObject* message_arr[] = {&tag, &send_port, &uri, &files};
- message.value.as_array.values = message_arr;
- message.value.as_array.length = message_len;
- Dart_PostCObject(kernel_port, &message);
+ intptr_t message_len = 5;
+ Dart_CObject files;
+ if (source_files_count != 0) {
+ files = BuildFilesPairs(source_files_count, source_files);
+ message_len++;
}
+ Dart_CObject* message_arr[] = {
+ &tag, &send_port, &uri, &dart_incremental, &isolate_id, &files};
+ message.value.as_array.values = message_arr;
+ message.value.as_array.length = message_len;
+ // Send the message.
+ Dart_PostCObject(kernel_port, &message);
// Wait for reply to arrive.
MonitorLocker ml(monitor_);
@@ -439,7 +460,8 @@ KernelCompilationRequest* KernelCompilationRequest::requests_ = NULL;
Dart_KernelCompilationResult KernelIsolate::CompileToKernel(
const char* script_uri,
int source_file_count,
- Dart_SourceFile source_files[]) {
+ Dart_SourceFile source_files[],
+ bool incremental_compile) {
// This must be the main script to be loaded. Wait for Kernel isolate
// to finish initialization.
Dart_Port kernel_port = WaitForKernelPort();
@@ -452,7 +474,8 @@ Dart_KernelCompilationResult KernelIsolate::CompileToKernel(
KernelCompilationRequest request;
return request.SendAndWaitForResponse(kernel_port, script_uri,
- source_file_count, source_files);
+ source_file_count, source_files,
+ incremental_compile);
}
#endif // DART_PRECOMPILED_RUNTIME
« no previous file with comments | « runtime/vm/kernel_isolate.h ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698