OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 exit_code = kErrorExitCode; \ | 53 exit_code = kErrorExitCode; \ |
54 } \ | 54 } \ |
55 Dart_ExitScope(); \ | 55 Dart_ExitScope(); \ |
56 Dart_ShutdownIsolate(); \ | 56 Dart_ShutdownIsolate(); \ |
57 exit(exit_code); \ | 57 exit(exit_code); \ |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 // Global state that indicates whether a snapshot is to be created and | 61 // Global state that indicates whether a snapshot is to be created and |
62 // if so which file to write the snapshot into. | 62 // if so which file to write the snapshot into. |
63 static const char* vm_isolate_snapshot_filename = NULL; | 63 static const char* vm_snapshot_data_filename = NULL; |
64 static const char* isolate_snapshot_filename = NULL; | 64 static const char* vm_snapshot_instructions_filename = NULL; |
65 static const char* isolate_snapshot_data_filename = NULL; | |
66 static const char* isolate_snapshot_instructions_filename = NULL; | |
65 static const char* assembly_filename = NULL; | 67 static const char* assembly_filename = NULL; |
66 static const char* instructions_blob_filename = NULL; | |
67 static const char* rodata_blob_filename = NULL; | |
68 | 68 |
69 | 69 |
70 // Value of the --package-root flag. | 70 // Value of the --package-root flag. |
71 // (This pointer points into an argv buffer and does not need to be | 71 // (This pointer points into an argv buffer and does not need to be |
72 // free'd.) | 72 // free'd.) |
73 static const char* commandline_package_root = NULL; | 73 static const char* commandline_package_root = NULL; |
74 | 74 |
75 // Value of the --packages flag. | 75 // Value of the --packages flag. |
76 // (This pointer points into an argv buffer and does not need to be | 76 // (This pointer points into an argv buffer and does not need to be |
77 // free'd.) | 77 // free'd.) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 | 182 |
183 static const char* ProcessOption(const char* option, const char* name) { | 183 static const char* ProcessOption(const char* option, const char* name) { |
184 const intptr_t length = strlen(name); | 184 const intptr_t length = strlen(name); |
185 if (strncmp(option, name, length) == 0) { | 185 if (strncmp(option, name, length) == 0) { |
186 return (option + length); | 186 return (option + length); |
187 } | 187 } |
188 return NULL; | 188 return NULL; |
189 } | 189 } |
190 | 190 |
191 | 191 |
192 static bool ProcessVmIsolateSnapshotOption(const char* option) { | 192 static bool ProcessVmSnapshotDataOption(const char* option) { |
193 const char* name = ProcessOption(option, "--vm_isolate_snapshot="); | 193 const char* name = ProcessOption(option, "--vm_snapshot_data="); |
194 if (name != NULL) { | 194 if (name != NULL) { |
195 vm_isolate_snapshot_filename = name; | 195 vm_snapshot_data_filename = name; |
196 return true; | 196 return true; |
197 } | 197 } |
198 return false; | 198 return false; |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 static bool ProcessIsolateSnapshotOption(const char* option) { | 202 static bool ProcessVmSnapshotInstructionsOption(const char* option) { |
203 const char* name = ProcessOption(option, "--isolate_snapshot="); | 203 const char* name = ProcessOption(option, "--vm_snapshot_instructions="); |
204 if (name != NULL) { | 204 if (name != NULL) { |
205 isolate_snapshot_filename = name; | 205 vm_snapshot_instructions_filename = name; |
206 return true; | |
207 } | |
208 return false; | |
209 } | |
210 | |
211 | |
212 static bool ProcessIsolateSnapshotDataOption(const char* option) { | |
213 const char* name = ProcessOption(option, "--isolate_snapshot_data="); | |
214 if (name != NULL) { | |
215 isolate_snapshot_data_filename = name; | |
216 return true; | |
217 } | |
218 return false; | |
219 } | |
220 | |
221 | |
222 static bool ProcessIsolateSnapshotInstructionsOption(const char* option) { | |
223 const char* name = ProcessOption(option, "--isolate_snapshot_instructions="); | |
224 if (name != NULL) { | |
225 isolate_snapshot_instructions_filename = name; | |
206 return true; | 226 return true; |
207 } | 227 } |
208 return false; | 228 return false; |
209 } | 229 } |
210 | 230 |
211 | 231 |
212 static bool ProcessAssemblyOption(const char* option) { | 232 static bool ProcessAssemblyOption(const char* option) { |
213 const char* name = ProcessOption(option, "--assembly="); | 233 const char* name = ProcessOption(option, "--assembly="); |
214 if (name != NULL) { | 234 if (name != NULL) { |
215 assembly_filename = name; | 235 assembly_filename = name; |
216 return true; | 236 return true; |
217 } | 237 } |
218 return false; | 238 return false; |
219 } | |
220 | |
221 | |
222 static bool ProcessInstructionsBlobOption(const char* option) { | |
223 const char* name = ProcessOption(option, "--instructions_blob="); | |
224 if (name != NULL) { | |
225 instructions_blob_filename = name; | |
226 return true; | |
227 } | |
228 return false; | |
229 } | |
230 | |
231 | |
232 static bool ProcessRodataBlobOption(const char* option) { | |
233 const char* name = ProcessOption(option, "--rodata_blob="); | |
234 if (name != NULL) { | |
235 rodata_blob_filename = name; | |
236 return true; | |
237 } | |
238 return false; | |
239 } | 239 } |
240 | 240 |
241 | 241 |
242 static bool ProcessEmbedderEntryPointsManifestOption(const char* option) { | 242 static bool ProcessEmbedderEntryPointsManifestOption(const char* option) { |
243 const char* name = ProcessOption(option, "--embedder_entry_points_manifest="); | 243 const char* name = ProcessOption(option, "--embedder_entry_points_manifest="); |
244 if (name != NULL) { | 244 if (name != NULL) { |
245 entry_points_files->AddArgument(name); | 245 entry_points_files->AddArgument(name); |
246 return true; | 246 return true; |
247 } | 247 } |
248 return false; | 248 return false; |
(...skipping 30 matching lines...) Expand all Loading... | |
279 } | 279 } |
280 if (mapping != NULL) { | 280 if (mapping != NULL) { |
281 DartUtils::url_mapping->AddArgument(mapping); | 281 DartUtils::url_mapping->AddArgument(mapping); |
282 return true; | 282 return true; |
283 } | 283 } |
284 return false; | 284 return false; |
285 } | 285 } |
286 | 286 |
287 | 287 |
288 static bool IsSnapshottingForPrecompilation() { | 288 static bool IsSnapshottingForPrecompilation() { |
289 return (assembly_filename != NULL) || (instructions_blob_filename != NULL); | 289 return (assembly_filename != NULL) || |
290 (vm_snapshot_instructions_filename != NULL); | |
290 } | 291 } |
291 | 292 |
292 | 293 |
293 // Parse out the command line arguments. Returns -1 if the arguments | 294 // Parse out the command line arguments. Returns -1 if the arguments |
294 // are incorrect, 0 otherwise. | 295 // are incorrect, 0 otherwise. |
295 static int ParseArguments(int argc, | 296 static int ParseArguments(int argc, |
296 char** argv, | 297 char** argv, |
297 CommandLineOptions* vm_options, | 298 CommandLineOptions* vm_options, |
298 char** script_name) { | 299 char** script_name) { |
299 const char* kPrefix = "-"; | 300 const char* kPrefix = "-"; |
300 const intptr_t kPrefixLen = strlen(kPrefix); | 301 const intptr_t kPrefixLen = strlen(kPrefix); |
301 | 302 |
302 // Skip the binary name. | 303 // Skip the binary name. |
303 int i = 1; | 304 int i = 1; |
304 | 305 |
305 // Parse out the vm options. | 306 // Parse out the vm options. |
306 while ((i < argc) && IsValidFlag(argv[i], kPrefix, kPrefixLen)) { | 307 while ((i < argc) && IsValidFlag(argv[i], kPrefix, kPrefixLen)) { |
307 if (ProcessVmIsolateSnapshotOption(argv[i]) || | 308 if (ProcessVmSnapshotDataOption(argv[i]) || |
308 ProcessIsolateSnapshotOption(argv[i]) || | 309 ProcessVmSnapshotInstructionsOption(argv[i]) || |
310 ProcessIsolateSnapshotDataOption(argv[i]) || | |
311 ProcessIsolateSnapshotInstructionsOption(argv[i]) || | |
309 ProcessAssemblyOption(argv[i]) || | 312 ProcessAssemblyOption(argv[i]) || |
310 ProcessInstructionsBlobOption(argv[i]) || | |
311 ProcessRodataBlobOption(argv[i]) || | |
312 ProcessEmbedderEntryPointsManifestOption(argv[i]) || | 313 ProcessEmbedderEntryPointsManifestOption(argv[i]) || |
313 ProcessURLmappingOption(argv[i]) || ProcessPackageRootOption(argv[i]) || | 314 ProcessURLmappingOption(argv[i]) || ProcessPackageRootOption(argv[i]) || |
314 ProcessPackagesOption(argv[i]) || ProcessEnvironmentOption(argv[i])) { | 315 ProcessPackagesOption(argv[i]) || ProcessEnvironmentOption(argv[i])) { |
315 i += 1; | 316 i += 1; |
316 continue; | 317 continue; |
317 } | 318 } |
318 vm_options->AddArgument(argv[i]); | 319 vm_options->AddArgument(argv[i]); |
319 i += 1; | 320 i += 1; |
320 } | 321 } |
321 | 322 |
322 // Get the script name. | 323 // Get the script name. |
323 if (i < argc) { | 324 if (i < argc) { |
324 *script_name = argv[i]; | 325 *script_name = argv[i]; |
325 i += 1; | 326 i += 1; |
326 } else { | 327 } else { |
327 *script_name = NULL; | 328 *script_name = NULL; |
328 } | 329 } |
329 | 330 |
330 // Verify consistency of arguments. | 331 // Verify consistency of arguments. |
331 if ((commandline_package_root != NULL) && | 332 if ((commandline_package_root != NULL) && |
332 (commandline_packages_file != NULL)) { | 333 (commandline_packages_file != NULL)) { |
333 Log::PrintErr( | 334 Log::PrintErr( |
334 "Specifying both a packages directory and a packages " | 335 "Specifying both a packages directory and a packages " |
335 "file is invalid.\n"); | 336 "file is invalid.\n"); |
336 return -1; | 337 return -1; |
337 } | 338 } |
338 | 339 |
339 if (vm_isolate_snapshot_filename == NULL) { | 340 if (vm_snapshot_data_filename == NULL) { |
340 Log::PrintErr("No vm isolate snapshot output file specified.\n\n"); | 341 Log::PrintErr("No vm snapshot output file specified.\n\n"); |
341 return -1; | 342 return -1; |
342 } | 343 } |
343 | 344 |
344 if (isolate_snapshot_filename == NULL) { | 345 if (isolate_snapshot_data_filename == NULL) { |
345 Log::PrintErr("No isolate snapshot output file specified.\n\n"); | 346 Log::PrintErr("No isolate snapshot output file specified.\n\n"); |
346 return -1; | 347 return -1; |
347 } | 348 } |
348 | 349 |
349 bool precompiled_as_assembly = assembly_filename != NULL; | 350 bool precompiled_as_assembly = assembly_filename != NULL; |
350 bool precompiled_as_blobs = | 351 bool precompiled_as_blobs = (vm_snapshot_instructions_filename != NULL) || |
351 (instructions_blob_filename != NULL) || (rodata_blob_filename != NULL); | 352 (isolate_snapshot_instructions_filename != NULL); |
352 if (precompiled_as_assembly && precompiled_as_blobs) { | 353 if (precompiled_as_assembly && precompiled_as_blobs) { |
353 Log::PrintErr( | 354 Log::PrintErr( |
354 "Cannot request a precompiled snapshot simultaneously as " | 355 "Cannot request a precompiled snapshot simultaneously as " |
355 "assembly (--assembly=<output.file>) and as blobs " | 356 "assembly (--assembly=<output.file>) and as blobs " |
356 "(--instructions-blob=<output.file> and " | 357 "(--instructions-blob=<output.file> and " |
357 "--rodata-blob=<output.file>)\n\n"); | 358 "--rodata-blob=<output.file>)\n\n"); |
358 return -1; | 359 return -1; |
359 } | 360 } |
360 if ((instructions_blob_filename != NULL) != (rodata_blob_filename != NULL)) { | 361 if ((vm_snapshot_instructions_filename != NULL) != |
362 (isolate_snapshot_instructions_filename != NULL)) { | |
361 Log::PrintErr( | 363 Log::PrintErr( |
362 "Requesting a precompiled snapshot as blobs requires both " | 364 "Requesting a precompiled snapshot as blobs requires both " |
363 "(--instructions-blob=<output.file> and " | 365 "(--vm_snapshot_instructions=<output.file> and " |
364 "--rodata-blob=<output.file>)\n\n"); | 366 "--isolate_snapshot_instructions=<output.file>)\n\n"); |
365 return -1; | 367 return -1; |
366 } | 368 } |
367 if (IsSnapshottingForPrecompilation() && (entry_points_files->count() == 0)) { | 369 if (IsSnapshottingForPrecompilation() && (entry_points_files->count() == 0)) { |
368 Log::PrintErr( | 370 Log::PrintErr( |
369 "Specifying an instructions snapshot filename indicates precompilation" | 371 "Specifying an instructions snapshot filename indicates precompilation" |
370 ". But no embedder entry points manifest was specified.\n\n"); | 372 ". But no embedder entry points manifest was specified.\n\n"); |
371 return -1; | 373 return -1; |
372 } | 374 } |
373 | 375 |
374 return 0; | 376 return 0; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 " assembly that must be linked into \n" | 660 " assembly that must be linked into \n" |
659 " the target binary \n" | 661 " the target binary \n" |
660 " \n" | 662 " \n" |
661 " --instructions_blob=<file> (Precompilation only) Contains the \n" | 663 " --instructions_blob=<file> (Precompilation only) Contains the \n" |
662 " --rodata_blob=<file> instructions and read-only data that \n" | 664 " --rodata_blob=<file> instructions and read-only data that \n" |
663 " must be mapped into the target binary \n" | 665 " must be mapped into the target binary \n" |
664 " \n" | 666 " \n" |
665 " --embedder_entry_points_manifest=<file> (Precompilation or app \n" | 667 " --embedder_entry_points_manifest=<file> (Precompilation or app \n" |
666 " snapshots) Contains embedder's entry \n" | 668 " snapshots) Contains embedder's entry \n" |
667 " points into Dart code from the C API. \n" | 669 " points into Dart code from the C API. \n" |
668 "\n"); | 670 "\n"); |
siva
2017/01/20 22:53:53
Contents of the Usage message seems to be outdated
rmacnak
2017/01/21 00:50:43
Done.
| |
669 } | 671 } |
670 // clang-format on | 672 // clang-format on |
671 | 673 |
672 | 674 |
673 static void VerifyLoaded(Dart_Handle library) { | 675 static void VerifyLoaded(Dart_Handle library) { |
674 if (Dart_IsError(library)) { | 676 if (Dart_IsError(library)) { |
675 const char* err_msg = Dart_GetError(library); | 677 const char* err_msg = Dart_GetError(library); |
676 Log::PrintErr("Errors encountered while loading: %s\n", err_msg); | 678 Log::PrintErr("Errors encountered while loading: %s\n", err_msg); |
677 CHECK_RESULT(library); | 679 CHECK_RESULT(library); |
678 } | 680 } |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1020 "Could not find native embedder entry points during precompilation\n"); | 1022 "Could not find native embedder entry points during precompilation\n"); |
1021 exit(kErrorExitCode); | 1023 exit(kErrorExitCode); |
1022 } | 1024 } |
1023 return entries; | 1025 return entries; |
1024 } | 1026 } |
1025 | 1027 |
1026 | 1028 |
1027 static void CreateAndWriteSnapshot() { | 1029 static void CreateAndWriteSnapshot() { |
1028 ASSERT(!IsSnapshottingForPrecompilation()); | 1030 ASSERT(!IsSnapshottingForPrecompilation()); |
1029 Dart_Handle result; | 1031 Dart_Handle result; |
1030 uint8_t* vm_isolate_buffer = NULL; | 1032 uint8_t* vm_snapshot_data_buffer = NULL; |
1031 intptr_t vm_isolate_size = 0; | 1033 intptr_t vm_snapshot_data_size = 0; |
1032 uint8_t* isolate_buffer = NULL; | 1034 uint8_t* isolate_snapshot_data_buffer = NULL; |
1033 intptr_t isolate_size = 0; | 1035 intptr_t isolate_snapshot_data_size = 0; |
1034 | 1036 |
1035 // First create a snapshot. | 1037 // First create a snapshot. |
1036 result = Dart_CreateSnapshot(&vm_isolate_buffer, &vm_isolate_size, | 1038 result = Dart_CreateSnapshot(&vm_snapshot_data_buffer, &vm_snapshot_data_size, |
1037 &isolate_buffer, &isolate_size); | 1039 &isolate_snapshot_data_buffer, |
1040 &isolate_snapshot_data_size); | |
1038 CHECK_RESULT(result); | 1041 CHECK_RESULT(result); |
1039 | 1042 |
1040 // Now write the vm isolate and isolate snapshots out to the | 1043 // Now write the vm isolate and isolate snapshots out to the |
1041 // specified file and exit. | 1044 // specified file and exit. |
1042 WriteSnapshotFile(vm_isolate_snapshot_filename, vm_isolate_buffer, | 1045 WriteSnapshotFile(vm_snapshot_data_filename, vm_snapshot_data_buffer, |
1043 vm_isolate_size); | 1046 vm_snapshot_data_size); |
1044 WriteSnapshotFile(isolate_snapshot_filename, isolate_buffer, isolate_size); | 1047 WriteSnapshotFile(isolate_snapshot_data_filename, |
1048 isolate_snapshot_data_buffer, isolate_snapshot_data_size); | |
1045 Dart_ExitScope(); | 1049 Dart_ExitScope(); |
1046 | 1050 |
1047 // Shutdown the isolate. | 1051 // Shutdown the isolate. |
1048 Dart_ShutdownIsolate(); | 1052 Dart_ShutdownIsolate(); |
1049 } | 1053 } |
1050 | 1054 |
1051 | 1055 |
1052 static void CreateAndWritePrecompiledSnapshot( | 1056 static void CreateAndWritePrecompiledSnapshot( |
1053 Dart_QualifiedFunctionName* standalone_entry_points) { | 1057 Dart_QualifiedFunctionName* standalone_entry_points) { |
1054 ASSERT(IsSnapshottingForPrecompilation()); | 1058 ASSERT(IsSnapshottingForPrecompilation()); |
1055 Dart_Handle result; | 1059 Dart_Handle result; |
1056 | 1060 |
1057 // Precompile with specified embedder entry points | 1061 // Precompile with specified embedder entry points |
1058 result = Dart_Precompile(standalone_entry_points, NULL, 0); | 1062 result = Dart_Precompile(standalone_entry_points, NULL, 0); |
1059 CHECK_RESULT(result); | 1063 CHECK_RESULT(result); |
1060 | 1064 |
1061 // Create a precompiled snapshot. | 1065 // Create a precompiled snapshot. |
1062 bool as_assembly = assembly_filename != NULL; | 1066 bool as_assembly = assembly_filename != NULL; |
1063 if (as_assembly) { | 1067 if (as_assembly) { |
1064 uint8_t* assembly_buffer = NULL; | 1068 uint8_t* assembly_buffer = NULL; |
1065 intptr_t assembly_size = 0; | 1069 intptr_t assembly_size = 0; |
1066 result = | 1070 result = |
1067 Dart_CreateAppAOTSnapshotAsAssembly(&assembly_buffer, &assembly_size); | 1071 Dart_CreateAppAOTSnapshotAsAssembly(&assembly_buffer, &assembly_size); |
1068 CHECK_RESULT(result); | 1072 CHECK_RESULT(result); |
1069 WriteSnapshotFile(assembly_filename, assembly_buffer, assembly_size); | 1073 WriteSnapshotFile(assembly_filename, assembly_buffer, assembly_size); |
1070 } else { | 1074 } else { |
1071 uint8_t* vm_isolate_buffer = NULL; | 1075 uint8_t* vm_snapshot_data_buffer = NULL; |
1072 intptr_t vm_isolate_size = 0; | 1076 intptr_t vm_snapshot_data_size = 0; |
1073 uint8_t* isolate_buffer = NULL; | 1077 uint8_t* vm_snapshot_instructions_buffer = NULL; |
1074 intptr_t isolate_size = 0; | 1078 intptr_t vm_snapshot_instructions_size = 0; |
1075 uint8_t* instructions_blob_buffer = NULL; | 1079 uint8_t* isolate_snapshot_data_buffer = NULL; |
1076 intptr_t instructions_blob_size = 0; | 1080 intptr_t isolate_snapshot_data_size = 0; |
1077 uint8_t* rodata_blob_buffer = NULL; | 1081 uint8_t* isolate_snapshot_instructions_buffer = NULL; |
1078 intptr_t rodata_blob_size = 0; | 1082 intptr_t isolate_snapshot_instructions_size = 0; |
1079 result = Dart_CreateAppAOTSnapshotAsBlobs( | 1083 result = Dart_CreateAppAOTSnapshotAsBlobs( |
1080 &vm_isolate_buffer, &vm_isolate_size, &isolate_buffer, &isolate_size, | 1084 &vm_snapshot_data_buffer, &vm_snapshot_data_size, |
1081 &instructions_blob_buffer, &instructions_blob_size, &rodata_blob_buffer, | 1085 &vm_snapshot_instructions_buffer, &vm_snapshot_instructions_size, |
1082 &rodata_blob_size); | 1086 &isolate_snapshot_data_buffer, &isolate_snapshot_data_size, |
1087 &isolate_snapshot_instructions_buffer, | |
1088 &isolate_snapshot_instructions_size); | |
1083 CHECK_RESULT(result); | 1089 CHECK_RESULT(result); |
1084 WriteSnapshotFile(vm_isolate_snapshot_filename, vm_isolate_buffer, | 1090 WriteSnapshotFile(vm_snapshot_data_filename, vm_snapshot_data_buffer, |
1085 vm_isolate_size); | 1091 vm_snapshot_data_size); |
1086 WriteSnapshotFile(isolate_snapshot_filename, isolate_buffer, isolate_size); | 1092 WriteSnapshotFile(vm_snapshot_instructions_filename, |
1087 WriteSnapshotFile(instructions_blob_filename, instructions_blob_buffer, | 1093 vm_snapshot_instructions_buffer, |
1088 instructions_blob_size); | 1094 vm_snapshot_instructions_size); |
1089 WriteSnapshotFile(rodata_blob_filename, rodata_blob_buffer, | 1095 WriteSnapshotFile(isolate_snapshot_data_filename, |
1090 rodata_blob_size); | 1096 isolate_snapshot_data_buffer, isolate_snapshot_data_size); |
1097 WriteSnapshotFile(isolate_snapshot_instructions_filename, | |
1098 isolate_snapshot_instructions_buffer, | |
1099 isolate_snapshot_instructions_size); | |
1091 } | 1100 } |
1092 | 1101 |
1093 Dart_ExitScope(); | 1102 Dart_ExitScope(); |
1094 | 1103 |
1095 // Shutdown the isolate. | 1104 // Shutdown the isolate. |
1096 Dart_ShutdownIsolate(); | 1105 Dart_ShutdownIsolate(); |
1097 } | 1106 } |
1098 | 1107 |
1099 | 1108 |
1100 static void SetupForUriResolution() { | 1109 static void SetupForUriResolution() { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 static Dart_Isolate CreateServiceIsolate(const char* script_uri, | 1141 static Dart_Isolate CreateServiceIsolate(const char* script_uri, |
1133 const char* main, | 1142 const char* main, |
1134 const char* package_root, | 1143 const char* package_root, |
1135 const char* package_config, | 1144 const char* package_config, |
1136 Dart_IsolateFlags* flags, | 1145 Dart_IsolateFlags* flags, |
1137 void* data, | 1146 void* data, |
1138 char** error) { | 1147 char** error) { |
1139 IsolateData* isolate_data = | 1148 IsolateData* isolate_data = |
1140 new IsolateData(script_uri, package_root, package_config); | 1149 new IsolateData(script_uri, package_root, package_config); |
1141 Dart_Isolate isolate = NULL; | 1150 Dart_Isolate isolate = NULL; |
1142 isolate = | 1151 isolate = Dart_CreateIsolate(script_uri, main, NULL, NULL, NULL, isolate_data, |
1143 Dart_CreateIsolate(script_uri, main, NULL, NULL, isolate_data, error); | 1152 error); |
1144 | 1153 |
1145 if (isolate == NULL) { | 1154 if (isolate == NULL) { |
1146 Log::PrintErr("Error: Could not create service isolate"); | 1155 Log::PrintErr("Error: Could not create service isolate"); |
1147 return NULL; | 1156 return NULL; |
1148 } | 1157 } |
1149 | 1158 |
1150 Dart_EnterScope(); | 1159 Dart_EnterScope(); |
1151 if (!Dart_IsServiceIsolate(isolate)) { | 1160 if (!Dart_IsServiceIsolate(isolate)) { |
1152 Log::PrintErr("Error: We only expect to create the service isolate"); | 1161 Log::PrintErr("Error: We only expect to create the service isolate"); |
1153 return NULL; | 1162 return NULL; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1236 char* error = Dart_Initialize(&init_params); | 1245 char* error = Dart_Initialize(&init_params); |
1237 if (error != NULL) { | 1246 if (error != NULL) { |
1238 Log::PrintErr("VM initialization failed: %s\n", error); | 1247 Log::PrintErr("VM initialization failed: %s\n", error); |
1239 free(error); | 1248 free(error); |
1240 return kErrorExitCode; | 1249 return kErrorExitCode; |
1241 } | 1250 } |
1242 | 1251 |
1243 IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root, | 1252 IsolateData* isolate_data = new IsolateData(NULL, commandline_package_root, |
1244 commandline_packages_file); | 1253 commandline_packages_file); |
1245 Dart_Isolate isolate = | 1254 Dart_Isolate isolate = |
1246 Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error); | 1255 Dart_CreateIsolate(NULL, NULL, NULL, NULL, NULL, isolate_data, &error); |
1247 if (isolate == NULL) { | 1256 if (isolate == NULL) { |
1248 Log::PrintErr("Error: %s", error); | 1257 Log::PrintErr("Error: %s", error); |
1249 free(error); | 1258 free(error); |
1250 exit(kErrorExitCode); | 1259 exit(kErrorExitCode); |
1251 } | 1260 } |
1252 | 1261 |
1253 Dart_Handle result; | 1262 Dart_Handle result; |
1254 Dart_Handle library; | 1263 Dart_Handle library; |
1255 Dart_EnterScope(); | 1264 Dart_EnterScope(); |
1256 | 1265 |
1257 result = Dart_SetEnvironmentCallback(EnvironmentCallback); | 1266 result = Dart_SetEnvironmentCallback(EnvironmentCallback); |
1258 CHECK_RESULT(result); | 1267 CHECK_RESULT(result); |
1259 | 1268 |
1260 ASSERT(vm_isolate_snapshot_filename != NULL); | 1269 ASSERT(vm_snapshot_data_filename != NULL); |
1261 ASSERT(isolate_snapshot_filename != NULL); | 1270 ASSERT(isolate_snapshot_data_filename != NULL); |
1262 // Load up the script before a snapshot is created. | 1271 // Load up the script before a snapshot is created. |
1263 if (app_script_name != NULL) { | 1272 if (app_script_name != NULL) { |
1264 // This is the case of a custom embedder (e.g: dartium) trying to | 1273 // This is the case of a custom embedder (e.g: dartium) trying to |
1265 // create a full snapshot. The current isolate is set up so that we can | 1274 // create a full snapshot. The current isolate is set up so that we can |
1266 // invoke the dart uri resolution code like _resolveURI. App script is | 1275 // invoke the dart uri resolution code like _resolveURI. App script is |
1267 // loaded into a separate isolate. | 1276 // loaded into a separate isolate. |
1268 SetupForUriResolution(); | 1277 SetupForUriResolution(); |
1269 | 1278 |
1270 // Prepare builtin and its dependent libraries for use to resolve URIs. | 1279 // Prepare builtin and its dependent libraries for use to resolve URIs. |
1271 // Set up various closures, e.g: printing, timers etc. | 1280 // Set up various closures, e.g: printing, timers etc. |
(...skipping 26 matching lines...) Expand all Loading... | |
1298 void* kernel_program = NULL; | 1307 void* kernel_program = NULL; |
1299 if (is_kernel_file) { | 1308 if (is_kernel_file) { |
1300 kernel_program = Dart_ReadKernelBinary(kernel, kernel_length); | 1309 kernel_program = Dart_ReadKernelBinary(kernel, kernel_length); |
1301 free(const_cast<uint8_t*>(kernel)); | 1310 free(const_cast<uint8_t*>(kernel)); |
1302 } | 1311 } |
1303 | 1312 |
1304 Dart_Isolate isolate = | 1313 Dart_Isolate isolate = |
1305 is_kernel_file | 1314 is_kernel_file |
1306 ? Dart_CreateIsolateFromKernel(NULL, NULL, kernel_program, NULL, | 1315 ? Dart_CreateIsolateFromKernel(NULL, NULL, kernel_program, NULL, |
1307 isolate_data, &error) | 1316 isolate_data, &error) |
1308 : Dart_CreateIsolate(NULL, NULL, NULL, NULL, isolate_data, &error); | 1317 : Dart_CreateIsolate(NULL, NULL, NULL, NULL, NULL, isolate_data, |
1318 &error); | |
1309 if (isolate == NULL) { | 1319 if (isolate == NULL) { |
1310 Log::PrintErr("%s", error); | 1320 Log::PrintErr("%s", error); |
1311 free(error); | 1321 free(error); |
1312 exit(kErrorExitCode); | 1322 exit(kErrorExitCode); |
1313 } | 1323 } |
1314 Dart_EnterScope(); | 1324 Dart_EnterScope(); |
1315 result = Dart_SetEnvironmentCallback(EnvironmentCallback); | 1325 result = Dart_SetEnvironmentCallback(EnvironmentCallback); |
1316 CHECK_RESULT(result); | 1326 CHECK_RESULT(result); |
1317 | 1327 |
1318 // Set up the library tag handler in such a manner that it will use the | 1328 // Set up the library tag handler in such a manner that it will use the |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1371 EventHandler::Stop(); | 1381 EventHandler::Stop(); |
1372 return 0; | 1382 return 0; |
1373 } | 1383 } |
1374 | 1384 |
1375 } // namespace bin | 1385 } // namespace bin |
1376 } // namespace dart | 1386 } // namespace dart |
1377 | 1387 |
1378 int main(int argc, char** argv) { | 1388 int main(int argc, char** argv) { |
1379 return dart::bin::main(argc, argv); | 1389 return dart::bin::main(argc, argv); |
1380 } | 1390 } |
OLD | NEW |