From 24bff230a902a486dc3f9c6e96baff2d447d3a84 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 19 Sep 2014 15:10:01 -0700 Subject: [PATCH] Bug 1063247: Amend JS::ubi::Node::size and its implementations to expect a mozilla::MallocSizeOf function. r=terrence Note that JS::ubi::Node::size has no callers at present, so we can change its type without changing any callers. --- js/public/UbiNode.h | 13 ++++++++++--- js/src/vm/UbiNode.cpp | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/js/public/UbiNode.h b/js/public/UbiNode.h index 49b787fad584..ae5144038fc1 100644 --- a/js/public/UbiNode.h +++ b/js/public/UbiNode.h @@ -10,6 +10,7 @@ #include "mozilla/Alignment.h" #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "jspubtd.h" @@ -178,7 +179,9 @@ class Base { // Return the size of this node, in bytes. Include any structures that this // node owns exclusively that are not exposed as their own ubi::Nodes. - virtual size_t size() const { return 0; } + // |mallocSizeOf| should be a malloc block sizing function; see + // |mfbt/MemoryReporting.h. + virtual size_t size(mozilla::MallocSizeOf mallocSizeof) const { return 0; } // Return an EdgeRange that initially contains all the referent's outgoing // edges. The EdgeRange should be freed with 'js_delete'. (You could use @@ -321,9 +324,13 @@ class Node { JS::Value exposeToJS() const; const char16_t *typeName() const { return base()->typeName(); } - size_t size() const { return base()->size(); } JS::Zone *zone() const { return base()->zone(); } JSCompartment *compartment() const { return base()->compartment(); } + + size_t size(mozilla::MallocSizeOf mallocSizeof) const { + return base()->size(mallocSizeof); + } + EdgeRange *edges(JSContext *cx, bool wantNames = true) const { return base()->edges(cx, wantNames); } @@ -455,7 +462,7 @@ template<> struct Concrete : TracerConcreteWithCompartment { template<> class Concrete : public Base { const char16_t *typeName() const MOZ_OVERRIDE; - size_t size() const MOZ_OVERRIDE; + size_t size(mozilla::MallocSizeOf mallocSizeOf) const MOZ_OVERRIDE; EdgeRange *edges(JSContext *cx, bool wantNames) const MOZ_OVERRIDE; JS::Zone *zone() const MOZ_OVERRIDE; JSCompartment *compartment() const MOZ_OVERRIDE; diff --git a/js/src/vm/UbiNode.cpp b/js/src/vm/UbiNode.cpp index dcef624ccaa7..ea38d70409b7 100644 --- a/js/src/vm/UbiNode.cpp +++ b/js/src/vm/UbiNode.cpp @@ -37,11 +37,16 @@ using JS::ubi::TracerConcreteWithCompartment; // All operations on null ubi::Nodes crash. const char16_t *Concrete::typeName() const { MOZ_CRASH("null ubi::Node"); } -size_t Concrete::size() const { MOZ_CRASH("null ubi::Node"); } EdgeRange *Concrete::edges(JSContext *, bool) const { MOZ_CRASH("null ubi::Node"); } JS::Zone *Concrete::zone() const { MOZ_CRASH("null ubi::Node"); } JSCompartment *Concrete::compartment() const { MOZ_CRASH("null ubi::Node"); } +size_t +Concrete::size(mozilla::MallocSizeOf mallocSizeof) const +{ + MOZ_CRASH("null ubi::Node"); +} + Node::Node(JSGCTraceKind kind, void *ptr) { switch (kind) {