2008-05-28 19:07:25 -07:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2008-07-05 11:18:26 -07:00
|
|
|
* vim: set ts=8 sw=4 et tw=99:
|
2008-05-28 19:07:25 -07:00
|
|
|
*
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
|
|
|
|
* May 28, 2008.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
2008-06-28 09:58:15 -07:00
|
|
|
* Brendan Eich <brendan@mozilla.org>
|
2008-05-28 19:07:25 -07:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
2008-06-28 09:58:15 -07:00
|
|
|
* Andreas Gal <gal@mozilla.com>
|
2008-05-28 19:07:25 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2008-07-03 23:57:57 -07:00
|
|
|
#include <math.h>
|
2008-05-28 19:07:25 -07:00
|
|
|
|
2008-06-21 14:55:32 -07:00
|
|
|
#include "nanojit/avmplus.h"
|
|
|
|
#include "nanojit/nanojit.h"
|
2008-07-05 06:47:59 -07:00
|
|
|
#include "jsarray.h"
|
|
|
|
#include "jsbool.h"
|
2008-07-03 22:08:13 -07:00
|
|
|
#include "jstracer.h"
|
|
|
|
#include "jscntxt.h"
|
2008-07-03 23:57:57 -07:00
|
|
|
#include "jsscript.h"
|
|
|
|
#include "jsprf.h"
|
2008-07-04 23:53:29 -07:00
|
|
|
#include "jsinterp.h"
|
|
|
|
#include "jsscope.h"
|
2008-06-21 14:55:32 -07:00
|
|
|
|
2008-07-03 23:57:57 -07:00
|
|
|
using namespace avmplus;
|
2008-06-21 14:55:32 -07:00
|
|
|
using namespace nanojit;
|
|
|
|
|
2008-07-03 23:57:57 -07:00
|
|
|
static GC gc = GC();
|
|
|
|
static avmplus::AvmCore* core = new (&gc) avmplus::AvmCore();
|
2008-05-30 10:11:56 -07:00
|
|
|
|
2008-07-06 12:03:51 -07:00
|
|
|
template<typename T>
|
2008-07-06 10:59:55 -07:00
|
|
|
Tracker<T>::Tracker()
|
2008-06-03 21:01:23 -07:00
|
|
|
{
|
2008-06-21 14:55:32 -07:00
|
|
|
pagelist = 0;
|
|
|
|
}
|
2008-06-10 21:40:47 -07:00
|
|
|
|
2008-07-06 12:03:51 -07:00
|
|
|
template<typename T>
|
2008-07-06 10:59:55 -07:00
|
|
|
Tracker<T>::~Tracker()
|
2008-06-21 14:55:32 -07:00
|
|
|
{
|
|
|
|
clear();
|
2008-06-03 21:01:23 -07:00
|
|
|
}
|
|
|
|
|
2008-07-06 12:03:51 -07:00
|
|
|
template<typename T> jsuword
|
2008-07-06 10:59:55 -07:00
|
|
|
Tracker<T>::getPageBase(const void* v) const
|
2008-06-03 21:01:23 -07:00
|
|
|
{
|
2008-07-05 11:18:26 -07:00
|
|
|
return jsuword(v) & ~jsuword(NJ_PAGE_SIZE-1);
|
2008-06-04 00:09:57 -07:00
|
|
|
}
|
2008-06-11 11:29:35 -07:00
|
|
|
|
2008-07-06 12:03:51 -07:00
|
|
|
template<typename T> struct Tracker<T>::Page*
|
2008-07-06 10:59:55 -07:00
|
|
|
Tracker<T>::findPage(const void* v) const
|
2008-06-11 11:29:35 -07:00
|
|
|
{
|
2008-07-05 11:18:26 -07:00
|
|
|
jsuword base = getPageBase(v);
|
2008-07-06 10:59:55 -07:00
|
|
|
struct Tracker<T>::Page* p = pagelist;
|
2008-06-21 14:55:32 -07:00
|
|
|
while (p) {
|
2008-06-29 13:53:40 -07:00
|
|
|
if (p->base == base) {
|
2008-06-21 14:55:32 -07:00
|
|
|
return p;
|
2008-06-29 13:53:40 -07:00
|
|
|
}
|
2008-06-21 14:55:32 -07:00
|
|
|
p = p->next;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-06 12:03:51 -07:00
|
|
|
template <typename T> struct Tracker<T>::Page*
|
2008-07-06 10:59:55 -07:00
|
|
|
Tracker<T>::addPage(const void* v) {
|
2008-07-05 11:18:26 -07:00
|
|
|
jsuword base = getPageBase(v);
|
2008-06-26 20:44:23 -07:00
|
|
|
struct Tracker::Page* p = (struct Tracker::Page*)
|
|
|
|
GC::Alloc(sizeof(struct Tracker::Page) + (NJ_PAGE_SIZE >> 2) * sizeof(LInsp));
|
2008-06-21 14:55:32 -07:00
|
|
|
p->base = base;
|
|
|
|
p->next = pagelist;
|
|
|
|
pagelist = p;
|
|
|
|
return p;
|
2008-06-11 11:29:35 -07:00
|
|
|
}
|
|
|
|
|
2008-07-06 12:03:51 -07:00
|
|
|
template <typename T> void
|
2008-07-06 10:59:55 -07:00
|
|
|
Tracker<T>::clear()
|
2008-06-11 11:29:35 -07:00
|
|
|
{
|
2008-06-21 14:55:32 -07:00
|
|
|
while (pagelist) {
|
|
|
|
Page* p = pagelist;
|
|
|
|
pagelist = pagelist->next;
|
|
|
|
GC::Free(p);
|
|
|
|
}
|
2008-06-11 11:29:35 -07:00
|
|
|
}
|
2008-06-11 17:59:28 -07:00
|
|
|
|
2008-07-06 12:03:51 -07:00
|
|
|
template <typename T> T
|
2008-07-06 10:59:55 -07:00
|
|
|
Tracker<T>::get(const void* v) const
|
2008-06-21 14:55:32 -07:00
|
|
|
{
|
2008-07-06 10:59:55 -07:00
|
|
|
struct Tracker<T>::Page* p = findPage(v);
|
2008-06-21 14:55:32 -07:00
|
|
|
JS_ASSERT(p != 0); /* we must have a page for the slot we are looking for */
|
2008-07-06 10:59:55 -07:00
|
|
|
T i = p->map[(jsuword(v) & 0xfff) >> 2];
|
2008-06-22 19:58:24 -07:00
|
|
|
JS_ASSERT(i != 0);
|
|
|
|
return i;
|
2008-06-21 14:55:32 -07:00
|
|
|
}
|
|
|
|
|
2008-07-06 12:03:51 -07:00
|
|
|
template <typename T> void
|
2008-07-06 10:59:55 -07:00
|
|
|
Tracker<T>::set(const void* v, T ins)
|
2008-06-11 20:22:00 -07:00
|
|
|
{
|
2008-07-06 10:59:55 -07:00
|
|
|
struct Tracker<T>::Page* p = findPage(v);
|
2008-06-22 23:42:54 -07:00
|
|
|
if (!p)
|
2008-06-21 14:55:32 -07:00
|
|
|
p = addPage(v);
|
2008-07-05 11:18:26 -07:00
|
|
|
p->map[(jsuword(v) & 0xfff) >> 2] = ins;
|
2008-06-11 20:22:00 -07:00
|
|
|
}
|
|
|
|
|
2008-06-21 14:55:32 -07:00
|
|
|
#define LO ARGSIZE_LO
|
|
|
|
#define F ARGSIZE_F
|
|
|
|
#define Q ARGSIZE_Q
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define NAME(op) ,#op
|
|
|
|
#else
|
|
|
|
#define NAME(op)
|
|
|
|
#endif
|
|
|
|
|
2008-06-22 19:58:24 -07:00
|
|
|
#define BUILTIN1(op, at0, atr, tr, t0, cse, fold) \
|
2008-07-02 14:38:12 -07:00
|
|
|
{ (intptr_t)&builtin_##op, (at0 << 2) | atr, cse, fold NAME(op) },
|
2008-06-22 19:58:24 -07:00
|
|
|
#define BUILTIN2(op, at0, at1, atr, tr, t0, t1, cse, fold) \
|
2008-07-02 22:05:30 -07:00
|
|
|
{ (intptr_t)&builtin_##op, (at0 << 4) | (at1 << 2) | atr, cse, fold NAME(op) },
|
2008-06-22 19:58:24 -07:00
|
|
|
#define BUILTIN3(op, at0, at1, at2, atr, tr, t0, t1, t2, cse, fold) \
|
2008-07-02 22:05:30 -07:00
|
|
|
{ (intptr_t)&builtin_##op, (at0 << 6) | (at1 << 4) | (at2 << 2) | atr, cse, fold NAME(op) },
|
2008-06-21 14:55:32 -07:00
|
|
|
|
|
|
|
static struct CallInfo builtins[] = {
|
|
|
|
#include "builtins.tbl"
|
2008-06-22 23:42:54 -07:00
|
|
|
};
|
2008-06-21 14:55:32 -07:00
|
|
|
|
2008-06-22 23:42:54 -07:00
|
|
|
#undef NAME
|
2008-06-21 14:55:32 -07:00
|
|
|
#undef BUILTIN1
|
|
|
|
#undef BUILTIN2
|
2008-06-22 23:42:54 -07:00
|
|
|
#undef BUILTIN3
|
2008-06-21 14:55:32 -07:00
|
|
|
|
2008-07-06 15:55:04 -07:00
|
|
|
/* Return the coerced type of a value. If its a number, we always return JSVAL_DOUBLE, no matter
|
|
|
|
whether its represented as an int or as a double. */
|
|
|
|
static inline int getCoercedType(jsval v)
|
2008-07-06 11:48:41 -07:00
|
|
|
{
|
|
|
|
if (JSVAL_IS_INT(v))
|
2008-07-06 15:55:04 -07:00
|
|
|
return JSVAL_DOUBLE;
|
2008-07-06 11:48:41 -07:00
|
|
|
return JSVAL_TAG(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool isNumber(jsval v)
|
|
|
|
{
|
|
|
|
return JSVAL_IS_INT(v) || JSVAL_IS_DOUBLE(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline jsdouble asNumber(jsval v)
|
|
|
|
{
|
|
|
|
JS_ASSERT(isNumber(v));
|
|
|
|
if (JSVAL_IS_DOUBLE(v))
|
|
|
|
return *JSVAL_TO_DOUBLE(v);
|
|
|
|
return (jsdouble)JSVAL_TO_INT(v);
|
|
|
|
}
|
|
|
|
|
2008-07-05 22:20:35 -07:00
|
|
|
static LIns* demote(LirWriter *out, LInsp i)
|
|
|
|
{
|
|
|
|
if (i->isCall())
|
|
|
|
return callArgN(i,0);
|
|
|
|
if (i->isop(LIR_i2f) || i->isop(LIR_u2f))
|
|
|
|
return i->oprnd1();
|
|
|
|
AvmAssert(i->isconstq());
|
|
|
|
double cf = i->constvalf();
|
|
|
|
int32_t ci = cf > 0x7fffffff ? uint32_t(cf) : int32_t(cf);
|
|
|
|
return out->insImm(ci);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isPromoteInt(LIns *i)
|
|
|
|
{
|
|
|
|
return i->isop(LIR_i2f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isPromoteUint(LIns *i)
|
|
|
|
{
|
|
|
|
return i->isop(LIR_u2f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isPromote(LIns *i)
|
|
|
|
{
|
|
|
|
return isPromoteInt(i) || isPromoteUint(i);;
|
|
|
|
}
|
|
|
|
|
|
|
|
class FuncFilter: public LirWriter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FuncFilter(LirWriter *out):
|
|
|
|
LirWriter(out)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LInsp ins2(LOpcode v, LInsp s1, LInsp s0)
|
|
|
|
{
|
|
|
|
if (s0 == s1 && v == LIR_feq) {
|
|
|
|
if (isPromote(s0)) {
|
|
|
|
// double(int) and double(uint) cannot be nan
|
|
|
|
return insImm(1);
|
|
|
|
}
|
|
|
|
if (s0->isop(LIR_fmul) || s0->isop(LIR_fsub) || s0->isop(LIR_fadd)) {
|
|
|
|
LInsp lhs = s0->oprnd1();
|
|
|
|
LInsp rhs = s0->oprnd2();
|
|
|
|
if (isPromote(lhs) && isPromote(rhs)) {
|
|
|
|
// add/sub/mul promoted ints can't be nan
|
|
|
|
return insImm(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (v >= LIR_feq && v <= LIR_fge) {
|
|
|
|
if (isPromoteInt(s0) && isPromoteInt(s1)) {
|
|
|
|
// demote fcmp to cmp
|
|
|
|
v = LOpcode(v + (LIR_eq - LIR_feq));
|
|
|
|
return out->ins2(v, demote(out, s1), demote(out, s0));
|
|
|
|
} else if (isPromoteUint(s0) && isPromoteUint(s1)) {
|
|
|
|
// uint compare
|
|
|
|
v = LOpcode(v + (LIR_eq - LIR_feq));
|
|
|
|
if (v != LIR_eq)
|
|
|
|
v = LOpcode(v + (LIR_ult - LIR_lt)); // cmp -> ucmp
|
|
|
|
return out->ins2(v, demote(out, s1), demote(out, s0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out->ins2(v, s1, s0);
|
|
|
|
}
|
|
|
|
|
|
|
|
LInsp insCall(int32_t fid, LInsp args[])
|
|
|
|
{
|
2008-07-06 16:38:54 -07:00
|
|
|
switch (fid) {
|
|
|
|
case F_doubleToInt32:
|
2008-07-05 22:20:35 -07:00
|
|
|
LInsp s0 = args[0];
|
|
|
|
if (s0->isop(LIR_fadd) || s0->isop(LIR_fsub) || s0->isop(LIR_fmul)) {
|
|
|
|
LInsp lhs = s0->oprnd1();
|
|
|
|
LInsp rhs = s0->oprnd2();
|
|
|
|
if (isPromote(lhs) && isPromote(rhs)) {
|
|
|
|
LOpcode op = LOpcode(s0->opcode() & ~LIR64);
|
|
|
|
return out->ins2(op, demote(out, lhs), demote(out, rhs));
|
|
|
|
}
|
|
|
|
}
|
2008-07-06 17:32:21 -07:00
|
|
|
if (s0->isop(LIR_i2f) || s0->isop(LIR_u2f)) {
|
|
|
|
return s0->oprnd1();
|
|
|
|
}
|
2008-07-06 16:38:54 -07:00
|
|
|
break;
|
|
|
|
case F_BoxDouble:
|
|
|
|
LInsp s1 = args[1];
|
|
|
|
if (s1->isop(LIR_i2f)) {
|
|
|
|
LInsp i = s1->oprnd1();
|
|
|
|
return out->insCall(F_BoxInt32, &i);
|
|
|
|
}
|
|
|
|
break;
|
2008-07-05 22:20:35 -07:00
|
|
|
}
|
|
|
|
return out->insCall(fid, args);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-07-06 11:48:41 -07:00
|
|
|
class ExitFilter: public LirWriter
|
|
|
|
{
|
|
|
|
TraceRecorder& recorder;
|
|
|
|
public:
|
|
|
|
ExitFilter(LirWriter *out, TraceRecorder& _recorder):
|
|
|
|
LirWriter(out), recorder(_recorder)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine the type of a store by looking at the current type of the actual value the
|
|
|
|
interpreter is using. For numbers we have to check what kind of store we used last
|
|
|
|
(integer or double) to figure out what the side exit show reflect in its typemap. */
|
|
|
|
int getStoreType(jsval& v) {
|
2008-07-06 15:55:04 -07:00
|
|
|
int t = isNumber(v)
|
|
|
|
? (recorder.get(&v)->isQuad() ? JSVAL_DOUBLE : JSVAL_INT)
|
|
|
|
: JSVAL_TAG(v);
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("%c", "OID?S?B"[t]);
|
|
|
|
#endif
|
|
|
|
return t;
|
2008-07-06 11:48:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write out a type map for the current scopes and all outer scopes,
|
|
|
|
up until the entry scope. */
|
|
|
|
void
|
|
|
|
buildTypeMap(JSStackFrame* fp, JSFrameRegs& regs, char* m)
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("side exit type map: ");
|
|
|
|
#endif
|
2008-07-06 11:48:41 -07:00
|
|
|
if (fp != recorder.getEntryFrame())
|
|
|
|
buildTypeMap(fp->down, *fp->down->regs, m);
|
|
|
|
for (unsigned n = 0; n < fp->argc; ++n)
|
|
|
|
*m++ = getStoreType(fp->argv[n]);
|
|
|
|
for (unsigned n = 0; n < fp->nvars; ++n)
|
|
|
|
*m++ = getStoreType(fp->vars[n]);
|
|
|
|
for (jsval* sp = fp->spbase; sp < regs.sp; ++sp)
|
|
|
|
*m++ = getStoreType(*sp);
|
2008-07-06 15:55:04 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
2008-07-06 11:48:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual LInsp insGuard(LOpcode v, LIns *c, SideExit *x) {
|
|
|
|
VMSideExitInfo* i = (VMSideExitInfo*)x->vmprivate;
|
|
|
|
buildTypeMap(recorder.getFp(), recorder.getRegs(), i->typeMap);
|
|
|
|
return out->insGuard(v, c, x);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-07-05 10:41:35 -07:00
|
|
|
TraceRecorder::TraceRecorder(JSContext* cx, Fragmento* fragmento, Fragment* _fragment)
|
2008-06-26 22:33:33 -07:00
|
|
|
{
|
2008-06-28 18:47:12 -07:00
|
|
|
this->cx = cx;
|
2008-07-02 17:19:07 -07:00
|
|
|
this->fragment = _fragment;
|
2008-06-28 18:47:12 -07:00
|
|
|
entryFrame = cx->fp;
|
2008-07-04 15:07:05 -07:00
|
|
|
entryRegs.pc = entryFrame->regs->pc;
|
2008-07-04 03:06:18 -07:00
|
|
|
entryRegs.sp = entryFrame->regs->sp;
|
2008-07-01 02:37:07 -07:00
|
|
|
|
2008-07-05 16:28:03 -07:00
|
|
|
#ifdef DEBUG
|
2008-07-04 15:07:05 -07:00
|
|
|
printf("entryRegs.pc=%p opcode=%d\n", entryRegs.pc, *entryRegs.pc);
|
2008-07-05 16:28:03 -07:00
|
|
|
#endif
|
|
|
|
|
2008-07-02 17:19:07 -07:00
|
|
|
fragment->calldepth = 0;
|
2008-06-27 18:06:50 -07:00
|
|
|
lirbuf = new (&gc) LirBuffer(fragmento, builtins);
|
2008-06-30 18:08:32 -07:00
|
|
|
fragment->lirbuf = lirbuf;
|
|
|
|
lir = lir_buf_writer = new (&gc) LirBufWriter(lirbuf);
|
2008-07-05 10:41:35 -07:00
|
|
|
#ifdef DEBUG
|
2008-06-27 18:06:50 -07:00
|
|
|
lirbuf->names = new (&gc) LirNameMap(&gc, builtins, fragmento->labels);
|
2008-06-30 18:08:32 -07:00
|
|
|
lir = verbose_filter = new (&gc) VerboseWriter(&gc, lir, lirbuf->names);
|
2008-07-05 10:41:35 -07:00
|
|
|
#endif
|
2008-06-30 18:08:32 -07:00
|
|
|
lir = cse_filter = new (&gc) CseFilter(lir, &gc);
|
|
|
|
lir = expr_filter = new (&gc) ExprFilter(lir);
|
2008-07-06 11:48:41 -07:00
|
|
|
lir = exit_filter = new (&gc) ExitFilter(lir, *this);
|
2008-07-05 23:21:53 -07:00
|
|
|
lir = func_filter = new (&gc) FuncFilter(lir);
|
2008-06-27 18:06:50 -07:00
|
|
|
lir->ins0(LIR_trace);
|
2008-07-01 19:43:10 -07:00
|
|
|
/* generate the entry map and stash it in the trace */
|
2008-07-02 14:38:12 -07:00
|
|
|
entryNativeFrameSlots = nativeFrameSlots(entryFrame, entryRegs);
|
2008-07-02 17:19:07 -07:00
|
|
|
maxNativeFrameSlots = entryNativeFrameSlots;
|
2008-07-05 14:05:25 -07:00
|
|
|
LIns* data = lir_buf_writer->skip(sizeof(VMFragmentInfo) +
|
|
|
|
entryNativeFrameSlots * sizeof(char));
|
2008-07-04 13:23:42 -07:00
|
|
|
fragmentInfo = (VMFragmentInfo*)data->payload();
|
2008-07-06 15:55:04 -07:00
|
|
|
char* m = fragmentInfo->typeMap;
|
|
|
|
for (unsigned n = 0; n < entryFrame->argc; ++n)
|
|
|
|
*m++ = getCoercedType(entryFrame->argv[n]);
|
|
|
|
for (unsigned n = 0; n < entryFrame->nvars; ++n)
|
|
|
|
*m++ = getCoercedType(entryFrame->vars[n]);
|
|
|
|
for (jsval* sp = entryFrame->spbase; sp < entryRegs.sp; ++sp)
|
|
|
|
*m++ = getCoercedType(*sp);
|
2008-07-04 13:23:42 -07:00
|
|
|
fragmentInfo->nativeStackBase = nativeFrameOffset(&cx->fp->spbase[0]);
|
|
|
|
fragment->vmprivate = fragmentInfo;
|
2008-06-27 18:06:50 -07:00
|
|
|
fragment->param0 = lir->insImm8(LIR_param, Assembler::argRegs[0], 0);
|
|
|
|
fragment->param1 = lir->insImm8(LIR_param, Assembler::argRegs[1], 0);
|
2008-06-30 17:12:52 -07:00
|
|
|
fragment->sp = lir->insLoadi(fragment->param0, offsetof(InterpState, sp));
|
2008-07-04 16:24:42 -07:00
|
|
|
cx_ins = lir->insLoadi(fragment->param0, offsetof(InterpState, cx));
|
2008-07-01 05:06:02 -07:00
|
|
|
#ifdef DEBUG
|
2008-07-01 19:43:10 -07:00
|
|
|
lirbuf->names->addName(fragment->param0, "state");
|
2008-07-01 05:06:02 -07:00
|
|
|
lirbuf->names->addName(fragment->sp, "sp");
|
2008-07-02 14:38:12 -07:00
|
|
|
lirbuf->names->addName(cx_ins, "cx");
|
2008-07-01 05:06:02 -07:00
|
|
|
#endif
|
2008-07-05 10:41:35 -07:00
|
|
|
|
2008-06-27 18:06:50 -07:00
|
|
|
JSStackFrame* fp = cx->fp;
|
|
|
|
unsigned n;
|
|
|
|
for (n = 0; n < fp->argc; ++n)
|
2008-07-02 15:14:43 -07:00
|
|
|
import(&fp->argv[n], "arg", n);
|
2008-07-05 10:41:35 -07:00
|
|
|
for (n = 0; n < fp->nvars; ++n)
|
2008-07-02 15:14:43 -07:00
|
|
|
import(&fp->vars[n], "var", n);
|
2008-07-05 11:18:26 -07:00
|
|
|
for (n = 0; n < unsigned(fp->regs->sp - fp->spbase); ++n)
|
2008-07-02 15:14:43 -07:00
|
|
|
import(&fp->spbase[n], "stack", n);
|
2008-06-27 18:06:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TraceRecorder::~TraceRecorder()
|
|
|
|
{
|
2008-06-30 18:08:32 -07:00
|
|
|
#ifdef DEBUG
|
2008-06-27 18:06:50 -07:00
|
|
|
delete lirbuf->names;
|
2008-06-30 18:08:32 -07:00
|
|
|
delete verbose_filter;
|
2008-07-05 10:41:35 -07:00
|
|
|
#endif
|
2008-06-30 18:08:32 -07:00
|
|
|
delete cse_filter;
|
|
|
|
delete expr_filter;
|
2008-07-06 11:48:41 -07:00
|
|
|
delete exit_filter;
|
2008-07-05 23:21:53 -07:00
|
|
|
delete func_filter;
|
2008-06-30 18:08:32 -07:00
|
|
|
delete lir_buf_writer;
|
2008-06-26 22:33:33 -07:00
|
|
|
}
|
|
|
|
|
2008-06-28 17:14:06 -07:00
|
|
|
/* Determine the current call depth (starting with the entry frame.) */
|
|
|
|
unsigned
|
2008-07-05 19:15:00 -07:00
|
|
|
TraceRecorder::getCallDepth() const
|
2008-06-28 17:14:06 -07:00
|
|
|
{
|
2008-06-28 18:47:12 -07:00
|
|
|
JSStackFrame* fp = cx->fp;
|
2008-06-28 17:14:06 -07:00
|
|
|
unsigned depth = 0;
|
|
|
|
while (fp != entryFrame) {
|
|
|
|
++depth;
|
|
|
|
fp = fp->down;
|
|
|
|
}
|
|
|
|
return depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the frame that this address belongs to (if any). */
|
|
|
|
JSStackFrame*
|
|
|
|
TraceRecorder::findFrame(void* p) const
|
|
|
|
{
|
2008-07-05 11:18:26 -07:00
|
|
|
jsval* vp = (jsval*) p;
|
2008-06-28 18:47:12 -07:00
|
|
|
JSStackFrame* fp = cx->fp;
|
2008-07-05 11:29:28 -07:00
|
|
|
for (;;) {
|
2008-07-05 11:18:26 -07:00
|
|
|
// FIXME: fixing bug 441686 collapses the last two tests here
|
|
|
|
if (size_t(vp - fp->argv) < fp->argc ||
|
|
|
|
size_t(vp - fp->vars) < fp->nvars ||
|
|
|
|
size_t(vp - fp->spbase) < fp->script->depth) {
|
2008-06-28 17:14:06 -07:00
|
|
|
return fp;
|
2008-07-05 11:18:26 -07:00
|
|
|
}
|
2008-06-28 17:14:06 -07:00
|
|
|
if (fp == entryFrame)
|
2008-07-05 11:29:28 -07:00
|
|
|
return NULL;
|
2008-06-28 17:14:06 -07:00
|
|
|
fp = fp->down;
|
|
|
|
}
|
2008-07-05 11:29:28 -07:00
|
|
|
JS_NOT_REACHED("findFrame");
|
2008-06-28 17:14:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine whether an address is part of a currently active frame. */
|
|
|
|
bool
|
|
|
|
TraceRecorder::onFrame(void* p) const
|
|
|
|
{
|
|
|
|
return findFrame(p) != NULL;
|
|
|
|
}
|
|
|
|
|
2008-06-30 09:36:10 -07:00
|
|
|
/* Calculate the total number of native frame slots we need from this frame
|
|
|
|
all the way back to the entry frame, including the current stack usage. */
|
2008-06-28 17:14:06 -07:00
|
|
|
unsigned
|
2008-07-01 19:43:10 -07:00
|
|
|
TraceRecorder::nativeFrameSlots(JSStackFrame* fp, JSFrameRegs& regs) const
|
2008-06-28 17:14:06 -07:00
|
|
|
{
|
2008-07-05 11:18:26 -07:00
|
|
|
unsigned slots = 0;
|
2008-07-05 11:29:28 -07:00
|
|
|
for (;;) {
|
2008-07-05 11:18:26 -07:00
|
|
|
slots += fp->argc + fp->nvars + (regs.sp - fp->spbase);
|
2008-06-28 17:14:06 -07:00
|
|
|
if (fp == entryFrame)
|
2008-07-05 11:29:28 -07:00
|
|
|
return slots;
|
2008-06-28 17:14:06 -07:00
|
|
|
fp = fp->down;
|
2008-07-05 10:41:35 -07:00
|
|
|
}
|
2008-07-05 11:29:28 -07:00
|
|
|
JS_NOT_REACHED("nativeFrameSlots");
|
2008-06-28 17:14:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine the offset in the native frame (marshal) for an address
|
|
|
|
that is part of a currently active frame. */
|
2008-07-05 11:18:26 -07:00
|
|
|
size_t
|
2008-06-28 17:14:06 -07:00
|
|
|
TraceRecorder::nativeFrameOffset(void* p) const
|
|
|
|
{
|
2008-07-05 11:18:26 -07:00
|
|
|
jsval* vp = (jsval*) p;
|
2008-06-28 17:14:06 -07:00
|
|
|
JSStackFrame* fp = findFrame(p);
|
|
|
|
JS_ASSERT(fp != NULL); // must be on the frame somewhere
|
2008-07-05 11:18:26 -07:00
|
|
|
size_t offset = size_t(vp - fp->argv);
|
|
|
|
if (offset >= fp->argc) {
|
|
|
|
// FIXME: fixing bug 441686 collapses the vars and spbase cases
|
|
|
|
offset = size_t(vp - fp->vars);
|
|
|
|
if (offset >= fp->nvars) {
|
|
|
|
JS_ASSERT(size_t(vp - fp->spbase) < fp->script->depth);
|
|
|
|
offset = fp->nvars + size_t(vp - fp->spbase);
|
|
|
|
}
|
|
|
|
offset += fp->argc;
|
2008-06-28 17:14:06 -07:00
|
|
|
}
|
2008-07-05 10:41:35 -07:00
|
|
|
if (fp != entryFrame)
|
2008-07-01 19:43:10 -07:00
|
|
|
offset += nativeFrameSlots(fp->down, *fp->regs);
|
2008-06-29 17:17:39 -07:00
|
|
|
return offset * sizeof(double);
|
2008-06-28 17:14:06 -07:00
|
|
|
}
|
|
|
|
|
2008-07-05 10:41:35 -07:00
|
|
|
/* Track the maximum number of native frame slots we need during
|
2008-07-02 17:19:07 -07:00
|
|
|
execution. */
|
|
|
|
void
|
|
|
|
TraceRecorder::trackNativeFrameUse(unsigned slots)
|
|
|
|
{
|
|
|
|
if (slots > maxNativeFrameSlots)
|
|
|
|
maxNativeFrameSlots = slots;
|
|
|
|
}
|
|
|
|
|
2008-07-05 10:41:35 -07:00
|
|
|
/* Unbox a jsval into a slot. Slots are wide enough to hold double values
|
2008-06-30 09:36:10 -07:00
|
|
|
directly (instead of storing a pointer to them). */
|
2008-07-02 17:19:07 -07:00
|
|
|
static bool
|
|
|
|
unbox_jsval(jsval v, int t, double* slot)
|
2008-06-29 20:56:06 -07:00
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
if (JSVAL_IS_INT(v)) {
|
|
|
|
if (t == JSVAL_INT || t == JSVAL_DOUBLE) {
|
|
|
|
JS_ASSERT(t == JSVAL_INT || t == JSVAL_DOUBLE);
|
|
|
|
jsint i = JSVAL_TO_INT(v);
|
|
|
|
if (t == JSVAL_INT)
|
|
|
|
*(jsint*)slot = i;
|
|
|
|
else
|
|
|
|
*(jsdouble*)slot = (jsdouble)i;
|
|
|
|
return true;
|
|
|
|
}
|
2008-06-29 20:56:06 -07:00
|
|
|
return false;
|
2008-07-06 15:55:04 -07:00
|
|
|
}
|
|
|
|
if (JSVAL_TAG(v) != (jsuint)t)
|
|
|
|
return false;
|
|
|
|
switch (JSVAL_TAG(v)) {
|
|
|
|
case JSVAL_BOOLEAN:
|
2008-06-29 20:56:06 -07:00
|
|
|
*(bool*)slot = JSVAL_TO_BOOLEAN(v);
|
2008-07-02 02:53:24 -07:00
|
|
|
break;
|
2008-07-06 15:55:04 -07:00
|
|
|
case JSVAL_DOUBLE:
|
2008-06-29 20:56:06 -07:00
|
|
|
*(jsdouble*)slot = *JSVAL_TO_DOUBLE(v);
|
2008-07-02 02:53:24 -07:00
|
|
|
break;
|
2008-07-06 15:55:04 -07:00
|
|
|
case JSVAL_STRING:
|
2008-07-02 02:53:24 -07:00
|
|
|
*(JSString**)slot = JSVAL_TO_STRING(v);
|
|
|
|
break;
|
2008-07-06 15:55:04 -07:00
|
|
|
default:
|
2008-06-29 20:56:06 -07:00
|
|
|
JS_ASSERT(JSVAL_IS_GCTHING(v));
|
|
|
|
*(void**)slot = JSVAL_TO_GCTHING(v);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-07-02 02:53:24 -07:00
|
|
|
/* Box a value from the native stack back into the jsval format. Integers
|
|
|
|
that are too large to fit into a jsval are automatically boxed into
|
|
|
|
heap-allocated doubles. */
|
2008-07-05 10:41:35 -07:00
|
|
|
static bool
|
2008-07-02 17:19:07 -07:00
|
|
|
box_jsval(JSContext* cx, jsval* vp, int t, double* slot)
|
2008-06-29 23:02:22 -07:00
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
jsdouble d;
|
2008-06-29 23:02:22 -07:00
|
|
|
switch (t) {
|
2008-07-05 10:41:35 -07:00
|
|
|
case JSVAL_BOOLEAN:
|
2008-06-29 23:02:22 -07:00
|
|
|
*vp = BOOLEAN_TO_JSVAL(*(bool*)slot);
|
2008-07-02 14:38:12 -07:00
|
|
|
break;
|
2008-07-05 10:41:35 -07:00
|
|
|
case JSVAL_INT:
|
2008-07-02 02:53:24 -07:00
|
|
|
jsint i = *(jsint*)slot;
|
2008-07-06 15:55:04 -07:00
|
|
|
if (INT_FITS_IN_JSVAL(i)) {
|
2008-07-04 16:24:42 -07:00
|
|
|
*vp = INT_TO_JSVAL(i);
|
2008-07-06 15:55:04 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
d = (jsdouble)i;
|
|
|
|
goto allocate_double;
|
2008-07-05 10:41:35 -07:00
|
|
|
case JSVAL_DOUBLE:
|
2008-07-06 15:55:04 -07:00
|
|
|
d = *slot;
|
|
|
|
allocate_double:
|
|
|
|
/* GC is not allowed to hit as we come out of the native frame. We have to teach
|
|
|
|
the GC how to scan native frames to avoid this race condition. */
|
|
|
|
JS_ASSERT(cx->doubleFreeList != NULL);
|
|
|
|
return js_NewDoubleInRootedValue(cx, d, vp);
|
2008-07-05 10:41:35 -07:00
|
|
|
case JSVAL_STRING:
|
2008-06-29 23:02:22 -07:00
|
|
|
*vp = STRING_TO_JSVAL(*(JSString**)slot);
|
2008-07-02 14:38:12 -07:00
|
|
|
break;
|
2008-07-05 10:41:35 -07:00
|
|
|
default:
|
2008-06-29 23:02:22 -07:00
|
|
|
JS_ASSERT(t == JSVAL_OBJECT);
|
|
|
|
*vp = OBJECT_TO_JSVAL(*(JSObject**)slot);
|
2008-07-02 14:38:12 -07:00
|
|
|
break;
|
2008-06-29 23:02:22 -07:00
|
|
|
}
|
2008-07-02 14:38:12 -07:00
|
|
|
return true;
|
2008-06-29 23:02:22 -07:00
|
|
|
}
|
|
|
|
|
2008-07-06 15:55:04 -07:00
|
|
|
/* Attempt to unbox the given JS frame into a native frame, checking along the way that the
|
|
|
|
supplied typemap holds. */
|
2008-07-02 17:19:07 -07:00
|
|
|
static bool
|
|
|
|
unbox(JSStackFrame* fp, JSFrameRegs& regs, char* m, double* native)
|
2008-06-29 20:56:06 -07:00
|
|
|
{
|
|
|
|
jsval* vp;
|
|
|
|
for (vp = fp->argv; vp < fp->argv + fp->argc; ++vp)
|
|
|
|
if (!unbox_jsval(*vp, (JSType)*m++, native++))
|
|
|
|
return false;
|
|
|
|
for (vp = fp->vars; vp < fp->vars + fp->nvars; ++vp)
|
|
|
|
if (!unbox_jsval(*vp, (JSType)*m++, native++))
|
|
|
|
return false;
|
2008-07-01 19:43:10 -07:00
|
|
|
for (vp = fp->spbase; vp < regs.sp; ++vp)
|
2008-06-29 20:56:06 -07:00
|
|
|
if (!unbox_jsval(*vp, (JSType)*m++, native++))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-07-06 15:55:04 -07:00
|
|
|
/* Box the given native frame into a JS frame. This only fails due to a hard error
|
|
|
|
(out of memory for example). */
|
2008-07-02 17:19:07 -07:00
|
|
|
static bool
|
|
|
|
box(JSContext* cx, JSStackFrame* fp, JSFrameRegs& regs, char* m, double* native)
|
2008-06-29 23:02:22 -07:00
|
|
|
{
|
|
|
|
jsval* vp;
|
|
|
|
for (vp = fp->argv; vp < fp->argv + fp->argc; ++vp)
|
2008-07-02 17:19:07 -07:00
|
|
|
if (!box_jsval(cx, vp, (JSType)*m++, native++))
|
2008-06-29 23:02:22 -07:00
|
|
|
return false;
|
|
|
|
for (vp = fp->vars; vp < fp->vars + fp->nvars; ++vp)
|
2008-07-02 17:19:07 -07:00
|
|
|
if (!box_jsval(cx, vp, (JSType)*m++, native++))
|
2008-06-29 23:02:22 -07:00
|
|
|
return false;
|
2008-07-01 19:43:10 -07:00
|
|
|
for (vp = fp->spbase; vp < regs.sp; ++vp)
|
2008-07-02 17:19:07 -07:00
|
|
|
if (!box_jsval(cx, vp, (JSType)*m++, native++))
|
2008-06-29 23:02:22 -07:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-06-30 09:36:10 -07:00
|
|
|
/* Emit load instructions onto the trace that read the initial stack state. */
|
2008-07-05 10:41:35 -07:00
|
|
|
void
|
2008-07-02 15:14:43 -07:00
|
|
|
TraceRecorder::import(jsval* p, char *prefix, int index)
|
2008-06-26 22:19:11 -07:00
|
|
|
{
|
2008-06-28 17:14:06 -07:00
|
|
|
JS_ASSERT(onFrame(p));
|
2008-07-06 15:55:04 -07:00
|
|
|
LIns *ins = lir->insLoad(isNumber(*p) ? LIR_ldq : LIR_ld,
|
2008-07-04 13:23:42 -07:00
|
|
|
fragment->sp, -fragmentInfo->nativeStackBase + nativeFrameOffset(p) + 8);
|
2008-07-01 05:06:02 -07:00
|
|
|
tracker.set(p, ins);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (prefix) {
|
|
|
|
char name[16];
|
|
|
|
JS_ASSERT(strlen(prefix) < 10);
|
2008-07-01 15:58:47 -07:00
|
|
|
JS_snprintf(name, sizeof name, "$%s%d", prefix, index);
|
2008-07-01 05:06:02 -07:00
|
|
|
lirbuf->names->addName(ins, name);
|
|
|
|
}
|
|
|
|
#endif
|
2008-06-26 22:19:11 -07:00
|
|
|
}
|
|
|
|
|
2008-07-05 10:41:35 -07:00
|
|
|
/* Update the tracker. If the value is part of any argv/vars/stack of any
|
2008-06-30 09:36:10 -07:00
|
|
|
currently active frame (onFrame), then issue a write back store. */
|
2008-07-05 10:41:35 -07:00
|
|
|
void
|
2008-06-26 22:58:57 -07:00
|
|
|
TraceRecorder::set(void* p, LIns* i)
|
2008-06-26 22:41:10 -07:00
|
|
|
{
|
2008-06-30 09:36:10 -07:00
|
|
|
tracker.set(p, i);
|
2008-07-05 10:41:35 -07:00
|
|
|
if (onFrame(p))
|
2008-07-04 13:23:42 -07:00
|
|
|
lir->insStorei(i, fragment->sp, -fragmentInfo->nativeStackBase + nativeFrameOffset(p) + 8);
|
2008-06-26 22:41:10 -07:00
|
|
|
}
|
|
|
|
|
2008-07-05 10:41:35 -07:00
|
|
|
LIns*
|
2008-06-26 22:58:57 -07:00
|
|
|
TraceRecorder::get(void* p)
|
2008-06-26 22:41:10 -07:00
|
|
|
{
|
|
|
|
return tracker.get(p);
|
|
|
|
}
|
|
|
|
|
2008-07-06 11:48:41 -07:00
|
|
|
JSStackFrame*
|
|
|
|
TraceRecorder::getEntryFrame() const
|
|
|
|
{
|
|
|
|
return entryFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSStackFrame*
|
|
|
|
TraceRecorder::getFp() const
|
|
|
|
{
|
|
|
|
return cx->fp;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSFrameRegs&
|
|
|
|
TraceRecorder::getRegs() const
|
|
|
|
{
|
|
|
|
return *cx->fp->regs;
|
|
|
|
}
|
|
|
|
|
2008-07-01 19:43:10 -07:00
|
|
|
SideExit*
|
|
|
|
TraceRecorder::snapshot()
|
|
|
|
{
|
|
|
|
/* generate the entry map and stash it in the trace */
|
2008-07-03 23:57:57 -07:00
|
|
|
unsigned slots = nativeFrameSlots(cx->fp, *cx->fp->regs);
|
2008-07-02 17:19:07 -07:00
|
|
|
trackNativeFrameUse(slots);
|
2008-07-06 11:48:41 -07:00
|
|
|
/* reserve space for the type map, ExitFilter will write it out for us */
|
2008-07-02 18:06:24 -07:00
|
|
|
LIns* data = lir_buf_writer->skip(sizeof(VMSideExitInfo) + slots * sizeof(char));
|
|
|
|
VMSideExitInfo* si = (VMSideExitInfo*)data->payload();
|
2008-07-01 19:43:10 -07:00
|
|
|
/* setup side exit structure */
|
|
|
|
memset(&exit, 0, sizeof(exit));
|
2008-07-05 10:41:35 -07:00
|
|
|
#ifdef DEBUG
|
2008-07-01 19:43:10 -07:00
|
|
|
exit.from = fragment;
|
2008-07-05 10:41:35 -07:00
|
|
|
#endif
|
2008-07-05 19:15:00 -07:00
|
|
|
exit.calldepth = getCallDepth();
|
2008-07-04 13:23:42 -07:00
|
|
|
exit.sp_adj = (cx->fp->regs->sp - entryRegs.sp) * sizeof(double);
|
2008-07-03 23:57:57 -07:00
|
|
|
exit.ip_adj = cx->fp->regs->pc - entryRegs.pc;
|
2008-07-02 18:06:24 -07:00
|
|
|
exit.vmprivate = si;
|
2008-07-01 19:43:10 -07:00
|
|
|
return &exit;
|
|
|
|
}
|
|
|
|
|
2008-06-27 00:22:16 -07:00
|
|
|
void
|
2008-07-04 13:23:42 -07:00
|
|
|
TraceRecorder::guard(bool expected, LIns* cond)
|
2008-06-27 00:22:16 -07:00
|
|
|
{
|
2008-07-05 10:41:35 -07:00
|
|
|
lir->insGuard(expected ? LIR_xf : LIR_xt,
|
|
|
|
cond,
|
|
|
|
snapshot());
|
2008-06-27 00:22:16 -07:00
|
|
|
}
|
|
|
|
|
2008-07-05 23:21:53 -07:00
|
|
|
bool
|
2008-07-06 15:55:04 -07:00
|
|
|
TraceRecorder::checkType(jsval& v, int type)
|
2008-07-05 23:21:53 -07:00
|
|
|
{
|
2008-07-06 17:32:21 -07:00
|
|
|
/* we initially start all numbers out as JSVAL_DOUBLE so this can't be integer here */
|
|
|
|
JS_ASSERT(type != JSVAL_INT);
|
|
|
|
if (type == JSVAL_DOUBLE && isNumber(v)) {
|
|
|
|
/* lets see whether this is an integer value that we are propagating across the
|
|
|
|
loop */
|
|
|
|
LIns* i = get(&v);
|
|
|
|
if (i->isop(LIR_i2f)) {
|
|
|
|
printf("yes!\n");
|
|
|
|
}
|
2008-07-05 23:21:53 -07:00
|
|
|
return true;
|
2008-07-06 17:32:21 -07:00
|
|
|
}
|
2008-07-06 15:55:04 -07:00
|
|
|
return JSVAL_TAG(v) == (jsuint)type;
|
2008-07-05 23:21:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure that all loop-carrying values have a stable type along the loop edge. */
|
|
|
|
bool
|
|
|
|
TraceRecorder::verifyTypeStability(JSStackFrame* fp, JSFrameRegs& regs, char* m)
|
|
|
|
{
|
|
|
|
if (fp != entryFrame)
|
|
|
|
verifyTypeStability(fp->down, *fp->down->regs, m);
|
|
|
|
for (unsigned n = 0; n < fp->argc; ++n, ++m)
|
2008-07-06 15:55:04 -07:00
|
|
|
if (!checkType(fp->argv[n], *m))
|
2008-07-05 23:21:53 -07:00
|
|
|
return false;
|
|
|
|
for (unsigned n = 0; n < fp->nvars; ++n, ++m)
|
2008-07-06 15:55:04 -07:00
|
|
|
if (!checkType(fp->vars[n], *m))
|
2008-07-05 23:21:53 -07:00
|
|
|
return false;
|
|
|
|
for (jsval* sp = fp->spbase; sp < regs.sp; ++sp, ++m)
|
2008-07-06 15:55:04 -07:00
|
|
|
if (!checkType(*sp, *m))
|
2008-07-05 23:21:53 -07:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-06-27 18:06:50 -07:00
|
|
|
void
|
|
|
|
TraceRecorder::closeLoop(Fragmento* fragmento)
|
|
|
|
{
|
2008-07-05 23:21:53 -07:00
|
|
|
if (!verifyTypeStability(entryFrame, entryRegs, fragmentInfo->typeMap)) {
|
2008-07-02 15:14:43 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("Trace rejected: unstable loop variables.\n");
|
2008-07-05 10:41:35 -07:00
|
|
|
#endif
|
2008-07-02 15:31:40 -07:00
|
|
|
return;
|
2008-07-02 15:14:43 -07:00
|
|
|
}
|
2008-06-27 18:06:50 -07:00
|
|
|
fragment->lastIns = lir->ins0(LIR_loop);
|
2008-07-02 17:19:07 -07:00
|
|
|
((VMFragmentInfo*)fragment->vmprivate)->maxNativeFrameSlots = maxNativeFrameSlots;
|
2008-06-27 18:06:50 -07:00
|
|
|
compile(fragmento->assm(), fragment);
|
|
|
|
}
|
|
|
|
|
2008-07-04 00:51:30 -07:00
|
|
|
bool
|
2008-07-05 19:15:00 -07:00
|
|
|
TraceRecorder::loopEdge()
|
2008-06-27 20:58:06 -07:00
|
|
|
{
|
2008-07-04 15:07:05 -07:00
|
|
|
if (cx->fp->regs->pc == entryRegs.pc) {
|
2008-07-04 00:51:30 -07:00
|
|
|
closeLoop(JS_TRACE_MONITOR(cx).fragmento);
|
|
|
|
return false; /* done recording */
|
|
|
|
}
|
|
|
|
return false; /* abort recording */
|
|
|
|
}
|
|
|
|
|
2008-07-05 19:15:00 -07:00
|
|
|
void
|
|
|
|
TraceRecorder::stop()
|
|
|
|
{
|
|
|
|
fragment->blacklist();
|
|
|
|
}
|
|
|
|
|
2008-07-05 10:41:35 -07:00
|
|
|
void
|
2008-07-04 00:51:30 -07:00
|
|
|
js_DeleteRecorder(JSContext* cx)
|
|
|
|
{
|
|
|
|
JSTraceMonitor* tm = &JS_TRACE_MONITOR(cx);
|
|
|
|
delete tm->recorder;
|
|
|
|
tm->recorder = NULL;
|
2008-06-27 20:58:06 -07:00
|
|
|
}
|
|
|
|
|
2008-07-05 23:21:53 -07:00
|
|
|
#define HOTLOOP1 10
|
|
|
|
#define HOTLOOP2 13
|
|
|
|
#define HOTLOOP3 37
|
2008-07-05 19:15:00 -07:00
|
|
|
|
2008-07-04 00:51:30 -07:00
|
|
|
bool
|
2008-07-04 15:07:05 -07:00
|
|
|
js_LoopEdge(JSContext* cx)
|
2008-06-11 20:22:00 -07:00
|
|
|
{
|
2008-06-22 23:42:54 -07:00
|
|
|
JSTraceMonitor* tm = &JS_TRACE_MONITOR(cx);
|
2008-07-05 10:41:35 -07:00
|
|
|
|
2008-07-04 00:51:30 -07:00
|
|
|
/* is the recorder currently active? */
|
|
|
|
if (tm->recorder) {
|
2008-07-05 19:15:00 -07:00
|
|
|
if (tm->recorder->loopEdge())
|
2008-07-04 00:51:30 -07:00
|
|
|
return true; /* keep recording */
|
|
|
|
js_DeleteRecorder(cx);
|
|
|
|
return false; /* done recording */
|
|
|
|
}
|
2008-07-05 10:41:35 -07:00
|
|
|
|
2008-07-02 17:19:07 -07:00
|
|
|
InterpState state;
|
2008-07-04 15:07:05 -07:00
|
|
|
state.ip = (FOpcodep)cx->fp->regs->pc;
|
2008-07-05 10:41:35 -07:00
|
|
|
|
2008-07-02 17:19:07 -07:00
|
|
|
Fragment* f = tm->fragmento->getLoop(state);
|
2008-07-04 00:51:30 -07:00
|
|
|
if (!f->code()) {
|
2008-07-05 23:21:53 -07:00
|
|
|
int hits = ++f->hits();
|
2008-07-06 06:56:25 -07:00
|
|
|
if (!f->isBlacklisted() && hits >= HOTLOOP1) {
|
2008-07-05 23:21:53 -07:00
|
|
|
if (hits == HOTLOOP1 || hits == HOTLOOP2 || hits == HOTLOOP3) {
|
|
|
|
tm->recorder = new (&gc) TraceRecorder(cx, tm->fragmento, f);
|
|
|
|
return true; /* start recording */
|
|
|
|
}
|
|
|
|
if (hits > HOTLOOP3)
|
|
|
|
f->blacklist();
|
2008-07-05 19:15:00 -07:00
|
|
|
}
|
|
|
|
return false;
|
2008-07-04 00:51:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* execute previously recorded race */
|
2008-07-02 17:19:07 -07:00
|
|
|
VMFragmentInfo* fi = (VMFragmentInfo*)f->vmprivate;
|
|
|
|
double native[fi->maxNativeFrameSlots+1];
|
|
|
|
#ifdef DEBUG
|
|
|
|
*(uint64*)&native[fi->maxNativeFrameSlots] = 0xdeadbeefdeadbeefLL;
|
2008-07-05 10:41:35 -07:00
|
|
|
#endif
|
2008-07-06 15:55:04 -07:00
|
|
|
if (!unbox(cx->fp, *cx->fp->regs, fi->typeMap, native)) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("typemap mismatch, skipping trace.\n");
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
2008-07-05 14:05:25 -07:00
|
|
|
double* entry_sp = &native[fi->nativeStackBase/sizeof(double) +
|
|
|
|
(cx->fp->regs->sp - cx->fp->spbase - 1)];
|
2008-07-04 13:23:42 -07:00
|
|
|
state.sp = (void*)entry_sp;
|
2008-07-02 17:19:07 -07:00
|
|
|
state.rp = NULL;
|
2008-07-04 16:24:42 -07:00
|
|
|
state.f = NULL;
|
|
|
|
state.cx = cx;
|
2008-07-02 17:19:07 -07:00
|
|
|
union { NIns *code; GuardRecord* (FASTCALL *func)(InterpState*, Fragment*); } u;
|
|
|
|
u.code = f->code();
|
2008-07-05 17:10:58 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("entering trace, pc=%p, sp=%p\n", state.ip, state.sp);
|
|
|
|
uint64 start = rdtsc();
|
|
|
|
#endif
|
2008-07-02 17:19:07 -07:00
|
|
|
GuardRecord* lr = u.func(&state, NULL);
|
2008-07-05 17:10:58 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("leaving trace, pc=%p, sp=%p, cycles=%llu\n", state.ip, state.sp,
|
|
|
|
(rdtsc() - start));
|
|
|
|
#endif
|
2008-07-04 15:07:05 -07:00
|
|
|
cx->fp->regs->sp += (((double*)state.sp - entry_sp));
|
2008-07-02 17:19:07 -07:00
|
|
|
cx->fp->regs->pc = (jsbytecode*)state.ip;
|
2008-07-02 18:06:24 -07:00
|
|
|
box(cx, cx->fp, *cx->fp->regs, ((VMSideExitInfo*)lr->vmprivate)->typeMap, native);
|
2008-07-02 17:19:07 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
JS_ASSERT(*(uint64*)&native[fi->maxNativeFrameSlots] == 0xdeadbeefdeadbeefLL);
|
2008-07-05 10:41:35 -07:00
|
|
|
#endif
|
|
|
|
|
2008-07-04 00:51:30 -07:00
|
|
|
return false; /* continue with regular interpreter */
|
2008-07-01 02:37:07 -07:00
|
|
|
}
|
|
|
|
|
2008-06-28 18:19:21 -07:00
|
|
|
void
|
2008-07-04 01:10:57 -07:00
|
|
|
js_AbortRecording(JSContext* cx, const char* reason)
|
2008-06-28 18:19:21 -07:00
|
|
|
{
|
2008-07-04 01:10:57 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("Abort recording: %s.\n", reason);
|
2008-07-05 10:41:35 -07:00
|
|
|
#endif
|
2008-07-05 19:15:00 -07:00
|
|
|
JS_TRACE_MONITOR(cx).recorder->stop();
|
2008-07-01 02:37:07 -07:00
|
|
|
js_DeleteRecorder(cx);
|
2008-06-28 18:19:21 -07:00
|
|
|
}
|
|
|
|
|
2008-07-05 19:15:00 -07:00
|
|
|
extern void
|
|
|
|
js_InitJIT(JSContext* cx)
|
|
|
|
{
|
|
|
|
JSTraceMonitor* tm = &JS_TRACE_MONITOR(cx);
|
|
|
|
if (!tm->fragmento) {
|
|
|
|
Fragmento* fragmento = new (&gc) Fragmento(core);
|
|
|
|
#ifdef DEBUG
|
|
|
|
fragmento->labels = new (&gc) LabelMap(core, NULL);
|
|
|
|
#endif
|
|
|
|
fragmento->assm()->setCallTable(builtins);
|
|
|
|
tm->fragmento = fragmento;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-04 03:06:18 -07:00
|
|
|
jsval&
|
|
|
|
TraceRecorder::argval(unsigned n) const
|
|
|
|
{
|
|
|
|
JS_ASSERT((n >= 0) && (n <= cx->fp->argc));
|
|
|
|
return cx->fp->argv[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
jsval&
|
|
|
|
TraceRecorder::varval(unsigned n) const
|
|
|
|
{
|
|
|
|
JS_ASSERT((n >= 0) && (n <= cx->fp->nvars));
|
|
|
|
return cx->fp->vars[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
jsval&
|
|
|
|
TraceRecorder::stackval(int n) const
|
|
|
|
{
|
2008-07-05 14:05:25 -07:00
|
|
|
JS_ASSERT((cx->fp->regs->sp + n < cx->fp->spbase + cx->fp->script->depth) &&
|
|
|
|
(cx->fp->regs->sp + n >= cx->fp->spbase));
|
2008-07-04 03:06:18 -07:00
|
|
|
return cx->fp->regs->sp[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
LIns*
|
2008-07-05 10:41:35 -07:00
|
|
|
TraceRecorder::arg(unsigned n)
|
2008-07-04 03:06:18 -07:00
|
|
|
{
|
|
|
|
return get(&argval(n));
|
|
|
|
}
|
|
|
|
|
2008-07-04 15:21:56 -07:00
|
|
|
void
|
|
|
|
TraceRecorder::arg(unsigned n, LIns* i)
|
|
|
|
{
|
|
|
|
set(&argval(n), i);
|
|
|
|
}
|
|
|
|
|
2008-07-04 03:06:18 -07:00
|
|
|
LIns*
|
2008-07-05 10:41:35 -07:00
|
|
|
TraceRecorder::var(unsigned n)
|
2008-07-04 03:06:18 -07:00
|
|
|
{
|
|
|
|
return get(&varval(n));
|
|
|
|
}
|
|
|
|
|
2008-07-04 15:21:56 -07:00
|
|
|
void
|
|
|
|
TraceRecorder::var(unsigned n, LIns* i)
|
|
|
|
{
|
|
|
|
set(&varval(n), i);
|
|
|
|
}
|
|
|
|
|
2008-07-04 03:06:18 -07:00
|
|
|
LIns*
|
|
|
|
TraceRecorder::stack(int n)
|
|
|
|
{
|
|
|
|
return get(&stackval(n));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-07-05 10:41:35 -07:00
|
|
|
TraceRecorder::stack(int n, LIns* i)
|
2008-07-04 03:06:18 -07:00
|
|
|
{
|
|
|
|
set(&stackval(n), i);
|
|
|
|
}
|
|
|
|
|
2008-07-06 15:55:04 -07:00
|
|
|
LIns* TraceRecorder::f2i(LIns* f)
|
|
|
|
{
|
|
|
|
return lir->insCall(F_doubleToInt32, &f);
|
|
|
|
}
|
|
|
|
|
2008-07-05 22:23:34 -07:00
|
|
|
bool TraceRecorder::ifop(bool sense)
|
|
|
|
{
|
|
|
|
jsval& v = stackval(-1);
|
|
|
|
LIns* cond_ins;
|
|
|
|
bool cond;
|
2008-07-06 12:16:55 -07:00
|
|
|
if (JSVAL_IS_BOOLEAN(v)) {
|
2008-07-06 16:18:45 -07:00
|
|
|
cond_ins = lir->ins_eq0(get(&v));
|
2008-07-05 22:23:34 -07:00
|
|
|
cond = JSVAL_TO_BOOLEAN(v);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sense) {
|
|
|
|
cond = !cond;
|
|
|
|
cond_ins = lir->ins_eq0(cond_ins);
|
|
|
|
}
|
|
|
|
guard(cond, cond_ins);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-07-04 03:06:18 -07:00
|
|
|
bool
|
|
|
|
TraceRecorder::inc(jsval& v, jsint incr, bool pre)
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
if (isNumber(v)) {
|
|
|
|
jsdouble d = (jsdouble)incr;
|
2008-07-04 03:06:18 -07:00
|
|
|
LIns* before = get(&v);
|
2008-07-06 15:55:04 -07:00
|
|
|
LIns* after = lir->ins2(LIR_fadd, before, lir->insImmq(*(uint64_t*)&d));
|
2008-07-04 03:06:18 -07:00
|
|
|
set(&v, after);
|
|
|
|
stack(0, pre ? after : before);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TraceRecorder::cmp(LOpcode op, bool negate)
|
|
|
|
{
|
|
|
|
jsval& r = stackval(-1);
|
|
|
|
jsval& l = stackval(-2);
|
2008-07-06 15:55:04 -07:00
|
|
|
if (isNumber(l) && isNumber(r)) {
|
2008-07-04 03:06:18 -07:00
|
|
|
LIns* x = lir->ins2(op, get(&l), get(&r));
|
|
|
|
if (negate)
|
2008-07-06 15:55:04 -07:00
|
|
|
x = lir->ins_eq0(x);
|
2008-07-04 03:06:18 -07:00
|
|
|
bool cond;
|
|
|
|
switch (op) {
|
2008-07-06 15:55:04 -07:00
|
|
|
case LIR_flt:
|
|
|
|
cond = asNumber(l) < asNumber(r);
|
2008-07-04 03:06:18 -07:00
|
|
|
break;
|
2008-07-06 15:55:04 -07:00
|
|
|
case LIR_fgt:
|
|
|
|
cond = asNumber(l) > asNumber(r);
|
2008-07-04 03:06:18 -07:00
|
|
|
break;
|
2008-07-06 15:55:04 -07:00
|
|
|
case LIR_fle:
|
|
|
|
cond = asNumber(l) <= asNumber(r);
|
2008-07-04 03:06:18 -07:00
|
|
|
break;
|
2008-07-06 15:55:04 -07:00
|
|
|
case LIR_fge:
|
|
|
|
cond = asNumber(l) >= asNumber(r);
|
2008-07-04 03:06:18 -07:00
|
|
|
break;
|
2008-07-05 10:41:35 -07:00
|
|
|
default:
|
2008-07-06 15:55:04 -07:00
|
|
|
JS_ASSERT(cond == LIR_feq);
|
|
|
|
cond = asNumber(l) == asNumber(r);
|
2008-07-04 03:06:18 -07:00
|
|
|
break;
|
|
|
|
}
|
2008-07-04 13:23:42 -07:00
|
|
|
/* The interpreter fuses comparisons and the following branch,
|
2008-07-04 03:06:18 -07:00
|
|
|
so we have to do that here as well. */
|
|
|
|
if (cx->fp->regs->pc[1] == ::JSOP_IFEQ)
|
2008-07-04 13:23:42 -07:00
|
|
|
guard(!cond, x);
|
2008-07-04 03:06:18 -07:00
|
|
|
else if (cx->fp->regs->pc[1] == ::JSOP_IFNE)
|
2008-07-04 13:23:42 -07:00
|
|
|
guard(cond, x);
|
|
|
|
/* We update the stack after the guard. This is safe since
|
|
|
|
the guard bails out at the comparison and the interpreter
|
|
|
|
will this re-execute the comparison. This way the
|
|
|
|
value of the condition doesn't have to be calculated and
|
|
|
|
saved on the stack in most cases. */
|
|
|
|
set(&l, x);
|
2008-07-04 03:06:18 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-07-05 11:35:55 -07:00
|
|
|
bool
|
2008-07-06 13:16:34 -07:00
|
|
|
TraceRecorder::unary(LOpcode op)
|
2008-07-05 11:35:55 -07:00
|
|
|
{
|
|
|
|
jsval& v = stackval(-1);
|
2008-07-06 13:16:34 -07:00
|
|
|
bool intop = !(op & LIR64);
|
2008-07-05 22:04:58 -07:00
|
|
|
if (isNumber(v)) {
|
2008-07-06 13:16:34 -07:00
|
|
|
LIns* a = get(&v);
|
|
|
|
if (intop)
|
2008-07-06 15:55:04 -07:00
|
|
|
a = f2i(a);
|
2008-07-06 13:16:34 -07:00
|
|
|
a = lir->ins1(op, a);
|
|
|
|
if (intop)
|
|
|
|
a = lir->ins1(LIR_i2f, a);
|
|
|
|
set(&v, a);
|
2008-07-05 11:35:55 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-07-04 15:21:56 -07:00
|
|
|
bool
|
2008-07-06 13:16:34 -07:00
|
|
|
TraceRecorder::binary(LOpcode op)
|
2008-07-04 15:21:56 -07:00
|
|
|
{
|
|
|
|
jsval& r = stackval(-1);
|
|
|
|
jsval& l = stackval(-2);
|
2008-07-06 13:16:34 -07:00
|
|
|
bool intop = !(op & LIR64);
|
|
|
|
if (isNumber(l) && isNumber(r)) {
|
|
|
|
LIns* a = get(&l);
|
|
|
|
LIns* b = get(&r);
|
|
|
|
if (intop) {
|
|
|
|
a = lir->insCall(op == LIR_ush ? F_doubleToUint32 : F_doubleToInt32, &a);
|
2008-07-06 15:55:04 -07:00
|
|
|
b = f2i(b);
|
2008-07-06 13:16:34 -07:00
|
|
|
}
|
|
|
|
a = lir->ins2(op, a, b);
|
|
|
|
if (intop)
|
|
|
|
a = lir->ins1(op == LIR_ush ? LIR_u2f : LIR_i2f, a);
|
|
|
|
set(&l, a);
|
2008-07-04 15:21:56 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-07-04 23:53:29 -07:00
|
|
|
bool
|
2008-07-06 09:15:55 -07:00
|
|
|
TraceRecorder::map_is_native(JSObjectMap* map, LIns* map_ins)
|
2008-07-04 23:53:29 -07:00
|
|
|
{
|
|
|
|
LIns* ops = lir->insLoadi(map_ins, offsetof(JSObjectMap, ops));
|
|
|
|
if (map->ops == &js_ObjectOps) {
|
2008-07-05 13:44:48 -07:00
|
|
|
guard(true, lir->ins2(LIR_eq, ops, lir->insImmPtr(&js_ObjectOps)));
|
2008-07-04 23:53:29 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
LIns* n = lir->insLoadi(ops, offsetof(JSObjectOps, newObjectMap));
|
|
|
|
if (map->ops->newObjectMap == js_ObjectOps.newObjectMap) {
|
2008-07-05 13:44:48 -07:00
|
|
|
guard(true, lir->ins2(LIR_eq, n, lir->insImmPtr(&js_ObjectOps.newObjectMap)));
|
2008-07-04 23:53:29 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-07-06 09:15:55 -07:00
|
|
|
bool
|
|
|
|
TraceRecorder::test_property_cache(JSObject* obj, LIns* obj_ins, JSObject*& obj2,
|
|
|
|
JSPropCacheEntry*& entry)
|
|
|
|
{
|
|
|
|
LIns* map_ins = lir->insLoadi(obj_ins, offsetof(JSObject, map));
|
|
|
|
if (!map_is_native(obj->map, map_ins))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
JSAtom* atom;
|
|
|
|
PROPERTY_CACHE_TEST(cx, cx->fp->regs->pc, obj, obj2, entry, atom);
|
2008-07-06 10:38:55 -07:00
|
|
|
if (atom)
|
2008-07-06 09:15:55 -07:00
|
|
|
return false;
|
2008-07-06 10:38:55 -07:00
|
|
|
|
|
|
|
if (PCVCAP_TAG(entry->vcap == 1))
|
|
|
|
return false; // need to look in the prototype, NYI
|
|
|
|
|
|
|
|
if (OBJ_SCOPE(obj)->object != obj)
|
|
|
|
return false; // need to normalize to the owner of the shared scope, NYI
|
2008-07-06 09:15:55 -07:00
|
|
|
|
|
|
|
LIns* shape_ins = lir->insLoadi(map_ins, offsetof(JSScope, shape));
|
2008-07-06 10:58:59 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
lirbuf->names->addName(shape_ins, "shape");
|
|
|
|
#endif
|
2008-07-06 09:15:55 -07:00
|
|
|
guard(true, lir->ins2i(LIR_eq, shape_ins, OBJ_SCOPE(obj)->shape));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-07-05 13:44:48 -07:00
|
|
|
void
|
|
|
|
TraceRecorder::stobj_set_slot(LIns* obj_ins, unsigned slot, LIns*& dslots_ins, LIns* v_ins)
|
2008-07-05 11:35:55 -07:00
|
|
|
{
|
|
|
|
if (slot < JS_INITIAL_NSLOTS)
|
|
|
|
lir->insStorei(v_ins,
|
|
|
|
obj_ins,
|
|
|
|
offsetof(JSObject, fslots) + slot * sizeof(jsval));
|
2008-07-05 13:44:48 -07:00
|
|
|
else {
|
|
|
|
if (!dslots_ins)
|
|
|
|
dslots_ins = lir->insLoadi(obj_ins, offsetof(JSObject, dslots));
|
2008-07-05 11:35:55 -07:00
|
|
|
lir->insStorei(v_ins,
|
2008-07-05 13:44:48 -07:00
|
|
|
dslots_ins,
|
2008-07-05 11:35:55 -07:00
|
|
|
(slot - JS_INITIAL_NSLOTS) * sizeof(jsval));
|
2008-07-05 13:44:48 -07:00
|
|
|
}
|
2008-07-05 11:35:55 -07:00
|
|
|
}
|
|
|
|
|
2008-07-06 09:15:55 -07:00
|
|
|
LIns*
|
|
|
|
TraceRecorder::stobj_get_slot(LIns* obj_ins, unsigned slot, LIns*& dslots_ins)
|
2008-07-05 11:35:55 -07:00
|
|
|
{
|
2008-07-06 09:15:55 -07:00
|
|
|
if (slot < JS_INITIAL_NSLOTS) {
|
|
|
|
return lir->insLoadi(obj_ins,
|
|
|
|
offsetof(JSObject, fslots) + slot * sizeof(jsval));
|
2008-07-05 13:44:48 -07:00
|
|
|
}
|
2008-07-06 09:15:55 -07:00
|
|
|
|
|
|
|
if (!dslots_ins)
|
|
|
|
dslots_ins = lir->insLoadi(obj_ins, offsetof(JSObject, dslots));
|
|
|
|
return lir->insLoadi(dslots_ins, (slot - JS_INITIAL_NSLOTS) * sizeof(jsval));
|
2008-07-05 11:35:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2008-07-05 13:44:48 -07:00
|
|
|
TraceRecorder::native_set(LIns* obj_ins, JSScopeProperty* sprop, LIns*& dslots_ins, LIns* v_ins)
|
2008-07-05 11:35:55 -07:00
|
|
|
{
|
|
|
|
if (SPROP_HAS_STUB_SETTER(sprop) && sprop->slot != SPROP_INVALID_SLOT) {
|
2008-07-05 13:44:48 -07:00
|
|
|
stobj_set_slot(obj_ins, sprop->slot, dslots_ins, v_ins);
|
|
|
|
return true;
|
2008-07-05 11:35:55 -07:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2008-07-05 13:44:48 -07:00
|
|
|
TraceRecorder::native_get(LIns* obj_ins, LIns* pobj_ins, JSScopeProperty* sprop,
|
|
|
|
LIns*& dslots_ins, LIns*& v_ins)
|
2008-07-05 11:35:55 -07:00
|
|
|
{
|
2008-07-06 09:15:55 -07:00
|
|
|
if (!SPROP_HAS_STUB_GETTER(sprop))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (sprop->slot != SPROP_INVALID_SLOT)
|
|
|
|
v_ins = stobj_get_slot(pobj_ins, sprop->slot, dslots_ins);
|
|
|
|
else
|
|
|
|
v_ins = lir->insImm(JSVAL_VOID);
|
|
|
|
return true;
|
2008-07-05 11:35:55 -07:00
|
|
|
}
|
|
|
|
|
2008-07-06 13:59:59 -07:00
|
|
|
bool
|
|
|
|
TraceRecorder::box_jsval(jsval v, LIns*& v_ins)
|
|
|
|
{
|
2008-07-06 16:18:45 -07:00
|
|
|
if (isNumber(v)) {
|
|
|
|
LIns* args[] = { cx_ins, v_ins };
|
|
|
|
v_ins = lir->insCall(F_BoxDouble, args);
|
|
|
|
guard(false, lir->ins2(LIR_eq, v_ins, lir->insImmPtr((void*)JSVAL_ERROR_COOKIE)));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
switch (JSVAL_TAG(v)) {
|
|
|
|
case JSVAL_BOOLEAN:
|
|
|
|
v_ins = lir->ins2i(LIR_or, lir->ins2i(LIR_lsh, v_ins, JSVAL_TAGBITS), JSVAL_BOOLEAN);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2008-07-06 13:59:59 -07:00
|
|
|
}
|
|
|
|
|
2008-07-06 10:38:55 -07:00
|
|
|
bool
|
|
|
|
TraceRecorder::unbox_jsval(jsval v, LIns*& v_ins)
|
|
|
|
{
|
2008-07-06 16:18:45 -07:00
|
|
|
if (isNumber(v)) {
|
|
|
|
// JSVAL_IS_NUMBER(v)
|
|
|
|
guard(true, lir->ins_eq0(
|
|
|
|
lir->ins_eq0(
|
|
|
|
lir->ins2(LIR_and, v_ins,
|
|
|
|
lir->insImmPtr((void*)(JSVAL_INT | JSVAL_DOUBLE))))));
|
|
|
|
v_ins = lir->insCall(F_UnboxDouble, &v_ins);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
switch (JSVAL_TAG(v)) {
|
|
|
|
case JSVAL_BOOLEAN:
|
|
|
|
guard(true, lir->ins2i(LIR_eq, lir->ins2(LIR_and, v_ins, lir->insImmPtr((void*)~JSVAL_TRUE)),
|
|
|
|
JSVAL_BOOLEAN));
|
|
|
|
v_ins = lir->ins2i(LIR_ush, v_ins, JSVAL_TAGBITS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2008-07-06 10:38:55 -07:00
|
|
|
}
|
|
|
|
|
2008-07-05 13:44:48 -07:00
|
|
|
bool TraceRecorder::guardThatObjectIsDenseArray(JSObject* obj, LIns* obj_ins, LIns*& dslots_ins)
|
|
|
|
{
|
|
|
|
if (!OBJ_IS_DENSE_ARRAY(cx, obj))
|
|
|
|
return false;
|
|
|
|
// guard(OBJ_GET_CLASS(obj) == &js_ArrayClass);
|
2008-07-06 09:15:55 -07:00
|
|
|
LIns* class_ins = stobj_get_slot(obj_ins, JSSLOT_CLASS, dslots_ins);
|
2008-07-05 13:44:48 -07:00
|
|
|
class_ins = lir->ins2(LIR_and, class_ins, lir->insImmPtr((void*)~3));
|
|
|
|
guard(true, lir->ins2(LIR_eq, class_ins, lir->insImmPtr(&js_ArrayClass)));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TraceRecorder::guardDenseArrayIndexWithinBounds(JSObject* obj, jsint idx,
|
|
|
|
LIns* obj_ins, LIns*& dslots_ins, LIns* idx_ins)
|
|
|
|
{
|
|
|
|
jsuint length = ARRAY_DENSE_LENGTH(obj);
|
|
|
|
if (!((jsuint)idx < length && idx < obj->fslots[JSSLOT_ARRAY_LENGTH]))
|
|
|
|
return false;
|
|
|
|
if (!dslots_ins)
|
|
|
|
dslots_ins = lir->insLoadi(obj_ins, offsetof(JSObject, dslots));
|
2008-07-06 09:15:55 -07:00
|
|
|
LIns* length_ins = stobj_get_slot(obj_ins, JSSLOT_ARRAY_LENGTH, dslots_ins);
|
2008-07-05 13:44:48 -07:00
|
|
|
// guard(index < length)
|
|
|
|
guard(true, lir->ins2(LIR_lt, idx_ins, length_ins));
|
|
|
|
// guard(index < capacity)
|
|
|
|
guard(false, lir->ins_eq0(dslots_ins));
|
|
|
|
guard(true, lir->ins2(LIR_lt, idx_ins,
|
|
|
|
lir->insLoadi(dslots_ins, -sizeof(jsval))));
|
|
|
|
return true;
|
2008-07-05 11:45:53 -07:00
|
|
|
}
|
|
|
|
|
2008-07-03 23:57:57 -07:00
|
|
|
bool TraceRecorder::JSOP_INTERRUPT()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_PUSH()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
stack(0, lir->insImm(JSVAL_VOID));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_POPV()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ENTERWITH()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LEAVEWITH()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_RETURN()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GOTO()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_IFEQ()
|
|
|
|
{
|
2008-07-05 22:23:34 -07:00
|
|
|
return ifop(true);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_IFNE()
|
|
|
|
{
|
2008-07-05 22:23:34 -07:00
|
|
|
return ifop(false);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ARGUMENTS()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FORARG()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FORVAR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DUP()
|
|
|
|
{
|
2008-07-05 20:47:24 -07:00
|
|
|
stack(0, get(&stackval(-1)));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DUP2()
|
|
|
|
{
|
2008-07-05 20:47:24 -07:00
|
|
|
stack(0, get(&stackval(-2)));
|
|
|
|
stack(1, get(&stackval(-1)));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETCONST()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_BITOR()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_or);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_BITXOR()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_xor);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_BITAND()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_and);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_EQ()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return cmp(LIR_feq);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NE()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return cmp(LIR_feq, true);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LT()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return cmp(LIR_flt);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LE()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return cmp(LIR_fle);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GT()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return cmp(LIR_fgt);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GE()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return cmp(LIR_fge);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LSH()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_lsh);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_RSH()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_rsh);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_URSH()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_ush);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ADD()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_fadd);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SUB()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_fsub);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_MUL()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_fmul);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DIV()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return binary(LIR_fdiv);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_MOD()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NOT()
|
|
|
|
{
|
2008-07-05 17:26:00 -07:00
|
|
|
jsval& v = stackval(-1);
|
2008-07-06 12:16:55 -07:00
|
|
|
if (JSVAL_IS_BOOLEAN(v)) {
|
2008-07-05 17:26:00 -07:00
|
|
|
set(&v, lir->ins_eq0(get(&v)));
|
|
|
|
return true;
|
|
|
|
}
|
2008-07-03 23:57:57 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_BITNOT()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
return unary(LIR_not);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NEG()
|
|
|
|
{
|
2008-07-06 06:33:13 -07:00
|
|
|
return false;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NEW()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DELNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DELPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DELELEM()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TYPEOF()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_VOID()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INCNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INCPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INCELEM()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DECNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DECPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DECELEM()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NAMEINC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_PROPINC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ELEMINC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NAMEDEC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_PROPDEC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ELEMDEC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETELEM()
|
|
|
|
{
|
2008-07-05 06:47:59 -07:00
|
|
|
jsval& r = stackval(-1);
|
|
|
|
jsval& l = stackval(-2);
|
2008-07-05 13:44:48 -07:00
|
|
|
/* no guards for type checks, trace specialized this already */
|
2008-07-06 15:55:04 -07:00
|
|
|
if (!JSVAL_IS_INT(r) || JSVAL_IS_PRIMITIVE(l))
|
2008-07-05 06:47:59 -07:00
|
|
|
return false;
|
2008-07-05 13:44:48 -07:00
|
|
|
JSObject* obj = JSVAL_TO_OBJECT(l);
|
|
|
|
LIns* obj_ins = get(&l);
|
|
|
|
/* make sure the object is actually a dense array */
|
|
|
|
LIns* dslots_ins = lir->insLoadi(obj_ins, offsetof(JSObject, dslots));
|
|
|
|
if (!guardThatObjectIsDenseArray(obj, obj_ins, dslots_ins))
|
|
|
|
return false;
|
|
|
|
/* check that the index is within bounds */
|
2008-07-06 15:55:04 -07:00
|
|
|
jsint idx = JSVAL_TO_INT(r);
|
|
|
|
LIns* idx_ins = f2i(get(&r));
|
2008-07-06 16:38:54 -07:00
|
|
|
/* we have to check that its really an integer, but this check will to go away
|
|
|
|
once we peel the loop type down to integer for this slot */
|
|
|
|
guard(true, lir->ins2(LIR_feq, get(&r), lir->ins1(LIR_i2f, idx_ins)));
|
2008-07-05 13:44:48 -07:00
|
|
|
if (!guardDenseArrayIndexWithinBounds(obj, idx, obj_ins, dslots_ins, idx_ins))
|
|
|
|
return false;
|
|
|
|
jsval v = obj->dslots[idx];
|
|
|
|
/* ok, we can trace this case since we now have the value and thus know the type */
|
|
|
|
LIns* addr = lir->ins2(LIR_add, dslots_ins,
|
|
|
|
lir->ins2i(LIR_lsh, idx_ins, sizeof(jsval) == 4 ? 2 : 3));
|
|
|
|
/* load the value, check the type (need to check JSVAL_HOLE only for booleans) */
|
|
|
|
LIns* v_ins = lir->insLoadi(addr, 0);
|
2008-07-06 10:38:55 -07:00
|
|
|
if (!unbox_jsval(v, v_ins))
|
|
|
|
return false;
|
2008-07-05 13:44:48 -07:00
|
|
|
set(&l, v_ins);
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETELEM()
|
|
|
|
{
|
2008-07-05 06:47:59 -07:00
|
|
|
jsval& v = stackval(-1);
|
|
|
|
jsval& r = stackval(-2);
|
|
|
|
jsval& l = stackval(-3);
|
2008-07-05 14:00:32 -07:00
|
|
|
/* no guards for type checks, trace specialized this already */
|
2008-07-06 15:55:04 -07:00
|
|
|
if (!JSVAL_IS_INT(r) || JSVAL_IS_PRIMITIVE(l))
|
2008-07-05 06:47:59 -07:00
|
|
|
return false;
|
2008-07-05 14:00:32 -07:00
|
|
|
JSObject* obj = JSVAL_TO_OBJECT(l);
|
|
|
|
LIns* obj_ins = get(&l);
|
|
|
|
/* make sure the object is actually a dense array */
|
|
|
|
LIns* dslots_ins = lir->insLoadi(obj_ins, offsetof(JSObject, dslots));
|
|
|
|
if (!guardThatObjectIsDenseArray(obj, obj_ins, dslots_ins))
|
|
|
|
return false;
|
|
|
|
/* check that the index is within bounds */
|
2008-07-06 15:55:04 -07:00
|
|
|
jsint idx = JSVAL_TO_INT(r);
|
|
|
|
LIns* idx_ins = f2i(get(&r));
|
2008-07-06 16:38:54 -07:00
|
|
|
/* we have to check that its really an integer, but this check will to go away
|
|
|
|
once we peel the loop type down to integer for this slot */
|
|
|
|
guard(true, lir->ins2(LIR_feq, get(&r), lir->ins1(LIR_i2f, idx_ins)));
|
2008-07-05 14:00:32 -07:00
|
|
|
if (!guardDenseArrayIndexWithinBounds(obj, idx, obj_ins, dslots_ins, idx_ins))
|
|
|
|
return false;
|
|
|
|
/* get us the address of the array slot */
|
|
|
|
LIns* addr = lir->ins2(LIR_add, dslots_ins,
|
2008-07-05 19:39:34 -07:00
|
|
|
lir->ins2i(LIR_lsh, idx_ins, JS_BYTES_PER_WORD_LOG2));
|
2008-07-05 14:00:32 -07:00
|
|
|
LIns* oldval = lir->insLoad(LIR_ld, addr, 0);
|
2008-07-05 18:50:54 -07:00
|
|
|
LIns* isHole = lir->ins2(LIR_eq, oldval, lir->insImmPtr((void*)JSVAL_HOLE));
|
|
|
|
LIns* count = lir->insLoadi(obj_ins,
|
|
|
|
offsetof(JSObject, fslots[JSSLOT_ARRAY_COUNT]));
|
|
|
|
lir->insStorei(lir->ins2(LIR_add, count, isHole), obj_ins,
|
|
|
|
offsetof(JSObject, fslots[JSSLOT_ARRAY_COUNT]));
|
2008-07-05 14:00:32 -07:00
|
|
|
/* ok, box the value we are storing, store it and we are done */
|
|
|
|
LIns* v_ins = get(&v);
|
2008-07-06 16:38:54 -07:00
|
|
|
LIns* boxed_ins = v_ins;
|
2008-07-06 13:59:59 -07:00
|
|
|
if (!box_jsval(v, boxed_ins))
|
|
|
|
return false;
|
2008-07-05 19:39:34 -07:00
|
|
|
lir->insStorei(boxed_ins, addr, 0);
|
2008-07-05 14:00:32 -07:00
|
|
|
set(&l, v_ins);
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CALLNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CALL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NAME()
|
|
|
|
{
|
2008-07-06 09:15:55 -07:00
|
|
|
JSObject* obj;
|
|
|
|
JSObject* obj2;
|
|
|
|
JSPropCacheEntry* entry;
|
2008-07-06 10:38:55 -07:00
|
|
|
|
|
|
|
LIns* obj_ins = lir->insLoadi(lir->insLoadi(cx_ins, offsetof(JSContext, fp)),
|
|
|
|
offsetof(JSStackFrame, scopeChain));
|
|
|
|
obj = cx->fp->scopeChain;
|
2008-07-06 09:15:55 -07:00
|
|
|
if (!test_property_cache(obj, obj_ins, obj2, entry))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!PCVAL_IS_SLOT(entry->vword))
|
|
|
|
return false;
|
2008-07-06 10:38:55 -07:00
|
|
|
|
2008-07-06 09:15:55 -07:00
|
|
|
LIns* dslots_ins = NULL;
|
2008-07-06 10:38:55 -07:00
|
|
|
uint32 slot = PCVAL_TO_SLOT(entry->vword);
|
|
|
|
LIns* v_ins = stobj_get_slot(obj_ins, slot, dslots_ins);
|
|
|
|
if (!unbox_jsval(STOBJ_GET_SLOT(obj, slot), v_ins))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
stack(0, v_ins);
|
2008-07-06 09:15:55 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DOUBLE()
|
|
|
|
{
|
2008-07-05 23:21:53 -07:00
|
|
|
jsval v = (jsval)cx->fp->script->atomMap.vector[GET_INDEX(cx->fp->regs->pc)];
|
2008-07-06 15:55:04 -07:00
|
|
|
stack(0, lir->insImmq(*(uint64_t*)JSVAL_TO_DOUBLE(v)));
|
2008-07-05 23:21:53 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_STRING()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ZERO()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
jsdouble d = (jsdouble)0;
|
|
|
|
stack(0, lir->insImmq(*(uint64_t*)&d));
|
2008-07-05 06:15:33 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ONE()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
jsdouble d = (jsdouble)1;
|
|
|
|
stack(0, lir->insImmq(*(uint64_t*)&d));
|
2008-07-05 06:15:33 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NULL()
|
|
|
|
{
|
2008-07-05 17:26:00 -07:00
|
|
|
stack(0, lir->insImmPtr(NULL));
|
2008-07-05 06:15:33 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_THIS()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FALSE()
|
|
|
|
{
|
2008-07-05 06:15:33 -07:00
|
|
|
stack(0, lir->insImm(0));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TRUE()
|
|
|
|
{
|
2008-07-05 06:15:33 -07:00
|
|
|
stack(0, lir->insImm(1));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_OR()
|
|
|
|
{
|
2008-07-06 13:16:34 -07:00
|
|
|
return false;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_AND()
|
|
|
|
{
|
2008-07-06 13:16:34 -07:00
|
|
|
return false;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TABLESWITCH()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LOOKUPSWITCH()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_STRICTEQ()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_STRICTNE()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CLOSURE()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_EXPORTALL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_EXPORTNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_IMPORTALL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_IMPORTPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_IMPORTELEM()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_OBJECT()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_POP()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_POS()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TRAP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETARG()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
stack(0, arg(GET_ARGNO(cx->fp->regs->pc)));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETARG()
|
|
|
|
{
|
2008-07-04 15:21:56 -07:00
|
|
|
arg(GET_ARGNO(cx->fp->regs->pc), stack(-1));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETVAR()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
stack(0, var(GET_VARNO(cx->fp->regs->pc)));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETVAR()
|
|
|
|
{
|
2008-07-04 15:21:56 -07:00
|
|
|
var(GET_VARNO(cx->fp->regs->pc), stack(-1));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_UINT16()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
jsdouble d = (jsdouble)GET_UINT16(cx->fp->regs->pc);
|
|
|
|
stack(0, lir->insImmq(*(uint64_t*)&d));
|
2008-07-04 03:06:18 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NEWINIT()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ENDINIT()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INITPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INITELEM()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DEFSHARP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_USESHARP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INCARG()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
return inc(argval(GET_ARGNO(cx->fp->regs->pc)), 1, true);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INCVAR()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
return inc(varval(GET_VARNO(cx->fp->regs->pc)), 1, true);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DECARG()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
return inc(argval(GET_ARGNO(cx->fp->regs->pc)), -1, true);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DECVAR()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
return inc(varval(GET_VARNO(cx->fp->regs->pc)), -1, true);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ARGINC()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
return inc(argval(GET_ARGNO(cx->fp->regs->pc)), 1, false);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_VARINC()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
return inc(varval(GET_VARNO(cx->fp->regs->pc)), 1, false);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ARGDEC()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
return inc(argval(GET_ARGNO(cx->fp->regs->pc)), -1, false);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_VARDEC()
|
|
|
|
{
|
2008-07-04 03:06:18 -07:00
|
|
|
return inc(varval(GET_VARNO(cx->fp->regs->pc)), -1, false);
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ITER()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FORNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FORPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FORELEM()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_POPN()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_BINDNAME()
|
|
|
|
{
|
2008-07-04 23:53:29 -07:00
|
|
|
/* BINDNAME is a no-op for the recorder. We wait until we hit the
|
2008-07-05 10:41:35 -07:00
|
|
|
SETNAME/SETPROP that uses it. This is safe because the
|
2008-07-04 23:53:29 -07:00
|
|
|
interpreter calculates here the scope we will use and we
|
|
|
|
will use that value to guard against in SETNAME/SETPROP. */
|
|
|
|
return true;
|
2008-07-05 10:41:35 -07:00
|
|
|
}
|
2008-07-03 23:57:57 -07:00
|
|
|
bool TraceRecorder::JSOP_SETNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_THROW()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_IN()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INSTANCEOF()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DEBUGGER()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GOSUB()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_RETSUB()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_EXCEPTION()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LINENO()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CONDSWITCH()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CASE()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DEFAULT()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_EVAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ENUMELEM()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETTER()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETTER()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DEFFUN()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DEFCONST()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DEFVAR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ANONFUNOBJ()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NAMEDFUNOBJ()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETLOCALPOP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GROUP()
|
|
|
|
{
|
2008-07-05 06:15:33 -07:00
|
|
|
return true; // no-op
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETCALL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TRY()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FINALLY()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NOP()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ARGSUB()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ARGCNT()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DEFLOCALFUN()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GOTOX()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_IFEQX()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return JSOP_IFEQ();
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_IFNEX()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return JSOP_IFNE();
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ORX()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return JSOP_OR();
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ANDX()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return JSOP_AND();
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GOSUBX()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return JSOP_GOSUB();
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CASEX()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return JSOP_CASE();
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DEFAULTX()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return JSOP_DEFAULT();
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TABLESWITCHX()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return JSOP_TABLESWITCH();
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LOOKUPSWITCHX()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return JSOP_LOOKUPSWITCH();
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_BACKPATCH()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_BACKPATCH_POP()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_THROWING()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETRVAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_RETRVAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-07-06 13:59:59 -07:00
|
|
|
|
2008-07-03 23:57:57 -07:00
|
|
|
bool TraceRecorder::JSOP_GETGVAR()
|
|
|
|
{
|
2008-07-06 13:59:59 -07:00
|
|
|
jsval slotval = cx->fp->vars[GET_VARNO(cx->fp->regs->pc)];
|
|
|
|
if (JSVAL_IS_NULL(slotval))
|
|
|
|
return true; // We will see JSOP_NAME from the interpreter's jump, so no-op here.
|
|
|
|
|
|
|
|
uint32 slot = JSVAL_TO_INT(slotval);
|
|
|
|
LIns* varobj_ins = lir->insLoadi(lir->insLoadi(cx_ins, offsetof(JSContext, fp)),
|
|
|
|
offsetof(JSStackFrame, varobj));
|
|
|
|
LIns* dslots_ins = NULL;
|
|
|
|
LIns* v_ins = stobj_get_slot(varobj_ins, slot, dslots_ins);
|
|
|
|
if (!unbox_jsval(STOBJ_GET_SLOT(cx->fp->varobj, slot), v_ins))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
stack(0, v_ins);
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETGVAR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INCGVAR()
|
|
|
|
{
|
2008-07-06 13:59:59 -07:00
|
|
|
jsval slotval = cx->fp->vars[GET_VARNO(cx->fp->regs->pc)];
|
|
|
|
if (JSVAL_IS_NULL(slotval))
|
|
|
|
return true; // We will see JSOP_INCNAME from the interpreter's jump, so no-op here.
|
|
|
|
|
|
|
|
uint32 slot = JSVAL_TO_INT(slotval);
|
|
|
|
LIns* varobj_ins = lir->insLoadi(lir->insLoadi(cx_ins, offsetof(JSContext, fp)),
|
|
|
|
offsetof(JSStackFrame, varobj));
|
|
|
|
LIns* dslots_ins = NULL;
|
|
|
|
LIns* v_ins = stobj_get_slot(varobj_ins, slot, dslots_ins);
|
|
|
|
jsval v = STOBJ_GET_SLOT(cx->fp->varobj, slot);
|
|
|
|
if (!unbox_jsval(v, v_ins))
|
|
|
|
return false;
|
|
|
|
LIns* incr = lir->ins2i(LIR_add, v_ins, 1);
|
|
|
|
guard(false, lir->ins1(LIR_ov, incr));
|
|
|
|
if (!box_jsval(v, incr))
|
|
|
|
return false;
|
|
|
|
stobj_set_slot(varobj_ins, slot, dslots_ins, incr);
|
|
|
|
stack(0, incr);
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DECGVAR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GVARINC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GVARDEC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_REGEXP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DEFXMLNS()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ANYNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_QNAMEPART()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_QNAMECONST()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_QNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TOATTRNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TOATTRVAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ADDATTRNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ADDATTRVAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_BINDXMLNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETXMLNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_XMLNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DESCENDANTS()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FILTER()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ENDFILTER()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TOXML()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TOXMLLIST()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_XMLTAGEXPR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_XMLELTEXPR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_XMLOBJECT()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_XMLCDATA()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_XMLCOMMENT()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_XMLPI()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CALLPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETFUNNS()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_UNUSED186()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DELDESC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_UINT24()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
jsdouble d = (jsdouble) GET_UINT24(cx->fp->regs->pc);
|
|
|
|
stack(0, lir->insImmq(*(uint64_t*)&d));
|
2008-07-04 03:06:18 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INDEXBASE()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_RESETBASE()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_RESETBASE0()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_STARTXML()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_STARTXMLEXPR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CALLELEM()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_STOP()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETXPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CALLXMLNAME()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_TYPEOFEXPR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ENTERBLOCK()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LEAVEBLOCK()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETLOCAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_SETLOCAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INCLOCAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_DECLOCAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LOCALINC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LOCALDEC()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FORLOCAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_FORCONST()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ENDITER()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GENERATOR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_YIELD()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ARRAYPUSH()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_UNUSED213()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_ENUMCONSTELEM()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LEAVEBLOCKEXPR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETTHISPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETARGPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETVARPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_GETLOCALPROP()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INDEXBASE1()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INDEXBASE2()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INDEXBASE3()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CALLGVAR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CALLVAR()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CALLARG()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_CALLLOCAL()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INT8()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
jsdouble d = (jsdouble)GET_INT8(cx->fp->regs->pc);
|
|
|
|
stack(0, lir->insImmq(*(uint64_t*)&d));
|
2008-07-04 03:06:18 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_INT32()
|
|
|
|
{
|
2008-07-06 15:55:04 -07:00
|
|
|
jsdouble d = (jsdouble)GET_INT32(cx->fp->regs->pc);
|
|
|
|
stack(0, lir->insImmq(*(uint64_t*)&d));
|
2008-07-04 03:06:18 -07:00
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_LENGTH()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_NEWARRAY()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool TraceRecorder::JSOP_HOLE()
|
|
|
|
{
|
2008-07-06 06:52:50 -07:00
|
|
|
stack(0, lir->insImm(JSVAL_HOLE));
|
|
|
|
return true;
|
2008-07-03 23:57:57 -07:00
|
|
|
}
|