From 546bf07f7d9072cbf3213f733b4e742937e6bc9a Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Tue, 2 Jun 2026 10:28:10 -0700 Subject: [PATCH] [vm] Remove transitions for removing VM isolate. TEST=ci Change-Id: I65c315e9efc3cd7b8b47d2c167681986278644da Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502780 Reviewed-by: Alexander Markov Commit-Queue: Ryan Macnak --- .../snapshot/macho/macho_image_writer.dart | 6 -- runtime/bin/dart_api_win.c | 14 --- runtime/bin/elf_loader.cc | 31 +++--- runtime/bin/elf_loader.h | 82 ++++++-------- runtime/bin/gen_snapshot.cc | 101 +++--------------- runtime/bin/macho_loader.cc | 6 +- runtime/bin/macho_loader.h | 36 +++---- runtime/bin/snapshot_utils.cc | 24 ++--- runtime/include/dart_api.h | 32 +----- runtime/tests/vm/dart/ama_test.dart | 4 +- .../tests/vm/dart/exported_symbols_test.dart | 11 +- runtime/vm/dart_api_impl.cc | 30 ------ runtime/vm/elf.cc | 18 ---- runtime/vm/image_snapshot.cc | 17 --- runtime/vm/mach_o.cc | 17 --- 15 files changed, 98 insertions(+), 331 deletions(-) diff --git a/pkg/native_compiler/lib/snapshot/macho/macho_image_writer.dart b/pkg/native_compiler/lib/snapshot/macho/macho_image_writer.dart index 7bd6072d59b..95d32e40663 100644 --- a/pkg/native_compiler/lib/snapshot/macho/macho_image_writer.dart +++ b/pkg/native_compiler/lib/snapshot/macho/macho_image_writer.dart @@ -164,12 +164,6 @@ final class MachoImageWriter extends ImageWriter { header = Header(this); symbolTable.addSymbol(snapshotTextAsmSymbol, textSection, 0); symbolTable.addSymbol(snapshotDataAsmSymbol, constSection, 0); - - // TRANSITION - symbolTable.addSymbol("_kDartVmSnapshotInstructions", textSection, 0); - symbolTable.addSymbol("_kDartIsolateSnapshotInstructions", textSection, 0); - symbolTable.addSymbol("_kDartVmSnapshotData", constSection, 0); - symbolTable.addSymbol("_kDartIsolateSnapshotData", constSection, 0); } @override diff --git a/runtime/bin/dart_api_win.c b/runtime/bin/dart_api_win.c index 65b464c6ec6..c31ae50174f 100644 --- a/runtime/bin/dart_api_win.c +++ b/runtime/bin/dart_api_win.c @@ -455,9 +455,6 @@ typedef Dart_Handle (*Dart_CreateAppAOTSnapshotAndRelocatableObjectType)( void*, const char*, const char*); -typedef Dart_Handle (*Dart_CreateVMAOTSnapshotAsAssemblyType)( - Dart_StreamingWriteCallback, - void*); typedef Dart_Handle (*Dart_WriteCallbackStubType)(Dart_StreamingWriteCallback, void*); typedef Dart_Handle (*Dart_SortClassesType)(); @@ -771,8 +768,6 @@ static Dart_CreateAppAOTSnapshotAsBinaryType Dart_CreateAppAOTSnapshotAsBinaryFn = NULL; static Dart_CreateAppAOTSnapshotAndRelocatableObjectType Dart_CreateAppAOTSnapshotAndRelocatableObjectFn = NULL; -static Dart_CreateVMAOTSnapshotAsAssemblyType - Dart_CreateVMAOTSnapshotAsAssemblyFn = NULL; static Dart_WriteCallbackStubType Dart_WriteCallbackStubFn = NULL; static Dart_SortClassesType Dart_SortClassesFn = NULL; static Dart_CreateAppJITSnapshotAsBlobsType Dart_CreateAppJITSnapshotAsBlobsFn = @@ -1367,9 +1362,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { Dart_CreateAppAOTSnapshotAndRelocatableObjectFn = (Dart_CreateAppAOTSnapshotAndRelocatableObjectType)GetProcAddress( process, "Dart_CreateAppAOTSnapshotAndRelocatableObject"); - Dart_CreateVMAOTSnapshotAsAssemblyFn = - (Dart_CreateVMAOTSnapshotAsAssemblyType)GetProcAddress( - process, "Dart_CreateVMAOTSnapshotAsAssembly"); Dart_WriteCallbackStubFn = (Dart_WriteCallbackStubType)GetProcAddress( process, "Dart_WriteCallbackStub"); Dart_SortClassesFn = @@ -2693,12 +2685,6 @@ Dart_Handle Dart_CreateAppAOTSnapshotAndRelocatableObject( debug_callback_data, identifier, path); } -Dart_Handle Dart_CreateVMAOTSnapshotAsAssembly( - Dart_StreamingWriteCallback callback, - void* callback_data) { - return Dart_CreateVMAOTSnapshotAsAssemblyFn(callback, callback_data); -} - Dart_Handle Dart_WriteCallbackStub(Dart_StreamingWriteCallback callback, void* callback_data) { return Dart_WriteCallbackStubFn(callback, callback_data); diff --git a/runtime/bin/elf_loader.cc b/runtime/bin/elf_loader.cc index e285e93b37b..4dfb9055b9b 100644 --- a/runtime/bin/elf_loader.cc +++ b/runtime/bin/elf_loader.cc @@ -416,11 +416,11 @@ using namespace dart::bin::elf; // NOLINT using Mappable = dart::bin::Mappable; #if defined(DART_HOST_OS_FUCHSIA) || defined(DART_HOST_OS_LINUX) -DART_EXPORT Dart_LoadedElf* Dart_LoadELF_Fd2(int fd, - uint64_t file_offset, - const char** error, - const uint8_t** snapshot_data, - const uint8_t** snapshot_text) { +DART_EXPORT Dart_LoadedElf* Dart_LoadELF_Fd(int fd, + uint64_t file_offset, + const char** error, + const uint8_t** snapshot_data, + const uint8_t** snapshot_text) { std::unique_ptr mappable(Mappable::FromFD(fd)); std::unique_ptr elf( new LoadedElf(std::move(mappable), file_offset)); @@ -434,11 +434,11 @@ DART_EXPORT Dart_LoadedElf* Dart_LoadELF_Fd2(int fd, } #endif -DART_EXPORT Dart_LoadedElf* Dart_LoadELF2(const char* filename, - uint64_t file_offset, - const char** error, - const uint8_t** snapshot_data, - const uint8_t** snapshot_text) { +DART_EXPORT Dart_LoadedElf* Dart_LoadELF(const char* filename, + uint64_t file_offset, + const char** error, + const uint8_t** snapshot_data, + const uint8_t** snapshot_text) { std::unique_ptr mappable(Mappable::FromPath(filename)); if (mappable == nullptr) { *error = "Couldn't open file."; @@ -455,12 +455,11 @@ DART_EXPORT Dart_LoadedElf* Dart_LoadELF2(const char* filename, return reinterpret_cast(elf.release()); } -DART_EXPORT Dart_LoadedElf* Dart_LoadELF_Memory2( - const uint8_t* snapshot, - uint64_t snapshot_size, - const char** error, - const uint8_t** snapshot_data, - const uint8_t** snapshot_text) { +DART_EXPORT Dart_LoadedElf* Dart_LoadELF_Memory(const uint8_t* snapshot, + uint64_t snapshot_size, + const char** error, + const uint8_t** snapshot_data, + const uint8_t** snapshot_text) { std::unique_ptr mappable( Mappable::FromMemory(snapshot, snapshot_size)); if (mappable == nullptr) { diff --git a/runtime/bin/elf_loader.h b/runtime/bin/elf_loader.h index ae1031c1302..3e6ff50c61b 100644 --- a/runtime/bin/elf_loader.h +++ b/runtime/bin/elf_loader.h @@ -26,60 +26,48 @@ typedef struct { /// does not take ownership of the memory, but borrows it for the duration of /// the call. The memory can be release as soon as Dart_LoadELF_Memory returns. #if defined(__Fuchsia__) || defined(__linux__) || defined(__FreeBSD__) -DART_EXPORT Dart_LoadedElf* Dart_LoadELF_Fd2(int fd, - uint64_t file_offset, - const char** error, - const uint8_t** snapshot_data, - const uint8_t** snapshot_text); -inline Dart_LoadedElf* Dart_LoadELF_Fd(int fd, - uint64_t file_offset, - const char** error, - const uint8_t** vm_data, - const uint8_t** vm_text, - const uint8_t** snapshot_data, - const uint8_t** snapshot_text) { - *vm_data = nullptr; - *vm_text = nullptr; - return Dart_LoadELF_Fd2(fd, file_offset, error, snapshot_data, snapshot_text); +DART_EXPORT Dart_LoadedElf* Dart_LoadELF_Fd(int fd, + uint64_t file_offset, + const char** error, + const uint8_t** snapshot_data, + const uint8_t** snapshot_text); +inline Dart_LoadedElf* Dart_LoadELF_Fd2(int fd, + uint64_t file_offset, + const char** error, + const uint8_t** snapshot_data, + const uint8_t** snapshot_text) { + return Dart_LoadELF_Fd(fd, file_offset, error, snapshot_data, snapshot_text); } #endif /// Please see documentation for Dart_LoadElf_Fd. -DART_EXPORT Dart_LoadedElf* Dart_LoadELF2(const char* filename, - uint64_t file_offset, - const char** error, - const uint8_t** snapshot_data, - const uint8_t** snapshot_text); -inline Dart_LoadedElf* Dart_LoadELF(const char* filename, - uint64_t file_offset, - const char** error, - const uint8_t** vm_data, - const uint8_t** vm_text, - const uint8_t** snapshot_data, - const uint8_t** snapshot_text) { - *vm_data = nullptr; - *vm_text = nullptr; - return Dart_LoadELF2(filename, file_offset, error, snapshot_data, - snapshot_text); +DART_EXPORT Dart_LoadedElf* Dart_LoadELF(const char* filename, + uint64_t file_offset, + const char** error, + const uint8_t** snapshot_data, + const uint8_t** snapshot_text); +inline Dart_LoadedElf* Dart_LoadELF2(const char* filename, + uint64_t file_offset, + const char** error, + const uint8_t** snapshot_data, + const uint8_t** snapshot_text) { + return Dart_LoadELF(filename, file_offset, error, snapshot_data, + snapshot_text); } /// Please see documentation for Dart_LoadElf_Fd. -DART_EXPORT Dart_LoadedElf* Dart_LoadELF_Memory2(const uint8_t* snapshot, - uint64_t snapshot_size, - const char** error, - const uint8_t** snapshot_data, - const uint8_t** snapshot_text); -inline Dart_LoadedElf* Dart_LoadELF_Memory(const uint8_t* snapshot, - uint64_t snapshot_size, - const char** error, - const uint8_t** vm_data, - const uint8_t** vm_text, - const uint8_t** snapshot_data, - const uint8_t** snapshot_text) { - *vm_data = nullptr; - *vm_text = nullptr; - return Dart_LoadELF_Memory2(snapshot, snapshot_size, error, snapshot_data, - snapshot_text); +DART_EXPORT Dart_LoadedElf* Dart_LoadELF_Memory(const uint8_t* snapshot, + uint64_t snapshot_size, + const char** error, + const uint8_t** snapshot_data, + const uint8_t** snapshot_text); +inline Dart_LoadedElf* Dart_LoadELF_Memory2(const uint8_t* snapshot, + uint64_t snapshot_size, + const char** error, + const uint8_t** snapshot_data, + const uint8_t** snapshot_text) { + return Dart_LoadELF_Memory(snapshot, snapshot_size, error, snapshot_data, + snapshot_text); } /// Unloads an ELF object loaded through Dart_LoadELF{_Fd, _Memory}. diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc index 1885ef08c68..ff72e9b8f39 100644 --- a/runtime/bin/gen_snapshot.cc +++ b/runtime/bin/gen_snapshot.cc @@ -79,7 +79,6 @@ enum SnapshotKind { kAppAOTAssembly, kAppAOTElf, kAppAOTMachODylib, - kVMAOTAssembly, kFfiCallbackStub, }; static SnapshotKind snapshot_kind = kCore; @@ -93,7 +92,6 @@ static const char* const kSnapshotKindNames[] = { "app-aot-assembly", "app-aot-elf", "app-aot-macho-dylib", - "vm-aot-assembly", "ffi-callback-stub", nullptr, // clang-format on @@ -105,10 +103,6 @@ static const char* const kSnapshotKindNames[] = { V(load_isolate_snapshot_data, load_isolate_snapshot_data_filename) \ V(load_isolate_snapshot_instructions, \ load_isolate_snapshot_instructions_filename) \ - V(vm_snapshot_data, vm_snapshot_data_filename) \ - V(vm_snapshot_instructions, vm_snapshot_instructions_filename) \ - V(isolate_snapshot_data, isolate_snapshot_data_filename) \ - V(isolate_snapshot_instructions, isolate_snapshot_instructions_filename) \ V(snapshot_data, snapshot_data_filename) \ V(snapshot_text, snapshot_text_filename) \ V(assembly, assembly_filename) \ @@ -146,7 +140,6 @@ DEFINE_CB_OPTION(ProcessEnvironmentOption); static bool IsSnapshottingForPrecompilation() { return (snapshot_kind == kAppAOTAssembly) || (snapshot_kind == kAppAOTElf) || (snapshot_kind == kAppAOTMachODylib) || - (snapshot_kind == kVMAOTAssembly) || (snapshot_kind == kFfiCallbackStub); } @@ -254,8 +247,8 @@ static int ParseArguments(int argc, switch (snapshot_kind) { case kCore: { - if ((snapshot_data_filename == nullptr) && - (isolate_snapshot_data_filename == nullptr)) { + if ((snapshot_data_filename == nullptr) || + (snapshot_text_filename == nullptr)) { Syslog::PrintErr( "Building a core snapshot requires specifying output files for " "--snapshot_data and --snapshot_text.\n\n"); @@ -265,10 +258,8 @@ static int ParseArguments(int argc, } case kApp: case kAppJIT: { - if (((snapshot_data_filename == nullptr) && - (isolate_snapshot_data_filename == nullptr)) || - ((snapshot_text_filename == nullptr) && - (isolate_snapshot_instructions_filename == nullptr))) { + if ((snapshot_data_filename == nullptr) || + (snapshot_text_filename == nullptr)) { Syslog::PrintErr( "Building an app JIT snapshot requires specifying input files for " "--load_vm_snapshot_data and --load_vm_snapshot_instructions, an " @@ -296,8 +287,7 @@ static int ParseArguments(int argc, } break; } - case kAppAOTAssembly: - case kVMAOTAssembly: { + case kAppAOTAssembly: { if (assembly_filename == nullptr) { Syslog::PrintErr( "Building an AOT snapshot as assembly requires specifying " @@ -426,11 +416,8 @@ static void MaybeLoadCode() { static void CreateAndWriteCoreSnapshot() { ASSERT(snapshot_kind == kCore); -#if 0 - // TRANSITION ASSERT(snapshot_data_filename != nullptr); ASSERT(snapshot_text_filename != nullptr); -#endif Dart_Handle result; uint8_t* snapshot_data_buffer = nullptr; @@ -439,33 +426,9 @@ static void CreateAndWriteCoreSnapshot() { result = Dart_CreateSnapshot(&snapshot_data_buffer, &snapshot_data_size); CHECK_RESULT(result); - if (snapshot_data_filename != nullptr) { - WriteFile(snapshot_data_filename, snapshot_data_buffer, snapshot_data_size); - } - if (snapshot_text_filename != nullptr) { - // Create empty file for the convenience of build systems. - WriteFile(snapshot_text_filename, nullptr, 0); - } - -#if 1 - // TRANSITION - if (vm_snapshot_data_filename != nullptr) { - // Create empty file for the convenience of build systems. - WriteFile(vm_snapshot_data_filename, nullptr, 0); - } - if (vm_snapshot_instructions_filename != nullptr) { - // Create empty file for the convenience of build systems. - WriteFile(vm_snapshot_instructions_filename, nullptr, 0); - } - if (isolate_snapshot_data_filename != nullptr) { - WriteFile(isolate_snapshot_data_filename, snapshot_data_buffer, - snapshot_data_size); - } - if (isolate_snapshot_instructions_filename != nullptr) { - // Create empty file for the convenience of build systems. - WriteFile(isolate_snapshot_instructions_filename, nullptr, 0); - } -#endif + WriteFile(snapshot_data_filename, snapshot_data_buffer, snapshot_data_size); + // Create empty file for the convenience of build systems. + WriteFile(snapshot_text_filename, nullptr, 0); } static std::unique_ptr MapFile(const char* filename, @@ -503,33 +466,18 @@ static void CreateAndWriteAppSnapshot() { result = Dart_CreateSnapshot(&snapshot_data_buffer, &snapshot_data_size); CHECK_RESULT(result); - if (snapshot_data_filename != nullptr) { - WriteFile(snapshot_data_filename, snapshot_data_buffer, snapshot_data_size); - } + WriteFile(snapshot_data_filename, snapshot_data_buffer, snapshot_data_size); if (snapshot_text_filename != nullptr) { // Create empty file for the convenience of build systems. WriteFile(snapshot_text_filename, nullptr, 0); } -#if 1 - // TRANSITION - if (isolate_snapshot_data_filename != nullptr) { - WriteFile(isolate_snapshot_data_filename, snapshot_data_buffer, - snapshot_data_size); - } - if (isolate_snapshot_instructions_filename != nullptr) { - // Create empty file for the convenience of build systems. - WriteFile(isolate_snapshot_instructions_filename, nullptr, 0); - } -#endif } static void CreateAndWriteAppJITSnapshot() { ASSERT(snapshot_kind == kAppJIT); -#if 0 - // TRANSITION ASSERT(snapshot_data_filename != nullptr); ASSERT(snapshot_text_filename != nullptr); -#endif + Dart_Handle result; uint8_t* snapshot_data_buffer = nullptr; intptr_t snapshot_data_size = 0; @@ -541,24 +489,8 @@ static void CreateAndWriteAppJITSnapshot() { &snapshot_text_size); CHECK_RESULT(result); - if (snapshot_data_filename != nullptr) { - WriteFile(snapshot_data_filename, snapshot_data_buffer, snapshot_data_size); - } - if (snapshot_text_filename != nullptr) { - WriteFile(snapshot_text_filename, snapshot_text_buffer, snapshot_text_size); - } - -#if 1 - // TRANSITION - if (isolate_snapshot_data_filename != nullptr) { - WriteFile(isolate_snapshot_data_filename, snapshot_data_buffer, - snapshot_data_size); - } - if (isolate_snapshot_instructions_filename != nullptr) { - WriteFile(isolate_snapshot_instructions_filename, snapshot_text_buffer, - snapshot_text_size); - } -#endif + WriteFile(snapshot_data_filename, snapshot_data_buffer, snapshot_data_size); + WriteFile(snapshot_text_filename, snapshot_text_buffer, snapshot_text_size); } static void StreamingWriteCallback(void* callback_data, @@ -678,14 +610,6 @@ static void NextElfCallback(void* callback_data, static void CreateAndWritePrecompiledSnapshot() { ASSERT(IsSnapshottingForPrecompilation()); - if (snapshot_kind == kVMAOTAssembly) { - File* file = OpenFile(assembly_filename); - RefCntReleaseScope rs(file); - Dart_Handle result = - Dart_CreateVMAOTSnapshotAsAssembly(StreamingWriteCallback, file); - CHECK_RESULT(result); - return; - } if (snapshot_kind == kFfiCallbackStub) { File* file = OpenFile(ffi_callback_stub_filename); RefCntReleaseScope rs(file); @@ -892,7 +816,6 @@ static int CreateIsolateAndSnapshot(const CommandLineOptions& inputs) { case kAppAOTAssembly: case kAppAOTElf: case kAppAOTMachODylib: - case kVMAOTAssembly: case kFfiCallbackStub: CreateAndWritePrecompiledSnapshot(); break; diff --git a/runtime/bin/macho_loader.cc b/runtime/bin/macho_loader.cc index a0baae9a125..700b86dc18f 100644 --- a/runtime/bin/macho_loader.cc +++ b/runtime/bin/macho_loader.cc @@ -528,7 +528,7 @@ using namespace dart::bin::mach_o; // NOLINT using Mappable = dart::bin::Mappable; #if defined(DART_HOST_OS_FUCHSIA) || defined(DART_HOST_OS_LINUX) -DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Fd2( +DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Fd( int fd, uint64_t file_offset, const char** error, @@ -547,7 +547,7 @@ DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Fd2( } #endif -DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib2( +DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib( const char* filename, uint64_t file_offset, const char** error, @@ -569,7 +569,7 @@ DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib2( return reinterpret_cast(macho.release()); } -DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Memory2( +DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Memory( const uint8_t* snapshot, uint64_t snapshot_size, const char** error, diff --git a/runtime/bin/macho_loader.h b/runtime/bin/macho_loader.h index cbf9e75e8e7..522539d8ba7 100644 --- a/runtime/bin/macho_loader.h +++ b/runtime/bin/macho_loader.h @@ -28,67 +28,55 @@ typedef struct { /// borrows it for the duration of the call. The memory can be release as soon // as Dart_LoadAOTSnapshot_Memory returns. #if defined(__Fuchsia__) || defined(__linux__) || defined(__FreeBSD__) -DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Fd2( +DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Fd( int fd, uint64_t file_offset, const char** error, const uint8_t** snapshot_data, const uint8_t** snapshot_text); -inline Dart_LoadedMachODylib* Dart_LoadMachODylib_Fd( +inline Dart_LoadedMachODylib* Dart_LoadMachODylib_Fd2( int fd, uint64_t file_offset, const char** error, - const uint8_t** vm_data, - const uint8_t** vm_text, const uint8_t** snapshot_data, const uint8_t** snapshot_text) { - *vm_data = nullptr; - *vm_text = nullptr; - return Dart_LoadMachODylib_Fd2(fd, file_offset, error, snapshot_data, - snapshot_text); + return Dart_LoadMachODylib_Fd(fd, file_offset, error, snapshot_data, + snapshot_text); } #endif /// Please see documentation for Dart_LoadMachODylib_Fd. -DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib2( +DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib( const char* filename, uint64_t file_offset, const char** error, const uint8_t** snapshot_data, const uint8_t** snapshot_text); -inline Dart_LoadedMachODylib* Dart_LoadMachODylib( +inline Dart_LoadedMachODylib* Dart_LoadMachODylib2( const char* filename, uint64_t file_offset, const char** error, - const uint8_t** vm_data, - const uint8_t** vm_text, const uint8_t** snapshot_data, const uint8_t** snapshot_text) { - *vm_data = nullptr; - *vm_text = nullptr; - return Dart_LoadMachODylib2(filename, file_offset, error, snapshot_data, - snapshot_text); + return Dart_LoadMachODylib(filename, file_offset, error, snapshot_data, + snapshot_text); } /// Please see documentation for Dart_LoadMachODylib_Fd. -DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Memory2( +DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Memory( const uint8_t* snapshot, uint64_t snapshot_size, const char** error, const uint8_t** snapshot_data, const uint8_t** snapshot_text); -inline Dart_LoadedMachODylib* Dart_LoadMachODylib_Memory( +inline Dart_LoadedMachODylib* Dart_LoadMachODylib_Memory2( const uint8_t* snapshot, uint64_t snapshot_size, const char** error, - const uint8_t** vm_data, - const uint8_t** vm_text, const uint8_t** snapshot_data, const uint8_t** snapshot_text) { - *vm_data = nullptr; - *vm_text = nullptr; - return Dart_LoadMachODylib_Memory2(snapshot, snapshot_size, error, - snapshot_data, snapshot_text); + return Dart_LoadMachODylib_Memory(snapshot, snapshot_size, error, + snapshot_data, snapshot_text); } /// Unloads an MachO dynamic library object loaded through diff --git a/runtime/bin/snapshot_utils.cc b/runtime/bin/snapshot_utils.cc index 7d983c6b013..b3e16a328ef 100644 --- a/runtime/bin/snapshot_utils.cc +++ b/runtime/bin/snapshot_utils.cc @@ -291,13 +291,13 @@ static AppSnapshot* TryReadAppSnapshotElf(const char* script_name, if (memory == nullptr) return nullptr; const uint8_t* address = reinterpret_cast(memory->address()); - handle = Dart_LoadELF_Memory2(address + file_offset, file->Length(), &error, - &snapshot_data_buffer, &snapshot_text_buffer); + handle = Dart_LoadELF_Memory(address + file_offset, file->Length(), &error, + &snapshot_data_buffer, &snapshot_text_buffer); delete memory; file->Release(); } else { - handle = Dart_LoadELF2(script_name, file_offset, &error, - &snapshot_data_buffer, &snapshot_text_buffer); + handle = Dart_LoadELF(script_name, file_offset, &error, + &snapshot_data_buffer, &snapshot_text_buffer); } if (handle == nullptr) { Syslog::PrintErr("Loading failed: %s\n", error); @@ -365,14 +365,14 @@ static AppSnapshot* TryReadAppSnapshotMachODylib( } const uint8_t* address = reinterpret_cast(memory->address()); - handle = Dart_LoadMachODylib_Memory2(address + file_offset, file->Length(), - &error, &snapshot_data_buffer, - &snapshot_text_buffer); + handle = Dart_LoadMachODylib_Memory(address + file_offset, file->Length(), + &error, &snapshot_data_buffer, + &snapshot_text_buffer); delete memory; file->Release(); } else { - handle = Dart_LoadMachODylib2(script_name, file_offset, &error, - &snapshot_data_buffer, &snapshot_text_buffer); + handle = Dart_LoadMachODylib(script_name, file_offset, &error, + &snapshot_data_buffer, &snapshot_text_buffer); } if (handle == nullptr) { Syslog::PrintErr("Loading failed: %s\n", error); @@ -542,8 +542,8 @@ AppSnapshot* Snapshot::TryReadAppendedAppSnapshotFromPE( if (magic_number == DartUtils::kAotELFMagicNumber) { Dart_LoadedElf* const handle = - Dart_LoadELF_Memory2(snapshot.get(), size, &error, - &snapshot_data_buffer, &snapshot_text_buffer); + Dart_LoadELF_Memory(snapshot.get(), size, &error, + &snapshot_data_buffer, &snapshot_text_buffer); if (handle == nullptr) { Syslog::PrintErr("Loading failed: %s\n", error); @@ -556,7 +556,7 @@ AppSnapshot* Snapshot::TryReadAppendedAppSnapshotFromPE( if (magic_number == DartUtils::kAotMachO32MagicNumber || magic_number == DartUtils::kAotMachO64MagicNumber) { - Dart_LoadedMachODylib* const handle = Dart_LoadMachODylib_Memory2( + Dart_LoadedMachODylib* const handle = Dart_LoadMachODylib_Memory( snapshot.get(), size, &error, &snapshot_data_buffer, &snapshot_text_buffer); diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h index 826bd4bfb4c..73a18b45a71 100644 --- a/runtime/include/dart_api.h +++ b/runtime/include/dart_api.h @@ -838,7 +838,7 @@ typedef Dart_Handle (*Dart_GetVMServiceAssetsArchive)(void); * The current version of the Dart_InitializeFlags. Should be incremented every * time Dart_InitializeFlags changes in a binary incompatible way. */ -#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x0000000A) +#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x0000000B) /** Forward declaration */ struct Dart_CodeObserver; @@ -874,10 +874,6 @@ typedef struct { */ int32_t version; - /* TRANSITION */ - const uint8_t* vm_snapshot_data; - const uint8_t* vm_snapshot_instructions; - /** * A function to be called during isolate group creation. * See Dart_IsolateGroupCreateCallback. @@ -4018,23 +4014,6 @@ DART_EXPORT Dart_Handle Dart_LoadingUnitLibraryUris(intptr_t loading_unit_id); #define kSnapshotTextAsmSymbol "_kDartSnapshotText" #define kSnapshotBssAsmSymbol "_kDartSnapshotBss" -/* TRANSITION */ -#if defined(__APPLE__) -#define kVmSnapshotDataCSymbol "kDartVmSnapshotData" -#define kVmSnapshotInstructionsCSymbol "kDartVmSnapshotInstructions" -#define kVmSnapshotBssCSymbol "kDartVmSnapshotBss" -#define kIsolateSnapshotDataCSymbol "kDartIsolateSnapshotData" -#define kIsolateSnapshotInstructionsCSymbol "kDartIsolateSnapshotInstructions" -#define kIsolateSnapshotBssCSymbol "kDartIsolateSnapshotBss" -#else -#define kVmSnapshotDataCSymbol "_kDartVmSnapshotData" -#define kVmSnapshotInstructionsCSymbol "_kDartVmSnapshotInstructions" -#define kVmSnapshotBssCSymbol "_kDartVmSnapshotBss" -#define kIsolateSnapshotDataCSymbol "_kDartIsolateSnapshotData" -#define kIsolateSnapshotInstructionsCSymbol "_kDartIsolateSnapshotInstructions" -#define kIsolateSnapshotBssCSymbol "_kDartIsolateSnapshotBss" -#endif - /** * Creates a precompiled snapshot. * - A root library must have been loaded. @@ -4207,15 +4186,10 @@ Dart_CreateAppAOTSnapshotAndRelocatableObject( const char* path); /** - * Like Dart_CreateAppAOTSnapshotAsAssembly, but only includes - * kDartVmSnapshotData and kDartVmSnapshotInstructions. It also does - * not strip DWARF information from the generated assembly or allow for - * separate debug information. + * Creates a blob needed only on Fuchsia to work around platform deficiencies. + * The embedder must place it at pkg/lib/ffi_callback_stub.bin. */ DART_EXPORT DART_API_WARN_UNUSED_RESULT Dart_Handle -Dart_CreateVMAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, - void* callback_data); -DART_EXPORT DART_API_WARN_UNUSED_RESULT Dart_Handle Dart_WriteCallbackStub(Dart_StreamingWriteCallback callback, void* callback_data); diff --git a/runtime/tests/vm/dart/ama_test.dart b/runtime/tests/vm/dart/ama_test.dart index 7f3c51bd10b..b3d59649997 100644 --- a/runtime/tests/vm/dart/ama_test.dart +++ b/runtime/tests/vm/dart/ama_test.dart @@ -38,9 +38,7 @@ main(List args) async { await withElfSnapshot((Elf elf) { // NOTE: These tests validate properties we should strive to maintain. // Please reach out to go/dart-ama before changing them. - final Symbol? symbol = elf.dynamicSymbolFor( - '_kDartIsolateSnapshotInstructions', - ); + final Symbol? symbol = elf.dynamicSymbolFor('_kDartSnapshotText'); Expect.isTrue(symbol != null && symbol.value > 0); }); } diff --git a/runtime/tests/vm/dart/exported_symbols_test.dart b/runtime/tests/vm/dart/exported_symbols_test.dart index 1c6baef54ec..f820fbedcff 100644 --- a/runtime/tests/vm/dart/exported_symbols_test.dart +++ b/runtime/tests/vm/dart/exported_symbols_test.dart @@ -82,7 +82,6 @@ main() { "Dart_CreateIsolateGroupFromKernel", "Dart_CreateIsolateInGroup", "Dart_CreateSnapshot", - "Dart_CreateVMAOTSnapshotAsAssembly", "Dart_CurrentIsolate", "Dart_CurrentIsolateData", "Dart_CurrentIsolateGroup", @@ -370,13 +369,13 @@ main() { "Dart_WriteHeapSnapshot", "Dart_WriteProfileToTimeline", if (isAOTRuntime) ...[ - "Dart_LoadELF2", - "Dart_LoadELF_Memory2", - "Dart_LoadMachODylib2", - "Dart_LoadMachODylib_Memory2", + "Dart_LoadELF", + "Dart_LoadELF_Memory", + "Dart_LoadMachODylib", + "Dart_LoadMachODylib_Memory", "Dart_UnloadELF", "Dart_UnloadMachODylib", - if (!Platform.isMacOS) ...["Dart_LoadELF_Fd2", "Dart_LoadMachODylib_Fd2"], + if (!Platform.isMacOS) ...["Dart_LoadELF_Fd", "Dart_LoadMachODylib_Fd"], ], ]; diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 7414d544730..19264959778 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -6884,36 +6884,6 @@ DART_EXPORT Dart_Handle Dart_CreateAppAOTSnapshotAsAssemblies( #endif } -DART_EXPORT Dart_Handle -Dart_CreateVMAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, - void* callback_data) { -#if defined(TARGET_ARCH_IA32) - return Api::NewError("AOT compilation is not supported on IA32."); -#elif !defined(DART_PRECOMPILER) - return Api::NewError( - "This VM was built without support for AOT compilation."); -#else - const char assembly[] = - ".text\n" - ".globl _kDartVmSnapshotInstructions\n" - ".balign 64, 0\n" - "_kDartVmSnapshotInstructions:\n" - ".quad 0\n" - ".size _kDartVmSnapshotInstructions, .-_kDartVmSnapshotInstructions\n" - ".type _kDartVmSnapshotInstructions, %object\n" - ".section .rodata\n" - ".globl _kDartVmSnapshotData\n" - ".balign 64, 0\n" - "_kDartVmSnapshotData:\n" - ".quad 0\n" - ".size _kDartVmSnapshotData, .-_kDartVmSnapshotData\n" - ".type _kDartVmSnapshotData, %object\n"; - callback(callback_data, reinterpret_cast(assembly), - sizeof(assembly)); - return Api::Success(); -#endif -} - DART_EXPORT Dart_Handle Dart_WriteCallbackStub(Dart_StreamingWriteCallback callback, void* callback_data) { diff --git a/runtime/vm/elf.cc b/runtime/vm/elf.cc index dba54403741..ab3aeccdd28 100644 --- a/runtime/vm/elf.cc +++ b/runtime/vm/elf.cc @@ -1220,24 +1220,6 @@ void ElfSymbolTable::Initialize(const GrowableArray& sections) { // dynamic symbols there also. (see dartbug.com/41783). AddSymbol(portion.symbol_name, binding, type, portion.size, section->index, portion.offset, portion.label); - -#if 1 - // TRANSITION - if (strcmp(portion.symbol_name, "_kDartSnapshotText") == 0) { - AddSymbol("_kDartVmSnapshotInstructions", binding, type, - portion.size, section->index, portion.offset, - portion.label); - AddSymbol("_kDartIsolateSnapshotInstructions", binding, type, - portion.size, section->index, portion.offset, - portion.label); - } - if (strcmp(portion.symbol_name, "_kDartSnapshotData") == 0) { - AddSymbol("_kDartVmSnapshotData", binding, type, portion.size, - section->index, portion.offset, portion.label); - AddSymbol("_kDartIsolateSnapshotData", binding, type, portion.size, - section->index, portion.offset, portion.label); - } -#endif } if (!dynamic_ && portion.symbols != nullptr) { for (const auto& symbol_data : *portion.symbols) { diff --git a/runtime/vm/image_snapshot.cc b/runtime/vm/image_snapshot.cc index b5c9586edb6..1a29c7a1988 100644 --- a/runtime/vm/image_snapshot.cc +++ b/runtime/vm/image_snapshot.cc @@ -1650,23 +1650,6 @@ void AssemblyImageWriter::ExitSection(ProgramSection name, UNIMPLEMENTED(); #endif -#if 1 - // TRANSITION - if (name == ProgramSection::Text) { - assembly_stream_->Printf( - ".globl _kDartVmSnapshotInstructions\n" - "_kDartVmSnapshotInstructions = _kDartSnapshotText\n" - ".globl _kDartIsolateSnapshotInstructions\n" - "_kDartIsolateSnapshotInstructions = _kDartSnapshotText\n"); - } else if (name == ProgramSection::Data) { - assembly_stream_->Printf( - ".globl _kDartVmSnapshotData\n" - "_kDartVmSnapshotData = _kDartSnapshotData\n" - ".globl _kDartIsolateSnapshotData\n" - "_kDartIsolateSnapshotData = _kDartSnapshotData\n"); - } -#endif - // We need to generate a text segment of the appropriate size in the shared // object writer for two reasons: // diff --git a/runtime/vm/mach_o.cc b/runtime/vm/mach_o.cc index e698164b1df..e821d1aa842 100644 --- a/runtime/vm/mach_o.cc +++ b/runtime/vm/mach_o.cc @@ -3651,23 +3651,6 @@ void MachOSymbolTable::Initialize(SharedObjectWriter::Type type, if (portion.symbol_name != nullptr) { AddSymbol(portion.symbol_name, mach_o::N_SECT | mach_o::N_EXT, section, desc, portion.offset, portion.label); -#if 1 - // TRANSITION - if (strcmp(portion.symbol_name, "_kDartSnapshotText") == 0) { - AddSymbol("_kDartVmSnapshotInstructions", - mach_o::N_SECT | mach_o::N_EXT, section, desc, - portion.offset, portion.label); - AddSymbol("_kDartIsolateSnapshotInstructions", - mach_o::N_SECT | mach_o::N_EXT, section, desc, - portion.offset, portion.label); - } - if (strcmp(portion.symbol_name, "_kDartSnapshotData") == 0) { - AddSymbol("_kDartVmSnapshotData", mach_o::N_SECT | mach_o::N_EXT, - section, desc, portion.offset, portion.label); - AddSymbol("_kDartIsolateSnapshotData", mach_o::N_SECT | mach_o::N_EXT, - section, desc, portion.offset, portion.label); - } -#endif } } }