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

Side by Side Diff: runtime/bin/dfe.cc

Issue 2998983002: 1. Figure out the modified libraries from the specifeid kernel file during (Closed)
Patch Set: Fix format errors. 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) 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 File::PathSeparator(), kPlatformBinaryName); 45 File::PathSeparator(), kPlatformBinaryName);
46 46
47 len = snprintf(NULL, 0, "%s%s%s", name, File::PathSeparator(), 47 len = snprintf(NULL, 0, "%s%s%s", name, File::PathSeparator(),
48 kVMServiceIOBinaryName) + 48 kVMServiceIOBinaryName) +
49 1; 49 1;
50 vmservice_io_binary_filename_ = new char[len]; 50 vmservice_io_binary_filename_ = new char[len];
51 snprintf(vmservice_io_binary_filename_, len, "%s%s%s", name, 51 snprintf(vmservice_io_binary_filename_, len, "%s%s%s", name,
52 File::PathSeparator(), kVMServiceIOBinaryName); 52 File::PathSeparator(), kVMServiceIOBinaryName);
53 } 53 }
54 54
55 Dart_Handle DFE::ReloadScript(Dart_Isolate isolate, const char* url_string) { 55 Dart_Handle DFE::ReadKernelBinary(Dart_Isolate isolate,
56 const char* url_string) {
56 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate)); 57 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate));
57 // First check if the URL points to a Kernel IR file in which case we 58 // 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. 59 // skip the compilation step and directly reload the file.
59 const uint8_t* kernel_ir = NULL; 60 const uint8_t* kernel_ir = NULL;
60 intptr_t kernel_ir_size = -1; 61 intptr_t kernel_ir_size = -1;
61 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) { 62 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) {
62 // We have a source file, compile it into a kernel ir first. 63 // 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 64 // 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 65 // that have changed. For now just pass in the main url_string and have it
65 // recompile the script. 66 // recompile the script.
66 Dart_KernelCompilationResult kresult = Dart_CompileToKernel(url_string); 67 Dart_KernelCompilationResult kresult = Dart_CompileToKernel(url_string);
67 if (kresult.status != Dart_KernelCompilationStatus_Ok) { 68 if (kresult.status != Dart_KernelCompilationStatus_Ok) {
68 return Dart_NewApiError(kresult.error); 69 return Dart_NewApiError(kresult.error);
69 } 70 }
70 kernel_ir = kresult.kernel; 71 kernel_ir = kresult.kernel;
71 kernel_ir_size = kresult.kernel_size; 72 kernel_ir_size = kresult.kernel_size;
72 } 73 }
73 void* kernel_program = Dart_ReadKernelBinary(kernel_ir, kernel_ir_size); 74 void* kernel_program = Dart_ReadKernelBinary(kernel_ir, kernel_ir_size);
74 ASSERT(kernel_program != NULL); 75 ASSERT(kernel_program != NULL);
75 Dart_Handle result = Dart_LoadKernel(kernel_program); 76 return Dart_NewExternalTypedData(Dart_TypedData_kUint64, kernel_program, 1);
76 if (Dart_IsError(result)) {
77 return result;
78 }
79 // Finalize loading. This will complete any futures for completed deferred
80 // loads.
81 result = Dart_FinalizeLoading(true);
82 if (Dart_IsError(result)) {
83 return result;
84 }
85 return Dart_Null();
86 } 77 }
87 78
88 void* DFE::CompileAndReadScript(const char* script_uri, 79 void* DFE::CompileAndReadScript(const char* script_uri,
89 char** error, 80 char** error,
90 int* exit_code) { 81 int* exit_code) {
91 Dart_KernelCompilationResult result = Dart_CompileToKernel(script_uri); 82 Dart_KernelCompilationResult result = Dart_CompileToKernel(script_uri);
92 switch (result.status) { 83 switch (result.status) {
93 case Dart_KernelCompilationStatus_Ok: 84 case Dart_KernelCompilationStatus_Ok:
94 return Dart_ReadKernelBinary(result.kernel, result.kernel_size); 85 return Dart_ReadKernelBinary(result.kernel, result.kernel_size);
95 case Dart_KernelCompilationStatus_Error: 86 case Dart_KernelCompilationStatus_Error:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 *kernel_ir = buffer; 142 *kernel_ir = buffer;
152 return true; 143 return true;
153 } 144 }
154 } 145 }
155 } 146 }
156 return false; 147 return false;
157 } 148 }
158 149
159 } // namespace bin 150 } // namespace bin
160 } // namespace dart 151 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dfe.h ('k') | runtime/bin/loader.cc » ('j') | runtime/include/dart_api.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698