diff --git a/mozilla/js2/src/js2engine.cpp b/mozilla/js2/src/js2engine.cpp index 577d21c807a..1cb2fa8fd6c 100644 --- a/mozilla/js2/src/js2engine.cpp +++ b/mozilla/js2/src/js2engine.cpp @@ -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); diff --git a/mozilla/js2/src/js2engine.h b/mozilla/js2/src/js2engine.h index a49878c154a..612854b9a5a 100644 --- a/mozilla/js2/src/js2engine.h +++ b/mozilla/js2/src/js2engine.h @@ -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: diff --git a/mozilla/js2/src/js2metadata.cpp b/mozilla/js2/src/js2metadata.cpp index 3ece3834f5a..9b323a624af 100644 --- a/mozilla/js2/src/js2metadata.cpp +++ b/mozilla/js2/src/js2metadata.cpp @@ -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(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(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(); } diff --git a/mozilla/js2/src/js2metadata.h b/mozilla/js2/src/js2metadata.h index 9878a1f40a4..25eab7be94e 100644 --- a/mozilla/js2/src/js2metadata.h +++ b/mozilla/js2/src/js2metadata.h @@ -223,16 +223,10 @@ public: ObjectKind kind; static Pond pond; -#ifdef DEBUG static std::list rootList; typedef std::list::iterator RootIterator; static RootIterator addRoot(RootKeeper *t); -#else - static std::list rootList; - typedef std::list::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 diff --git a/mozilla/js2/src/regexpwrapper.cpp b/mozilla/js2/src/regexpwrapper.cpp index 7072df1789d..29f3a4091fd 100644 --- a/mozilla/js2/src/regexpwrapper.cpp +++ b/mozilla/js2/src/regexpwrapper.cpp @@ -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 { diff --git a/mozilla/js2/src/strings.h b/mozilla/js2/src/strings.h index 76146505ac1..6bf2d8bfa16 100644 --- a/mozilla/js2/src/strings.h +++ b/mozilla/js2/src/strings.h @@ -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___ */