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

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

Issue 2694623008: Fix double-printing of loading errors in gen_snapshot. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | 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) 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 " binary \n" 667 " binary \n"
668 " \n" 668 " \n"
669 " --embedder_entry_points_manifest=<file> (Precompilation or app \n" 669 " --embedder_entry_points_manifest=<file> (Precompilation or app \n"
670 " snapshots) Contains embedder's entry \n" 670 " snapshots) Contains embedder's entry \n"
671 " points into Dart code from the C API. \n" 671 " points into Dart code from the C API. \n"
672 "\n"); 672 "\n");
673 } 673 }
674 // clang-format on 674 // clang-format on
675 675
676 676
677 static void VerifyLoaded(Dart_Handle library) {
678 if (Dart_IsError(library)) {
679 const char* err_msg = Dart_GetError(library);
680 Log::PrintErr("Errors encountered while loading: %s\n", err_msg);
681 CHECK_RESULT(library);
682 }
683 ASSERT(Dart_IsLibrary(library));
684 }
685
686
687 static const char StubNativeFunctionName[] = "StubNativeFunction"; 677 static const char StubNativeFunctionName[] = "StubNativeFunction";
688 678
689 679
690 void StubNativeFunction(Dart_NativeArguments arguments) { 680 void StubNativeFunction(Dart_NativeArguments arguments) {
691 // This is a stub function for the resolver 681 // This is a stub function for the resolver
692 Dart_SetReturnValue( 682 Dart_SetReturnValue(
693 arguments, Dart_NewApiError("<EMBEDDER DID NOT SETUP NATIVE RESOLVER>")); 683 arguments, Dart_NewApiError("<EMBEDDER DID NOT SETUP NATIVE RESOLVER>"));
694 } 684 }
695 685
696 686
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); 1103 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
1114 if (Dart_IsError(result)) { 1104 if (Dart_IsError(result)) {
1115 Log::PrintErr("%s", Dart_GetError(result)); 1105 Log::PrintErr("%s", Dart_GetError(result));
1116 Dart_ExitScope(); 1106 Dart_ExitScope();
1117 Dart_ShutdownIsolate(); 1107 Dart_ShutdownIsolate();
1118 exit(kErrorExitCode); 1108 exit(kErrorExitCode);
1119 } 1109 }
1120 // This is a generic dart snapshot which needs builtin library setup. 1110 // This is a generic dart snapshot which needs builtin library setup.
1121 Dart_Handle library = 1111 Dart_Handle library =
1122 LoadGenericSnapshotCreationScript(Builtin::kBuiltinLibrary); 1112 LoadGenericSnapshotCreationScript(Builtin::kBuiltinLibrary);
1123 VerifyLoaded(library); 1113 CHECK_RESULT(library);
1124 } 1114 }
1125 1115
1126 1116
1127 static void SetupForGenericSnapshotCreation() { 1117 static void SetupForGenericSnapshotCreation() {
1128 SetupForUriResolution(); 1118 SetupForUriResolution();
1129 1119
1130 Dart_Handle library = LoadGenericSnapshotCreationScript(Builtin::kIOLibrary); 1120 Dart_Handle library = LoadGenericSnapshotCreationScript(Builtin::kIOLibrary);
1131 VerifyLoaded(library); 1121 CHECK_RESULT(library);
1132 Dart_Handle result = Dart_FinalizeLoading(false); 1122 Dart_Handle result = Dart_FinalizeLoading(false);
1133 if (Dart_IsError(result)) { 1123 if (Dart_IsError(result)) {
1134 const char* err_msg = Dart_GetError(library); 1124 const char* err_msg = Dart_GetError(library);
1135 Log::PrintErr("Errors encountered while loading: %s\n", err_msg); 1125 Log::PrintErr("Errors encountered while loading: %s\n", err_msg);
1136 Dart_ExitScope(); 1126 Dart_ExitScope();
1137 Dart_ShutdownIsolate(); 1127 Dart_ShutdownIsolate();
1138 exit(kErrorExitCode); 1128 exit(kErrorExitCode);
1139 } 1129 }
1140 } 1130 }
1141 1131
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 CHECK_RESULT(result); 1335 CHECK_RESULT(result);
1346 } 1336 }
1347 1337
1348 SetupStubNativeResolversForPrecompilation(entry_points); 1338 SetupStubNativeResolversForPrecompilation(entry_points);
1349 1339
1350 SetupStubNativeResolvers(); 1340 SetupStubNativeResolvers();
1351 1341
1352 if (!is_kernel_file) { 1342 if (!is_kernel_file) {
1353 // Load the specified script. 1343 // Load the specified script.
1354 library = LoadSnapshotCreationScript(app_script_name); 1344 library = LoadSnapshotCreationScript(app_script_name);
1355 VerifyLoaded(library); 1345 CHECK_RESULT(library);
1356 1346
1357 ImportNativeEntryPointLibrariesIntoRoot(entry_points); 1347 ImportNativeEntryPointLibrariesIntoRoot(entry_points);
1358 } 1348 }
1359 1349
1360 // Ensure that we mark all libraries as loaded. 1350 // Ensure that we mark all libraries as loaded.
1361 result = Dart_FinalizeLoading(false); 1351 result = Dart_FinalizeLoading(false);
1362 CHECK_RESULT(result); 1352 CHECK_RESULT(result);
1363 1353
1364 if (!IsSnapshottingForPrecompilation()) { 1354 if (!IsSnapshottingForPrecompilation()) {
1365 CreateAndWriteSnapshot(); 1355 CreateAndWriteSnapshot();
(...skipping 17 matching lines...) Expand all
1383 EventHandler::Stop(); 1373 EventHandler::Stop();
1384 return 0; 1374 return 0;
1385 } 1375 }
1386 1376
1387 } // namespace bin 1377 } // namespace bin
1388 } // namespace dart 1378 } // namespace dart
1389 1379
1390 int main(int argc, char** argv) { 1380 int main(int argc, char** argv) {
1391 return dart::bin::main(argc, argv); 1381 return dart::bin::main(argc, argv);
1392 } 1382 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698