зеркало из https://github.com/mozilla/gecko-dev.git
Bug 898356 Part 7 -- Rename TypedObject/TypedHandle to TransparentTypedObject/OpaqueTypedObject r=sfink
This commit is contained in:
Родитель
e6a9cbc55d
Коммит
f652ca5c39
|
@ -239,7 +239,7 @@ const Class UnsizedArrayTypeDescr::class_ = {
|
|||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
TypedObject::constructUnsized,
|
||||
TypedDatum::constructUnsized,
|
||||
nullptr
|
||||
};
|
||||
|
||||
|
@ -256,7 +256,7 @@ const Class SizedArrayTypeDescr::class_ = {
|
|||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
TypedObject::constructSized,
|
||||
TypedDatum::constructSized,
|
||||
nullptr
|
||||
};
|
||||
|
||||
|
@ -545,7 +545,7 @@ const Class StructTypeDescr::class_ = {
|
|||
nullptr, /* finalize */
|
||||
nullptr, /* call */
|
||||
nullptr, /* hasInstance */
|
||||
TypedObject::constructSized,
|
||||
TypedDatum::constructSized,
|
||||
nullptr /* trace */
|
||||
};
|
||||
|
||||
|
@ -1150,9 +1150,9 @@ TypedDatum::createUnattached(JSContext *cx,
|
|||
int32_t length)
|
||||
{
|
||||
if (descr->opaque())
|
||||
return createUnattachedWithClass(cx, &TypedHandle::class_, descr, length);
|
||||
return createUnattachedWithClass(cx, &OpaqueTypedObject::class_, descr, length);
|
||||
else
|
||||
return createUnattachedWithClass(cx, &TypedObject::class_, descr, length);
|
||||
return createUnattachedWithClass(cx, &TransparentTypedObject::class_, descr, length);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1162,7 +1162,8 @@ TypedDatum::createUnattachedWithClass(JSContext *cx,
|
|||
HandleTypeDescr type,
|
||||
int32_t length)
|
||||
{
|
||||
JS_ASSERT(clasp == &TypedObject::class_ || clasp == &TypedHandle::class_);
|
||||
JS_ASSERT(clasp == &TransparentTypedObject::class_ ||
|
||||
clasp == &OpaqueTypedObject::class_);
|
||||
JS_ASSERT(JSCLASS_RESERVED_SLOTS(clasp) == JS_DATUM_SLOTS);
|
||||
JS_ASSERT(clasp->hasPrivate());
|
||||
|
||||
|
@ -2007,7 +2008,7 @@ TypedDatum::neuter(JSContext *cx)
|
|||
* Typed Objects
|
||||
*/
|
||||
|
||||
const Class TypedObject::class_ = {
|
||||
const Class TransparentTypedObject::class_ = {
|
||||
"TypedObject",
|
||||
Class::NON_NATIVE |
|
||||
JSCLASS_HAS_RESERVED_SLOTS(JS_DATUM_SLOTS) |
|
||||
|
@ -2335,7 +2336,7 @@ TypedDatum::constructUnsized(JSContext *cx, unsigned int argc, Value *vp)
|
|||
* Handles
|
||||
*/
|
||||
|
||||
const Class TypedHandle::class_ = {
|
||||
const Class OpaqueTypedObject::class_ = {
|
||||
"Handle",
|
||||
Class::NON_NATIVE |
|
||||
JSCLASS_HAS_RESERVED_SLOTS(JS_DATUM_SLOTS) |
|
||||
|
@ -2384,7 +2385,7 @@ const Class TypedHandle::class_ = {
|
|||
}
|
||||
};
|
||||
|
||||
const JSFunctionSpec TypedHandle::handleStaticMethods[] = {
|
||||
const JSFunctionSpec OpaqueTypedObject::handleStaticMethods[] = {
|
||||
{"move", {nullptr, nullptr}, 3, 0, "HandleMove"},
|
||||
{"get", {nullptr, nullptr}, 1, 0, "HandleGet"},
|
||||
{"set", {nullptr, nullptr}, 2, 0, "HandleSet"},
|
||||
|
@ -2397,7 +2398,7 @@ const JSFunctionSpec TypedHandle::handleStaticMethods[] = {
|
|||
*/
|
||||
|
||||
bool
|
||||
js::NewTypedHandle(JSContext *cx, unsigned argc, Value *vp)
|
||||
js::NewOpaqueTypedObject(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
JS_ASSERT(args.length() == 1);
|
||||
|
@ -2406,7 +2407,7 @@ js::NewTypedHandle(JSContext *cx, unsigned argc, Value *vp)
|
|||
Rooted<SizedTypeDescr*> descr(cx, &args[0].toObject().as<SizedTypeDescr>());
|
||||
int32_t length = DatumLengthFromType(*descr);
|
||||
Rooted<TypedDatum*> obj(cx);
|
||||
obj = TypedDatum::createUnattachedWithClass(cx, &TypedHandle::class_, descr, length);
|
||||
obj = TypedDatum::createUnattachedWithClass(cx, &OpaqueTypedObject::class_, descr, length);
|
||||
if (!obj)
|
||||
return false;
|
||||
args.rval().setObject(*obj);
|
||||
|
@ -2436,23 +2437,24 @@ js::NewDerivedTypedDatum(JSContext *cx, unsigned argc, Value *vp)
|
|||
}
|
||||
|
||||
bool
|
||||
js::AttachHandle(ThreadSafeContext *, unsigned argc, Value *vp)
|
||||
js::AttachDatum(ThreadSafeContext *, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
JS_ASSERT(args.length() == 3);
|
||||
JS_ASSERT(args[0].isObject() && args[0].toObject().is<TypedHandle>());
|
||||
JS_ASSERT(args[0].isObject() && args[0].toObject().is<TypedDatum>());
|
||||
JS_ASSERT(args[1].isObject() && args[1].toObject().is<TypedDatum>());
|
||||
JS_ASSERT(args[2].isInt32());
|
||||
|
||||
TypedHandle &handle = args[0].toObject().as<TypedHandle>();
|
||||
TypedDatum &handle = args[0].toObject().as<TypedDatum>();
|
||||
TypedDatum &target = args[1].toObject().as<TypedDatum>();
|
||||
JS_ASSERT(handle.typedMem() == nullptr); // must not be attached already
|
||||
size_t offset = args[2].toInt32();
|
||||
handle.attach(target, offset);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_JITINFO_NATIVE_PARALLEL_THREADSAFE(js::AttachHandleJitInfo, AttachHandleJitInfo,
|
||||
js::AttachHandle);
|
||||
JS_JITINFO_NATIVE_PARALLEL_THREADSAFE(js::AttachDatumJitInfo, AttachDatumJitInfo,
|
||||
js::AttachDatum);
|
||||
|
||||
bool
|
||||
js::ObjectIsTypeDescr(ThreadSafeContext *, unsigned argc, Value *vp)
|
||||
|
@ -2468,30 +2470,32 @@ JS_JITINFO_NATIVE_PARALLEL_THREADSAFE(js::ObjectIsTypeDescrJitInfo, ObjectIsType
|
|||
js::ObjectIsTypeDescr);
|
||||
|
||||
bool
|
||||
js::ObjectIsTypedHandle(ThreadSafeContext *, unsigned argc, Value *vp)
|
||||
js::ObjectIsOpaqueTypedObject(ThreadSafeContext *, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
JS_ASSERT(args.length() == 1);
|
||||
JS_ASSERT(args[0].isObject());
|
||||
args.rval().setBoolean(args[0].toObject().is<TypedHandle>());
|
||||
args.rval().setBoolean(args[0].toObject().is<OpaqueTypedObject>());
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_JITINFO_NATIVE_PARALLEL_THREADSAFE(js::ObjectIsTypedHandleJitInfo, ObjectIsTypedHandleJitInfo,
|
||||
js::ObjectIsTypedHandle);
|
||||
JS_JITINFO_NATIVE_PARALLEL_THREADSAFE(js::ObjectIsOpaqueTypedObjectJitInfo,
|
||||
ObjectIsOpaqueTypedObjectJitInfo,
|
||||
js::ObjectIsOpaqueTypedObject);
|
||||
|
||||
bool
|
||||
js::ObjectIsTypedObject(ThreadSafeContext *, unsigned argc, Value *vp)
|
||||
js::ObjectIsTransparentTypedObject(ThreadSafeContext *, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
JS_ASSERT(args.length() == 1);
|
||||
JS_ASSERT(args[0].isObject());
|
||||
args.rval().setBoolean(args[0].toObject().is<TypedObject>());
|
||||
args.rval().setBoolean(args[0].toObject().is<TransparentTypedObject>());
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_JITINFO_NATIVE_PARALLEL_THREADSAFE(js::ObjectIsTypedObjectJitInfo, ObjectIsTypedObjectJitInfo,
|
||||
js::ObjectIsTypedObject);
|
||||
JS_JITINFO_NATIVE_PARALLEL_THREADSAFE(js::ObjectIsTransparentTypedObjectJitInfo,
|
||||
ObjectIsTransparentTypedObjectJitInfo,
|
||||
js::ObjectIsTransparentTypedObject);
|
||||
|
||||
bool
|
||||
js::DatumIsAttached(ThreadSafeContext *cx, unsigned argc, Value *vp)
|
||||
|
@ -2503,7 +2507,9 @@ js::DatumIsAttached(ThreadSafeContext *cx, unsigned argc, Value *vp)
|
|||
return true;
|
||||
}
|
||||
|
||||
JS_JITINFO_NATIVE_PARALLEL_THREADSAFE(js::DatumIsAttachedJitInfo, DatumIsAttachedJitInfo, js::DatumIsAttached);
|
||||
JS_JITINFO_NATIVE_PARALLEL_THREADSAFE(js::DatumIsAttachedJitInfo,
|
||||
DatumIsAttachedJitInfo,
|
||||
js::DatumIsAttached);
|
||||
|
||||
bool
|
||||
js::ClampToUint8(ThreadSafeContext *, unsigned argc, Value *vp)
|
||||
|
|
|
@ -458,15 +458,15 @@ class TypedDatum : public ArrayBufferViewObject
|
|||
|
||||
typedef Handle<TypedDatum*> HandleTypedDatum;
|
||||
|
||||
class TypedObject : public TypedDatum
|
||||
class TransparentTypedObject : public TypedDatum
|
||||
{
|
||||
public:
|
||||
static const Class class_;
|
||||
};
|
||||
|
||||
typedef Handle<TypedObject*> HandleTypedObject;
|
||||
typedef Handle<TransparentTypedObject*> HandleTransparentTypedObject;
|
||||
|
||||
class TypedHandle : public TypedDatum
|
||||
class OpaqueTypedObject : public TypedDatum
|
||||
{
|
||||
public:
|
||||
static const Class class_;
|
||||
|
@ -474,18 +474,11 @@ class TypedHandle : public TypedDatum
|
|||
};
|
||||
|
||||
/*
|
||||
* Usage: NewTypedHandle(typeObj)
|
||||
* Usage: NewOpaqueTypedObject(typeObj)
|
||||
*
|
||||
* Constructs a new, unattached instance of `Handle`.
|
||||
*/
|
||||
bool NewTypedHandle(JSContext *cx, unsigned argc, Value *vp);
|
||||
|
||||
/*
|
||||
* Usage: NewTypedHandle(typeObj)
|
||||
*
|
||||
* Constructs a new, unattached instance of `Handle`.
|
||||
*/
|
||||
bool NewTypedHandle(JSContext *cx, unsigned argc, Value *vp);
|
||||
bool NewOpaqueTypedObject(JSContext *cx, unsigned argc, Value *vp);
|
||||
|
||||
/*
|
||||
* Usage: NewDerivedTypedDatum(typeObj, owner, offset)
|
||||
|
@ -495,13 +488,13 @@ bool NewTypedHandle(JSContext *cx, unsigned argc, Value *vp);
|
|||
bool NewDerivedTypedDatum(JSContext *cx, unsigned argc, Value *vp);
|
||||
|
||||
/*
|
||||
* Usage: AttachHandle(handle, newOwner, newOffset)
|
||||
* Usage: AttachDatum(datum, newDatum, newOffset)
|
||||
*
|
||||
* Moves `handle` to point at the memory owned by `newOwner` with
|
||||
* Moves `datum` to point at the memory referenced by `newDatum` with
|
||||
* the offset `newOffset`.
|
||||
*/
|
||||
bool AttachHandle(ThreadSafeContext *cx, unsigned argc, Value *vp);
|
||||
extern const JSJitInfo AttachHandleJitInfo;
|
||||
bool AttachDatum(ThreadSafeContext *cx, unsigned argc, Value *vp);
|
||||
extern const JSJitInfo AttachDatumJitInfo;
|
||||
|
||||
/*
|
||||
* Usage: ObjectIsTypeDescr(obj)
|
||||
|
@ -512,20 +505,20 @@ bool ObjectIsTypeDescr(ThreadSafeContext *cx, unsigned argc, Value *vp);
|
|||
extern const JSJitInfo ObjectIsTypeDescrJitInfo;
|
||||
|
||||
/*
|
||||
* Usage: ObjectIsTypedHandle(obj)
|
||||
* Usage: ObjectIsOpaqueTypedObject(obj)
|
||||
*
|
||||
* True if `obj` is a handle.
|
||||
*/
|
||||
bool ObjectIsTypedHandle(ThreadSafeContext *cx, unsigned argc, Value *vp);
|
||||
extern const JSJitInfo ObjectIsTypedHandleJitInfo;
|
||||
bool ObjectIsOpaqueTypedObject(ThreadSafeContext *cx, unsigned argc, Value *vp);
|
||||
extern const JSJitInfo ObjectIsOpaqueTypedObjectJitInfo;
|
||||
|
||||
/*
|
||||
* Usage: ObjectIsTypedObject(obj)
|
||||
* Usage: ObjectIsTransparentTypedObject(obj)
|
||||
*
|
||||
* True if `obj` is a typed object.
|
||||
*/
|
||||
bool ObjectIsTypedObject(ThreadSafeContext *cx, unsigned argc, Value *vp);
|
||||
extern const JSJitInfo ObjectIsTypedObjectJitInfo;
|
||||
bool ObjectIsTransparentTypedObject(ThreadSafeContext *cx, unsigned argc, Value *vp);
|
||||
extern const JSJitInfo ObjectIsTransparentTypedObjectJitInfo;
|
||||
|
||||
/*
|
||||
* Usage: DatumIsAttached(obj)
|
||||
|
@ -674,8 +667,8 @@ JS_FOR_EACH_REFERENCE_TYPE_REPR(JS_LOAD_REFERENCE_CLASS_DEFN)
|
|||
inline bool
|
||||
IsTypedDatumClass(const Class *class_)
|
||||
{
|
||||
return class_ == &TypedObject::class_ ||
|
||||
class_ == &TypedHandle::class_;
|
||||
return class_ == &TransparentTypedObject::class_ ||
|
||||
class_ == &OpaqueTypedObject::class_;
|
||||
}
|
||||
|
||||
} // namespace js
|
||||
|
|
|
@ -791,12 +791,10 @@ function ArrayShorthand(...dims) {
|
|||
// Warning: user exposed!
|
||||
function StorageOfTypedDatum(obj) {
|
||||
if (IsObject(obj)) {
|
||||
// Opaque
|
||||
if (ObjectIsTypedHandle(obj))
|
||||
if (ObjectIsOpaqueTypedObject(obj))
|
||||
return null;
|
||||
|
||||
// Transparent
|
||||
if (ObjectIsTypedDatum(obj))
|
||||
if (ObjectIsTransparentTypedObject(obj))
|
||||
return { buffer: DATUM_OWNER(obj),
|
||||
byteLength: DATUM_BYTELENGTH(obj),
|
||||
byteOffset: DATUM_BYTEOFFSET(obj) };
|
||||
|
@ -833,7 +831,7 @@ function TypeOfTypedDatum(obj) {
|
|||
|
||||
function ObjectIsTypedDatum(obj) {
|
||||
assert(IsObject(obj), "ObjectIsTypedDatum invoked with non-object")
|
||||
return ObjectIsTypedObject(obj) || ObjectIsTypedHandle(obj);
|
||||
return ObjectIsTransparentTypedObject(obj) || ObjectIsOpaqueTypedObject(obj);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -4088,7 +4088,7 @@ CodeGenerator::visitNeuterCheck(LNeuterCheck *lir)
|
|||
{
|
||||
Register obj = ToRegister(lir->object());
|
||||
Register temp = ToRegister(lir->temp());
|
||||
masm.loadPtr(Address(obj, TypedObject::dataOffset()), temp);
|
||||
masm.loadPtr(Address(obj, TypedDatum::dataOffset()), temp);
|
||||
masm.testPtr(temp, temp);
|
||||
if (!bailoutIf(Assembler::Zero, lir->snapshot()))
|
||||
return false;
|
||||
|
@ -4100,7 +4100,7 @@ CodeGenerator::visitTypedObjectElements(LTypedObjectElements *lir)
|
|||
{
|
||||
Register obj = ToRegister(lir->object());
|
||||
Register out = ToRegister(lir->output());
|
||||
masm.loadPtr(Address(obj, TypedObject::dataOffset()), out);
|
||||
masm.loadPtr(Address(obj, TypedDatum::dataOffset()), out);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -956,14 +956,15 @@ InitBaselineFrameForOsr(BaselineFrame *frame, StackFrame *interpFrame, uint32_t
|
|||
return frame->initForOsr(interpFrame, numStackValues);
|
||||
}
|
||||
|
||||
JSObject *CreateDerivedTypedObj(JSContext *cx, HandleObject descr,
|
||||
HandleObject owner, int32_t offset)
|
||||
JSObject *
|
||||
CreateDerivedTypedObj(JSContext *cx, HandleObject descr,
|
||||
HandleObject owner, int32_t offset)
|
||||
{
|
||||
JS_ASSERT(descr->is<SizedTypeDescr>());
|
||||
JS_ASSERT(owner->is<TypedDatum>());
|
||||
Rooted<SizedTypeDescr*> descr1(cx, &descr->as<SizedTypeDescr>());
|
||||
Rooted<TypedDatum*> owner1(cx, &owner->as<TypedDatum>());
|
||||
return TypedObject::createDerived(cx, descr1, owner1, offset);
|
||||
return TypedDatum::createDerived(cx, descr1, owner1, offset);
|
||||
}
|
||||
|
||||
JSString *
|
||||
|
|
|
@ -698,30 +698,27 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
|||
&intrinsic_InParallelSection_jitInfo, 0, 0),
|
||||
|
||||
// See builtin/TypedObject.h for descriptors of the typedobj functions.
|
||||
JS_FN("NewTypedHandle",
|
||||
js::NewTypedHandle,
|
||||
JS_FN("NewOpaqueTypedObject",
|
||||
js::NewOpaqueTypedObject,
|
||||
1, 0),
|
||||
JS_FN("NewDerivedTypedDatum",
|
||||
js::NewDerivedTypedDatum,
|
||||
3, 0),
|
||||
JS_FNINFO("AttachHandle",
|
||||
JSNativeThreadSafeWrapper<js::AttachHandle>,
|
||||
&js::AttachHandleJitInfo, 5, 0),
|
||||
JS_FNINFO("AttachDatum",
|
||||
JSNativeThreadSafeWrapper<js::AttachDatum>,
|
||||
&js::AttachDatumJitInfo, 5, 0),
|
||||
JS_FNINFO("ObjectIsTypeDescr",
|
||||
JSNativeThreadSafeWrapper<js::ObjectIsTypeDescr>,
|
||||
&js::ObjectIsTypeDescrJitInfo, 5, 0),
|
||||
JS_FNINFO("ObjectIsTypedObject",
|
||||
JSNativeThreadSafeWrapper<js::ObjectIsTypedObject>,
|
||||
&js::ObjectIsTypedObjectJitInfo, 5, 0),
|
||||
JS_FNINFO("ObjectIsTransparentTypedObject",
|
||||
JSNativeThreadSafeWrapper<js::ObjectIsTransparentTypedObject>,
|
||||
&js::ObjectIsTransparentTypedObjectJitInfo, 5, 0),
|
||||
JS_FNINFO("DatumIsAttached",
|
||||
JSNativeThreadSafeWrapper<js::DatumIsAttached>,
|
||||
&js::DatumIsAttachedJitInfo, 1, 0),
|
||||
JS_FNINFO("ObjectIsTypedHandle",
|
||||
JSNativeThreadSafeWrapper<js::ObjectIsTypedHandle>,
|
||||
&js::ObjectIsTypedHandleJitInfo, 5, 0),
|
||||
JS_FN("NewHandle",
|
||||
js::NewTypedHandle,
|
||||
1, 0),
|
||||
JS_FNINFO("ObjectIsOpaqueTypedObject",
|
||||
JSNativeThreadSafeWrapper<js::ObjectIsOpaqueTypedObject>,
|
||||
&js::ObjectIsOpaqueTypedObjectJitInfo, 5, 0),
|
||||
JS_FNINFO("ClampToUint8",
|
||||
JSNativeThreadSafeWrapper<js::ClampToUint8>,
|
||||
&js::ClampToUint8JitInfo, 1, 0),
|
||||
|
|
Загрузка…
Ссылка в новой задаче