Backout 73d2c854d770 (Bug 1182124) for being on top of a suspected regression.
authorTerrence Cole <terrence@mozilla.com>
Fri, 17 Jul 2015 14:02:46 -0700
changeset 253531 d86fa46b62b8b35406fef4b014eb3d76ec73ec61
parent 253530 71541c64c605ddf0463ab356c837dfc4e5e203cb
child 253532 b3d242f2cf2c5fb2969df773d7c1af3f32c1a74e
push id62472
push usertcole@mozilla.com
push dateFri, 17 Jul 2015 22:52:01 +0000
treeherdermozilla-inbound@b3d242f2cf2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1182124
milestone42.0a1
backs out73d2c854d7703ee94c0d0ddbc71cfb947648cd15
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
Backout 73d2c854d770 (Bug 1182124) for being on top of a suspected regression.
js/public/RootingAPI.h
js/src/builtin/SIMD.cpp
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -504,16 +504,79 @@ class MOZ_STACK_CLASS MutableHandle : pu
     T* ptr;
 };
 
 } /* namespace JS */
 
 namespace js {
 
 /*
+ * InternalHandle is a handle to an internal pointer into a gcthing. Use
+ * InternalHandle when you have a pointer to a direct field of a gcthing, or
+ * when you need a parameter type for something that *may* be a pointer to a
+ * direct field of a gcthing.
+ */
+template <typename T>
+class InternalHandle {};
+
+template <typename T>
+class InternalHandle<T*>
+{
+    void * const* holder;
+    size_t offset;
+
+  public:
+    /*
+     * Create an InternalHandle using a Handle to the gcthing containing the
+     * field in question, and a pointer to the field.
+     */
+    template<typename H>
+    InternalHandle(const JS::Handle<H>& handle, T* field)
+      : holder((void**)handle.address()), offset(uintptr_t(field) - uintptr_t(handle.get()))
+    {}
+
+    /*
+     * Create an InternalHandle to a field within a Rooted<>.
+     */
+    template<typename R>
+    InternalHandle(const JS::Rooted<R>& root, T* field)
+      : holder((void**)root.address()), offset(uintptr_t(field) - uintptr_t(root.get()))
+    {}
+
+    InternalHandle(const InternalHandle<T*>& other)
+      : holder(other.holder), offset(other.offset) {}
+
+    T* get() const { return reinterpret_cast<T*>(uintptr_t(*holder) + offset); }
+
+    const T& operator*() const { return *get(); }
+    T* operator->() const { return get(); }
+
+    static InternalHandle<T*> fromMarkedLocation(T* fieldPtr) {
+        return InternalHandle(fieldPtr);
+    }
+
+  private:
+    /*
+     * Create an InternalHandle to something that is not a pointer to a
+     * gcthing, and so does not need to be rooted in the first place. Use these
+     * InternalHandles to pass pointers into functions that also need to accept
+     * regular InternalHandles to gcthing fields.
+     *
+     * Make this private to prevent accidental misuse; this is only for
+     * fromMarkedLocation().
+     */
+    explicit InternalHandle(T* field)
+      : holder(&js::ConstNullValue),
+        offset(uintptr_t(field))
+    {}
+
+    void operator=(InternalHandle<T*> other) = delete;
+};
+
+/*
  * By default, things should use the inheritance hierarchy to find their
  * ThingRootKind. Some pointer types are explicitly set in jspubtd.h so that
  * Rooted<T> may be used without the class definition being available.
  */
 template <typename T>
 struct RootKind
 {
     static ThingRootKind rootKind() { return T::rootKind(); }
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -411,21 +411,22 @@ CreateAndBindSimdClass(JSContext* cx, Ha
     return typeDescr;
 }
 
 template <typename T>
 static bool
 FillLanes(JSContext* cx, Handle<TypedObject*> result, const CallArgs& args)
 {
     typedef typename T::Elem Elem;
+    InternalHandle<Elem*> mem(result, reinterpret_cast<Elem*>(result->typedMem()));
     Elem tmp;
     for (unsigned i = 0; i < T::lanes; i++) {
         if (!T::toType(cx, args.get(i), &tmp))
             return false;
-        reinterpret_cast<Elem*>(result->typedMem())[i] = tmp;
+        mem.get()[i] = tmp;
     }
     args.rval().setObject(*result);
     return true;
 }
 
 bool
 SimdTypeDescr::call(JSContext* cx, unsigned argc, Value* vp)
 {