dart-sdk/runtime/vm/v8_snapshot_writer.h

338 lines
12 KiB
C
Raw Normal View History

// 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_V8_SNAPSHOT_WRITER_H_
#define RUNTIME_VM_V8_SNAPSHOT_WRITER_H_
#include <utility>
#include "platform/assert.h"
#include "vm/allocation.h"
#include "vm/hash_map.h"
#include "vm/hash_table.h"
#include "vm/json_writer.h"
#include "vm/object.h"
namespace dart {
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
enum class IdSpace : uint8_t {
kInvalid = 0, // So default-constructed ObjectIds are invalid.
kSnapshot = 1, // Can be VM or Isolate heap, they share ids.
kVmText = 2,
kIsolateText = 3,
kVmData = 4,
kIsolateData = 5,
kArtificial = 6, // Artificial objects (e.g. the global root).
// Change ObjectId::kIdSpaceBits to use last entry if more are added.
};
class V8SnapshotProfileWriter : public ZoneAllocated {
public:
struct ObjectId {
ObjectId() : ObjectId(IdSpace::kInvalid, -1) {}
ObjectId(IdSpace space, int64_t nonce)
: encoded_((static_cast<uint64_t>(nonce) << kIdSpaceBits) |
static_cast<intptr_t>(space)) {
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
ASSERT(Utils::IsInt(kBitsPerInt64 - kIdSpaceBits, nonce));
}
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
inline bool operator!=(const ObjectId& other) const {
return encoded_ != other.encoded_;
}
inline bool operator==(const ObjectId& other) const {
return !(*this != other);
}
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
inline uword Hash() const { return Utils::WordHash(encoded_); }
inline int64_t nonce() const { return encoded_ >> kIdSpaceBits; }
inline IdSpace space() const {
return static_cast<IdSpace>(encoded_ & kIdSpaceMask);
}
inline bool IsArtificial() const { return space() == IdSpace::kArtificial; }
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
const char* ToCString(Zone* zone) const;
void Write(JSONWriter* writer, const char* property = nullptr) const;
void WriteDebug(JSONWriter* writer, const char* property = nullptr) const;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
private:
static constexpr size_t kIdSpaceBits =
Utils::BitLength(static_cast<int64_t>(IdSpace::kArtificial));
static constexpr int64_t kIdSpaceMask =
Utils::NBitMask<int64_t>(kIdSpaceBits);
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
static const char* IdSpaceToCString(IdSpace space);
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
int64_t encoded_;
};
struct Reference {
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
enum class Type {
kElement,
kProperty,
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
} type;
intptr_t offset; // kElement
const char* name; // kProperty
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
static Reference Element(intptr_t offset) {
return {Type::kElement, offset, nullptr};
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
}
static Reference Property(const char* name) {
return {Type::kProperty, 0, name};
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
}
bool IsElement() const { return type == Type::kElement; }
};
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
static const ObjectId kArtificialRootId;
#if !defined(DART_PRECOMPILER)
explicit V8SnapshotProfileWriter(Zone* zone) {}
virtual ~V8SnapshotProfileWriter() {}
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
void SetObjectTypeAndName(const ObjectId& object_id,
const char* type,
const char* name) {}
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
void AttributeBytesTo(const ObjectId& object_id, size_t num_bytes) {}
void AttributeReferenceTo(const ObjectId& from_object_id,
const Reference& reference,
const ObjectId& to_object_id) {}
void AttributeWeakReferenceTo(const ObjectId& from_object_id,
const Reference& reference,
const ObjectId& to_object_id,
const ObjectId& replacement_object_id) {}
void AddRoot(const ObjectId& object_id, const char* name = nullptr) {}
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
bool HasId(const ObjectId& object_id) { return false; }
#else
explicit V8SnapshotProfileWriter(Zone* zone);
virtual ~V8SnapshotProfileWriter() {}
// Records that the object referenced by 'object_id' has type 'type'. The
// 'type' for all 'Instance's should be 'Instance', not the user-visible type
// and use 'name' for the real type instead.
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
void SetObjectTypeAndName(const ObjectId& object_id,
const char* type,
const char* name);
// Charges 'num_bytes'-many bytes to 'object_id'. In a clustered snapshot,
// objects can have their data spread across multiple sections, so this can be
// called multiple times for the same object.
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
void AttributeBytesTo(const ObjectId& object_id, size_t num_bytes);
// Records that a reference to the object with id 'to_object_id' was written
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
// in order to serialize the object with id 'from_object_id'. This does not
// affect the number of bytes charged to 'from_object_id'.
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
void AttributeReferenceTo(const ObjectId& from_object_id,
const Reference& reference,
const ObjectId& to_object_id);
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
// Records that a weak serialization reference to a dropped object
// with id 'to_object_id' was written in order to serialize the object with id
// 'from_object_id'. 'to_object_id' must be an artificial node and
// 'replacement_object_id' is recorded as the replacement for the
// dropped object in the snapshot. This does not affect the number of
// bytes charged to 'from_object_id'.
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
void AttributeDroppedReferenceTo(const ObjectId& from_object_id,
const Reference& reference,
const ObjectId& to_object_id,
const ObjectId& replacement_object_id);
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
// Marks an object as being a root in the graph. Used for analysis of
// the graph.
void AddRoot(const ObjectId& object_id, const char* name = nullptr);
// Write to a file in the V8 Snapshot Profile (JSON/.heapsnapshot) format.
void Write(const char* file);
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
// Whether the given object ID has been added to the profile (via AddRoot,
// SetObjectTypeAndName, etc.).
bool HasId(const ObjectId& object_id);
private:
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
static constexpr intptr_t kInvalidString =
CStringIntMapKeyValueTrait::kNoValue;
static constexpr intptr_t kNumNodeFields = 5;
static constexpr intptr_t kNumEdgeFields = 3;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
struct Edge {
enum class Type : int32_t {
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
kInvalid = -1,
kContext = 0,
kElement = 1,
kProperty = 2,
kInternal = 3,
kHidden = 4,
kShortcut = 5,
kWeak = 6,
kExtra = 7,
};
Edge() : Edge(nullptr, Type::kInvalid, -1) {}
Edge(V8SnapshotProfileWriter* profile_writer, const Reference& reference)
: Edge(profile_writer,
reference.type == Reference::Type::kElement ? Type::kElement
: Type::kProperty,
reference.type == Reference::Type::kElement
? reference.offset
: profile_writer->strings_.Add(reference.name)) {}
Edge(V8SnapshotProfileWriter* profile_writer,
Type type,
intptr_t name_or_offset)
: type(type), name_or_offset(name_or_offset) {}
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
inline bool operator!=(const Edge& other) {
return type != other.type || name_or_offset != other.name_or_offset;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
}
inline bool operator==(const Edge& other) { return !(*this != other); }
void Write(V8SnapshotProfileWriter* profile_writer,
JSONWriter* writer,
const ObjectId& target_id) const;
void WriteDebug(V8SnapshotProfileWriter* profile_writer,
JSONWriter* writer,
const ObjectId& target_id) const;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
Type type;
int32_t name_or_offset;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
};
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
struct EdgeToObjectIdMapTrait {
using Key = Edge;
using Value = ObjectId;
struct Pair {
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
Pair() : edge{}, target(kArtificialRootId) {}
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
Pair(Key key, Value value) : edge(key), target(value) {}
Edge edge;
ObjectId target;
};
static Key KeyOf(Pair kv) { return kv.edge; }
static Value ValueOf(Pair kv) { return kv.target; }
static uword Hash(Key key) {
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
return FinalizeHash(
CombineHashes(static_cast<intptr_t>(key.type), key.name_or_offset));
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
}
static bool IsKeyEqual(Pair kv, Key key) { return kv.edge == key; }
};
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
struct EdgeMap : public ZoneDirectChainedHashMap<EdgeToObjectIdMapTrait> {
explicit EdgeMap(Zone* zone)
: ZoneDirectChainedHashMap<EdgeToObjectIdMapTrait>(zone, 1) {}
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
const char* ToCString(V8SnapshotProfileWriter* profile_writer,
Zone* zone) const;
void WriteDebug(V8SnapshotProfileWriter* profile_writer,
JSONWriter* writer,
const char* property = nullptr) const;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
};
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
struct NodeInfo {
NodeInfo() {}
NodeInfo(V8SnapshotProfileWriter* profile_writer,
const ObjectId& id,
intptr_t type = kInvalidString,
intptr_t name = kInvalidString)
: id(id),
edges(new (profile_writer->zone_) EdgeMap(profile_writer->zone_)),
type(type),
name(name) {}
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
inline bool operator!=(const NodeInfo& other) {
return id != other.id || type != other.type || name != other.name ||
self_size != other.self_size || edges != other.edges ||
offset_ != other.offset_;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
}
inline bool operator==(const NodeInfo& other) { return !(*this != other); }
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
void AddEdge(const Edge& edge, const ObjectId& target) {
edges->Insert({edge, target});
}
bool HasEdge(const Edge& edge) { return edges->HasKey(edge); }
const char* ToCString(V8SnapshotProfileWriter* profile_writer,
Zone* zone) const;
void Write(V8SnapshotProfileWriter* profile_writer,
JSONWriter* writer) const;
void WriteDebug(V8SnapshotProfileWriter* profile_writer,
JSONWriter* writer) const;
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
intptr_t offset() const { return offset_; }
void set_offset(intptr_t offset) {
ASSERT_EQUAL(offset_, -1);
offset_ = offset;
}
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
ObjectId id;
EdgeMap* edges = nullptr;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
intptr_t type = kInvalidString;
intptr_t name = kInvalidString;
intptr_t self_size = 0;
private:
// Populated during serialization.
intptr_t offset_ = -1;
// 'trace_node_id' isn't supported.
// 'edge_count' is computed on-demand.
};
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
NodeInfo* EnsureId(const ObjectId& object_id);
void Write(JSONWriter* writer);
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
// Class that encapsulates both an array of strings and a mapping from
// strings to their index in the array.
class StringsTable {
public:
explicit StringsTable(Zone* zone)
: zone_(zone), index_map_(zone), strings_(zone, 2) {}
intptr_t Add(const char* str);
intptr_t AddFormatted(const char* fmt, ...) PRINTF_ATTRIBUTE(2, 3);
const char* At(intptr_t index) const;
void Write(JSONWriter* writer, const char* property = nullptr) const;
private:
Zone* zone_;
CStringIntMap index_map_;
GrowableArray<const char*> strings_;
};
struct ObjectIdToNodeInfoTraits {
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
typedef NodeInfo Pair;
typedef ObjectId Key;
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
typedef Pair Value;
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
static Key KeyOf(const Pair& pair) { return pair.id; }
[vm] Handle WSRs more generally in v8 snapshot profile writing. Instead of special-casing the current fields that may have WeakSerializationReferences, handle WSRs appearing as elements or properties of objects more generally. This removes existing special casing and avoids the need for it in case of new future uses of WSRs. For artificial nodes being added for dropped WeakSerializationReference targets, add them as kArtificial nodes (not kSnapshot) that has the original offset (element) or name (property). The replacement is added as a kSnapshot node that has a negative offset with the same magnitude as the artificial node (element) or ":real_<property name>" (property). This simplifies the work done in pkg/vm_snapshot_analysis to use the artificial nodes instead of replacement ones for reassembling hierarchies and the like. This CL also cleans up the old SerializerWritingObjectScope class, both moving it to Serializer::WritingObjectScope and allowing nesting of WritingObjectScopes with the correct semantics. Thanks to this, not only can we recur when under a WritingObjectScope instead of lifting recursion outside of those scopes, but we can also create artificial nodes for non-empty per-code object pools and static call target tables instead of attributing their contents as supposed elements of the Code object being written. TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try Change-Id: Ib945c5afcd89b1458b8be3559b6eae24048aba2f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194243 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 08:44:58 +00:00
static Value ValueOf(const Pair& pair) { return pair; }
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
static uword Hash(const Key& key) { return key.Hash(); }
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
static bool IsKeyEqual(const Pair& x, const Key& y) { return x.id == y; }
};
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
struct ObjectIdSetKeyValueTrait {
using Pair = ObjectId;
using Key = Pair;
using Value = Pair;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
static Key KeyOf(const Pair& pair) { return pair; }
static Value ValueOf(const Pair& pair) { return pair; }
static uword Hash(const Key& key) { return key.Hash(); }
static bool IsKeyEqual(const Pair& pair, const Key& key) {
return pair == key;
}
};
Zone* const zone_;
Reland "[vm] Fix V8 snapshot profile handling of the dispatch table." This is a reland of 5909fd111d52e459b4c1885c5805849336df0f71 Does a large refactoring on the V8 snapshot profile writer to clean things up, add more debugging support, and to fix the problems that surfaced during the original landing. Other changes: Changes Serializer::CreateArtificialNodeIfNeeded() to create artificial nodes for Code objects and immutable arrays. Fixes CodeSerializationCluster::Trace() to only push needed parts of discarded code objects, instead of tracing them like full code objects. Adds test cases to v8_snapshot_profile_writer_test that exercise the following situations (both separately and together): * Non-symbolic stack traces are enabled and code and function objects are dropped when not needed at runtime. * Creation of the dispatch table is disabled. TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test Original change's description: > [vm] Fix V8 snapshot profile handling of the dispatch table. > > Fixes https://github.com/dart-lang/sdk/issues/45702. > > TEST=Tests listed in the issue above. > > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try > Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272 > Reviewed-by: Daco Harkes <dacoharkes@google.com> > Commit-Queue: Tess Strickland <sstrickl@google.com> Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
DirectChainedHashMap<ObjectIdToNodeInfoTraits> nodes_;
StringsTable node_types_;
StringsTable edge_types_;
StringsTable strings_;
DirectChainedHashMap<ObjectIdSetKeyValueTrait> roots_;
#endif
};
} // namespace dart
#endif // RUNTIME_VM_V8_SNAPSHOT_WRITER_H_