e01457d138
Now, when writing an AOT snapshot in bare instructions mode, only the actual instructions in the RawInstructions payload are serialized instead of the entire RawInstructions object. Since there are no longer RawInstructions objects in these AOT snapshots, we also change how Code objects are serialized. Instead of just containing a reference to the RawInstructions object, we serialize two pieces of information: where the instructions payload for this Code object begins and whether there was a single entry for the instructions payload. (To save space, the single entry bit is serialized as the low order bit of the unchecked offset, which was already being serialized). While we also need the length of the instructions payload, we approximate it for all but the last Code object by subtracting the next Code object's payload start from this Code object's payload start. For the last Code object, we assume it extends to the end of the instructions image. Changes on flutter gallery in release mode: armv7: instructions size -2.70%, total size -1.73% armv8: instructions size -6.04%, total size -3.63% Fixes https://github.com/dart-lang/sdk/issues/38451. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try Change-Id: Ia0a5c4e5e47c956776dc62503da38ec55a143c04 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134325 Commit-Queue: Teagan Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
// Copyright (c) 2018, 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.
|
|
|
|
#include "vm/reverse_pc_lookup_cache.h"
|
|
|
|
#include "vm/isolate.h"
|
|
|
|
namespace dart {
|
|
|
|
#if defined(DART_PRECOMPILED_RUNTIME)
|
|
|
|
static uword BeginPcFromCode(const RawCode* code) {
|
|
return Code::PayloadStartOf(code);
|
|
}
|
|
|
|
static uword EndPcFromCode(const RawCode* code) {
|
|
return Code::PayloadStartOf(code) + Code::PayloadSizeOf(code);
|
|
}
|
|
|
|
void ReversePcLookupCache::BuildAndAttachToIsolate(Isolate* isolate) {
|
|
auto object_store = isolate->object_store();
|
|
auto& array = Array::Handle(object_store->code_order_table());
|
|
if (!array.IsNull()) {
|
|
const intptr_t length = array.Length();
|
|
{
|
|
NoSafepointScope no_safepoint_scope;
|
|
|
|
const uword begin =
|
|
BeginPcFromCode(reinterpret_cast<RawCode*>(array.At(0)));
|
|
const uword end =
|
|
EndPcFromCode(reinterpret_cast<RawCode*>(array.At(length - 1)));
|
|
|
|
auto pc_array = new uint32_t[length];
|
|
for (intptr_t i = 0; i < length; i++) {
|
|
const auto end_pc =
|
|
EndPcFromCode(reinterpret_cast<RawCode*>(array.At(i)));
|
|
pc_array[i] = end_pc - begin;
|
|
}
|
|
#if defined(DEBUG)
|
|
for (intptr_t i = 1; i < length; i++) {
|
|
ASSERT(pc_array[i - 1] <= pc_array[i]);
|
|
}
|
|
#endif // defined(DEBUG)
|
|
auto cache =
|
|
new ReversePcLookupCache(isolate, pc_array, length, begin, end);
|
|
isolate->set_reverse_pc_lookup_cache(cache);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif // defined(DART_PRECOMPILED_RUNTIME)
|
|
|
|
} // namespace dart
|