mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1170107 part 1 - Call GetProperty/CallProperty from the interpreter and Baseline. r=bhackett
--HG-- extra : rebase_source : 9fae676e0ca98f81481d19c305c7cb24d729cd31
This commit is contained in:
parent
95f6dd0f30
commit
d9ddab0d4a
@ -7586,27 +7586,19 @@ ComputeGetPropResult(JSContext* cx, BaselineFrame* frame, JSOp op, HandlePropert
|
||||
res.setObject(*frame->callee());
|
||||
}
|
||||
} else {
|
||||
// Handle when val is an object.
|
||||
RootedObject obj(cx, ToObjectFromStack(cx, val));
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
RootedId id(cx, NameToId(name));
|
||||
if (op == JSOP_GETXPROP) {
|
||||
if (!GetPropertyForNameLookup(cx, obj, id, res))
|
||||
if (op == JSOP_GETPROP || op == JSOP_LENGTH) {
|
||||
if (!GetProperty(cx, val, name, res))
|
||||
return false;
|
||||
} else if (op == JSOP_CALLPROP) {
|
||||
if (!CallProperty(cx, val, name, res))
|
||||
return false;
|
||||
} else {
|
||||
if (!GetProperty(cx, obj, obj, id, res))
|
||||
MOZ_ASSERT(op == JSOP_GETXPROP);
|
||||
RootedObject obj(cx, &val.toObject());
|
||||
RootedId id(cx, NameToId(name));
|
||||
if (!GetPropertyForNameLookup(cx, obj, id, res))
|
||||
return false;
|
||||
}
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
// Handle objects with __noSuchMethod__.
|
||||
if (op == JSOP_CALLPROP && MOZ_UNLIKELY(res.isUndefined()) && val.isObject()) {
|
||||
if (!OnUnknownMethod(cx, obj, IdToValue(id), res))
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -241,47 +241,22 @@ GetPropertyOperation(JSContext* cx, InterpreterFrame* fp, HandleScript script, j
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedId id(cx, NameToId(script->getName(pc)));
|
||||
RootedPropertyName name(cx, script->getName(pc));
|
||||
|
||||
if (id == NameToId(cx->names().callee) && IsOptimizedArguments(fp, lval)) {
|
||||
if (name == cx->names().callee && IsOptimizedArguments(fp, lval)) {
|
||||
vp.setObject(fp->callee());
|
||||
return true;
|
||||
}
|
||||
|
||||
Rooted<GlobalObject*> global(cx, &fp->global());
|
||||
RootedObject obj(cx);
|
||||
|
||||
/* Optimize (.1).toString(). */
|
||||
if (lval.isNumber() && id == NameToId(cx->names().toString)) {
|
||||
NativeObject* proto = GlobalObject::getOrCreateNumberPrototype(cx, global);
|
||||
if (!proto)
|
||||
return false;
|
||||
if (ClassMethodIsNative(cx, proto, &NumberObject::class_, id, num_toString))
|
||||
obj = proto;
|
||||
if (op == JSOP_CALLPROP) {
|
||||
// The __noSuchMethod__ code in CallProperty requires non-aliasing
|
||||
// v and vp arguments.
|
||||
RootedValue v(cx, lval);
|
||||
return CallProperty(cx, v, name, vp);
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
obj = ToObjectFromStack(cx, lval);
|
||||
if (!obj)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wasObject = lval.isObject();
|
||||
|
||||
if (!GetProperty(cx, obj, obj, id, vp))
|
||||
return false;
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
if (op == JSOP_CALLPROP &&
|
||||
MOZ_UNLIKELY(vp.isUndefined()) &&
|
||||
wasObject)
|
||||
{
|
||||
if (!OnUnknownMethod(cx, obj, IdToValue(id), vp))
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
MOZ_ASSERT(op == JSOP_GETPROP || op == JSOP_LENGTH);
|
||||
return GetProperty(cx, lval, name, vp);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
@ -4064,21 +4039,36 @@ js::GetProperty(JSContext* cx, HandleValue v, HandlePropertyName name, MutableHa
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedObject obj(cx, ToObjectFromStack(cx, v));
|
||||
if (!obj)
|
||||
return false;
|
||||
/* Optimize (.1).toString(). */
|
||||
RootedObject obj(cx);
|
||||
if (v.isNumber() && name == cx->names().toString) {
|
||||
NativeObject* proto = GlobalObject::getOrCreateNumberPrototype(cx, cx->global());
|
||||
if (!proto)
|
||||
return false;
|
||||
if (ClassMethodIsNative(cx, proto, &NumberObject::class_, NameToId(name), num_toString))
|
||||
obj = proto;
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
obj = ToObjectFromStack(cx, v);
|
||||
if (!obj)
|
||||
return false;
|
||||
}
|
||||
|
||||
return GetProperty(cx, obj, obj, name, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
js::CallProperty(JSContext* cx, HandleValue v, HandlePropertyName name, MutableHandleValue vp)
|
||||
{
|
||||
// __noSuchMethod__ code below depends on this.
|
||||
MOZ_ASSERT(v.address() != vp.address());
|
||||
|
||||
if (!GetProperty(cx, v, name, vp))
|
||||
return false;
|
||||
|
||||
#if JS_HAS_NO_SUCH_METHOD
|
||||
if (MOZ_UNLIKELY(vp.isUndefined()) && v.isObject())
|
||||
{
|
||||
if (MOZ_UNLIKELY(vp.isUndefined()) && v.isObject()) {
|
||||
RootedObject obj(cx, &v.toObject());
|
||||
if (!OnUnknownMethod(cx, obj, StringValue(name), vp))
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user