mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Don't use a builtin for this. For functions its interned in the native frame. For global this we read from fp->thisp. Restore jsinterp.cpp and jsinterp.h (no longer need COMPUTE_THIS exposed).
This commit is contained in:
parent
5dca2ad552
commit
43b7ba1be4
@ -47,4 +47,3 @@ BUILTIN1(Math_sin, F, F, jsdouble, jsdouble,
|
||||
BUILTIN1(Math_cos, F, F, jsdouble, jsdouble, 1, 1)
|
||||
BUILTIN2(Math_pow, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1)
|
||||
BUILTIN1(Math_sqrt, F, F, jsdouble, jsdouble, 1, 1)
|
||||
BUILTIN1(get_this, LO, LO, JSObject*, JSContext*, 1, 1)
|
||||
|
@ -154,15 +154,6 @@ jsdouble FASTCALL builtin_Math_sqrt(jsdouble d)
|
||||
return sqrt(d);
|
||||
}
|
||||
|
||||
JSObject* FASTCALL builtin_get_this(JSContext* cx)
|
||||
{
|
||||
JSObject *obj;
|
||||
JS_COMPUTE_THIS(cx, cx->fp, obj);
|
||||
return obj;
|
||||
error:
|
||||
return NULL; /* XXX error */
|
||||
}
|
||||
|
||||
#define LO ARGSIZE_LO
|
||||
#define F ARGSIZE_F
|
||||
#define Q ARGSIZE_Q
|
||||
|
@ -4245,17 +4245,32 @@ js_Interpret(JSContext *cx)
|
||||
DO_NEXT_OP(len);
|
||||
}
|
||||
|
||||
#define COMPUTE_THIS(cx, fp, obj) \
|
||||
JS_BEGIN_MACRO \
|
||||
if (fp->flags & JSFRAME_COMPUTED_THIS) { \
|
||||
obj = fp->thisp; \
|
||||
} else { \
|
||||
obj = js_ComputeThis(cx, JS_TRUE, fp->argv); \
|
||||
if (!obj) \
|
||||
goto error; \
|
||||
fp->thisp = obj; \
|
||||
fp->flags |= JSFRAME_COMPUTED_THIS; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
BEGIN_CASE(JSOP_THIS)
|
||||
JS_COMPUTE_THIS(cx, fp, obj);
|
||||
COMPUTE_THIS(cx, fp, obj);
|
||||
PUSH_OPND(OBJECT_TO_JSVAL(obj));
|
||||
END_CASE(JSOP_THIS)
|
||||
|
||||
BEGIN_CASE(JSOP_GETTHISPROP)
|
||||
i = 0;
|
||||
JS_COMPUTE_THIS(cx, fp, obj);
|
||||
COMPUTE_THIS(cx, fp, obj);
|
||||
PUSH(JSVAL_NULL);
|
||||
goto do_getprop_with_obj;
|
||||
|
||||
#undef COMPUTE_THIS
|
||||
|
||||
BEGIN_CASE(JSOP_GETARGPROP)
|
||||
i = ARGNO_LEN;
|
||||
slot = GET_ARGNO(regs.pc);
|
||||
|
@ -399,20 +399,6 @@ extern const uint16 js_PrimitiveTestFlags[];
|
||||
JSFUN_THISP_TEST(JSFUN_THISP_FLAGS((fun)->flags), \
|
||||
js_PrimitiveTestFlags[JSVAL_TAG(thisv) - 1]))
|
||||
|
||||
#define JS_COMPUTE_THIS(cx, fp, obj) \
|
||||
JS_BEGIN_MACRO \
|
||||
if (fp->flags & JSFRAME_COMPUTED_THIS) { \
|
||||
obj = fp->thisp; \
|
||||
} else { \
|
||||
obj = js_ComputeThis(cx, JS_TRUE, fp->argv); \
|
||||
if (!obj) \
|
||||
goto error; \
|
||||
fp->thisp = obj; \
|
||||
fp->flags |= JSFRAME_COMPUTED_THIS; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
|
||||
/*
|
||||
* NB: js_Invoke requires that cx is currently running JS (i.e., that cx->fp
|
||||
* is non-null), and that vp points to the callee, |this| parameter, and
|
||||
|
@ -354,6 +354,9 @@ public:
|
||||
SET_VPNAME("rval"); \
|
||||
vp = &f->rval; code; \
|
||||
if (f->callee) { \
|
||||
SET_VPNAME("this"); \
|
||||
vp = &f->argv[-1]; \
|
||||
code; \
|
||||
SET_VPNAME("argv"); \
|
||||
vp = &f->argv[0]; vpstop = &f->argv[f->argc]; \
|
||||
while (vp < vpstop) { code; ++vp; INC_VPNUM(); } \
|
||||
@ -642,7 +645,7 @@ TraceRecorder::nativeFrameSlots(JSStackFrame* fp, JSFrameRegs& regs) const
|
||||
for (;;) {
|
||||
slots += 1/*rval*/ + (regs.sp - fp->spbase);
|
||||
if (fp->callee)
|
||||
slots += fp->argc + fp->nvars;
|
||||
slots += 1/*this*/ + fp->argc + fp->nvars;
|
||||
if (fp == entryFrame)
|
||||
return slots;
|
||||
fp = fp->down;
|
||||
@ -1588,6 +1591,22 @@ TraceRecorder::unbox_jsval(jsval v, LIns*& v_ins)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TraceRecorder::getThis(LIns*& this_ins)
|
||||
{
|
||||
if (cx->fp->callee) { /* in a function */
|
||||
if (JSVAL_IS_NULL(cx->fp->argv[-1]))
|
||||
return false;
|
||||
this_ins = get(&cx->fp->argv[-1]);
|
||||
guard(false, lir->ins_eq0(this_ins));
|
||||
} else { /* in global code */
|
||||
JS_ASSERT(!JSVAL_IS_NULL(cx->fp->argv[-1]));
|
||||
this_ins = lir->insLoadi(lir->insLoadi(cx_ins, offsetof(JSContext, fp)),
|
||||
offsetof(JSStackFrame, thisp));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TraceRecorder::guardThatObjectHasClass(JSObject* obj, LIns* obj_ins,
|
||||
JSClass* cls, LIns*& dslots_ins)
|
||||
@ -1866,7 +1885,7 @@ bool TraceRecorder::record_JSOP_ELEMDEC()
|
||||
|
||||
bool TraceRecorder::record_JSOP_GETPROP()
|
||||
{
|
||||
return get_prop(stackval(-1));
|
||||
return getProp(stackval(-1));
|
||||
}
|
||||
|
||||
bool TraceRecorder::record_JSOP_SETPROP()
|
||||
@ -2026,14 +2045,8 @@ bool TraceRecorder::record_JSOP_CALL()
|
||||
ABORT_TRACE("unknown native");
|
||||
}
|
||||
|
||||
LIns *
|
||||
TraceRecorder::get_this_ins()
|
||||
{
|
||||
return lir->insCall(F_get_this, &cx_ins);
|
||||
}
|
||||
|
||||
bool
|
||||
TraceRecorder::get_prop(JSObject* obj, LIns* obj_ins)
|
||||
TraceRecorder::getProp(JSObject* obj, LIns* obj_ins)
|
||||
{
|
||||
uint32 slot;
|
||||
if (!test_property_cache_direct_slot(obj, obj_ins, slot))
|
||||
@ -2049,12 +2062,12 @@ TraceRecorder::get_prop(JSObject* obj, LIns* obj_ins)
|
||||
}
|
||||
|
||||
bool
|
||||
TraceRecorder::get_prop(jsval& v)
|
||||
TraceRecorder::getProp(jsval& v)
|
||||
{
|
||||
if (JSVAL_IS_PRIMITIVE(v))
|
||||
ABORT_TRACE("primitive lhs");
|
||||
|
||||
return get_prop(JSVAL_TO_OBJECT(v), get(&v));
|
||||
return getProp(JSVAL_TO_OBJECT(v), get(&v));
|
||||
}
|
||||
|
||||
bool TraceRecorder::record_JSOP_NAME()
|
||||
@ -2065,7 +2078,7 @@ bool TraceRecorder::record_JSOP_NAME()
|
||||
|
||||
LIns* obj_ins = lir->insLoadi(lir->insLoadi(cx_ins, offsetof(JSContext, fp)),
|
||||
offsetof(JSStackFrame, scopeChain));
|
||||
/* Can't use get_prop here, because we don't want unboxing. */
|
||||
/* Can't use getProp here, because we don't want unboxing. */
|
||||
uint32 slot;
|
||||
if (!test_property_cache_direct_slot(obj, obj_ins, slot))
|
||||
return false;
|
||||
@ -2107,7 +2120,10 @@ bool TraceRecorder::record_JSOP_NULL()
|
||||
}
|
||||
bool TraceRecorder::record_JSOP_THIS()
|
||||
{
|
||||
stack(0, get_this_ins());
|
||||
LIns* this_ins;
|
||||
if (!getThis(this_ins))
|
||||
return false;
|
||||
stack(0, this_ins);
|
||||
return true;
|
||||
}
|
||||
bool TraceRecorder::record_JSOP_FALSE()
|
||||
@ -2863,21 +2879,20 @@ bool TraceRecorder::record_JSOP_LEAVEBLOCKEXPR()
|
||||
|
||||
bool TraceRecorder::record_JSOP_GETTHISPROP()
|
||||
{
|
||||
JSObject *obj;
|
||||
JS_COMPUTE_THIS(cx, cx->fp, obj);
|
||||
return get_prop(obj, get_this_ins());
|
||||
error:
|
||||
return false;
|
||||
LIns* this_ins;
|
||||
/* its safe to just use cx->fp->thisp here because getThis() returns false if thisp
|
||||
is not available */
|
||||
return getThis(this_ins) && getProp(cx->fp->thisp, this_ins);
|
||||
}
|
||||
|
||||
bool TraceRecorder::record_JSOP_GETARGPROP()
|
||||
{
|
||||
return get_prop(argval(GET_ARGNO(cx->fp->regs->pc)));
|
||||
return getProp(argval(GET_ARGNO(cx->fp->regs->pc)));
|
||||
}
|
||||
|
||||
bool TraceRecorder::record_JSOP_GETVARPROP()
|
||||
{
|
||||
return get_prop(varval(GET_VARNO(cx->fp->regs->pc)));
|
||||
return getProp(varval(GET_VARNO(cx->fp->regs->pc)));
|
||||
}
|
||||
|
||||
bool TraceRecorder::record_JSOP_GETLOCALPROP()
|
||||
|
@ -190,10 +190,10 @@ class TraceRecorder {
|
||||
bool native_get(nanojit::LIns* obj_ins, nanojit::LIns* pobj_ins, JSScopeProperty* sprop,
|
||||
nanojit::LIns*& dslots_ins, nanojit::LIns*& v_ins);
|
||||
|
||||
bool get_prop(JSObject* obj, nanojit::LIns* obj_ins);
|
||||
bool get_prop(jsval& v);
|
||||
nanojit::LIns* get_this_ins();
|
||||
|
||||
bool getProp(JSObject* obj, nanojit::LIns* obj_ins);
|
||||
bool getProp(jsval& v);
|
||||
bool getThis(nanojit::LIns*& this_ins);
|
||||
|
||||
bool box_jsval(jsval v, nanojit::LIns*& v_ins);
|
||||
bool unbox_jsval(jsval v, nanojit::LIns*& v_ins);
|
||||
bool guardThatObjectHasClass(JSObject* obj, nanojit::LIns* obj_ins,
|
||||
|
Loading…
Reference in New Issue
Block a user