@@ -822,6 +822,7 @@ static void SnapshotOnExitHook(int64_t exit_code) {
822
822
823
823
static Dart_Isolate IsolateSetupHelper (Dart_Isolate isolate,
824
824
bool is_main_isolate,
825
+ bool kernel_file_specified,
825
826
const char * script_uri,
826
827
const char * package_root,
827
828
const char * packages_config,
@@ -844,15 +845,20 @@ static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
844
845
result = DartUtils::PrepareForScriptLoading (false , trace_loading);
845
846
CHECK_RESULT (result);
846
847
847
- if (kernel_program != NULL ) {
848
- Dart_Handle uri = Dart_NewStringFromCString (script_uri);
849
- CHECK_RESULT (uri);
850
- Dart_Handle resolved_script_uri = DartUtils::ResolveScript (uri);
851
- CHECK_RESULT (resolved_script_uri);
852
- result =
853
- Dart_LoadScript (uri, resolved_script_uri,
854
- reinterpret_cast <Dart_Handle>(kernel_program), 0 , 0 );
855
- CHECK_RESULT (result);
848
+ if (kernel_file_specified) {
849
+ ASSERT (kernel_program != NULL );
850
+ result = Dart_LoadKernel (kernel_program);
851
+ } else {
852
+ if (kernel_program != NULL ) {
853
+ Dart_Handle uri = Dart_NewStringFromCString (script_uri);
854
+ CHECK_RESULT (uri);
855
+ Dart_Handle resolved_script_uri = DartUtils::ResolveScript (uri);
856
+ CHECK_RESULT (resolved_script_uri);
857
+ result =
858
+ Dart_LoadScript (uri, resolved_script_uri,
859
+ reinterpret_cast <Dart_Handle>(kernel_program), 0 , 0 );
860
+ CHECK_RESULT (result);
861
+ }
856
862
}
857
863
if (set_native_resolvers) {
858
864
// Setup the native resolver as the snapshot does not carry it.
@@ -976,7 +982,7 @@ static Dart_Isolate CreateAndSetupKernelIsolate(const char* main,
976
982
return NULL ;
977
983
}
978
984
979
- return IsolateSetupHelper (isolate, false , script_uri, package_root,
985
+ return IsolateSetupHelper (isolate, false , false , script_uri, package_root,
980
986
packages_config, isolate_snapshot_data,
981
987
isolate_run_app_snapshot, error, exit_code);
982
988
}
@@ -1074,6 +1080,7 @@ static Dart_Isolate CreateIsolateAndSetupHelper(bool is_main_isolate,
1074
1080
void * kernel_platform = NULL ;
1075
1081
void * kernel_program = NULL ;
1076
1082
AppSnapshot* app_snapshot = NULL ;
1083
+ bool kernel_file_specified = false ;
1077
1084
1078
1085
IsolateData* isolate_data =
1079
1086
new IsolateData (script_uri, package_root, packages_config, app_snapshot);
@@ -1114,7 +1121,11 @@ static Dart_Isolate CreateIsolateAndSetupHelper(bool is_main_isolate,
1114
1121
if (!isolate_run_app_snapshot) {
1115
1122
kernel_platform = dfe.kernel_platform ();
1116
1123
kernel_program = dfe.ReadScript (script_uri);
1117
- if (kernel_program == NULL && dfe.UseDartFrontend ()) {
1124
+ if (kernel_program != NULL ) {
1125
+ // A kernel file was specified on the command line instead of a source
1126
+ // file. Load that kernel file directly.
1127
+ kernel_file_specified = true ;
1128
+ } else if (dfe.UseDartFrontend ()) {
1118
1129
kernel_program = dfe.CompileAndReadScript (script_uri, error, exit_code);
1119
1130
if (kernel_program == NULL ) {
1120
1131
return NULL ;
@@ -1142,9 +1153,10 @@ static Dart_Isolate CreateIsolateAndSetupHelper(bool is_main_isolate,
1142
1153
}
1143
1154
1144
1155
bool set_native_resolvers = (kernel_program || isolate_snapshot_data);
1145
- return IsolateSetupHelper (isolate, is_main_isolate, script_uri, package_root,
1146
- packages_config, set_native_resolvers,
1147
- isolate_run_app_snapshot, error, exit_code);
1156
+ return IsolateSetupHelper (isolate, is_main_isolate, kernel_file_specified,
1157
+ script_uri, package_root, packages_config,
1158
+ set_native_resolvers, isolate_run_app_snapshot,
1159
+ error, exit_code);
1148
1160
}
1149
1161
1150
1162
#undef CHECK_RESULT
0 commit comments