Bug 1024774 - Part 13: Change to new SpiderMonkey style from bug 1144366; r=me

This commit is contained in:
Nick Fitzgerald 2015-04-22 11:09:55 -07:00
parent 15556f254f
commit d6fab00041
16 changed files with 145 additions and 146 deletions

View File

@ -322,12 +322,12 @@ onPromiseSettled(JSContext* cx, HandleObject promise);
// Return true if the given value is a Debugger object, false otherwise.
JS_PUBLIC_API(bool)
IsDebugger(const JSObject &obj);
IsDebugger(const JSObject& obj);
// Append each of the debuggee global objects observed by the Debugger object
// |dbgObj| to |vector|. Returns true on success, false on failure.
JS_PUBLIC_API(bool)
GetDebuggeeGlobals(JSContext *cx, const JSObject &dbgObj, AutoObjectVector &vector);
GetDebuggeeGlobals(JSContext* cx, const JSObject& dbgObj, AutoObjectVector& vector);
} // namespace dbg
} // namespace JS

View File

@ -474,7 +474,7 @@ extern JS_FRIEND_API(bool)
IsAtomsCompartment(JSCompartment* comp);
extern JS_FRIEND_API(bool)
IsAtomsZone(JS::Zone *zone);
IsAtomsZone(JS::Zone* zone);
/*
* Returns whether we're in a non-strict property set (in that we're in a

View File

@ -7882,17 +7882,17 @@ JS::dbg::onPromiseSettled(JSContext* cx, HandleObject promise)
}
JS_PUBLIC_API(bool)
JS::dbg::IsDebugger(const JSObject &obj)
JS::dbg::IsDebugger(const JSObject& obj)
{
return js::GetObjectClass(&obj) == &Debugger::jsclass &&
js::Debugger::fromJSObject(&obj) != nullptr;
}
JS_PUBLIC_API(bool)
JS::dbg::GetDebuggeeGlobals(JSContext *cx, const JSObject &dbgObj, AutoObjectVector &vector)
JS::dbg::GetDebuggeeGlobals(JSContext* cx, const JSObject& dbgObj, AutoObjectVector& vector)
{
MOZ_ASSERT(IsDebugger(dbgObj));
js::Debugger *dbg = js::Debugger::fromJSObject(&dbgObj);
js::Debugger* dbg = js::Debugger::fromJSObject(&dbgObj);
if (!vector.reserve(vector.length() + dbg->debuggees.count())) {
JS_ReportOutOfMemory(cx);

View File

@ -326,7 +326,7 @@ JS::dbg::SetDebuggerMallocSizeOf(JSRuntime* rt, mozilla::MallocSizeOf mallocSize
}
JS_PUBLIC_API(mozilla::MallocSizeOf)
JS::dbg::GetDebuggerMallocSizeOf(JSRuntime *rt)
JS::dbg::GetDebuggerMallocSizeOf(JSRuntime* rt)
{
return rt->debuggerMallocSizeOf;
}

View File

@ -35,7 +35,7 @@ using namespace dom;
// globals, find the set of zones the globals are allocated within. Returns
// false on OOM failure.
static bool
PopulateZonesWithGlobals(ZoneSet &zones, AutoObjectVector &globals)
PopulateZonesWithGlobals(ZoneSet& zones, AutoObjectVector& globals)
{
if (!zones.init())
return false;
@ -52,7 +52,7 @@ PopulateZonesWithGlobals(ZoneSet &zones, AutoObjectVector &globals)
// Add the given set of globals as explicit roots in the given roots
// list. Returns false on OOM failure.
static bool
AddGlobalsAsRoots(AutoObjectVector &globals, ubi::RootList &roots)
AddGlobalsAsRoots(AutoObjectVector& globals, ubi::RootList& roots)
{
unsigned length = globals.length();
for (unsigned i = 0; i < length; i++) {
@ -75,11 +75,11 @@ AddGlobalsAsRoots(AutoObjectVector &globals, ubi::RootList &roots)
// handle it, or we run out of memory, set `rv` appropriately and return
// `false`.
static bool
EstablishBoundaries(JSContext *cx,
ErrorResult &rv,
const HeapSnapshotBoundaries &boundaries,
ubi::RootList &roots,
ZoneSet &zones)
EstablishBoundaries(JSContext* cx,
ErrorResult& rv,
const HeapSnapshotBoundaries& boundaries,
ubi::RootList& roots,
ZoneSet& zones)
{
MOZ_ASSERT(!roots.initialized());
MOZ_ASSERT(!zones.initialized());
@ -107,7 +107,7 @@ EstablishBoundaries(JSContext *cx,
}
foundBoundaryProperty = true;
JSObject *dbgObj = boundaries.mDebugger.Value();
JSObject* dbgObj = boundaries.mDebugger.Value();
if (!dbgObj || !dbg::IsDebugger(*dbgObj)) {
rv.Throw(NS_ERROR_INVALID_ARG);
return false;
@ -139,7 +139,7 @@ EstablishBoundaries(JSContext *cx,
AutoObjectVector globals(cx);
for (uint32_t i = 0; i < length; i++) {
JSObject *global = boundaries.mGlobals.Value().ElementAt(i);
JSObject* global = boundaries.mGlobals.Value().ElementAt(i);
if (!JS_IsGlobalObject(global)) {
rv.Throw(NS_ERROR_INVALID_ARG);
return false;
@ -175,12 +175,12 @@ EstablishBoundaries(JSContext *cx,
// given `ZeroCopyOutputStream`.
class MOZ_STACK_CLASS StreamWriter : public CoreDumpWriter
{
JSContext *cx;
JSContext* cx;
bool wantNames;
::google::protobuf::io::ZeroCopyOutputStream &stream;
::google::protobuf::io::ZeroCopyOutputStream& stream;
bool writeMessage(const ::google::protobuf::MessageLite &message) {
bool writeMessage(const ::google::protobuf::MessageLite& message) {
// We have to create a new CodedOutputStream when writing each message so
// that the 64MB size limit used by Coded{Output,Input}Stream to prevent
// integer overflow is enforced per message rather than on the whole stream.
@ -191,8 +191,8 @@ class MOZ_STACK_CLASS StreamWriter : public CoreDumpWriter
}
public:
StreamWriter(JSContext *cx,
::google::protobuf::io::ZeroCopyOutputStream &stream,
StreamWriter(JSContext* cx,
::google::protobuf::io::ZeroCopyOutputStream& stream,
bool wantNames)
: cx(cx)
, wantNames(wantNames)
@ -207,16 +207,16 @@ public:
return writeMessage(metadata);
}
virtual bool writeNode(const JS::ubi::Node &ubiNode,
virtual bool writeNode(const JS::ubi::Node& ubiNode,
EdgePolicy includeEdges) override {
protobuf::Node protobufNode;
protobufNode.set_id(ubiNode.identifier());
const char16_t *typeName = ubiNode.typeName();
const char16_t* typeName = ubiNode.typeName();
size_t length = NS_strlen(typeName) * sizeof(char16_t);
protobufNode.set_typename_(typeName, length);
JSRuntime *rt = JS_GetRuntime(cx);
JSRuntime* rt = JS_GetRuntime(cx);
mozilla::MallocSizeOf mallocSizeOf = dbg::GetDebuggerMallocSizeOf(rt);
MOZ_ASSERT(mallocSizeOf);
protobufNode.set_size(ubiNode.size(mallocSizeOf));
@ -227,9 +227,9 @@ public:
return false;
for ( ; !edges->empty(); edges->popFront()) {
const ubi::Edge &ubiEdge = edges->front();
const ubi::Edge& ubiEdge = edges->front();
protobuf::Edge *protobufEdge = protobufNode.add_edges();
protobuf::Edge* protobufEdge = protobufNode.add_edges();
if (NS_WARN_IF(!protobufEdge)) {
return false;
}
@ -251,7 +251,7 @@ public:
// core dump.
class MOZ_STACK_CLASS HeapSnapshotHandler {
CoreDumpWriter& writer;
JS::ZoneSet* zones;
JS::ZoneSet* zones;
public:
HeapSnapshotHandler(CoreDumpWriter& writer,
@ -264,10 +264,10 @@ public:
class NodeData { };
typedef JS::ubi::BreadthFirst<HeapSnapshotHandler> Traversal;
bool operator() (Traversal &traversal,
bool operator() (Traversal& traversal,
JS::ubi::Node origin,
const JS::ubi::Edge &edge,
NodeData *,
const JS::ubi::Edge& edge,
NodeData*,
bool first)
{
// We're only interested in the first time we reach edge.referent, not in
@ -279,7 +279,7 @@ public:
if (!first)
return true;
const JS::ubi::Node &referent = edge.referent;
const JS::ubi::Node& referent = edge.referent;
if (!zones)
// We aren't targeting a particular set of zones, so serialize all the
@ -293,7 +293,7 @@ public:
// by traversing the heap graph. However, we do not serialize its outgoing
// edges and we abandon further traversal from this node.
JS::Zone *zone = referent.zone();
JS::Zone* zone = referent.zone();
if (zones->has(zone))
return writer.writeNode(referent, CoreDumpWriter::INCLUDE_EDGES);
@ -305,12 +305,12 @@ public:
bool
WriteHeapGraph(JSContext *cx,
const JS::ubi::Node &node,
CoreDumpWriter &writer,
WriteHeapGraph(JSContext* cx,
const JS::ubi::Node& node,
CoreDumpWriter& writer,
bool wantNames,
JS::ZoneSet *zones,
JS::AutoCheckCannotGC &noGC)
JS::ZoneSet* zones,
JS::AutoCheckCannotGC& noGC)
{
// Serialize the starting node to the core dump.
@ -332,10 +332,10 @@ WriteHeapGraph(JSContext *cx,
}
/* static */ void
ChromeUtils::SaveHeapSnapshot(GlobalObject &global,
JSContext *cx,
const nsAString &filePath,
const HeapSnapshotBoundaries &boundaries,
ChromeUtils::SaveHeapSnapshot(GlobalObject& global,
JSContext* cx,
const nsAString& filePath,
const HeapSnapshotBoundaries& boundaries,
ErrorResult& rv)
{
bool wantNames = true;
@ -384,10 +384,10 @@ ChromeUtils::SaveHeapSnapshot(GlobalObject &global,
}
/* static */ already_AddRefed<HeapSnapshot>
ChromeUtils::ReadHeapSnapshot(GlobalObject &global,
JSContext *cx,
const nsAString &filePath,
ErrorResult &rv)
ChromeUtils::ReadHeapSnapshot(GlobalObject& global,
JSContext* cx,
const nsAString& filePath,
ErrorResult& rv)
{
UniquePtr<char[]> path(ToNewCString(filePath));
if (!path) {
@ -402,13 +402,13 @@ ChromeUtils::ReadHeapSnapshot(GlobalObject &global,
}
uint32_t size = fileInfo.size;
ScopedFreePtr<uint8_t> buffer(static_cast<uint8_t *>(malloc(size)));
ScopedFreePtr<uint8_t> buffer(static_cast<uint8_t*>(malloc(size)));
if (!buffer) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
PRFileDesc *fd = PR_Open(path.get(), PR_RDONLY, 0);
PRFileDesc* fd = PR_Open(path.get(), PR_RDONLY, 0);
if (!fd) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;

View File

@ -39,7 +39,7 @@ public:
// Write the given `JS::ubi::Node` to the core dump. The given `EdgePolicy`
// dictates whether its outgoing edges should also be written to the core
// dump, or excluded.
virtual bool writeNode(const JS::ubi::Node &node,
virtual bool writeNode(const JS::ubi::Node& node,
EdgePolicy includeEdges) = 0;
};
@ -49,12 +49,12 @@ public:
// non-null, only capture the sub-graph within the zone set, otherwise capture
// the whole heap graph. Returns false on failure.
bool
WriteHeapGraph(JSContext *cx,
const JS::ubi::Node &node,
CoreDumpWriter &writer,
WriteHeapGraph(JSContext* cx,
const JS::ubi::Node& node,
CoreDumpWriter& writer,
bool wantNames,
JS::ZoneSet *zones,
JS::AutoCheckCannotGC &noGC);
JS::ZoneSet* zones,
JS::AutoCheckCannotGC& noGC);
class HeapSnapshot;
@ -63,16 +63,16 @@ class HeapSnapshot;
class ChromeUtils
{
public:
static void SaveHeapSnapshot(dom::GlobalObject &global,
JSContext *cx,
const nsAString &filePath,
const dom::HeapSnapshotBoundaries &boundaries,
ErrorResult &rv);
static void SaveHeapSnapshot(dom::GlobalObject& global,
JSContext* cx,
const nsAString& filePath,
const dom::HeapSnapshotBoundaries& boundaries,
ErrorResult& rv);
static already_AddRefed<HeapSnapshot> ReadHeapSnapshot(dom::GlobalObject &global,
JSContext *cx,
const nsAString &filePath,
ErrorResult &rv);
static already_AddRefed<HeapSnapshot> ReadHeapSnapshot(dom::GlobalObject& global,
JSContext* cx,
const nsAString& filePath,
ErrorResult& rv);
};
} // namespace devtools

View File

@ -15,13 +15,13 @@ DeserializedEdge::DeserializedEdge()
, name(nullptr)
{ }
DeserializedEdge::DeserializedEdge(DeserializedEdge &&rhs)
DeserializedEdge::DeserializedEdge(DeserializedEdge&& rhs)
{
referent = rhs.referent;
name = rhs.name;
}
DeserializedEdge &DeserializedEdge::operator=(DeserializedEdge &&rhs)
DeserializedEdge& DeserializedEdge::operator=(DeserializedEdge&& rhs)
{
MOZ_ASSERT(&rhs != this);
this->~DeserializedEdge();
@ -30,7 +30,7 @@ DeserializedEdge &DeserializedEdge::operator=(DeserializedEdge &&rhs)
}
bool
DeserializedEdge::init(const protobuf::Edge &edge, HeapSnapshot &owner)
DeserializedEdge::init(const protobuf::Edge& edge, HeapSnapshot& owner)
{
// Although the referent property is optional in the protobuf format for
// future compatibility, we can't semantically have an edge to nowhere and
@ -50,7 +50,7 @@ DeserializedEdge::init(const protobuf::Edge &edge, HeapSnapshot &owner)
}
/* static */ UniquePtr<DeserializedNode>
DeserializedNode::Create(const protobuf::Node &node, HeapSnapshot &owner)
DeserializedNode::Create(const protobuf::Node& node, HeapSnapshot& owner)
{
if (!node.has_id())
return nullptr;
@ -88,10 +88,10 @@ DeserializedNode::Create(const protobuf::Node &node, HeapSnapshot &owner)
}
DeserializedNode::DeserializedNode(NodeId id,
const char16_t *typeName,
const char16_t* typeName,
uint64_t size,
EdgeVector &&edges,
HeapSnapshot &owner)
EdgeVector&& edges,
HeapSnapshot& owner)
: id(id)
, typeName(typeName)
, size(size)
@ -99,7 +99,7 @@ DeserializedNode::DeserializedNode(NodeId id,
, owner(&owner)
{ }
DeserializedNode::DeserializedNode(NodeId id, const char16_t *typeName, uint64_t size)
DeserializedNode::DeserializedNode(NodeId id, const char16_t* typeName, uint64_t size)
: id(id)
, typeName(typeName)
, size(size)
@ -107,8 +107,8 @@ DeserializedNode::DeserializedNode(NodeId id, const char16_t *typeName, uint64_t
, owner(nullptr)
{ }
DeserializedNode &
DeserializedNode::getEdgeReferent(const DeserializedEdge &edge)
DeserializedNode&
DeserializedNode::getEdgeReferent(const DeserializedEdge& edge)
{
auto ptr = owner->nodes.lookup(edge.referent);
MOZ_ASSERT(ptr);
@ -126,7 +126,7 @@ using mozilla::devtools::DeserializedEdge;
const char16_t Concrete<DeserializedNode>::concreteTypeName[] =
MOZ_UTF16("mozilla::devtools::DeserializedNode");
const char16_t *
const char16_t*
Concrete<DeserializedNode>::typeName() const
{
return get().typeName;
@ -155,23 +155,23 @@ public:
settle();
}
bool init(DeserializedNode &node)
bool init(DeserializedNode& node)
{
if (!edges.reserve(node.edges.length()))
return false;
for (DeserializedEdge *edgep = node.edges.begin();
for (DeserializedEdge* edgep = node.edges.begin();
edgep != node.edges.end();
edgep++)
{
char16_t *name = nullptr;
char16_t* name = nullptr;
if (edgep->name) {
name = NS_strdup(edgep->name);
if (!name)
return false;
}
DeserializedNode &referent = node.getEdgeReferent(*edgep);
DeserializedNode& referent = node.getEdgeReferent(*edgep);
edges.infallibleAppend(mozilla::Move(SimpleEdge(name, Node(&referent))));
}

View File

@ -37,18 +37,18 @@ using NodeId = uint64_t;
struct DeserializedEdge {
NodeId referent;
// A borrowed reference to a string owned by this node's owning HeapSnapshot.
const char16_t *name;
const char16_t* name;
explicit DeserializedEdge();
DeserializedEdge(DeserializedEdge &&rhs);
DeserializedEdge &operator=(DeserializedEdge &&rhs);
DeserializedEdge(DeserializedEdge&& rhs);
DeserializedEdge& operator=(DeserializedEdge&& rhs);
// Initialize this `DeserializedEdge` from the given `protobuf::Edge` message.
bool init(const protobuf::Edge &edge, HeapSnapshot &owner);
bool init(const protobuf::Edge& edge, HeapSnapshot& owner);
private:
DeserializedEdge(const DeserializedEdge &) = delete;
DeserializedEdge& operator=(const DeserializedEdge &) = delete;
DeserializedEdge(const DeserializedEdge&) = delete;
DeserializedEdge& operator=(const DeserializedEdge&) = delete;
};
// A `DeserializedNode` is a node in the heap graph that we deserialized from a
@ -59,35 +59,35 @@ struct DeserializedNode {
NodeId id;
// A borrowed reference to a string owned by this node's owning HeapSnapshot.
const char16_t *typeName;
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;
HeapSnapshot* owner;
// Create a new `DeserializedNode` from the given `protobuf::Node` message.
static UniquePtr<DeserializedNode> Create(const protobuf::Node &node,
HeapSnapshot &owner);
static UniquePtr<DeserializedNode> Create(const protobuf::Node& node,
HeapSnapshot& owner);
DeserializedNode(NodeId id,
const char16_t *typeName,
const char16_t* typeName,
uint64_t size,
EdgeVector &&edges,
HeapSnapshot &owner);
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);
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);
DeserializedNode(NodeId id, const char16_t* typeName, uint64_t size);
private:
DeserializedNode(const DeserializedNode &) = delete;
DeserializedNode &operator=(const DeserializedNode &) = delete;
DeserializedNode(const DeserializedNode&) = delete;
DeserializedNode& operator=(const DeserializedNode&) = delete;
};
} // namespace devtools
@ -103,21 +103,21 @@ template<>
struct Concrete<DeserializedNode> : public Base
{
protected:
explicit Concrete(DeserializedNode *ptr) : Base(ptr) { }
DeserializedNode &get() const {
return *static_cast<DeserializedNode *>(ptr);
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) {
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;
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

View File

@ -46,18 +46,18 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(HeapSnapshot)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
/* virtual */ JSObject *
/* virtual */ JSObject*
HeapSnapshot::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return dom::HeapSnapshotBinding::Wrap(aCx, this, aGivenProto);
}
/* static */ already_AddRefed<HeapSnapshot>
HeapSnapshot::Create(JSContext *cx,
dom::GlobalObject &global,
const uint8_t *buffer,
HeapSnapshot::Create(JSContext* cx,
dom::GlobalObject& global,
const uint8_t* buffer,
uint32_t size,
ErrorResult &rv)
ErrorResult& rv)
{
nsRefPtr<HeapSnapshot> snapshot = new HeapSnapshot(cx, global.GetAsSupports());
if (!snapshot->init(buffer, size)) {
@ -69,7 +69,7 @@ HeapSnapshot::Create(JSContext *cx,
template<typename MessageType>
static bool
parseMessage(ZeroCopyInputStream &stream, MessageType &message)
parseMessage(ZeroCopyInputStream& stream, MessageType& message)
{
// We need to create a new `CodedInputStream` for each message so that the
// 64MB limit is applied per-message rather than to the whole stream.
@ -96,7 +96,7 @@ parseMessage(ZeroCopyInputStream &stream, MessageType &message)
}
bool
HeapSnapshot::saveNode(const protobuf::Node &node)
HeapSnapshot::saveNode(const protobuf::Node& node)
{
UniquePtr<DeserializedNode> dn(DeserializedNode::Create(node, *this));
if (!dn)
@ -105,14 +105,14 @@ HeapSnapshot::saveNode(const protobuf::Node &node)
}
static inline bool
StreamHasData(GzipInputStream &stream)
StreamHasData(GzipInputStream& stream)
{
// Test for the end of the stream. The protobuf library gives no way to tell
// the difference between an underlying read error and the stream being
// done. All we can do is attempt to read data and extrapolate guestimations
// from the result of that operation.
const void *buf;
const void* buf;
int size;
bool more = stream.Next(&buf, &size);
if (!more)
@ -128,7 +128,7 @@ StreamHasData(GzipInputStream &stream)
}
bool
HeapSnapshot::init(const uint8_t *buffer, uint32_t size)
HeapSnapshot::init(const uint8_t* buffer, uint32_t size)
{
if (!nodes.init() || !strings.init())
return false;

View File

@ -61,7 +61,7 @@ class HeapSnapshot final : public nsISupports
{
friend struct DeserializedNode;
explicit HeapSnapshot(JSContext *cx, nsISupports *aParent)
explicit HeapSnapshot(JSContext* cx, nsISupports* aParent)
: timestamp(Nothing())
, rootId(0)
, nodes(cx)
@ -74,11 +74,11 @@ class HeapSnapshot final : public nsISupports
// Initialize this HeapSnapshot from the given buffer that contains a
// serialized core dump. Do NOT take ownership of the buffer, only borrow it
// for the duration of the call. Return false on failure.
bool init(const uint8_t *buffer, uint32_t size);
bool init(const uint8_t* buffer, uint32_t size);
// Save the given `protobuf::Node` message in this `HeapSnapshot` as a
// `DeserializedNode`.
bool saveNode(const protobuf::Node &node);
bool saveNode(const protobuf::Node& node);
// If present, a timestamp in the same units that `PR_Now` gives.
Maybe<uint64_t> timestamp;
@ -108,19 +108,19 @@ public:
// Create a `HeapSnapshot` from the given buffer that contains a serialized
// core dump. Do NOT take ownership of the buffer, only borrow it for the
// duration of the call.
static already_AddRefed<HeapSnapshot> Create(JSContext *cx,
dom::GlobalObject &global,
const uint8_t *buffer,
static already_AddRefed<HeapSnapshot> Create(JSContext* cx,
dom::GlobalObject& global,
const uint8_t* buffer,
uint32_t size,
ErrorResult &rv);
ErrorResult& rv);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(HeapSnapshot)
MOZ_DECLARE_REFCOUNTED_TYPENAME(HeapSnapshot)
nsISupports *GetParentObject() const { return mParent; }
nsISupports* GetParentObject() const { return mParent; }
virtual JSObject *WrapObject(JSContext* aCx,
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
const char16_t* borrowUniqueString(const char16_t* duplicateString,

View File

@ -10,7 +10,7 @@
namespace mozilla {
namespace devtools {
ZeroCopyNSIOutputStream::ZeroCopyNSIOutputStream(nsCOMPtr<nsIOutputStream> &out)
ZeroCopyNSIOutputStream::ZeroCopyNSIOutputStream(nsCOMPtr<nsIOutputStream>& out)
: out(out)
, result_(NS_OK)
, amountUsed(0)
@ -57,7 +57,7 @@ ZeroCopyNSIOutputStream::writeBuffer()
// ZeroCopyOutputStream Interface
bool
ZeroCopyNSIOutputStream::Next(void **data, int *size)
ZeroCopyNSIOutputStream::Next(void** data, int* size)
{
MOZ_ASSERT(data != nullptr);
MOZ_ASSERT(size != nullptr);

View File

@ -28,7 +28,7 @@ class MOZ_STACK_CLASS ZeroCopyNSIOutputStream
static const int BUFFER_SIZE = 8192;
// The nsIOutputStream we are streaming to.
nsCOMPtr<nsIOutputStream> &out;
nsCOMPtr<nsIOutputStream>& out;
// The buffer we write data to before passing it to the output stream.
char buffer[BUFFER_SIZE];
@ -48,7 +48,7 @@ class MOZ_STACK_CLASS ZeroCopyNSIOutputStream
nsresult writeBuffer();
public:
explicit ZeroCopyNSIOutputStream(nsCOMPtr<nsIOutputStream> &out);
explicit ZeroCopyNSIOutputStream(nsCOMPtr<nsIOutputStream>& out);
nsresult flush() { return writeBuffer(); }
@ -59,7 +59,7 @@ public:
// ZeroCopyOutputStream Interface
virtual ~ZeroCopyNSIOutputStream() override;
virtual bool Next(void **data, int *size) override;
virtual bool Next(void** data, int* size) override;
virtual void BackUp(int count) override;
virtual ::google::protobuf::int64 ByteCount() const override;
};

View File

@ -17,19 +17,19 @@ using testing::ReturnRef;
// A mock DeserializedNode for testing.
struct MockDeserializedNode : public DeserializedNode
{
MockDeserializedNode(NodeId id, const char16_t *typeName, uint64_t size)
MockDeserializedNode(NodeId id, const char16_t* typeName, uint64_t size)
: DeserializedNode(id, typeName, size)
{ }
bool addEdge(DeserializedEdge &&edge)
bool addEdge(DeserializedEdge&& edge)
{
return edges.append(Move(edge));
}
MOCK_METHOD1(getEdgeReferent, DeserializedNode &(const DeserializedEdge &));
MOCK_METHOD1(getEdgeReferent, DeserializedNode&(const DeserializedEdge&));
};
size_t fakeMallocSizeOf(const void *) {
size_t fakeMallocSizeOf(const void*) {
EXPECT_TRUE(false);
MOZ_ASSERT_UNREACHABLE("fakeMallocSizeOf should never be called because "
"DeserializedNodes report the deserialized size.");
@ -37,13 +37,13 @@ size_t fakeMallocSizeOf(const void *) {
}
DEF_TEST(DeserializedNodeUbiNodes, {
const char16_t *typeName = MOZ_UTF16("TestTypeName");
const char16_t* typeName = MOZ_UTF16("TestTypeName");
NodeId id = 1L << 33;
uint64_t size = 1L << 60;
MockDeserializedNode mocked(id, typeName, size);
DeserializedNode &deserialized = mocked;
DeserializedNode& deserialized = mocked;
JS::ubi::Node ubi(&deserialized);
// Test the ubi::Node accessors.

View File

@ -26,10 +26,10 @@ using namespace testing;
// GTest fixture class that all of our tests derive from.
struct DevTools : public ::testing::Test {
bool _initialized;
JSRuntime *rt;
JSContext *cx;
JSCompartment *compartment;
JS::Zone *zone;
JSRuntime* rt;
JSContext* cx;
JSCompartment* compartment;
JS::Zone* zone;
JS::PersistentRootedObject global;
DevTools()
@ -65,7 +65,7 @@ struct DevTools : public ::testing::Test {
return CycleCollectedJSRuntime::Get()->Runtime();
}
static void setNativeStackQuota(JSRuntime *rt)
static void setNativeStackQuota(JSRuntime* rt)
{
const size_t MAX_STACK_SIZE =
/* Assume we can't use more than 5e5 bytes of C stack by default. */
@ -83,18 +83,18 @@ struct DevTools : public ::testing::Test {
JS_SetNativeStackQuota(rt, MAX_STACK_SIZE);
}
static void reportError(JSContext *cx, const char *message, JSErrorReport *report) {
static void reportError(JSContext* cx, const char* message, JSErrorReport* report) {
fprintf(stderr, "%s:%u:%s\n",
report->filename ? report->filename : "<no filename>",
(unsigned int) report->lineno,
message);
}
JSContext *createContext() {
JSContext* createContext() {
return JS_NewContext(rt, 8192);
}
static const JSClass *getGlobalClass() {
static const JSClass* getGlobalClass() {
static const JSClass globalClass = {
"global", JSCLASS_GLOBAL_FLAGS,
nullptr, nullptr, nullptr, nullptr,
@ -105,7 +105,7 @@ struct DevTools : public ::testing::Test {
return &globalClass;
}
JSObject *createGlobal()
JSObject* createGlobal()
{
/* Create the global object. */
JS::RootedObject newGlobal(cx);
@ -151,7 +151,6 @@ struct DevTools : public ::testing::Test {
// Fake JS::ubi::Node implementation
class MOZ_STACK_CLASS FakeNode
{
public:
@ -212,8 +211,8 @@ const char16_t Concrete<FakeNode>::concreteTypeName[] = MOZ_UTF16("FakeNode");
} // namespace ubi
} // namespace JS
void AddEdge(FakeNode &node, FakeNode &referent, const char16_t *edgeName = nullptr) {
char16_t *ownedEdgeName = nullptr;
void AddEdge(FakeNode& node, FakeNode& referent, const char16_t* edgeName = nullptr) {
char16_t* ownedEdgeName = nullptr;
if (edgeName) {
ownedEdgeName = NS_strdup(edgeName);
ASSERT_NE(ownedEdgeName, nullptr);
@ -253,7 +252,7 @@ MATCHER_P3(Edge, cx, n, matcher, "") {
int i = 0;
for ( ; !edges->empty(); edges->popFront()) {
if (i == n) {
return Matcher<const JS::ubi::Edge &>(matcher)
return Matcher<const JS::ubi::Edge&>(matcher)
.MatchAndExplain(edges->front(), result_listener);
}
@ -276,11 +275,11 @@ class MockWriter : public CoreDumpWriter
{
public:
virtual ~MockWriter() override { }
MOCK_METHOD2(writeNode, bool(const JS::ubi::Node &, CoreDumpWriter::EdgePolicy));
MOCK_METHOD2(writeNode, bool(const JS::ubi::Node&, CoreDumpWriter::EdgePolicy));
MOCK_METHOD1(writeMetadata, bool(uint64_t));
};
void ExpectWriteNode(MockWriter &writer, FakeNode &node) {
void ExpectWriteNode(MockWriter& writer, FakeNode& node) {
EXPECT_CALL(writer, writeNode(Eq(JS::ubi::Node(&node)), _))
.Times(1)
.WillOnce(Return(true));

View File

@ -14,7 +14,7 @@ DEF_TEST(DoesCrossZoneBoundaries, {
nullptr,
JS::FireOnNewGlobalHook));
ASSERT_TRUE(newGlobal);
JS::Zone *newZone = nullptr;
JS::Zone* newZone = nullptr;
{
JSAutoCompartment ac(cx, newGlobal);
ASSERT_TRUE(JS_InitStandardClasses(cx, newGlobal));

View File

@ -14,7 +14,7 @@ DEF_TEST(DoesntCrossZoneBoundaries, {
nullptr,
JS::FireOnNewGlobalHook));
ASSERT_TRUE(newGlobal);
JS::Zone *newZone = nullptr;
JS::Zone* newZone = nullptr;
{
JSAutoCompartment ac(cx, newGlobal);
ASSERT_TRUE(JS_InitStandardClasses(cx, newGlobal));