From f33e4a593af554c04449b8e9506a3c8f535ad29f Mon Sep 17 00:00:00 2001 From: "rogerl%netscape.com" Date: Mon, 19 May 2003 21:06:38 +0000 Subject: [PATCH] GC fixes --- js2/src/epimetheus.cpp | 19 +++++++++++-------- js2/src/js2engine.cpp | 4 ++-- js2/src/js2engine.h | 2 +- js2/src/js2metadata.cpp | 37 ++----------------------------------- js2/src/js2metadata.h | 11 +++++++++++ js2/src/js2string.cpp | 3 ++- 6 files changed, 29 insertions(+), 47 deletions(-) diff --git a/js2/src/epimetheus.cpp b/js2/src/epimetheus.cpp index 44d18f2bee1d..a1ec5928a36e 100644 --- a/js2/src/epimetheus.cpp +++ b/js2/src/epimetheus.cpp @@ -223,6 +223,14 @@ js2val print(JS2Metadata * /* meta */, const js2val /* thisValue */, js2val argv return JS2VAL_UNDEFINED; } +#ifdef TRACE_DEBUG +js2val trace(JS2Metadata *meta, const js2val /* thisValue */, js2val /* argv */ [], uint32 /* argc */) +{ + meta->engine->traceInstructions = !meta->engine->traceInstructions; + return JS2VAL_UNDEFINED; +} +#endif + #ifdef DEBUG js2val trees(JS2Metadata *meta, const js2val /* thisValue */, js2val /* argv */ [], uint32 /* argc */) { @@ -230,12 +238,6 @@ js2val trees(JS2Metadata *meta, const js2val /* thisValue */, js2val /* argv */ return JS2VAL_UNDEFINED; } -js2val trace(JS2Metadata *meta, const js2val /* thisValue */, js2val /* argv */ [], uint32 /* argc */) -{ - meta->engine->traceInstructions = !meta->engine->traceInstructions; - return JS2VAL_UNDEFINED; -} - void accessAccess(AccessSet access) { if (access & ReadAccess) @@ -487,10 +489,11 @@ int main(int argc, char **argv) metadata->addGlobalObjectFunction("dump", dump, 1); metadata->addGlobalObjectFunction("dumpAt", dumpAt, 1); metadata->addGlobalObjectFunction("trees", trees, 0); - metadata->addGlobalObjectFunction("trace", trace, 0); metadata->addGlobalObjectFunction("gc", forceGC, 0); #endif - +#ifdef TRACE_DEBUG + metadata->addGlobalObjectFunction("trace", trace, 0); +#endif try { bool doInteractive = true; int result = 0; diff --git a/js2/src/js2engine.cpp b/js2/src/js2engine.cpp index 47bee3955353..45a770ea9d95 100644 --- a/js2/src/js2engine.cpp +++ b/js2/src/js2engine.cpp @@ -107,7 +107,7 @@ namespace MetaData { try { a = JS2VAL_VOID; b = JS2VAL_VOID; -#ifdef DEBUG +#ifdef TRACE_DEBUG if (traceInstructions) printInstruction(pc, bCon->getCodeStart(), bCon, this); #endif @@ -493,7 +493,7 @@ namespace MetaData { delete [] activationStack; } -#ifdef DEBUG +#ifdef TRACE_DEBUG enum { BRANCH_OFFSET = 1, STR_PTR, TYPE_PTR, NAME_INDEX, FRAME_INDEX, BRANCH_PAIR, U16, FLOAT64, S32, BREAK_OFFSET_AND_COUNT }; struct { diff --git a/js2/src/js2engine.h b/js2/src/js2engine.h index a82a31b5a000..b3cfadade81e 100644 --- a/js2/src/js2engine.h +++ b/js2/src/js2engine.h @@ -372,7 +372,7 @@ public: }; -#ifdef DEBUG +#ifdef TRACE_DEBUG uint8 *printInstruction(uint8 *pc, uint8 *start, BytecodeContainer *bCon, JS2Engine *engine); #endif diff --git a/js2/src/js2metadata.cpp b/js2/src/js2metadata.cpp index 97530e3775ab..e3ae06b17c52 100644 --- a/js2/src/js2metadata.cpp +++ b/js2/src/js2metadata.cpp @@ -3884,7 +3884,8 @@ static const uint8 urlCharType[256] = // A 'forbidden' member, used to mark hidden bindings forbiddenMember = new LocalMember(Member::ForbiddenMember, true); - FunctionInstance *fInst; + FunctionInstance *fInst = NULL; + DEFINE_ROOTKEEPER(rk1, fInst); Variable *v; // XXX Built-in Attributes... XXX @@ -4865,27 +4866,6 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now... { } - /************************************************************************************ - * - * Getter - * - ************************************************************************************/ - - void Getter::mark() - { - GCMARKOBJECT(type); - } - - /************************************************************************************ - * - * Setter - * - ************************************************************************************/ - - void Setter::mark() - { - GCMARKOBJECT(type); - } /************************************************************************************ * @@ -5118,19 +5098,6 @@ XXX see EvalAttributeExpression, where identifiers are being handled for now... } - /************************************************************************************ - * - * InstanceMember - * - ************************************************************************************/ - - // gc-mark all contained JS2Objects and visit contained structures to do likewise - void InstanceMember::mark() - { - GCMARKOBJECT(multiname); - } - - /************************************************************************************ * * InstanceVariable diff --git a/js2/src/js2metadata.h b/js2/src/js2metadata.h index 2b35d1919b73..a7f6b1d9afff 100644 --- a/js2/src/js2metadata.h +++ b/js2/src/js2metadata.h @@ -610,6 +610,8 @@ public: JS2Class *type; // Type of values that may be stored in this variable virtual Access instanceMemberAccess() { return ReadAccess; } + virtual void mark(); + }; class InstanceSetter : public InstanceMember { @@ -620,6 +622,7 @@ public: JS2Class *type; // Type of values that may be stored in this variable virtual Access instanceMemberAccess() { return WriteAccess; } + virtual void mark(); }; class InstanceBinding { @@ -1615,6 +1618,14 @@ public: inline char narrow(char16 ch) { return char(ch); } + inline void Setter::mark() { GCMARKOBJECT(type); GCMARKOBJECT(code); } + inline void Getter::mark() { GCMARKOBJECT(type); GCMARKOBJECT(code); } + + inline void InstanceGetter::mark() { InstanceMember::mark(); GCMARKOBJECT(type); GCMARKOBJECT(fInst); } + inline void InstanceSetter::mark() { InstanceMember::mark(); GCMARKOBJECT(type); GCMARKOBJECT(fInst); } + + inline void InstanceMember::mark() { GCMARKOBJECT(multiname); } + }; // namespace MetaData inline bool operator==(MetaData::LocalBindingEntry *s1, const String &s2) { return s1->name == s2;} diff --git a/js2/src/js2string.cpp b/js2/src/js2string.cpp index f581c070f33a..7ef33e3af4db 100644 --- a/js2/src/js2string.cpp +++ b/js2/src/js2string.cpp @@ -435,6 +435,7 @@ static js2val String_split(JS2Metadata *meta, const js2val thisValue, js2val *ar JS2RegExp *RE = NULL; const String *R = NULL; + DEFINE_ROOTKEEPER(rk2, R); if (meta->objectType(separatorV) == meta->regexpClass) RE = (checked_cast(JS2VAL_TO_OBJECT(separatorV)))->mRegExp; else @@ -463,7 +464,7 @@ static js2val String_split(JS2Metadata *meta, const js2val thisValue, js2val *ar } String *T = NULL; - DEFINE_ROOTKEEPER(rk2, T); + DEFINE_ROOTKEEPER(rk3, T); while (true) { uint32 q = p;