mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 916949 - Minor refactor and clean-up of property access logic in VM. r=jorendorff
This commit is contained in:
parent
f686b0b73c
commit
2ce1390662
@ -5965,13 +5965,8 @@ DoGetPropFallback(JSContext *cx, BaselineFrame *frame, ICGetProp_Fallback *stub,
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
if (obj->getOps()->getProperty) {
|
||||
if (!JSObject::getGeneric(cx, obj, obj, id, res))
|
||||
return false;
|
||||
} else {
|
||||
if (!GetPropertyHelper(cx, obj, id, 0, res))
|
||||
return false;
|
||||
}
|
||||
if (!JSObject::getGeneric(cx, obj, obj, id, res))
|
||||
return false;
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
// Handle objects with __noSuchMethod__.
|
||||
|
@ -1731,13 +1731,8 @@ GetPropertyIC::update(JSContext *cx, size_t cacheIndex,
|
||||
}
|
||||
|
||||
RootedId id(cx, NameToId(name));
|
||||
if (obj->getOps()->getProperty) {
|
||||
if (!JSObject::getGeneric(cx, obj, obj, id, vp))
|
||||
return false;
|
||||
} else {
|
||||
if (!GetPropertyHelper(cx, obj, id, 0, vp))
|
||||
return false;
|
||||
}
|
||||
if (!JSObject::getGeneric(cx, obj, obj, id, vp))
|
||||
return false;
|
||||
|
||||
if (!cache.idempotent()) {
|
||||
RootedScript script(cx);
|
||||
|
@ -670,7 +670,7 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
|
||||
return Reject(cx, JSMSG_CANT_REDEFINE_PROP, throwError, id, rval);
|
||||
}
|
||||
|
||||
if (!js_NativeGet(cx, obj, obj2, shape, 0, &v))
|
||||
if (!js_NativeGet(cx, obj, obj2, shape, &v))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -4021,7 +4021,6 @@ NativeGetInline(JSContext *cx,
|
||||
typename MaybeRooted<JSObject*, allowGC>::HandleType receiver,
|
||||
typename MaybeRooted<JSObject*, allowGC>::HandleType pobj,
|
||||
typename MaybeRooted<Shape*, allowGC>::HandleType shape,
|
||||
unsigned getHow,
|
||||
typename MaybeRooted<Value, allowGC>::MutableHandleType vp)
|
||||
{
|
||||
JS_ASSERT(pobj->isNative());
|
||||
@ -4076,9 +4075,9 @@ NativeGetInline(JSContext *cx,
|
||||
|
||||
bool
|
||||
js_NativeGet(JSContext *cx, Handle<JSObject*> obj, Handle<JSObject*> pobj, Handle<Shape*> shape,
|
||||
unsigned getHow, MutableHandle<Value> vp)
|
||||
MutableHandle<Value> vp)
|
||||
{
|
||||
return NativeGetInline<CanGC>(cx, obj, obj, pobj, shape, getHow, vp);
|
||||
return NativeGetInline<CanGC>(cx, obj, obj, pobj, shape, vp);
|
||||
}
|
||||
|
||||
|
||||
@ -4135,7 +4134,6 @@ GetPropertyHelperInline(JSContext *cx,
|
||||
typename MaybeRooted<JSObject*, allowGC>::HandleType obj,
|
||||
typename MaybeRooted<JSObject*, allowGC>::HandleType receiver,
|
||||
typename MaybeRooted<jsid, allowGC>::HandleType id,
|
||||
uint32_t getHow,
|
||||
typename MaybeRooted<Value, allowGC>::MutableHandleType vp)
|
||||
{
|
||||
/* This call site is hot -- use the always-inlined variant of LookupPropertyWithFlags(). */
|
||||
@ -4233,30 +4231,24 @@ GetPropertyHelperInline(JSContext *cx,
|
||||
}
|
||||
|
||||
/* This call site is hot -- use the always-inlined variant of js_NativeGet(). */
|
||||
if (!NativeGetInline<allowGC>(cx, obj, receiver, obj2, shape, getHow, vp))
|
||||
if (!NativeGetInline<allowGC>(cx, obj, receiver, obj2, shape, vp))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::GetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, uint32_t getHow, MutableHandleValue vp)
|
||||
{
|
||||
return GetPropertyHelperInline<CanGC>(cx, obj, obj, id, getHow, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
baseops::GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id, MutableHandleValue vp)
|
||||
{
|
||||
/* This call site is hot -- use the always-inlined variant of GetPropertyHelper(). */
|
||||
return GetPropertyHelperInline<CanGC>(cx, obj, receiver, id, 0, vp);
|
||||
return GetPropertyHelperInline<CanGC>(cx, obj, receiver, id, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
baseops::GetPropertyNoGC(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
|
||||
{
|
||||
AutoAssertNoException nogc(cx);
|
||||
return GetPropertyHelperInline<NoGC>(cx, obj, receiver, id, 0, vp);
|
||||
return GetPropertyHelperInline<NoGC>(cx, obj, receiver, id, vp);
|
||||
}
|
||||
|
||||
static JS_ALWAYS_INLINE bool
|
||||
@ -4441,7 +4433,7 @@ baseops::GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint
|
||||
return false;
|
||||
|
||||
/* This call site is hot -- use the always-inlined variant of js_GetPropertyHelper(). */
|
||||
return GetPropertyHelperInline<CanGC>(cx, obj, receiver, id, 0, vp);
|
||||
return GetPropertyHelperInline<CanGC>(cx, obj, receiver, id, vp);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -909,6 +909,7 @@ class JSObject : public js::ObjectImpl
|
||||
static bool getGeneric(JSContext *cx, js::HandleObject obj, js::HandleObject receiver,
|
||||
js::HandleId id, js::MutableHandleValue vp)
|
||||
{
|
||||
JS_ASSERT(!!obj->getOps()->getGeneric == !!obj->getOps()->getProperty);
|
||||
js::GenericIdOp op = obj->getOps()->getGeneric;
|
||||
if (op) {
|
||||
if (!op(cx, obj, receiver, id, vp))
|
||||
@ -1397,15 +1398,9 @@ LookupNameWithGlobalDefault(JSContext *cx, HandlePropertyName name, HandleObject
|
||||
extern JSObject *
|
||||
js_FindVariableScope(JSContext *cx, JSFunction **funp);
|
||||
|
||||
/*
|
||||
* NB: js_NativeGet and js_NativeSet are called with the scope containing shape
|
||||
* (pobj's scope for Get, obj's for Set) locked, and on successful return, that
|
||||
* scope is again locked. But on failure, both functions return false with the
|
||||
* scope containing shape unlocked.
|
||||
*/
|
||||
extern bool
|
||||
js_NativeGet(JSContext *cx, js::Handle<JSObject*> obj, js::Handle<JSObject*> pobj,
|
||||
js::Handle<js::Shape*> shape, unsigned getHow, js::MutableHandle<js::Value> vp);
|
||||
js::Handle<js::Shape*> shape, js::MutableHandle<js::Value> vp);
|
||||
|
||||
extern bool
|
||||
js_NativeSet(JSContext *cx, js::Handle<JSObject*> obj, js::Handle<JSObject*> receiver,
|
||||
@ -1413,16 +1408,6 @@ js_NativeSet(JSContext *cx, js::Handle<JSObject*> obj, js::Handle<JSObject*> rec
|
||||
|
||||
namespace js {
|
||||
|
||||
bool
|
||||
GetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, uint32_t getHow, MutableHandleValue vp);
|
||||
|
||||
inline bool
|
||||
GetPropertyHelper(JSContext *cx, HandleObject obj, PropertyName *name, uint32_t getHow, MutableHandleValue vp)
|
||||
{
|
||||
RootedId id(cx, NameToId(name));
|
||||
return GetPropertyHelper(cx, obj, id, getHow, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
LookupPropertyPure(JSObject *obj, jsid id, JSObject **objp, Shape **propp);
|
||||
|
||||
|
@ -902,7 +902,7 @@ Debugger::parseResumptionValue(Maybe<AutoCompartment> &ac, bool ok, const Value
|
||||
}
|
||||
|
||||
RootedValue v(cx, vp.get());
|
||||
if (!js_NativeGet(cx, obj, obj, shape, 0, &v) || !unwrapDebuggeeValue(cx, &v))
|
||||
if (!js_NativeGet(cx, obj, obj, shape, &v) || !unwrapDebuggeeValue(cx, &v))
|
||||
return handleUncaughtException(ac, &v, callHook);
|
||||
|
||||
ac.destroy();
|
||||
|
@ -130,7 +130,7 @@ ValuePropertyBearer(JSContext *cx, StackFrame *fp, HandleValue v, int spindex)
|
||||
|
||||
inline bool
|
||||
NativeGet(JSContext *cx, JSObject *objArg, JSObject *pobjArg, Shape *shapeArg,
|
||||
unsigned getHow, MutableHandleValue vp)
|
||||
MutableHandleValue vp)
|
||||
{
|
||||
if (shapeArg->isDataDescriptor() && shapeArg->hasDefaultGetter()) {
|
||||
/* Fast path for Object instance properties. */
|
||||
@ -140,7 +140,7 @@ NativeGet(JSContext *cx, JSObject *objArg, JSObject *pobjArg, Shape *shapeArg,
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedObject pobj(cx, pobjArg);
|
||||
RootedShape shape(cx, shapeArg);
|
||||
if (!js_NativeGet(cx, obj, pobj, shape, getHow, vp))
|
||||
if (!js_NativeGet(cx, obj, pobj, shape, vp))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -204,7 +204,7 @@ FetchName(JSContext *cx, HandleObject obj, HandleObject obj2, HandlePropertyName
|
||||
Rooted<JSObject*> normalized(cx, obj);
|
||||
if (normalized->getClass() == &WithObject::class_ && !shape->hasDefaultGetter())
|
||||
normalized = &normalized->as<WithObject>().object();
|
||||
if (!NativeGet(cx, normalized, obj2, shape, 0, vp))
|
||||
if (!NativeGet(cx, normalized, obj2, shape, vp))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -263,13 +263,8 @@ GetPropertyOperation(JSContext *cx, StackFrame *fp, HandleScript script, jsbytec
|
||||
|
||||
bool wasObject = lval.isObject();
|
||||
|
||||
if (obj->getOps()->getProperty) {
|
||||
if (!JSObject::getGeneric(cx, obj, obj, id, vp))
|
||||
return false;
|
||||
} else {
|
||||
if (!GetPropertyHelper(cx, obj, id, 0, vp))
|
||||
return false;
|
||||
}
|
||||
if (!JSObject::getGeneric(cx, obj, obj, id, vp))
|
||||
return false;
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
if (op == JSOP_CALLPROP &&
|
||||
|
Loading…
Reference in New Issue
Block a user