Bug 1182124 - Remove InternalHandle and its last use; r=bbouvier

This commit is contained in:
Terrence Cole 2015-07-09 13:35:01 -07:00
Родитель 7e782d20f9
Коммит 36fc415b4f
2 изменённых файлов: 1 добавлений и 65 удалений

Просмотреть файл

@ -508,69 +508,6 @@ class MOZ_STACK_CLASS MutableHandle : public js::MutableHandleBase<T>
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

Просмотреть файл

@ -416,12 +416,11 @@ 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;
mem.get()[i] = tmp;
reinterpret_cast<Elem*>(result->typedMem())[i] = tmp;
}
args.rval().setObject(*result);
return true;