Files
palemoon27/toolkit/devtools/server/DeserializedNode.h
T
roytam1 6629d22907 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1170717 - Move heapState check up to readBarrier; r=jonco (b9c4df5ea)
- Bug 1163908 - Export GL draw data to layerscope for drawing heat-map view. r=:djg (cf078d4fd)
- Bug 1161372 - Add EventRegions on LayerScope. r=dglastonbury (49fc29e8a)
- Files as of Bug 1138721 - Application reputation should check mac file extensions. r=mmc (4b76de8d8)
- Bug 1024774 - Part 0: Upgrade the protobuf library. r=mmc,glandium (c98c08fbd)
- Bug 1149397 - JS::ubi::Node::edges should return a mozilla::UniquePtr; r=jimb (32f755867)
- Bug 1110039 - Part 1 - Add nsLayoutUtils::ClampRectToScrollFrames. r=roc (a8812c287)
- Bug 1110039 - Part 2.1 - Add logger facility. r=roc (1a400bb1f)
- Bug 1110039 - Part 2.2 - Add AccessibleCaret. r=roc (d8c2c759f)
- Bug 1110039 - Part 2.3 - Add AccessibleCaretManager. r=roc (ba8ad6424)
- Bug 1110039 - Part 2.4 - Add AccessibleCaretEventHub. r=roc (db4ef1fe6)
- Bug 1110039 - Part 2.5 - Add all files to build system. r=roc (bee54dc43)
- fix nsRefPtr includes - but build still broken (423d9f32d)
- Bug 1110039 - Part 3 - Add gtest for AccessibleCaretEventHub. r=roc (cdf0df240)
- Bug 1110039 - Part 4 - Hook new classes into the system. r=roc (438a4df68)
- Bug 1109183 - Fix imports of the marionette client and remove spurious entry from sys.path provided by mach. r=ahal (86b814562)
- Bug 1110039 - Part 5 - Reuse marionette tests for AccessibleCaret. r=roc (d5cd35016)
- Bug 1110039 followup: Add 'override' keyword to Name() decl in Access# (cd0d9b0f6)
- Bug 1140994 - Notify gaia to hide selection bubble when scrolling without APZ. r=roc (ca15626fa)
- Bug 1143665 - Remove the ambiguous scroll position being passed around in scroll started/stop notifications. r=roc,ehsan (ce8f1d2a9)
- Bug 1140238 - Part 1: Add a test to drag first caret over non-selectable. r=automatedtester (4080723fe)
- Bug 1140238 - Part 2: Adjust ranges after changing selection direction. r=mats (add1f155d)
- Bug 1140238 - Part 3: Clear maintain selection when dragging caret. r=mats (0aba36f24)
- Bug 1024774 - Part 2: Implement a google::protobuf::ZeroCopyOutputStream wrapper around nsIOutputStream; r=jimb (30c6272d2)
- Bug 1024774 - Part 3: Serialize heap snapshots. r=jimb (9d0c8f6ec)
- Bug 1024774 - Part 1: Add the ChromeUtils WebIDL interface. r=bholley (8e81e8344)
- Bug 1024774 - Part 4: Add an xpcshell test for saving heap snapshots. r=jimb (6e0a07069)
- Bug 1024774 - Part 5: Add GTests for core dump serialization. r=jimb (79315c540)
- clean up spurious char (9a1f9bc18)
- Bug 1121528 - Avoid the inspector going blank when quickly navigating; r=bgrins (f4cff269f)
- Bug 1155168 - Always use the same actor pool. r=ochameau (3e6cc5504)
- Bug 1137527 - Part 1: Make the memory actor emit events for garbage collection. r=jryans (6dcdb18f8)
- Bug 1137527 - Part 2: Add a test for GC MemoryActor events. r=jryans (df2bcf120)
- Bug 1024774 - Part 6: Add a mochitest-chrome sanity check test. r=bholley (4b5bffe79)
- Bug 1024774 - Part 7: Add HeapSnapshot WebIDL interface; r=bholley (7b5ae703a)
- Bug 1024774 - Part 8: Add JS::ubi::Node::isLive; r=jimb (42a965f56)
- Bug 1024774 - Part 9: Deserialize heap snapshots; r=jimb (fb3edfbc0)
- Bug 1024774 - Part 10: Add an xpcshell test for reading heap snapshots. r=jimb (09c3390a1)
- Bug 1024774 - Part 11: Implement a JS::ubi::Node specialization for DeserializedNode; r=jimb (d73362efe)
- Bug 1024774 - Part 12: Add a GTest for the JS::ubi::Node specialization for DeserializedNode; r=jimb (4415acb73)
- Bug 1024774 - Part 13: Change to new SpiderMonkey style from bug 1144366; r=me (15c4bcf87)
- Bug 1024774 - Part 14: Ignore protobuf indirect calls in the GC hazard analysis; r=sfink (c5b141c59)
- Bug 1024774 - Followup: Don't redefine the Debugger property in xpcshell tests; r=jorendorff (dc4f1f109)
- Bug 1169791 - Strongly type NoteJSRoot; r=mccr8 (ba722a44f)
- Bug 1169791 - Strongly type MergeZone; r=mccr8 (a118cf612)
- Bug 1169791 - Strongly type GetTenuredGCThingZone; r=jonco, r=mccr8 (a4da82aea)
- Bug 1171780 - We no longer need to cast out of barrieried types in GC; r=jonco (be83218fa)
- Bug 1144361: Re-enable JIT code randomization on Win64. r=jandem (6c88b4312)
- pointer style (458344bcd)
- Bug 1156914 - Fix the MacroAssembler::pushValue(const Address&) footgun on 32 bit platforms. (r=jandem) (52d5c351d)
- Bug 1156030 - Remove some obsolete static assertion macros from the tree; r=Waldo (84d8f3fea)
- pointer style (ac3c92ce1)
- Bug 1151323 - Handle loading unboxed int32 properties into floating point registers, r=jandem. (790920f3d)
- Bug 1023297 - Use explicit constructors for ARM-specific classes. r=jandem (f7f12cd76)
- Bug 1164229 - Rename ARM SetCond_ to SBit. r=efaust (c55e1d535)
- Bug 977805 - Add an option to mark JIT pages as non-writable. r=luke bug 977805 - add missing #include. r=jandem (384abd6ad)
- Bug 1173992 - Add ARM64 build support. r=glandium (540a7c784)
- Bug 1170750 - Replace %f by %.16g in js/src. r=jandem (48f808c73)
- Bug 1170750 - Use mfbt snprintf_literal instead of sprintf. r=jandem (3b2016484)
- Bug 1170750 - jsprf.cpp: Sort headers properly. r=me (0956cd3a5)
- Bug 923717 - Use structured control flow when testing for the forceInlineCaches option, r=nbp. (fc1dcef6e)
- Bug 1158044 - Remove unused TypeWrapper class and untemplatize/cleanup some code. r=bhackett (a4d5de646)
- Bug 1169355 - Remove unnecessary assertion, r=jandem. (f55c99552)
- Bug 1162986 - Allow objects to be turned into singletons dynamically, r=jandem. (9c683e420)
- Bug 1169731 - [[Call]] on a class constructor should throw. (r=jandem) (470895e3f)
and fix for shared-js in UbiNode.h
2020-11-09 23:37:50 +08:00

132 lines
4.4 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_devtools_DeserializedNode__
#define mozilla_devtools_DeserializedNode__
#include "js/UbiNode.h"
#include "mozilla/devtools/CoreDump.pb.h"
#include "mozilla/MaybeOneOf.h"
#include "mozilla/Move.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/Vector.h"
// `Deserialized{Node,Edge}` translate protobuf messages from our core dump
// format into structures we can rely upon for implementing `JS::ubi::Node`
// specializations on top of. All of the properties of the protobuf messages are
// optional for future compatibility, and this is the layer where we validate
// that the properties that do actually exist in any given message fulfill our
// semantic requirements.
//
// Both `DeserializedNode` and `DeserializedEdge` are always owned by a
// `HeapSnapshot` instance, and their lifetimes must not extend after that of
// their owning `HeapSnapshot`.
namespace mozilla {
namespace devtools {
class HeapSnapshot;
using NodeId = uint64_t;
// A `DeserializedEdge` represents an edge in the heap graph pointing to the
// node with id equal to `DeserializedEdge::referent` that we deserialized from
// a core dump.
struct DeserializedEdge {
NodeId referent;
// A borrowed reference to a string owned by this node's owning HeapSnapshot.
const char16_t* name;
explicit DeserializedEdge();
DeserializedEdge(DeserializedEdge&& rhs);
DeserializedEdge& operator=(DeserializedEdge&& rhs);
// Initialize this `DeserializedEdge` from the given `protobuf::Edge` message.
bool init(const protobuf::Edge& edge, HeapSnapshot& owner);
private:
DeserializedEdge(const DeserializedEdge&) = delete;
DeserializedEdge& operator=(const DeserializedEdge&) = delete;
};
// A `DeserializedNode` is a node in the heap graph that we deserialized from a
// core dump.
struct DeserializedNode {
using EdgeVector = Vector<DeserializedEdge>;
using UniqueStringPtr = UniquePtr<char16_t[]>;
NodeId id;
// A borrowed reference to a string owned by this node's owning HeapSnapshot.
const char16_t* typeName;
uint64_t size;
EdgeVector edges;
// A weak pointer to this node's owning `HeapSnapshot`. Safe without
// AddRef'ing because this node's lifetime is equal to that of its owner.
HeapSnapshot* owner;
// Create a new `DeserializedNode` from the given `protobuf::Node` message.
static UniquePtr<DeserializedNode> Create(const protobuf::Node& node,
HeapSnapshot& owner);
DeserializedNode(NodeId id,
const char16_t* typeName,
uint64_t size,
EdgeVector&& edges,
HeapSnapshot& owner);
virtual ~DeserializedNode() { }
// Get a borrowed reference to the given edge's referent. This method is
// virtual to provide a hook for gmock and gtest.
virtual DeserializedNode& getEdgeReferent(const DeserializedEdge& edge);
protected:
// This is only for use with `MockDeserializedNode` in testing.
DeserializedNode(NodeId id, const char16_t* typeName, uint64_t size);
private:
DeserializedNode(const DeserializedNode&) = delete;
DeserializedNode& operator=(const DeserializedNode&) = delete;
};
} // namespace devtools
} // namespace mozilla
namespace JS {
namespace ubi {
using mozilla::devtools::DeserializedNode;
using mozilla::UniquePtr;
template<>
struct Concrete<DeserializedNode> : public Base
{
protected:
explicit Concrete(DeserializedNode* ptr) : Base(ptr) { }
DeserializedNode& get() const {
return *static_cast<DeserializedNode*>(ptr);
}
public:
static const char16_t concreteTypeName[];
static void construct(void* storage, DeserializedNode* ptr) {
new (storage) Concrete(ptr);
}
Id identifier() const override { return get().id; }
bool isLive() const override { return false; }
const char16_t* typeName() const override;
size_t size(mozilla::MallocSizeOf mallocSizeof) const override;
// We ignore the `bool wantNames` parameter because we can't control whether
// the core dump was serialized with edge names or not.
UniquePtr<EdgeRange> edges(JSContext* cx, bool) const override;
};
} // namespace JS
} // namespace ubi
#endif // mozilla_devtools_DeserializedNode__