Bug 1075564: Give JS::ubi::Node its implicit constructor back, with the right annotation this time. r=luke
authorJim Blandy <jimb@mozilla.com>
Thu, 02 Oct 2014 10:19:10 +0100
changeset 208372 c70ca7e5474135b799f0bc26f5d8ff9c66faaf1b
parent 208371 4bff4b0ed99cc3d43745515b3a4716856312072f
child 208373 a59c2ddcf04cae9dc2e3a7702c8703b7430c3ff3
push id49907
push userjblandy@mozilla.com
push dateThu, 02 Oct 2014 09:19:55 +0000
treeherdermozilla-inbound@a59c2ddcf04c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1075564
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1075564: Give JS::ubi::Node its implicit constructor back, with the right annotation this time. r=luke
js/public/UbiNode.h
js/src/builtin/TestingFunctions.cpp
--- a/js/public/UbiNode.h
+++ b/js/public/UbiNode.h
@@ -269,17 +269,20 @@ class Node {
     }
     template<typename T>
     Node &operator=(const Rooted<T *> &root) {
         construct(root.get());
         return *this;
     }
 
     // Constructors accepting SpiderMonkey's other generic-pointer-ish types.
-    explicit Node(JS::HandleValue value);
+    // Note that we *do* want an implicit constructor here: JS::Value and
+    // JS::ubi::Node are both essentially tagged references to other sorts of
+    // objects, so letting conversions happen automatically is appropriate.
+    MOZ_IMPLICIT Node(JS::HandleValue value);
     Node(JSGCTraceKind kind, void *ptr);
 
     // copy construction and copy assignment just use memcpy, since we know
     // instances contain nothing but a vtable pointer and a data pointer.
     //
     // To be completely correct, concrete classes could provide a virtual
     // 'construct' member function, which we could invoke on rhs to construct an
     // instance in our storage. But this is good enough; there's no need to jump
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -2064,17 +2064,17 @@ IsSimdAvailable(JSContext *cx, unsigned 
     return true;
 }
 
 static bool
 ByteSize(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     mozilla::MallocSizeOf mallocSizeOf = cx->runtime()->debuggerMallocSizeOf;
-    JS::ubi::Node node(args.get(0));
+    JS::ubi::Node node = args.get(0);
     if (node)
         args.rval().set(NumberValue(node.size(mallocSizeOf)));
     else
         args.rval().setUndefined();
     return true;
 }
 
 static const JSFunctionSpecWithHelp TestingFunctions[] = {