diff --git a/runtime/bin/main_impl.cc b/runtime/bin/main_impl.cc index 4a26768a1d4a..f0075f109044 100644 --- a/runtime/bin/main_impl.cc +++ b/runtime/bin/main_impl.cc @@ -1296,10 +1296,22 @@ void main(int argc, char** argv) { script_name); Platform::Exit(kErrorExitCode); } + if (app_snapshot->IsJIT() && Dart_IsPrecompiledRuntime()) { + Syslog::PrintErr( + "%s is a JIT snapshot, it cannot be run with 'dartaotruntime'\n", + script_name); + Platform::Exit(kErrorExitCode); + } vm_run_app_snapshot = true; app_snapshot->SetBuffers(&vm_snapshot_data, &vm_snapshot_instructions, &app_isolate_snapshot_data, &app_isolate_snapshot_instructions); + } else if (app_snapshot == nullptr && Dart_IsPrecompiledRuntime()) { + Syslog::PrintErr( + "%s is not an AOT snapshot," + " it cannot be run with 'dartaotruntime'\n", + script_name); + Platform::Exit(kErrorExitCode); } }; diff --git a/runtime/bin/snapshot_utils.cc b/runtime/bin/snapshot_utils.cc index 3ebe7d8ed20b..0ff14997265b 100644 --- a/runtime/bin/snapshot_utils.cc +++ b/runtime/bin/snapshot_utils.cc @@ -48,7 +48,6 @@ class DummySnapshot : public AppSnapshot { private: }; -#endif // !defined(DART_PRECOMPILED_RUNTIME) class MappedAppSnapshot : public AppSnapshot { public: @@ -143,6 +142,7 @@ static AppSnapshot* TryReadAppSnapshotBlobs(const char* script_name, nullptr, nullptr, isolate_data_mapping, isolate_instr_mapping); return app_snapshot; } +#endif // !defined(DART_PRECOMPILED_RUNTIME) #if defined(DART_PRECOMPILED_RUNTIME) class ElfAppSnapshot : public AppSnapshot { @@ -594,10 +594,6 @@ AppSnapshot* Snapshot::TryReadAppSnapshot(const char* script_uri, } DartUtils::MagicNumber magic_number = DartUtils::SniffForMagicNumber(header, sizeof(header)); - if (magic_number == DartUtils::kAppJITMagicNumber) { - // Return the JIT snapshot. - return TryReadAppSnapshotBlobs(script_name, file); - } #if defined(DART_PRECOMPILED_RUNTIME) if (!DartUtils::IsAotMagicNumber(magic_number)) { return nullptr; @@ -623,6 +619,10 @@ AppSnapshot* Snapshot::TryReadAppSnapshot(const char* script_uri, return TryReadAppSnapshotElf(script_name, /*file_offset=*/0, force_load_elf_from_memory); #else + if (magic_number == DartUtils::kAppJITMagicNumber) { + // Return the JIT snapshot. + return TryReadAppSnapshotBlobs(script_name, file); + } // We create a dummy snapshot object just to remember the type which // has already been identified by sniffing the magic number. return new DummySnapshot(magic_number);