| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Generate a snapshot file after loading all the scripts specified on the | 5 // Generate a snapshot file after loading all the scripts specified on the |
| 6 // command line. | 6 // command line. |
| 7 | 7 |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 return 255; | 292 return 255; |
| 293 } | 293 } |
| 294 | 294 |
| 295 DartUtils::SetOriginalWorkingDirectory(); | 295 DartUtils::SetOriginalWorkingDirectory(); |
| 296 | 296 |
| 297 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 297 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 298 | 298 |
| 299 // Initialize the Dart VM. | 299 // Initialize the Dart VM. |
| 300 // Note: We don't expect isolates to be created from dart code during | 300 // Note: We don't expect isolates to be created from dart code during |
| 301 // snapshot generation. | 301 // snapshot generation. |
| 302 Dart_Initialize(NULL, NULL, NULL); | 302 if (!Dart_Initialize(NULL, NULL, NULL)) { |
| 303 fprintf(stderr, "VM initialization failed\n"); |
| 304 return 255; |
| 305 } |
| 303 | 306 |
| 304 char* error; | 307 char* error; |
| 305 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error); | 308 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error); |
| 306 if (isolate == NULL) { | 309 if (isolate == NULL) { |
| 307 fprintf(stderr, "Error: %s", error); | 310 fprintf(stderr, "Error: %s", error); |
| 308 free(error); | 311 free(error); |
| 309 exit(255); | 312 exit(255); |
| 310 } | 313 } |
| 311 | 314 |
| 312 Dart_Handle result; | 315 Dart_Handle result; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 384 |
| 382 // Now create and write snapshot of script. | 385 // Now create and write snapshot of script. |
| 383 CreateAndWriteSnapshot(true); | 386 CreateAndWriteSnapshot(true); |
| 384 } | 387 } |
| 385 } else { | 388 } else { |
| 386 SetupForGenericSnapshotCreation(); | 389 SetupForGenericSnapshotCreation(); |
| 387 CreateAndWriteSnapshot(false); | 390 CreateAndWriteSnapshot(false); |
| 388 } | 391 } |
| 389 return 0; | 392 return 0; |
| 390 } | 393 } |
| OLD | NEW |