dart-sdk/runtime/vm/reverse_pc_lookup_cache.h
Alexander Markov 5129cff930 [vm/aot] Discard Code objects from the heap
While deserializing AOT snapshot, Code objects which do not contain
valuable information besides entry point and stack maps are discarded
and not allocated on the heap (they are replaced with
StubCode::UnknownDartCode()).

PC -> Code/CompressedStackMaps lookup is implemented using a separate
table (InstructionsTable).

Flutter gallery in release-sizeopt mode:
Heap size of snapshot objects: arm -26.89%, arm64 -27.68%

Large Flutter application in release mode with --dwarf-stack-traces:
Heap size of snapshot objects: -24.3%.
Discarded Code objects: 72.5% of all Code objects.

Issue: https://github.com/dart-lang/sdk/issues/44852.

TEST=existing tests; "--dwarf_stack_traces --no-retain_function_objects
--no-retain_code_objects" mode is enabled for a few tests.

Change-Id: I5fe3e283630c8e8f4442319d5dcae38d174dd0d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189560
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-04-13 02:36:16 +00:00

48 lines
1.9 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.
#ifndef RUNTIME_VM_REVERSE_PC_LOOKUP_CACHE_H_
#define RUNTIME_VM_REVERSE_PC_LOOKUP_CACHE_H_
#include "vm/allocation.h"
#include "vm/globals.h"
#include "vm/tagged_pointer.h"
namespace dart {
class IsolateGroup;
// This class provides mechanism to find Code and CompressedStackMaps
// objects corresponding to the given PC.
// Can only be used in AOT runtime with bare instructions.
class ReversePc : public AllStatic {
public:
// Looks for Code object corresponding to |pc| in the
// given isolate |group| and vm isolate group.
static CodePtr Lookup(IsolateGroup* group, uword pc, bool is_return_address);
// Looks for CompressedStackMaps corresponding to |pc| in the
// given isolate |group| and vm isolate group.
// Sets |code_start| to the beginning of the instructions corresponding
// to |pc| (like Code::PayloadStart()).
static CompressedStackMapsPtr FindCompressedStackMaps(IsolateGroup* group,
uword pc,
bool is_return_address,
uword* code_start);
private:
static ObjectPtr FindCodeDescriptorInGroup(IsolateGroup* group,
uword pc,
bool is_return_address,
uword* code_start);
static ObjectPtr FindCodeDescriptor(IsolateGroup* group,
uword pc,
bool is_return_address,
uword* code_start);
};
} // namespace dart
#endif // RUNTIME_VM_REVERSE_PC_LOOKUP_CACHE_H_