mirror of
https://github.com/dart-lang/sdk
synced 2024-09-06 00:59:09 +00:00
[standalone] Remove dead VM sections from blob container format.
TEST=ci Change-Id: I78940e2c617c33983748e7532cec305b1ecd1c18 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369101 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
ea44765874
commit
3bf8f35014
|
@ -26,7 +26,7 @@
|
|||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
static constexpr int64_t kAppSnapshotHeaderSize = 4 * kInt64Size;
|
||||
static constexpr int64_t kAppSnapshotHeaderSize = 2 * kInt64Size;
|
||||
// The largest possible page size among the platforms we support (Linux ARM64).
|
||||
static constexpr int64_t kAppSnapshotPageSize = 64 * KB;
|
||||
|
||||
|
@ -104,24 +104,15 @@ static AppSnapshot* TryReadAppSnapshotBlobs(const char* script_name,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
int64_t header[4];
|
||||
int64_t header[2];
|
||||
ASSERT(sizeof(header) == kAppSnapshotHeaderSize);
|
||||
if (!file->ReadFully(&header, kAppSnapshotHeaderSize)) {
|
||||
return nullptr;
|
||||
}
|
||||
int64_t vm_data_size = header[0];
|
||||
int64_t vm_data_position =
|
||||
int64_t isolate_data_size = header[0];
|
||||
int64_t isolate_data_position =
|
||||
Utils::RoundUp(file->Position(), kAppSnapshotPageSize);
|
||||
int64_t vm_instructions_size = header[1];
|
||||
int64_t vm_instructions_position = vm_data_position + vm_data_size;
|
||||
if (vm_instructions_size != 0) {
|
||||
vm_instructions_position =
|
||||
Utils::RoundUp(vm_instructions_position, kAppSnapshotPageSize);
|
||||
}
|
||||
int64_t isolate_data_size = header[2];
|
||||
int64_t isolate_data_position = Utils::RoundUp(
|
||||
vm_instructions_position + vm_instructions_size, kAppSnapshotPageSize);
|
||||
int64_t isolate_instructions_size = header[3];
|
||||
int64_t isolate_instructions_size = header[1];
|
||||
int64_t isolate_instructions_position =
|
||||
isolate_data_position + isolate_data_size;
|
||||
if (isolate_instructions_size != 0) {
|
||||
|
@ -129,24 +120,6 @@ static AppSnapshot* TryReadAppSnapshotBlobs(const char* script_name,
|
|||
Utils::RoundUp(isolate_instructions_position, kAppSnapshotPageSize);
|
||||
}
|
||||
|
||||
MappedMemory* vm_data_mapping = nullptr;
|
||||
if (vm_data_size != 0) {
|
||||
vm_data_mapping =
|
||||
file->Map(File::kReadOnly, vm_data_position, vm_data_size);
|
||||
if (vm_data_mapping == nullptr) {
|
||||
FATAL("Failed to memory map snapshot: %s\n", script_name);
|
||||
}
|
||||
}
|
||||
|
||||
MappedMemory* vm_instr_mapping = nullptr;
|
||||
if (vm_instructions_size != 0) {
|
||||
vm_instr_mapping = file->Map(File::kReadExecute, vm_instructions_position,
|
||||
vm_instructions_size);
|
||||
if (vm_instr_mapping == nullptr) {
|
||||
FATAL("Failed to memory map snapshot: %s\n", script_name);
|
||||
}
|
||||
}
|
||||
|
||||
MappedMemory* isolate_data_mapping = nullptr;
|
||||
if (isolate_data_size != 0) {
|
||||
isolate_data_mapping =
|
||||
|
@ -166,9 +139,8 @@ static AppSnapshot* TryReadAppSnapshotBlobs(const char* script_name,
|
|||
}
|
||||
}
|
||||
|
||||
auto app_snapshot =
|
||||
new MappedAppSnapshot(vm_data_mapping, vm_instr_mapping,
|
||||
isolate_data_mapping, isolate_instr_mapping);
|
||||
auto app_snapshot = new MappedAppSnapshot(
|
||||
nullptr, nullptr, isolate_data_mapping, isolate_instr_mapping);
|
||||
return app_snapshot;
|
||||
}
|
||||
|
||||
|
@ -682,10 +654,6 @@ static bool WriteInt64(File* file, int64_t size) {
|
|||
}
|
||||
|
||||
void Snapshot::WriteAppSnapshot(const char* filename,
|
||||
uint8_t* vm_data_buffer,
|
||||
intptr_t vm_data_size,
|
||||
uint8_t* vm_instructions_buffer,
|
||||
intptr_t vm_instructions_size,
|
||||
uint8_t* isolate_data_buffer,
|
||||
intptr_t isolate_data_size,
|
||||
uint8_t* isolate_instructions_buffer,
|
||||
|
@ -696,32 +664,11 @@ void Snapshot::WriteAppSnapshot(const char* filename,
|
|||
}
|
||||
|
||||
file->WriteFully(appjit_magic_number.bytes, appjit_magic_number.length);
|
||||
WriteInt64(file, vm_data_size);
|
||||
WriteInt64(file, vm_instructions_size);
|
||||
WriteInt64(file, isolate_data_size);
|
||||
WriteInt64(file, isolate_instructions_size);
|
||||
ASSERT(file->Position() ==
|
||||
(kAppSnapshotHeaderSize + DartUtils::kMaxMagicNumberSize));
|
||||
|
||||
file->SetPosition(Utils::RoundUp(file->Position(), kAppSnapshotPageSize));
|
||||
if (LOG_SECTION_BOUNDARIES) {
|
||||
Syslog::PrintErr("%" Px64 ": VM Data\n", file->Position());
|
||||
}
|
||||
if (!file->WriteFully(vm_data_buffer, vm_data_size)) {
|
||||
ErrorExit(kErrorExitCode, "Unable to write snapshot file '%s'\n", filename);
|
||||
}
|
||||
|
||||
if (vm_instructions_size != 0) {
|
||||
file->SetPosition(Utils::RoundUp(file->Position(), kAppSnapshotPageSize));
|
||||
if (LOG_SECTION_BOUNDARIES) {
|
||||
Syslog::PrintErr("%" Px64 ": VM Instructions\n", file->Position());
|
||||
}
|
||||
if (!file->WriteFully(vm_instructions_buffer, vm_instructions_size)) {
|
||||
ErrorExit(kErrorExitCode, "Unable to write snapshot file '%s'\n",
|
||||
filename);
|
||||
}
|
||||
}
|
||||
|
||||
file->SetPosition(Utils::RoundUp(file->Position(), kAppSnapshotPageSize));
|
||||
if (LOG_SECTION_BOUNDARIES) {
|
||||
Syslog::PrintErr("%" Px64 ": Isolate Data\n", file->Position());
|
||||
|
@ -786,8 +733,7 @@ void Snapshot::GenerateAppJIT(const char* snapshot_filename) {
|
|||
ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
|
||||
}
|
||||
|
||||
WriteAppSnapshot(snapshot_filename, nullptr, 0, nullptr, 0, isolate_buffer,
|
||||
isolate_size, nullptr, 0);
|
||||
WriteAppSnapshot(snapshot_filename, isolate_buffer, isolate_size, nullptr, 0);
|
||||
#else
|
||||
uint8_t* isolate_data_buffer = nullptr;
|
||||
intptr_t isolate_data_size = 0;
|
||||
|
@ -799,8 +745,7 @@ void Snapshot::GenerateAppJIT(const char* snapshot_filename) {
|
|||
if (Dart_IsError(result)) {
|
||||
ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
|
||||
}
|
||||
WriteAppSnapshot(snapshot_filename, nullptr, 0, nullptr, 0,
|
||||
isolate_data_buffer, isolate_data_size,
|
||||
WriteAppSnapshot(snapshot_filename, isolate_data_buffer, isolate_data_size,
|
||||
isolate_instructions_buffer, isolate_instructions_size);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -59,10 +59,6 @@ class Snapshot {
|
|||
bool force_load_elf_from_memory = false,
|
||||
bool decode_uri = true);
|
||||
static void WriteAppSnapshot(const char* filename,
|
||||
uint8_t* vm_data_buffer,
|
||||
intptr_t vm_data_size,
|
||||
uint8_t* vm_instructions_buffer,
|
||||
intptr_t vm_instructions_size,
|
||||
uint8_t* isolate_data_buffer,
|
||||
intptr_t isolate_data_size,
|
||||
uint8_t* isolate_instructions_buffer,
|
||||
|
|
Loading…
Reference in a new issue