d36adbacaf
The former contents of the VM isolate are now included into each isolate group. This makes each isolate group's heap independent, and in particular allows each heap to be allocated to a separate pointer cage (not done in this CL). The duplicated stubs that allowed PC relative calls are removed, since the originals can now be the target of PC relative calls. The bootstrapping needing to load an AppJIT or AppAOT snapshot is reduced to allocating the oddballs. The code is entirely dropped in the AOT runtime, but the JIT runtime still has it to allow for flags to affect the compilation of the stub code. Further refactoring might be able to remove this for the JIT runtime too, with only gen_snapshot knowing how to bootstrap. Class serialization no longer distinguishes predefined classes. The page containing null is marked as never-evacuate. null, false and true must not move because the compiler relies on their low bits having certain patterns for some optimizations. (Previously, the entire VM isolate heap never moved.) Compaction is disabled for IA32. Due to register pressure, some stub calls must not use a scratch register and embed the address of Code. The page containing the call-through-safepoint stub is frozen when running with --write-protect-code and the stub is created at runtime (instead of loaded from an AppJIT or AppAOT snapshot). This stub must remain executable even during a safepoint, as a foreign call might during return during a safepoint and only block after the stub directs it to the runtime. The snapshot symbols are renamed to kDartSnapshotData and kDartSnapshotText. There is no need to distinguish the VM isolate's snapshot, and snaphots are per isolate group not per isolate. Aliases with the old names are added to ease migration. Some global flags that were automatically set based on the VM isolate's snapshot are now isolate group flags and automatically set by the isolate group's snapshot. TEST=ci Change-Id: Iee82016057d609112e9b021d178fc3d4d18b5044 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500621 Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Tess Strickland <sstrickl@google.com> SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
104 lines
3.6 KiB
C
104 lines
3.6 KiB
C
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef RUNTIME_BIN_MACHO_LOADER_H_
|
|
#define RUNTIME_BIN_MACHO_LOADER_H_
|
|
|
|
#include "../include/dart_api.h"
|
|
|
|
typedef struct {
|
|
} Dart_LoadedMachODylib;
|
|
|
|
/// Load an Mach-O dynamic library object from a file.
|
|
///
|
|
/// On success, return a handle to the library which may be used to close it
|
|
/// in Dart_UnloadMachODylib. On error, returns 'nullptr' and sets 'error'. The
|
|
/// error string should not be 'free'-d.
|
|
///
|
|
/// `file_offset` may be non-zero to read an snapshot embedded inside another
|
|
/// type of file.
|
|
///
|
|
/// Look up the Dart snapshot symbols "_kVmSnapshotData",
|
|
/// "_kVmSnapshotInstructions", "_kVmIsolateData" and "_kVmIsolateInstructions"
|
|
/// into the respectively named out-parameters.
|
|
///
|
|
/// Dart_LoadMachODylib_Fd takes ownership of the file descriptor.
|
|
/// Dart_LoadMachODylib_Memory 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_LoadAOTSnapshot_Memory returns.
|
|
#if defined(__Fuchsia__) || defined(__linux__) || defined(__FreeBSD__)
|
|
DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Fd2(
|
|
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(
|
|
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);
|
|
}
|
|
#endif
|
|
|
|
/// Please see documentation for Dart_LoadMachODylib_Fd.
|
|
DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib2(
|
|
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(
|
|
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);
|
|
}
|
|
|
|
/// Please see documentation for Dart_LoadMachODylib_Fd.
|
|
DART_EXPORT Dart_LoadedMachODylib* Dart_LoadMachODylib_Memory2(
|
|
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(
|
|
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);
|
|
}
|
|
|
|
/// Unloads an MachO dynamic library object loaded through
|
|
/// Dart_LoadMachODylib{_Fd, _Memory}.
|
|
///
|
|
/// Unlike dlclose(), this does not use reference counting.
|
|
/// Dart_LoadMachODylib{_Fd, _Memory} will return load the target library
|
|
/// separately each time it is called, and the results must be unloaded
|
|
/// separately.
|
|
DART_EXPORT void Dart_UnloadMachODylib(Dart_LoadedMachODylib* loaded);
|
|
|
|
#endif // RUNTIME_BIN_MACHO_LOADER_H_
|