Files
roytam1 cc81aca6b2 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1236321 - Annotate intentional switch fallthroughs to suppress -Wimplicit-fallthrough warnings in js/. r=luke (32d46328ef)
- Bug 1236552 - Odin: handle unfinished AsmJSModuleObject in addSizeOfMisc (r=bbouvier) (dafbd77b10)
- Bug 1229399: Make writing the IR fallible, provide a fallible readingAPI; r=luke (cbc536c3fa)
- Bug 1237272 - Only for Coverity - check arg1, arg2 and arg3 for validity. r=luke (1456e58951)
- Bug 1229399: Split FuncIR into Bytecode/Encoder/Decoder/FuncBytecode; r=luke (9f438b4d5f)
- Bug 1237508 - Odin: make AsmJSModule derive wasm::Module (r=bbouvier) (0186bf908b)
- Bug 1238195 - Switch over some AutoVectorRooters to Rooted<TraceableVector>s and fill in some missing support (r=terrence) (b556fdc27e)
- Bug 1234193 - IsRelazifiableFunction: Return false when we report an error. r=jandem (bd3c33e1e6)
- Bug 1221361: Mark SetARMHwCapFlags as unsafe for fuzzing; r=jolesen (3134febc32)
- Bug 1236564 - Fix various minor issues with getting/setting GC parameters r=terrence (45e251eba7)
- Bug 1235237 - Annotate intentional switch fallthrough to suppress -Wimplicit-fallthrough warning in storage/. r=mak (f81714fdab)
- Bug 1235236 - Annotate intentional switch fallthrough to suppress -Wimplicit-fallthrough warning in modules/libjar/. r=aklotz (f3a210802b)
- Bug 1236324 - Annotate intentional switch fallthroughs to suppress -Wimplicit-fallthrough warnings in toolkit/components/places/. r=mak (f2d09b5041)
- Bug 1238711 - Rename TraceableVector to GCVector; r=sfink Bug 1237153 - Fix gcparam() parameter verification to not allow negative numbers r=terrence (deccfd7f01)
- Bug 1235092 - Part 1: Optimize spread call with rest parameter. r=efaust (e6cc1294d1)
- Bug 1235092 - Part 2: Support allowContentSpread in the optimization for spread call with rest parameter. r=efaust (31c881893d)
- Bug 1235092 - Part 3: Root function in BytecodeEmitter::isRestParameter. r=bustage (ede37f48b6)
- Bug 1233152 - Use PersistentRooted for ParseTask script and sourceObject. r=terrence (d99d9b81fb)
- Bug 1236476: Report out of memory in ExpandErrorArgumentsVA; r=jandem (6a2327222c)
- Bug 1239601 - improve the UniquePtr situation (r=jorendorff) (640322c8c1)
- Bug 1239724: Introduce RegExp registers to non-ion builds; r=arai (f2d837e65b)
- Bug 1137624 - Remove ArrayJoin code duplication, and use a correct alias set. r=jandem (ab8a98a5e3)
- Bug 1237284: Make SIMD names more consistent in MCallOptimize; r=jolesen (d50f74a31e)
- Bug 1238582 - Fix spurious assertion failure in array sort due to over-eager OOM simulation r=jandem (587f4976e5)
- Bug 1235874 - handle null filename in DescribeScriptedCaller (r=sunfish) (b347469108)
- Bug 1239601 - improve the UniquePtr situation (r=jandem) (a8b9f15dcb)
2023-08-04 10:46:07 +08:00

151 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));
}
js::UniquePtr<EdgeRange>
Concrete<DeserializedNode>::edges(JSRuntime* rt, bool) const
{
js::UniquePtr<DeserializedEdgeRange> range(js_new<DeserializedEdgeRange>(get()));
if (!range)
return nullptr;
return js::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