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

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

Issue 2933203004: Replace the --platform vm option with --kernel-binaries option. (Closed)
Patch Set: s/set_kernel_binaries_directory/SetKernelBinaries Created 3 years, 6 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
« no previous file with comments | « runtime/bin/dfe.h ('k') | runtime/bin/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9
9 #include "vm/kernel.h" 10 #include "vm/kernel.h"
10 11
11 namespace dart { 12 namespace dart {
12 namespace bin { 13 namespace bin {
13 14
15 const char kPlatformBinaryName[] = "platform.dill";
16
17
14 DFE::DFE() 18 DFE::DFE()
15 : frontend_filename_(NULL), 19 : frontend_filename_(NULL),
16 platform_binary_filename_(NULL), 20 platform_binary_filename_(NULL),
17 kernel_platform_(NULL) {} 21 kernel_platform_(NULL) {}
18 22
19 23
20 DFE::~DFE() { 24 DFE::~DFE() {
21 frontend_filename_ = NULL; 25 frontend_filename_ = NULL;
22 platform_binary_filename_ = NULL; 26
27 if (platform_binary_filename_ != NULL) {
28 delete platform_binary_filename_;
29 platform_binary_filename_ = NULL;
30 }
31
23 if (kernel_platform_ != NULL) { 32 if (kernel_platform_ != NULL) {
24 delete reinterpret_cast<kernel::Program*>(kernel_platform_); 33 delete reinterpret_cast<kernel::Program*>(kernel_platform_);
34 kernel_platform_ = NULL;
25 } 35 }
26 kernel_platform_ = NULL;
27 } 36 }
28 37
38
39 void DFE::SetKernelBinaries(const char* name) {
40 intptr_t len = snprintf(NULL, 0, "%s%s%s", name, File::PathSeparator(),
41 kPlatformBinaryName) +
42 1;
43 platform_binary_filename_ = new char[len];
44 snprintf(platform_binary_filename_, len, "%s%s%s", name,
45 File::PathSeparator(), kPlatformBinaryName);
46 }
47
48
29 Dart_Handle DFE::ReloadScript(Dart_Isolate isolate, const char* url_string) { 49 Dart_Handle DFE::ReloadScript(Dart_Isolate isolate, const char* url_string) {
30 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate)); 50 ASSERT(!Dart_IsServiceIsolate(isolate) && !Dart_IsKernelIsolate(isolate));
31 // First check if the URL points to a Kernel IR file in which case we 51 // First check if the URL points to a Kernel IR file in which case we
32 // skip the compilation step and directly reload the file. 52 // skip the compilation step and directly reload the file.
33 const uint8_t* kernel_ir = NULL; 53 const uint8_t* kernel_ir = NULL;
34 intptr_t kernel_ir_size = -1; 54 intptr_t kernel_ir_size = -1;
35 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) { 55 if (!TryReadKernelFile(url_string, &kernel_ir, &kernel_ir_size)) {
36 // We have a source file, compile it into a kernel ir first. 56 // We have a source file, compile it into a kernel ir first.
37 // TODO(asiva): We will have to change this API to pass in a list of files 57 // TODO(asiva): We will have to change this API to pass in a list of files
38 // that have changed. For now just pass in the main url_string and have it 58 // that have changed. For now just pass in the main url_string and have it
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 case Dart_KernelCompilationStatus_Unknown: 98 case Dart_KernelCompilationStatus_Unknown:
79 *error = result.error; // Copy error message. 99 *error = result.error; // Copy error message.
80 *exit_code = kErrorExitCode; 100 *exit_code = kErrorExitCode;
81 break; 101 break;
82 } 102 }
83 return NULL; 103 return NULL;
84 } 104 }
85 105
86 106
87 void* DFE::ReadPlatform() { 107 void* DFE::ReadPlatform() {
88 const uint8_t* buffer = NULL; 108 return kernel_platform_ = ReadScript(platform_binary_filename_);
89 intptr_t buffer_length = -1;
90 bool result =
91 TryReadKernelFile(platform_binary_filename_, &buffer, &buffer_length);
92 if (result) {
93 kernel_platform_ = Dart_ReadKernelBinary(buffer, buffer_length);
94 return kernel_platform_;
95 }
96 return NULL;
97 } 109 }
98 110
99 111
100 void* DFE::ReadScript(const char* script_uri) { 112 void* DFE::ReadScript(const char* script_uri) {
101 const uint8_t* buffer = NULL; 113 const uint8_t* buffer = NULL;
102 intptr_t buffer_length = -1; 114 intptr_t buffer_length = -1;
103 bool result = TryReadKernelFile(script_uri, &buffer, &buffer_length); 115 bool result = TryReadKernelFile(script_uri, &buffer, &buffer_length);
104 if (result) { 116 if (result) {
105 return Dart_ReadKernelBinary(buffer, buffer_length); 117 return Dart_ReadKernelBinary(buffer, buffer_length);
106 } 118 }
(...skipping 30 matching lines...) Expand all
137 return true; 149 return true;
138 } 150 }
139 } 151 }
140 } 152 }
141 return false; 153 return false;
142 } 154 }
143 155
144 156
145 } // namespace bin 157 } // namespace bin
146 } // namespace dart 158 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dfe.h ('k') | runtime/bin/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698