| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 "bin/dfe.h" | 5 #include "bin/dfe.h" |
| 6 #include "bin/dartutils.h" | 6 #include "bin/dartutils.h" |
| 7 #include "bin/error_exit.h" | 7 #include "bin/error_exit.h" |
| 8 #include "bin/file.h" | 8 #include "bin/file.h" |
| 9 | 9 |
| 10 #include "vm/kernel.h" | 10 #include "vm/kernel.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate)); | 56 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate)); |
| 57 // First check if the URL points to a Kernel IR file in which case we | 57 // First check if the URL points to a Kernel IR file in which case we |
| 58 // skip the compilation step and directly reload the file. | 58 // skip the compilation step and directly reload the file. |
| 59 const uint8_t* kernel_ir = NULL; | 59 const uint8_t* kernel_ir = NULL; |
| 60 intptr_t kernel_ir_size = -1; | 60 intptr_t kernel_ir_size = -1; |
| 61 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) { | 61 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) { |
| 62 // We have a source file, compile it into a kernel ir first. | 62 // We have a source file, compile it into a kernel ir first. |
| 63 // TODO(asiva): We will have to change this API to pass in a list of files | 63 // TODO(asiva): We will have to change this API to pass in a list of files |
| 64 // that have changed. For now just pass in the main url_string and have it | 64 // that have changed. For now just pass in the main url_string and have it |
| 65 // recompile the script. | 65 // recompile the script. |
| 66 Dart_KernelCompilationResult kresult = Dart_CompileToKernel(url_string); | 66 // TODO(aam): When Frontend is ready, VM should be passing outline.dill |
| 67 // instead of platform.dill to Frontend for compilation. |
| 68 Dart_KernelCompilationResult kresult = |
| 69 Dart_CompileToKernel(url_string, platform_binary_filename_); |
| 67 if (kresult.status != Dart_KernelCompilationStatus_Ok) { | 70 if (kresult.status != Dart_KernelCompilationStatus_Ok) { |
| 68 return Dart_NewApiError(kresult.error); | 71 return Dart_NewApiError(kresult.error); |
| 69 } | 72 } |
| 70 kernel_ir = kresult.kernel; | 73 kernel_ir = kresult.kernel; |
| 71 kernel_ir_size = kresult.kernel_size; | 74 kernel_ir_size = kresult.kernel_size; |
| 72 } | 75 } |
| 73 void* kernel_program = Dart_ReadKernelBinary(kernel_ir, kernel_ir_size); | 76 void* kernel_program = Dart_ReadKernelBinary(kernel_ir, kernel_ir_size); |
| 74 ASSERT(kernel_program != NULL); | 77 ASSERT(kernel_program != NULL); |
| 75 Dart_Handle result = Dart_LoadKernel(kernel_program); | 78 Dart_Handle result = Dart_LoadKernel(kernel_program); |
| 76 if (Dart_IsError(result)) { | 79 if (Dart_IsError(result)) { |
| 77 return result; | 80 return result; |
| 78 } | 81 } |
| 79 // Finalize loading. This will complete any futures for completed deferred | 82 // Finalize loading. This will complete any futures for completed deferred |
| 80 // loads. | 83 // loads. |
| 81 result = Dart_FinalizeLoading(true); | 84 result = Dart_FinalizeLoading(true); |
| 82 if (Dart_IsError(result)) { | 85 if (Dart_IsError(result)) { |
| 83 return result; | 86 return result; |
| 84 } | 87 } |
| 85 return Dart_Null(); | 88 return Dart_Null(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 void* DFE::CompileAndReadScript(const char* script_uri, | 91 void* DFE::CompileAndReadScript(const char* script_uri, |
| 89 char** error, | 92 char** error, |
| 90 int* exit_code) { | 93 int* exit_code) { |
| 91 Dart_KernelCompilationResult result = Dart_CompileToKernel(script_uri); | 94 // TODO(aam): When Frontend is ready, VM should be passing outline.dill |
| 95 // instead of platform.dill to Frontend for compilation. |
| 96 Dart_KernelCompilationResult result = |
| 97 Dart_CompileToKernel(script_uri, platform_binary_filename_); |
| 92 switch (result.status) { | 98 switch (result.status) { |
| 93 case Dart_KernelCompilationStatus_Ok: | 99 case Dart_KernelCompilationStatus_Ok: |
| 94 return Dart_ReadKernelBinary(result.kernel, result.kernel_size); | 100 return Dart_ReadKernelBinary(result.kernel, result.kernel_size); |
| 95 case Dart_KernelCompilationStatus_Error: | 101 case Dart_KernelCompilationStatus_Error: |
| 96 *error = result.error; // Copy error message. | 102 *error = result.error; // Copy error message. |
| 97 *exit_code = kCompilationErrorExitCode; | 103 *exit_code = kCompilationErrorExitCode; |
| 98 break; | 104 break; |
| 99 case Dart_KernelCompilationStatus_Crash: | 105 case Dart_KernelCompilationStatus_Crash: |
| 100 *error = result.error; // Copy error message. | 106 *error = result.error; // Copy error message. |
| 101 *exit_code = kDartFrontendErrorExitCode; | 107 *exit_code = kDartFrontendErrorExitCode; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 *kernel_ir = buffer; | 157 *kernel_ir = buffer; |
| 152 return true; | 158 return true; |
| 153 } | 159 } |
| 154 } | 160 } |
| 155 } | 161 } |
| 156 return false; | 162 return false; |
| 157 } | 163 } |
| 158 | 164 |
| 159 } // namespace bin | 165 } // namespace bin |
| 160 } // namespace dart | 166 } // namespace dart |
| OLD | NEW |