@@ -24,9 +24,9 @@ extern intptr_t kKernelServiceDillSize;
2424extern const uint8_t kPlatformStrongDill [];
2525extern intptr_t kPlatformStrongDillSize ;
2626#else
27- const uint8_t * kKernelServiceDill = NULL ;
27+ const uint8_t * kKernelServiceDill = nullptr ;
2828intptr_t kKernelServiceDillSize = 0 ;
29- const uint8_t * kPlatformStrongDill = NULL ;
29+ const uint8_t * kPlatformStrongDill = nullptr ;
3030intptr_t kPlatformStrongDillSize = 0 ;
3131#endif // !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
3232}
@@ -65,8 +65,8 @@ static char* GetDirectoryPrefixFromExeName() {
6565DFE::DFE ()
6666 : use_dfe_(false ),
6767 use_incremental_compiler_ (false ),
68- frontend_filename_(NULL ),
69- application_kernel_buffer_(NULL ),
68+ frontend_filename_(nullptr ),
69+ application_kernel_buffer_(nullptr ),
7070 application_kernel_buffer_size_(0 ) {
7171 // The run_vm_tests binary has the DART_PRECOMPILER set in order to allow unit
7272 // tests to exercise JIT and AOT pipeline.
@@ -75,26 +75,30 @@ DFE::DFE()
7575 // need to fall back to the built-in one (if we have it).
7676#if defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM) || defined(DART_NO_SNAPSHOT) || \
7777 (defined (DART_PRECOMPILER) && defined (TARGET_ARCH_X64))
78- kernel_service_dill_ = NULL ;
78+ kernel_service_dill_ = nullptr ;
7979 kernel_service_dill_size_ = 0 ;
80- platform_strong_dill_ = NULL ;
81- platform_strong_dill_size_ = 0 ;
80+ platform_strong_dill_for_compilation_ = nullptr ;
81+ platform_strong_dill_for_compilation_size_ = 0 ;
82+ platform_strong_dill_for_execution_ = nullptr ;
83+ platform_strong_dill_for_execution_size_ = 0 ;
8284#else
8385 kernel_service_dill_ = kKernelServiceDill ;
8486 kernel_service_dill_size_ = kKernelServiceDillSize ;
85- platform_strong_dill_ = kPlatformStrongDill ;
86- platform_strong_dill_size_ = kPlatformStrongDillSize ;
87+ platform_strong_dill_for_compilation_ = kPlatformStrongDill ;
88+ platform_strong_dill_for_compilation_size_ = kPlatformStrongDillSize ;
89+ platform_strong_dill_for_execution_ = kPlatformStrongDill ;
90+ platform_strong_dill_for_execution_size_ = kPlatformStrongDillSize ;
8791#endif
8892}
8993
9094DFE::~DFE () {
91- if (frontend_filename_ != NULL ) {
95+ if (frontend_filename_ != nullptr ) {
9296 free (frontend_filename_);
9397 }
94- frontend_filename_ = NULL ;
98+ frontend_filename_ = nullptr ;
9599
96100 free (application_kernel_buffer_);
97- application_kernel_buffer_ = NULL ;
101+ application_kernel_buffer_ = nullptr ;
98102 application_kernel_buffer_size_ = 0 ;
99103}
100104
@@ -103,24 +107,24 @@ void DFE::Init() {
103107}
104108
105109void DFE::Init (int target_abi_version) {
106- if (platform_strong_dill_ == NULL ) {
110+ if (platform_strong_dill_for_compilation_ == nullptr ) {
107111 return ;
108112 }
109113
110114 if (!InitKernelServiceAndPlatformDills (target_abi_version)) {
111115 return ;
112116 }
113117
114- Dart_SetDartLibrarySourcesKernel (platform_strong_dill_ ,
115- platform_strong_dill_size_ );
118+ Dart_SetDartLibrarySourcesKernel (platform_strong_dill_for_compilation_ ,
119+ platform_strong_dill_for_compilation_size_ );
116120}
117121
118122bool DFE::InitKernelServiceAndPlatformDills (int target_abi_version) {
119123 const char kAbiVersionsDir [] = " dart-sdk/lib/_internal/abiversions" ;
120124 const char kKernelServiceDillFile [] = " kernel_service.dill" ;
121125 const char kPlatformStrongDillFile [] = " vm_platform_strong.dill" ;
122126
123- if (frontend_filename_ != NULL ) {
127+ if (frontend_filename_ != nullptr ) {
124128 return true ;
125129 }
126130
@@ -129,18 +133,19 @@ bool DFE::InitKernelServiceAndPlatformDills(int target_abi_version) {
129133 GetDirectoryPrefixFromExeName (), free);
130134
131135 if (target_abi_version != Options::kAbiVersionUnset ) {
132- kernel_service_dill_ = NULL ;
136+ kernel_service_dill_ = nullptr ;
133137 kernel_service_dill_size_ = 0 ;
134- platform_strong_dill_ = NULL ;
135- platform_strong_dill_size_ = 0 ;
138+ platform_strong_dill_for_compilation_ = nullptr ;
139+ platform_strong_dill_for_compilation_size_ = 0 ;
136140
137141 // Look in the old abi version directory.
138142 char * script_uri =
139143 Utils::SCreate (" %s%s/%d/%s" , dir_prefix.get (), kAbiVersionsDir ,
140144 target_abi_version, kPlatformStrongDillFile );
141- if (!TryReadKernelFile (script_uri,
142- const_cast <uint8_t **>(&platform_strong_dill_),
143- &platform_strong_dill_size_)) {
145+ if (!TryReadKernelFile (
146+ script_uri,
147+ const_cast <uint8_t **>(&platform_strong_dill_for_compilation_),
148+ &platform_strong_dill_for_compilation_size_)) {
144149 Syslog::PrintErr (" Can't find old ABI dill file: %s\n " , script_uri);
145150 free (script_uri);
146151 return false ;
@@ -163,27 +168,27 @@ bool DFE::InitKernelServiceAndPlatformDills(int target_abi_version) {
163168 // Look for the frontend snapshot next to the executable.
164169 frontend_filename_ =
165170 Utils::SCreate (" %s%s" , dir_prefix.get (), kKernelServiceSnapshot );
166- if (File::Exists (NULL , frontend_filename_)) {
171+ if (File::Exists (nullptr , frontend_filename_)) {
167172 return true ;
168173 }
169174 free (frontend_filename_);
170- frontend_filename_ = NULL ;
175+ frontend_filename_ = nullptr ;
171176
172177 // If the frontend snapshot is not found next to the executable, then look for
173178 // it in the "snapshots" directory.
174179 frontend_filename_ =
175180 Utils::SCreate (" %s%s%s%s" , dir_prefix.get (), kSnapshotsDirectory ,
176181 File::PathSeparator (), kKernelServiceSnapshot );
177- if (File::Exists (NULL , frontend_filename_)) {
182+ if (File::Exists (nullptr , frontend_filename_)) {
178183 return true ;
179184 }
180185 free (frontend_filename_);
181- frontend_filename_ = NULL ;
186+ frontend_filename_ = nullptr ;
182187 return true ;
183188}
184189
185190bool DFE::KernelServiceDillAvailable () const {
186- return kernel_service_dill_ != NULL ;
191+ return kernel_service_dill_ != nullptr ;
187192}
188193
189194void DFE::LoadKernelService (const uint8_t ** kernel_service_buffer,
@@ -194,13 +199,13 @@ void DFE::LoadKernelService(const uint8_t** kernel_service_buffer,
194199
195200void DFE::LoadPlatform (const uint8_t ** kernel_buffer,
196201 intptr_t * kernel_buffer_size) {
197- *kernel_buffer = platform_strong_dill_ ;
198- *kernel_buffer_size = platform_strong_dill_size_ ;
202+ *kernel_buffer = platform_strong_dill_for_execution_ ;
203+ *kernel_buffer_size = platform_strong_dill_for_execution_size_ ;
199204}
200205
201206bool DFE::CanUseDartFrontend () const {
202- return (platform_strong_dill_ != NULL ) &&
203- (KernelServiceDillAvailable () || (frontend_filename () != NULL ));
207+ return (platform_strong_dill_for_compilation_ != nullptr ) &&
208+ (KernelServiceDillAvailable () || (frontend_filename () != nullptr ));
204209}
205210
206211class WindowsPathSanitizer {
@@ -217,7 +222,7 @@ class WindowsPathSanitizer {
217222 // (see builtin.dart#_sanitizeWindowsPath)
218223 intptr_t len = strlen (path);
219224 sanitized_uri_ = reinterpret_cast <char *>(malloc (len + 1 + 1 ));
220- if (sanitized_uri_ == NULL ) {
225+ if (sanitized_uri_ == nullptr ) {
221226 OUT_OF_MEMORY ();
222227 }
223228 char * s = sanitized_uri_;
@@ -251,9 +256,9 @@ Dart_KernelCompilationResult DFE::CompileScript(const char* script_uri,
251256 const char * sanitized_uri = script_uri;
252257#endif
253258
254- return Dart_CompileToKernel (sanitized_uri, platform_strong_dill_,
255- platform_strong_dill_size_, incremental ,
256- package_config);
259+ return Dart_CompileToKernel (
260+ sanitized_uri, platform_strong_dill_for_compilation_ ,
261+ platform_strong_dill_for_compilation_size_, incremental, package_config);
257262}
258263
259264void DFE::CompileAndReadScript (const char * script_uri,
@@ -268,7 +273,7 @@ void DFE::CompileAndReadScript(const char* script_uri,
268273 case Dart_KernelCompilationStatus_Ok:
269274 *kernel_buffer = result.kernel ;
270275 *kernel_buffer_size = result.kernel_size ;
271- *error = NULL ;
276+ *error = nullptr ;
272277 *exit_code = 0 ;
273278 break ;
274279 case Dart_KernelCompilationStatus_Error:
@@ -298,18 +303,18 @@ void DFE::ReadScript(const char* script_uri,
298303 }
299304 if (!Dart_IsKernel (*kernel_buffer, *kernel_buffer_size)) {
300305 free (*kernel_buffer);
301- *kernel_buffer = NULL ;
306+ *kernel_buffer = nullptr ;
302307 *kernel_buffer_size = -1 ;
303308 }
304309 int64_t end = Dart_TimelineGetMicros ();
305310 Dart_TimelineEvent (" DFE::ReadScript" , start, end,
306- Dart_Timeline_Event_Duration, 0 , NULL , NULL );
311+ Dart_Timeline_Event_Duration, 0 , nullptr , nullptr );
307312}
308313
309314// Attempts to treat [buffer] as a in-memory kernel byte representation.
310315// If successful, returns [true] and places [buffer] into [kernel_ir], byte size
311316// into [kernel_ir_size].
312- // If unsuccessful, returns [false], puts [NULL ] into [kernel_ir], -1 into
317+ // If unsuccessful, returns [false], puts [nullptr ] into [kernel_ir], -1 into
313318// [kernel_ir_size].
314319static bool TryReadSimpleKernelBuffer (uint8_t * buffer,
315320 uint8_t ** p_kernel_ir,
@@ -325,7 +330,7 @@ static bool TryReadSimpleKernelBuffer(uint8_t* buffer,
325330 return true ;
326331 }
327332 free (buffer);
328- *p_kernel_ir = NULL ;
333+ *p_kernel_ir = nullptr ;
329334 *p_kernel_ir_size = -1 ;
330335 return false ;
331336}
@@ -337,12 +342,12 @@ static bool TryReadSimpleKernelBuffer(uint8_t* buffer,
337342static bool TryReadFile (const char * script_uri, uint8_t ** buffer,
338343 intptr_t * size) {
339344 void * script_file = DartUtils::OpenFileUri (script_uri, false );
340- if (script_file == NULL ) {
345+ if (script_file == nullptr ) {
341346 return false ;
342347 }
343348 DartUtils::ReadFile (buffer, size, script_file);
344349 DartUtils::CloseFile (script_file);
345- if (*size <= 0 || buffer == NULL ) {
350+ if (*size <= 0 || buffer == nullptr ) {
346351 return false ;
347352 }
348353 return true ;
@@ -359,7 +364,7 @@ class KernelIRNode {
359364
360365 static void Add (KernelIRNode** p_head, KernelIRNode** p_tail,
361366 KernelIRNode* node) {
362- if (*p_head == NULL ) {
367+ if (*p_head == nullptr ) {
363368 *p_head = node;
364369 } else {
365370 (*p_tail)->next_ = node;
@@ -370,17 +375,17 @@ class KernelIRNode {
370375 static void Merge (KernelIRNode* head, uint8_t ** p_bytes,
371376 intptr_t * p_size) {
372377 intptr_t size = 0 ;
373- for (KernelIRNode* node = head; node != NULL ; node = node->next_ ) {
378+ for (KernelIRNode* node = head; node != nullptr ; node = node->next_ ) {
374379 size = size + node->kernel_size_ ;
375380 }
376381
377382 *p_bytes = reinterpret_cast <uint8_t *>(malloc (size));
378- if (*p_bytes == NULL ) {
383+ if (*p_bytes == nullptr ) {
379384 OUT_OF_MEMORY ();
380385 }
381386 uint8_t * p = *p_bytes;
382387 KernelIRNode* node = head;
383- while (node != NULL ) {
388+ while (node != nullptr ) {
384389 memmove (p, node->kernel_ir_ , node->kernel_size_ );
385390 p += node->kernel_size_ ;
386391 KernelIRNode* next = node->next_ ;
@@ -391,7 +396,7 @@ class KernelIRNode {
391396
392397 static void Delete (KernelIRNode* head) {
393398 KernelIRNode* node = head;
394- while (node != NULL ) {
399+ while (node != nullptr ) {
395400 KernelIRNode* next = node->next_ ;
396401 delete (node);
397402 node = next;
@@ -402,7 +407,7 @@ class KernelIRNode {
402407 uint8_t * kernel_ir_;
403408 intptr_t kernel_size_;
404409
405- KernelIRNode* next_ = NULL ;
410+ KernelIRNode* next_ = nullptr ;
406411
407412 DISALLOW_COPY_AND_ASSIGN (KernelIRNode);
408413};
@@ -435,14 +440,14 @@ static bool TryReadKernelListBuffer(const char* script_uri,
435440 uint8_t ** kernel_ir,
436441 intptr_t * kernel_ir_size) {
437442 const char * kernel_list_dirname = DartUtils::DirName (script_uri);
438- KernelIRNode* kernel_ir_head = NULL ;
439- KernelIRNode* kernel_ir_tail = NULL ;
443+ KernelIRNode* kernel_ir_head = nullptr ;
444+ KernelIRNode* kernel_ir_tail = nullptr ;
440445 // Add all kernels to the linked list
441446 char * filename =
442447 reinterpret_cast <char *>(buffer + kernel_list_magic_number.length );
443448 intptr_t filename_size = buffer_size - kernel_list_magic_number.length ;
444449 char * tail = reinterpret_cast <char *>(memchr (filename, ' \n ' , filename_size));
445- while (tail != NULL ) {
450+ while (tail != nullptr ) {
446451 *tail = ' \0 ' ;
447452 intptr_t this_kernel_size;
448453 uint8_t * this_buffer;
@@ -461,7 +466,7 @@ static bool TryReadKernelListBuffer(const char* script_uri,
461466 &this_kernel_size)) {
462467 // Abandon read if any of the files in the list are invalid.
463468 KernelIRNode::Delete (kernel_ir_head);
464- *kernel_ir = NULL ;
469+ *kernel_ir = nullptr ;
465470 *kernel_ir_size = -1 ;
466471 return false ;
467472 }
@@ -481,7 +486,7 @@ static bool TryReadKernelListBuffer(const char* script_uri,
481486bool DFE::TryReadKernelFile (const char * script_uri,
482487 uint8_t ** kernel_ir,
483488 intptr_t * kernel_ir_size) {
484- *kernel_ir = NULL ;
489+ *kernel_ir = nullptr ;
485490 *kernel_ir_size = -1 ;
486491
487492 uint8_t * buffer;
0 commit comments