Files
palemoon27/toolkit/devtools/server/DeserializedNode.cpp
T
roytam1 df6f7b7065 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1212298 - Use inner script instead of outer script in CodeGenerator::visitCallDirectEval. r=shu (cee3f366a6)
- Bug 1233331 - CodeGenerator: Properly indent IonScript::New. r=jandem (6d110c45a3)
- Bug 1233331 - CodeGenerator: Prepare the invalidation of the recompileInfo as soon as the contraints are recorded. r=jandem (679d22dd8e)
- Bug 1238417 - Part 1: Fix wrong rebase for _SetCanonicalName call on RegExpToString. r=till (31ee926189)
- Bug 1238417 - Part 2: Fix argument count of RegExpMatcher and RegExpTester. r=till (9dc5dcadd5)
- Bug 1238417 - Part 4: Enable recover instruction for RegExpMatcher and RegExpTester. r=h4writer (5479b238ac)
- Bug 1238417 - Part 5: Add RegExpMatcher to MustCloneRegExp optimization. r=h4writer (554905fa3a)
- Bug 1238417 - Part 6: Make RegExpMatcher and RegExpTester movable. r=h4writer (72091090ee)
- Bug 1238417 - Part 7: Add comment for OutOfLineRegExpMatcher and OutOfLineRegExpTester. r=nbp (f5e4519728)
- Bug 1238630 - Fix unicode surrogate pair handling in RegExp. r=h4writer (d4c1e1d49d)
- Bug 1236600 - Properly pre-barrier sets to inline TypedObject Any-type Elements. (r=jandem) (1f23bb6d61)
- Bug 1149245 - Make DeserializedEdgeRange re-use its referents edge vector; r=vporof (ea861bfd43)
- Bug 1235631 - Odin: remove change-heap support (r=bbouvier) (940a0d58bc)
- Bug 1231224 part 11 - Add missing OOM checks in Module::setProfilingEnabled. r=luke (0d264fa46b)
- Bug 1234402 - Crash on OOM in AlternativeGenerationList constructor. r=bbouvier (baa7b3da17)
- Bug 1231224 part 12 - Use InfallibleVector in irregexp code to avoid MOZ_WARN_UNUSED_RESULT warnings. r=luke (72ac897dab)
- Bug 1231224 part 13 - Add OOM checks to Statistics::initialize. r=jonco (5033150018)
- Bug 1237508 - Odin: remove function index from Export (r=bbouvier) (d368ef7f85)
- Bug 1236541 - Odin: when enabling profiling, only patch actual callsites (r=bbouvie) (713dbcc45c)
- Bug 1235046 - Optimize JIT-code poisoning to be fast with W^X. r=bhackett (25972b36a9)
- Bug 1215479 - Turn on W^X JIT code by default. r=luke (82c4b94315)
- Bug 1235868 - Change nonWritableJITCode to ifdefs. r=jandem (4dee262ff4)
- Bug 1237508 - Add missing #include to fix non-unified builds (r=me) (327242e706)
- Bug 1236530 - Make ExecutableAllocator::reprotectRegion fallible and handle in asm.js (r=jandem) (9444127563)
- Bug 1229399: Make initialization of asm.js local variables closer to wasm; r=luke (732d40b42c)
- Bug 1229399: Store line/column info in the FuncIR rather than the bytecode stream; r=luke (483faefbdd)
- Bug 1235989 - Add a null check for filename in ModuleValidator::finish. r=luke (abc62aa437)
- Bug 1235041 - Cast value to uint64_t in order to prevent int overflow when value is greater than 2^12. r=jonco (ef754091ea)
- Bug 1182369 - Remove js/Class.h include from nsWrapperCache.h. - r=bz (cc7b3c856b)
- Bug 1231964 - Move CC participant code that touches JS out of mozglue. r=smaug (100fceeb2b)
- Bug 1120016 - Allocate short lived JS wrappers in the Nursery, r=mccr8,terrence (2a17a5484d)
- Bug 1235277 - Define MOZ_FALLTHROUGH_ASSERT to workaround -Wunreachable-code warnings about MOZ_FALLTHROUGH in debug builds. r=botond (262589e609)
- Bug 1247679, part 1 - Make ClearJSHolder publicly inherit from TraceCallbacks. r=smaug (1a3543fd31)
- Bug 1235598 - Part 1: Add better SpiderMonkey API support for tracing in C++; r=sfinxk (f23bf81919)
- Bug 1235598 - Part 2: Use TraceEdge exclusively in Gecko; r=smaug (a3ad4d0ef7)
2023-08-02 11:57:35 +08:00

152 lines
3.9 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/. */
#include "mozilla/devtools/DeserializedNode.h"
#include "mozilla/devtools/HeapSnapshot.h"
#include "nsCRTGlue.h"
namespace mozilla {
namespace devtools {
DeserializedEdge::DeserializedEdge(DeserializedEdge&& rhs)
{
referent = rhs.referent;
name = rhs.name;
}
DeserializedEdge& DeserializedEdge::operator=(DeserializedEdge&& rhs)
{
MOZ_ASSERT(&rhs != this);
this->~DeserializedEdge();
new(this) DeserializedEdge(Move(rhs));
return *this;
}
JS::ubi::Node
DeserializedNode::getEdgeReferent(const DeserializedEdge& edge)
{
auto ptr = owner->nodes.lookup(edge.referent);
MOZ_ASSERT(ptr);
// `HashSets` only provide const access to their values, because mutating a
// value might change its hash, rendering it unfindable in the set.
// Unfortunately, the `ubi::Node` constructor requires a non-const pointer to
// its referent. However, the only aspect of a `DeserializedNode` we hash on
// is its id, which can't be changed via `ubi::Node`, so this cast can't cause
// the trouble `HashSet` is concerned a non-const reference would cause.
return JS::ubi::Node(const_cast<DeserializedNode*>(&*ptr));
}
JS::ubi::StackFrame
DeserializedStackFrame::getParentStackFrame() const
{
MOZ_ASSERT(parent.isSome());
auto ptr = owner->frames.lookup(parent.ref());
MOZ_ASSERT(ptr);
// See above comment in DeserializedNode::getEdgeReferent about why this
// const_cast is needed and safe.
return JS::ubi::StackFrame(const_cast<DeserializedStackFrame*>(&*ptr));
}
} // namespace devtools
} // namespace mozilla
namespace JS {
namespace ubi {
using mozilla::devtools::DeserializedEdge;
const char16_t Concrete<DeserializedNode>::concreteTypeName[] =
MOZ_UTF16("mozilla::devtools::DeserializedNode");
const char16_t*
Concrete<DeserializedNode>::typeName() const
{
return get().typeName;
}
Node::Size
Concrete<DeserializedNode>::size(mozilla::MallocSizeOf mallocSizeof) const
{
return get().size;
}
class DeserializedEdgeRange : public EdgeRange
{
DeserializedNode* node;
Edge currentEdge;
size_t i;
void settle() {
if (i >= node->edges.length()) {
front_ = nullptr;
return;
}
auto& edge = node->edges[i];
auto referent = node->getEdgeReferent(edge);
currentEdge = mozilla::Move(Edge(edge.name ? NS_strdup(edge.name) : nullptr,
referent));
front_ = &currentEdge;
}
public:
explicit DeserializedEdgeRange(DeserializedNode& node)
: node(&node)
, i(0)
{
settle();
}
void popFront() override
{
i++;
settle();
}
};
StackFrame
Concrete<DeserializedNode>::allocationStack() const
{
MOZ_ASSERT(hasAllocationStack());
auto id = get().allocationStack.ref();
auto ptr = get().owner->frames.lookup(id);
MOZ_ASSERT(ptr);
// See above comment in DeserializedNode::getEdgeReferent about why this
// const_cast is needed and safe.
return JS::ubi::StackFrame(const_cast<DeserializedStackFrame*>(&*ptr));
}
UniquePtr<EdgeRange>
Concrete<DeserializedNode>::edges(JSRuntime* rt, bool) const
{
UniquePtr<DeserializedEdgeRange, JS::DeletePolicy<DeserializedEdgeRange>> range(
js_new<DeserializedEdgeRange>(get()));
if (!range)
return nullptr;
return UniquePtr<EdgeRange>(range.release());
}
StackFrame
ConcreteStackFrame<DeserializedStackFrame>::parent() const
{
return get().parent.isNothing() ? StackFrame() : get().getParentStackFrame();
}
bool
ConcreteStackFrame<DeserializedStackFrame>::constructSavedFrameStack(
JSContext* cx,
MutableHandleObject outSavedFrameStack) const
{
StackFrame f(&get());
return ConstructSavedFrameStackSlow(cx, f, outSavedFrameStack);
}
} // namespace ubi
} // namespace JS