This commit is contained in:
rogerl%netscape.com 2003-05-08 23:09:27 +00:00
Родитель e4715b7a78
Коммит 029d306fe3
6 изменённых файлов: 56 добавлений и 64 удалений

Просмотреть файл

@ -86,12 +86,18 @@ namespace MetaData {
// Execute the opcode sequence at pc.
js2val JS2Engine::interpreterLoop()
{
js2val a = JS2VAL_VOID;
js2val b = JS2VAL_VOID;
js2val baseVal = JS2VAL_VOID;
js2val indexVal = JS2VAL_VOID;
ParameterFrame *pFrame = NULL;
const String *astr = NULL;
const String *bstr = NULL;
DEFINE_ROOTKEEPER(rk1, pFrame);
DEFINE_ROOTKEEPER(rk2, astr);
DEFINE_ROOTKEEPER(rk3, bstr);
retval = JS2VAL_VOID;
baseVal = JS2VAL_VOID;
indexVal = JS2VAL_VOID;
astr = NULL;
bstr = NULL;
pFrame = NULL;
while (true) {
try {
a = JS2VAL_VOID;
@ -434,14 +440,6 @@ namespace MetaData {
pc(NULL),
bCon(NULL),
phase(RunPhase),
retval(JS2VAL_VOID),
a(JS2VAL_VOID),
b(JS2VAL_VOID),
baseVal(JS2VAL_VOID),
indexVal(JS2VAL_VOID),
pFrame(NULL),
astr(NULL),
bstr(NULL),
INIT_STRINGATOM(true),
INIT_STRINGATOM(false),
INIT_STRINGATOM(null),
@ -1055,14 +1053,6 @@ namespace MetaData {
JS2Object::mark(float64Table[i]);
}
GCMARKVALUE(retval);
GCMARKVALUE(a);
GCMARKVALUE(b);
GCMARKVALUE(baseVal);
GCMARKVALUE(indexVal);
GCMARKOBJECT(pFrame);
if (astr) JS2Object::mark(astr);
if (bstr) JS2Object::mark(bstr);
JS2Object::mark(true_StringAtom);
JS2Object::mark(false_StringAtom);

Просмотреть файл

@ -266,15 +266,8 @@ private:
// A cache of f.p. values (XXX experimentally trying to reduce # of double pointers XXX)
float64 *float64Table[256];
float64 *newDoubleValue(float64 x);
js2val retval;
js2val a,b;
js2val baseVal,indexVal;
ParameterFrame *pFrame;
const String *astr;
const String *bstr;
public:

Просмотреть файл

@ -3743,8 +3743,11 @@ static const uint8 urlCharType[256] =
static js2val Object_underbarProtoGet(JS2Metadata *meta, const js2val thisValue, js2val /* argv */ [], uint32 /* argc */)
{
ASSERT(JS2VAL_IS_OBJECT(thisValue));
JS2Object *obj = JS2VAL_TO_OBJECT(thisValue);
JS2Object *obj;
if (!JS2VAL_IS_OBJECT(thisValue))
obj = JS2VAL_TO_OBJECT(meta->toObject(thisValue));
else
obj = JS2VAL_TO_OBJECT(thisValue);
if (obj->kind == SimpleInstanceKind)
return (checked_cast<SimpleInstance *>(obj))->super;
else
@ -3753,8 +3756,11 @@ static const uint8 urlCharType[256] =
static js2val Object_underbarProtoSet(JS2Metadata *meta, const js2val thisValue, js2val *argv, uint32 argc)
{
ASSERT(JS2VAL_IS_OBJECT(thisValue));
JS2Object *obj = JS2VAL_TO_OBJECT(thisValue);
JS2Object *obj;
if (!JS2VAL_IS_OBJECT(thisValue))
obj = JS2VAL_TO_OBJECT(meta->toObject(thisValue));
else
obj = JS2VAL_TO_OBJECT(thisValue);
if ((argc > 0) && (obj->kind == SimpleInstanceKind)) {
(checked_cast<SimpleInstance *>(obj))->super = argv[0];
return argv[0];
@ -3893,7 +3899,7 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
fInst->fWrap = new FunctionWrapper(true, new ParameterFrame(JS2VAL_VOID, true), Object_underbarProtoSet, env);
fInst->fWrap->length = 0;
InstanceSetter *s = new InstanceSetter(&mn, fInst, objectClass, true, true);
defineInstanceMember(objectClass, &cxt, mn.name, *mn.nsList, Attribute::NoOverride, false, g, 0);
defineInstanceMember(objectClass, &cxt, mn.name, *mn.nsList, Attribute::NoOverride, false, s, 0);
// Adding 'toString' to the Object.prototype XXX Or make this a static class member?
@ -5142,30 +5148,25 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now...
pond.resetMarks();
// Anything on the root list may also be a pointer to a JS2Object.
for (RootIterator i = rootList.begin(), end = rootList.end(); (i != end); i++) {
#ifdef DEBUG
RootKeeper *r = *i;
if (*(r->p)) {
PondScum *p = (*(r->p) - 1);
ASSERT(p->owner && (p->getSize() >= sizeof(PondScum)) && (p->owner->sanity == POND_SANITY));
if (p->isJS2Object()) {
JS2Object *obj = (JS2Object *)(p + 1);
PondScum *scum = NULL;
if (r->is_js2val) {
if (JS2VAL_IS_OBJECT(*(r->p))
scum = ((PondScum *)(JS2VAL_TO_OBJECT(*(r->p)))) - 1;
}
else {
if (*(r->p))
scum = (*(r->p) - 1);
}
if (scum) {
ASSERT(scum->owner && (scum->getSize() >= sizeof(PondScum)) && (scum->owner->sanity == POND_SANITY));
if (scum->isJS2Object()) {
JS2Object *obj = (JS2Object *)(scum + 1);
GCMARKOBJECT(obj)
}
else
mark(p + 1);
mark(scum + 1);
}
#else
if (**i) {
PondScum *p = (**i) - 1;
ASSERT(p->owner && (p->getSize() >= sizeof(PondScum)) && (p->owner->sanity == POND_SANITY));
if (p->isJS2Object()) {
JS2Object *obj = (JS2Object *)(p + 1);
GCMARKOBJECT(obj)
}
else
mark(p + 1);
}
#endif
}
return pond.moveUnmarkedToFreeList();
}

Просмотреть файл

@ -223,16 +223,10 @@ public:
ObjectKind kind;
static Pond pond;
#ifdef DEBUG
static std::list<RootKeeper *> rootList;
typedef std::list<RootKeeper *>::iterator RootIterator;
static RootIterator addRoot(RootKeeper *t);
#else
static std::list<PondScum **> rootList;
typedef std::list<PondScum **>::iterator RootIterator;
static RootIterator addRoot(void *t); // pass the address of any JS2Object pointer
// Note: Not the address of a JS2VAL!
#endif
static uint32 gc();
static void clear(JS2Metadata *meta);
static void removeRoot(RootIterator ri);
@ -256,7 +250,13 @@ public:
class RootKeeper {
public:
#ifdef DEBUG
RootKeeper(void *p, int line, char *pfile) : p((PondScum **)p), line(line)
RootKeeper(JS2Object **p, int line, char *pfile) : is_js2val(false), p(p), line(line)
{
file = new char[strlen(pfile) + 1];
strcpy(file, pfile);
ri = JS2Object::addRoot(this);
}
RootKeeper(js2val *p, int line, char *pfile) : is_js2val(true), p(p), line(line)
{
file = new char[strlen(pfile) + 1];
strcpy(file, pfile);
@ -264,14 +264,16 @@ public:
}
~RootKeeper() { JS2Object::removeRoot(ri); delete file; }
#else
RootKeeper(void *p) { ri = JS2Object::addRoot(p); }
RootKeeper(JS2Object **p) : is_js2val(false), p(p), { ri = JS2Object::addRoot(p); }
RootKeeper(js2val *p) : is_js2val(true), p(p) { ri = JS2Object::addRoot(p); }
~RootKeeper() { JS2Object::removeRoot(ri); }
#endif
JS2Object::RootIterator ri;
bool is_js2val;
void *p;
#ifdef DEBUG
PondScum **p;
int line;
char *file;
#endif

Просмотреть файл

@ -113,6 +113,12 @@ void JS_ReportErrorNumber(JS2Metadata *meta, const char *message)
#define JUMP_OFFSET_MAX ((int16)0x7fff)
typedef bool JSBool;
typedef uint32 uintN;
typedef int32 intN;
typedef uint32 jsint;
typedef char16 JSString;
typedef char16 JSSubString;
typedef struct REMatchState {

Просмотреть файл

@ -242,6 +242,6 @@ namespace JavaScript
}
#define JS7_ISHEX(c) ((c) < 128 && isxdigit(c))
#define JS7_UNHEX(c) (uintN)(isdigit(c) ? (c) - '0' : 10 + tolower(c) - 'a')
#define JS7_UNHEX(c) (uint32)(isdigit(c) ? (c) - '0' : 10 + tolower(c) - 'a')
#endif /* strings_h___ */