dart-sdk/runtime/vm/dispatch_table.h
Teagan Strickland 2195c3282a [vm] Reland two dispatch table related changes as a single change.
These changes were originally submitted separately on different days,
and a major performance regression was seen after the first change
when creating snapshots that led to both being reverted. However,
that performance regression should be addressed by the followup.

First change:
"[vm] Treat the dispatch table as a root in the snapshot.

Additional changes:
* Only serialize a dispatch table in precompiled snapshots.
* Add information in v8 snapshot profiles for the dispatch table.
* Fix a typo in a field name.
* Print the number of Instructions objects (or payloads, for
  precompiled bare instructions mode) in the fake cluster for
  the data section.
* Fix v8 snapshots profiles so objects in memory mapped segments
  and only those are prefixed with "(RO) ".
* Add names for Instructions objects in v8 snapshot profiles
  when we can use the assembly namer.
* Add command line flag for old #define'd false flag."

Second change:
"[vm/aot] Keep GC-visible references to dispatch table Code entries.

This change splits dispatch table handling into four distinct
parts:

* The dispatch table generator does not make a dispatch table
  directly, but rather creates an Array that contains the Code
  objects for dispatch table entries.
* The precompiler takes this Array and puts it in the object
  store, which makes it a new GC root.
* The serializer takes this information and serializes the
  dispatch table information in the same form as before.
* The deserializer creates a DispatchTable object and populates
  it using the serialized information.

The change in the precompiler ensures that the Code objects
used in the dispatch table have GC-visible references. Thus,
even if all other references to them from the other GC roots
were removed, they would be accessible in the serializer in
the case of a GC pass between the precompiler and serializer.

This change also means that the serializer can retrieve and
trace the Code objects directly rather than first looking up
the Code objects by their entry point."

Bug: https://github.com/dart-lang/sdk/issues/41022
Change-Id: I52c83b0536fc588da0bef9aed1f0c72e8ee4663f
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
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139285
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-03-13 17:19:52 +00:00

41 lines
1.1 KiB
C++

// Copyright (c) 2020, 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_DISPATCH_TABLE_H_
#define RUNTIME_VM_DISPATCH_TABLE_H_
#include <memory>
#include "vm/globals.h"
namespace dart {
class DispatchTable {
public:
explicit DispatchTable(intptr_t length)
: length_(length), array_(new uword[length]()) {}
intptr_t length() const { return length_; }
// The element of the dispatch table array to which the dispatch table
// register points.
static intptr_t OriginElement();
static intptr_t LargestSmallOffset();
// Dispatch table array pointer to put into the dispatch table register.
const uword* ArrayOrigin() const;
private:
uword* array() { return array_.get(); }
intptr_t length_;
std::unique_ptr<uword[]> array_;
friend class Deserializer; // For non-const array().
DISALLOW_COPY_AND_ASSIGN(DispatchTable);
};
} // namespace dart
#endif // RUNTIME_VM_DISPATCH_TABLE_H_