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" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 namespace bin { | 13 namespace bin { |
14 | 14 |
15 const char kPlatformBinaryName[] = "platform.dill"; | 15 const char kPlatformBinaryName[] = "platform.dill"; |
| 16 const char kVMServiceIOBinaryName[] = "vmservice_io.dill"; |
16 | 17 |
17 | 18 |
18 DFE::DFE() | 19 DFE::DFE() |
19 : frontend_filename_(NULL), | 20 : frontend_filename_(NULL), |
20 platform_binary_filename_(NULL), | 21 platform_binary_filename_(NULL), |
21 kernel_platform_(NULL) {} | 22 vmservice_io_binary_filename_(NULL), |
| 23 kernel_platform_(NULL), |
| 24 kernel_vmservice_io_(NULL) {} |
22 | 25 |
23 | 26 |
24 DFE::~DFE() { | 27 DFE::~DFE() { |
25 frontend_filename_ = NULL; | 28 frontend_filename_ = NULL; |
26 | 29 |
27 if (platform_binary_filename_ != NULL) { | 30 if (platform_binary_filename_ != NULL) { |
28 delete platform_binary_filename_; | 31 delete platform_binary_filename_; |
29 platform_binary_filename_ = NULL; | 32 platform_binary_filename_ = NULL; |
30 } | 33 } |
31 | 34 |
32 if (kernel_platform_ != NULL) { | 35 if (kernel_platform_ != NULL) { |
33 delete reinterpret_cast<kernel::Program*>(kernel_platform_); | 36 delete reinterpret_cast<kernel::Program*>(kernel_platform_); |
34 kernel_platform_ = NULL; | 37 kernel_platform_ = NULL; |
35 } | 38 } |
| 39 |
| 40 if (kernel_vmservice_io_ != NULL) { |
| 41 delete reinterpret_cast<kernel::Program*>(kernel_vmservice_io_); |
| 42 kernel_vmservice_io_ = NULL; |
| 43 } |
36 } | 44 } |
37 | 45 |
38 | 46 |
39 void DFE::SetKernelBinaries(const char* name) { | 47 void DFE::SetKernelBinaries(const char* name) { |
40 intptr_t len = snprintf(NULL, 0, "%s%s%s", name, File::PathSeparator(), | 48 intptr_t len = snprintf(NULL, 0, "%s%s%s", name, File::PathSeparator(), |
41 kPlatformBinaryName) + | 49 kPlatformBinaryName) + |
42 1; | 50 1; |
43 platform_binary_filename_ = new char[len]; | 51 platform_binary_filename_ = new char[len]; |
44 snprintf(platform_binary_filename_, len, "%s%s%s", name, | 52 snprintf(platform_binary_filename_, len, "%s%s%s", name, |
45 File::PathSeparator(), kPlatformBinaryName); | 53 File::PathSeparator(), kPlatformBinaryName); |
| 54 |
| 55 len = snprintf(NULL, 0, "%s%s%s", name, File::PathSeparator(), |
| 56 kVMServiceIOBinaryName) + |
| 57 1; |
| 58 vmservice_io_binary_filename_ = new char[len]; |
| 59 snprintf(vmservice_io_binary_filename_, len, "%s%s%s", name, |
| 60 File::PathSeparator(), kVMServiceIOBinaryName); |
46 } | 61 } |
47 | 62 |
48 | 63 |
49 Dart_Handle DFE::ReloadScript(Dart_Isolate isolate, const char* url_string) { | 64 Dart_Handle DFE::ReloadScript(Dart_Isolate isolate, const char* url_string) { |
50 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate)); | 65 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate)); |
51 // First check if the URL points to a Kernel IR file in which case we | 66 // First check if the URL points to a Kernel IR file in which case we |
52 // skip the compilation step and directly reload the file. | 67 // skip the compilation step and directly reload the file. |
53 const uint8_t* kernel_ir = NULL; | 68 const uint8_t* kernel_ir = NULL; |
54 intptr_t kernel_ir_size = -1; | 69 intptr_t kernel_ir_size = -1; |
55 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) { | 70 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 117 } |
103 return NULL; | 118 return NULL; |
104 } | 119 } |
105 | 120 |
106 | 121 |
107 void* DFE::ReadPlatform() { | 122 void* DFE::ReadPlatform() { |
108 return kernel_platform_ = ReadScript(platform_binary_filename_); | 123 return kernel_platform_ = ReadScript(platform_binary_filename_); |
109 } | 124 } |
110 | 125 |
111 | 126 |
| 127 void* DFE::ReadVMServiceIO() { |
| 128 return kernel_vmservice_io_ = ReadScript(vmservice_io_binary_filename_); |
| 129 } |
| 130 |
| 131 |
112 void* DFE::ReadScript(const char* script_uri) { | 132 void* DFE::ReadScript(const char* script_uri) { |
113 const uint8_t* buffer = NULL; | 133 const uint8_t* buffer = NULL; |
114 intptr_t buffer_length = -1; | 134 intptr_t buffer_length = -1; |
115 bool result = TryReadKernelFile(script_uri, &buffer, &buffer_length); | 135 bool result = TryReadKernelFile(script_uri, &buffer, &buffer_length); |
116 if (result) { | 136 if (result) { |
117 return Dart_ReadKernelBinary(buffer, buffer_length); | 137 return Dart_ReadKernelBinary(buffer, buffer_length); |
118 } | 138 } |
119 return NULL; | 139 return NULL; |
120 } | 140 } |
121 | 141 |
(...skipping 27 matching lines...) Expand all Loading... |
149 return true; | 169 return true; |
150 } | 170 } |
151 } | 171 } |
152 } | 172 } |
153 return false; | 173 return false; |
154 } | 174 } |
155 | 175 |
156 | 176 |
157 } // namespace bin | 177 } // namespace bin |
158 } // namespace dart | 178 } // namespace dart |
OLD | NEW |