Backed out changeset 2620e5ba1067 (bug 1282795) for 'Concrete' redeclaration in HeapSnapshot.h (static failure). r=backout

This commit is contained in:
Sebastian Hengst 2016-07-07 19:26:27 +02:00
parent ccddc5c404
commit cfa0d595fb
10 changed files with 115 additions and 120 deletions

View File

@ -244,7 +244,7 @@ using mozilla::devtools::DeserializedNode;
using mozilla::devtools::DeserializedStackFrame; using mozilla::devtools::DeserializedStackFrame;
template<> template<>
class Concrete<DeserializedNode> : public Base struct Concrete<DeserializedNode> : public Base
{ {
protected: protected:
explicit Concrete(DeserializedNode* ptr) : Base(ptr) { } explicit Concrete(DeserializedNode* ptr) : Base(ptr) { }
@ -253,6 +253,8 @@ protected:
} }
public: public:
static const char16_t concreteTypeName[];
static void construct(void* storage, DeserializedNode* ptr) { static void construct(void* storage, DeserializedNode* ptr) {
new (storage) Concrete(ptr); new (storage) Concrete(ptr);
} }
@ -271,8 +273,6 @@ public:
// We ignore the `bool wantNames` parameter because we can't control whether // We ignore the `bool wantNames` parameter because we can't control whether
// the core dump was serialized with edge names or not. // the core dump was serialized with edge names or not.
js::UniquePtr<EdgeRange> edges(JSRuntime* rt, bool) const override; js::UniquePtr<EdgeRange> edges(JSRuntime* rt, bool) const override;
static const char16_t concreteTypeName[];
}; };
template<> template<>

View File

@ -641,28 +641,28 @@ class Base {
}; };
// A traits template with a specialization for each referent type that // A traits template with a specialization for each referent type that
// ubi::Node supports. The specialization must be the concrete subclass of Base // ubi::Node supports. The specialization must be the concrete subclass of
// that represents a pointer to the referent type. It must include these // Base that represents a pointer to the referent type. It must also
// members: // include the members described here.
//
// // The specific char16_t array returned by Concrete<T>::typeName().
// static const char16_t concreteTypeName[];
//
// // Construct an instance of this concrete class in |storage| referring
// // to |referent|. Implementations typically use a placement 'new'.
// //
// // In some cases, |referent| will contain dynamic type information that
// // identifies it a some more specific subclass of |Referent|. For
// // example, when |Referent| is |JSObject|, then |referent->getClass()|
// // could tell us that it's actually a JSFunction. Similarly, if
// // |Referent| is |nsISupports|, we would like a ubi::Node that knows its
// // final implementation type.
// //
// // So we delegate the actual construction to this specialization, which
// // knows Referent's details.
// static void construct(void* storage, Referent* referent);
template<typename Referent> template<typename Referent>
class Concrete; struct Concrete {
// The specific char16_t array returned by Concrete<T>::typeName.
static const char16_t concreteTypeName[];
// Construct an instance of this concrete class in |storage| referring
// to |referent|. Implementations typically use a placement 'new'.
//
// In some cases, |referent| will contain dynamic type information that
// identifies it a some more specific subclass of |Referent|. For example,
// when |Referent| is |JSObject|, then |referent->getClass()| could tell us
// that it's actually a JSFunction. Similarly, if |Referent| is
// |nsISupports|, we would like a ubi::Node that knows its final
// implementation type.
//
// So, we delegate the actual construction to this specialization, which
// knows Referent's details.
static void construct(void* storage, Referent* referent);
};
// A container for a Base instance; all members simply forward to the contained // A container for a Base instance; all members simply forward to the contained
// instance. This container allows us to pass ubi::Node instances by value. // instance. This container allows us to pass ubi::Node instances by value.
@ -994,24 +994,24 @@ class MOZ_STACK_CLASS RootList {
/*** Concrete classes for ubi::Node referent types ************************************************/ /*** Concrete classes for ubi::Node referent types ************************************************/
template<> template<>
class Concrete<RootList> : public Base { struct Concrete<RootList> : public Base {
js::UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override;
const char16_t* typeName() const override { return concreteTypeName; }
protected: protected:
explicit Concrete(RootList* ptr) : Base(ptr) { } explicit Concrete(RootList* ptr) : Base(ptr) { }
RootList& get() const { return *static_cast<RootList*>(ptr); } RootList& get() const { return *static_cast<RootList*>(ptr); }
public: public:
static void construct(void* storage, RootList* ptr) { new (storage) Concrete(ptr); }
js::UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override;
const char16_t* typeName() const override { return concreteTypeName; }
static const char16_t concreteTypeName[]; static const char16_t concreteTypeName[];
static void construct(void* storage, RootList* ptr) { new (storage) Concrete(ptr); }
}; };
// A reusable ubi::Concrete specialization base class for types supported by // A reusable ubi::Concrete specialization base class for types supported by
// JS::TraceChildren. // JS::TraceChildren.
template<typename Referent> template<typename Referent>
class TracerConcrete : public Base { class TracerConcrete : public Base {
const char16_t* typeName() const override { return concreteTypeName; }
js::UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override; js::UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override;
JS::Zone* zone() const override; JS::Zone* zone() const override;
@ -1020,6 +1020,7 @@ class TracerConcrete : public Base {
Referent& get() const { return *static_cast<Referent*>(ptr); } Referent& get() const { return *static_cast<Referent*>(ptr); }
public: public:
static const char16_t concreteTypeName[];
static void construct(void* storage, Referent* ptr) { new (storage) TracerConcrete(ptr); } static void construct(void* storage, Referent* ptr) { new (storage) TracerConcrete(ptr); }
}; };
@ -1041,7 +1042,9 @@ class TracerConcreteWithCompartment : public TracerConcrete<Referent> {
// Define specializations for some commonly-used public JSAPI types. // Define specializations for some commonly-used public JSAPI types.
// These can use the generic templates above. // These can use the generic templates above.
template<> template<>
class Concrete<JS::Symbol> : TracerConcrete<JS::Symbol> { struct Concrete<JS::Symbol> : TracerConcrete<JS::Symbol> {
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
protected: protected:
explicit Concrete(JS::Symbol* ptr) : TracerConcrete(ptr) { } explicit Concrete(JS::Symbol* ptr) : TracerConcrete(ptr) { }
@ -1049,40 +1052,23 @@ class Concrete<JS::Symbol> : TracerConcrete<JS::Symbol> {
static void construct(void* storage, JS::Symbol* ptr) { static void construct(void* storage, JS::Symbol* ptr) {
new (storage) Concrete(ptr); new (storage) Concrete(ptr);
} }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
const char16_t* typeName() const override { return concreteTypeName; }
static const char16_t concreteTypeName[];
}; };
template<> template<> struct Concrete<JSScript> : TracerConcreteWithCompartment<JSScript> {
class Concrete<JSScript> : TracerConcreteWithCompartment<JSScript> { CoarseType coarseType() const final { return CoarseType::Script; }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
const char* scriptFilename() const final;
protected: protected:
explicit Concrete(JSScript *ptr) : TracerConcreteWithCompartment<JSScript>(ptr) { } explicit Concrete(JSScript *ptr) : TracerConcreteWithCompartment<JSScript>(ptr) { }
public: public:
static void construct(void *storage, JSScript *ptr) { new (storage) Concrete(ptr); } static void construct(void *storage, JSScript *ptr) { new (storage) Concrete(ptr); }
CoarseType coarseType() const final { return CoarseType::Script; }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
const char* scriptFilename() const final;
const char16_t* typeName() const override { return concreteTypeName; }
static const char16_t concreteTypeName[];
}; };
// The JSObject specialization. // The JSObject specialization.
template<> template<>
class Concrete<JSObject> : public TracerConcreteWithCompartment<JSObject> { class Concrete<JSObject> : public TracerConcreteWithCompartment<JSObject> {
protected:
explicit Concrete(JSObject* ptr) : TracerConcreteWithCompartment(ptr) { }
public:
static void construct(void* storage, JSObject* ptr) {
new (storage) Concrete(ptr);
}
const char* jsObjectClassName() const override; const char* jsObjectClassName() const override;
MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName) MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName)
const override; const override;
@ -1093,25 +1079,26 @@ class Concrete<JSObject> : public TracerConcreteWithCompartment<JSObject> {
CoarseType coarseType() const final { return CoarseType::Object; } CoarseType coarseType() const final { return CoarseType::Object; }
const char16_t* typeName() const override { return concreteTypeName; } protected:
static const char16_t concreteTypeName[]; explicit Concrete(JSObject* ptr) : TracerConcreteWithCompartment(ptr) { }
public:
static void construct(void* storage, JSObject* ptr) {
new (storage) Concrete(ptr);
}
}; };
// For JSString, we extend the generic template with a 'size' implementation. // For JSString, we extend the generic template with a 'size' implementation.
template<> template<> struct Concrete<JSString> : TracerConcrete<JSString> {
class Concrete<JSString> : TracerConcrete<JSString> { Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
CoarseType coarseType() const final { return CoarseType::String; }
protected: protected:
explicit Concrete(JSString *ptr) : TracerConcrete<JSString>(ptr) { } explicit Concrete(JSString *ptr) : TracerConcrete<JSString>(ptr) { }
public: public:
static void construct(void *storage, JSString *ptr) { new (storage) Concrete(ptr); } static void construct(void *storage, JSString *ptr) { new (storage) Concrete(ptr); }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
CoarseType coarseType() const final { return CoarseType::String; }
const char16_t* typeName() const override { return concreteTypeName; }
static const char16_t concreteTypeName[];
}; };
// The ubi::Node null pointer. Any attempt to operate on a null ubi::Node asserts. // The ubi::Node null pointer. Any attempt to operate on a null ubi::Node asserts.
@ -1128,6 +1115,7 @@ class Concrete<void> : public Base {
public: public:
static void construct(void* storage, void* ptr) { new (storage) Concrete(ptr); } static void construct(void* storage, void* ptr) { new (storage) Concrete(ptr); }
static const char16_t concreteTypeName[];
}; };

View File

@ -788,13 +788,7 @@ IsMarked(const jit::VMFunction*)
namespace JS { namespace JS {
namespace ubi { namespace ubi {
template<> template<>
class Concrete<js::jit::JitCode> : TracerConcrete<js::jit::JitCode> { struct Concrete<js::jit::JitCode> : TracerConcrete<js::jit::JitCode> {
protected:
explicit Concrete(js::jit::JitCode *ptr) : TracerConcrete<js::jit::JitCode>(ptr) { }
public:
static void construct(void *storage, js::jit::JitCode *ptr) { new (storage) Concrete(ptr); }
CoarseType coarseType() const final { return CoarseType::Script; } CoarseType coarseType() const final { return CoarseType::Script; }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override { Size size(mozilla::MallocSizeOf mallocSizeOf) const override {
@ -804,8 +798,11 @@ class Concrete<js::jit::JitCode> : TracerConcrete<js::jit::JitCode> {
return size; return size;
} }
const char16_t* typeName() const override { return concreteTypeName; } protected:
static const char16_t concreteTypeName[]; explicit Concrete(js::jit::JitCode *ptr) : TracerConcrete<js::jit::JitCode>(ptr) { }
public:
static void construct(void *storage, js::jit::JitCode *ptr) { new (storage) Concrete(ptr); }
}; };
} // namespace ubi } // namespace ubi

View File

@ -41,14 +41,10 @@ namespace JS {
namespace ubi { namespace ubi {
template<> template<>
class Concrete<FakeNode> : public Base struct Concrete<FakeNode> : public Base
{ {
protected: static const char16_t concreteTypeName[];
explicit Concrete(FakeNode* ptr) : Base(ptr) { } const char16_t* typeName() const override { return concreteTypeName; }
FakeNode& get() const { return *static_cast<FakeNode*>(ptr); }
public:
static void construct(void* storage, FakeNode* ptr) { new (storage) Concrete(ptr); }
UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override { UniquePtr<EdgeRange> edges(JSRuntime* rt, bool wantNames) const override {
return UniquePtr<EdgeRange>(js_new<PreComputedEdgeRange>(get().edges)); return UniquePtr<EdgeRange>(js_new<PreComputedEdgeRange>(get().edges));
@ -58,8 +54,11 @@ class Concrete<FakeNode> : public Base
return 1; return 1;
} }
static const char16_t concreteTypeName[]; static void construct(void* storage, FakeNode* ptr) { new (storage) Concrete(ptr); }
const char16_t* typeName() const override { return concreteTypeName; }
protected:
explicit Concrete(FakeNode* ptr) : Base(ptr) { }
FakeNode& get() const { return *static_cast<FakeNode*>(ptr); }
}; };
const char16_t Concrete<FakeNode>::concreteTypeName[] = MOZ_UTF16("FakeNode"); const char16_t Concrete<FakeNode>::concreteTypeName[] = MOZ_UTF16("FakeNode");

View File

@ -3831,7 +3831,8 @@ JS::ubi::Concrete<JSObject>::size(mozilla::MallocSizeOf mallocSizeOf) const
return obj.tenuredSizeOfThis() + info.sizeOfAllThings(); return obj.tenuredSizeOfThis() + info.sizeOfAllThings();
} }
const char16_t JS::ubi::Concrete<JSObject>::concreteTypeName[] = MOZ_UTF16("JSObject"); template<> const char16_t JS::ubi::TracerConcrete<JSObject>::concreteTypeName[] =
MOZ_UTF16("JSObject");
void void
JSObject::traceChildren(JSTracer* trc) JSObject::traceChildren(JSTracer* trc)

View File

@ -2552,19 +2552,16 @@ CloneGlobalScript(JSContext* cx, Handle<StaticScope*> enclosingScope, HandleScri
namespace JS { namespace JS {
namespace ubi { namespace ubi {
template<> template<>
class Concrete<js::LazyScript> : TracerConcrete<js::LazyScript> { struct Concrete<js::LazyScript> : TracerConcrete<js::LazyScript> {
CoarseType coarseType() const final { return CoarseType::Script; }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
const char* scriptFilename() const final;
protected: protected:
explicit Concrete(js::LazyScript *ptr) : TracerConcrete<js::LazyScript>(ptr) { } explicit Concrete(js::LazyScript *ptr) : TracerConcrete<js::LazyScript>(ptr) { }
public: public:
static void construct(void *storage, js::LazyScript *ptr) { new (storage) Concrete(ptr); } static void construct(void *storage, js::LazyScript *ptr) { new (storage) Concrete(ptr); }
CoarseType coarseType() const final { return CoarseType::Script; }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
const char* scriptFilename() const final;
const char16_t* typeName() const override { return concreteTypeName; }
static const char16_t concreteTypeName[];
}; };
} // namespace ubi } // namespace ubi
} // namespace JS } // namespace JS

View File

@ -538,7 +538,7 @@ class Shape : public gc::TenuredCell
friend class TenuringTracer; friend class TenuringTracer;
friend struct StackBaseShape; friend struct StackBaseShape;
friend struct StackShape; friend struct StackShape;
friend class JS::ubi::Concrete<Shape>; friend struct JS::ubi::Concrete<Shape>;
friend class js::gc::RelocationOverlay; friend class js::gc::RelocationOverlay;
protected: protected:
@ -1459,32 +1459,24 @@ ReshapeForAllocKind(JSContext* cx, Shape* shape, TaggedProto proto,
namespace JS { namespace JS {
namespace ubi { namespace ubi {
template<> template<> struct Concrete<js::Shape> : TracerConcreteWithCompartment<js::Shape> {
class Concrete<js::Shape> : TracerConcreteWithCompartment<js::Shape> { Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
protected: protected:
explicit Concrete(js::Shape *ptr) : TracerConcreteWithCompartment<js::Shape>(ptr) { } explicit Concrete(js::Shape *ptr) : TracerConcreteWithCompartment<js::Shape>(ptr) { }
public: public:
static void construct(void *storage, js::Shape *ptr) { new (storage) Concrete(ptr); } static void construct(void *storage, js::Shape *ptr) { new (storage) Concrete(ptr); }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
const char16_t* typeName() const override { return concreteTypeName; }
static const char16_t concreteTypeName[];
}; };
template<> template<> struct Concrete<js::BaseShape> : TracerConcreteWithCompartment<js::BaseShape> {
class Concrete<js::BaseShape> : TracerConcreteWithCompartment<js::BaseShape> { Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
protected: protected:
explicit Concrete(js::BaseShape *ptr) : TracerConcreteWithCompartment<js::BaseShape>(ptr) { } explicit Concrete(js::BaseShape *ptr) : TracerConcreteWithCompartment<js::BaseShape>(ptr) { }
public: public:
static void construct(void *storage, js::BaseShape *ptr) { new (storage) Concrete(ptr); } static void construct(void *storage, js::BaseShape *ptr) { new (storage) Concrete(ptr); }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
const char16_t* typeName() const override { return concreteTypeName; }
static const char16_t concreteTypeName[];
}; };
} // namespace ubi } // namespace ubi

View File

@ -82,7 +82,8 @@ JS::ubi::Concrete<JSString>::size(mozilla::MallocSizeOf mallocSizeOf) const
return size; return size;
} }
const char16_t JS::ubi::Concrete<JSString>::concreteTypeName[] = MOZ_UTF16("JSString"); template<> const char16_t JS::ubi::TracerConcrete<JSString>::concreteTypeName[] =
MOZ_UTF16("JSString");
#ifdef DEBUG #ifdef DEBUG

View File

@ -1325,17 +1325,14 @@ namespace JS {
namespace ubi { namespace ubi {
template<> template<>
class Concrete<js::ObjectGroup> : TracerConcrete<js::ObjectGroup> { struct Concrete<js::ObjectGroup> : TracerConcrete<js::ObjectGroup> {
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
protected: protected:
explicit Concrete(js::ObjectGroup *ptr) : TracerConcrete<js::ObjectGroup>(ptr) { } explicit Concrete(js::ObjectGroup *ptr) : TracerConcrete<js::ObjectGroup>(ptr) { }
public: public:
static void construct(void *storage, js::ObjectGroup *ptr) { new (storage) Concrete(ptr); } static void construct(void *storage, js::ObjectGroup *ptr) { new (storage) Concrete(ptr); }
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
const char16_t* typeName() const override { return concreteTypeName; }
static const char16_t concreteTypeName[];
}; };
} // namespace ubi } // namespace ubi

View File

@ -371,15 +371,38 @@ Concrete<JSObject>::jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& o
return true; return true;
} }
const char16_t Concrete<JS::Symbol>::concreteTypeName[] = MOZ_UTF16("JS::Symbol"); template<> const char16_t TracerConcrete<JS::Symbol>::concreteTypeName[] =
const char16_t Concrete<JSScript>::concreteTypeName[] = MOZ_UTF16("JSScript"); MOZ_UTF16("JS::Symbol");
const char16_t Concrete<js::LazyScript>::concreteTypeName[] = MOZ_UTF16("js::LazyScript"); template<> const char16_t TracerConcrete<JSScript>::concreteTypeName[] =
const char16_t Concrete<js::jit::JitCode>::concreteTypeName[] = MOZ_UTF16("js::jit::JitCode"); MOZ_UTF16("JSScript");
const char16_t Concrete<js::Shape>::concreteTypeName[] = MOZ_UTF16("js::Shape"); template<> const char16_t TracerConcrete<js::LazyScript>::concreteTypeName[] =
const char16_t Concrete<js::BaseShape>::concreteTypeName[] = MOZ_UTF16("js::BaseShape"); MOZ_UTF16("js::LazyScript");
const char16_t Concrete<js::ObjectGroup>::concreteTypeName[] = MOZ_UTF16("js::ObjectGroup"); template<> const char16_t TracerConcrete<js::jit::JitCode>::concreteTypeName[] =
MOZ_UTF16("js::jit::JitCode");
template<> const char16_t TracerConcrete<js::Shape>::concreteTypeName[] =
MOZ_UTF16("js::Shape");
template<> const char16_t TracerConcrete<js::BaseShape>::concreteTypeName[] =
MOZ_UTF16("js::BaseShape");
template<> const char16_t TracerConcrete<js::ObjectGroup>::concreteTypeName[] =
MOZ_UTF16("js::ObjectGroup");
// Instantiate all the TracerConcrete and templates here, where
// we have the member functions' definitions in scope.
namespace JS {
namespace ubi {
template class TracerConcreteWithCompartment<JSObject>;
template class TracerConcrete<JSString>;
template class TracerConcrete<JS::Symbol>;
template class TracerConcreteWithCompartment<JSScript>;
template class TracerConcrete<js::LazyScript>;
template class TracerConcrete<js::jit::JitCode>;
template class TracerConcreteWithCompartment<js::Shape>;
template class TracerConcreteWithCompartment<js::BaseShape>;
template class TracerConcrete<js::ObjectGroup>;
} // namespace ubi
} // namespace JS
namespace JS { namespace JS {
namespace ubi { namespace ubi {