This commit is contained in:
rogerl%netscape.com 2002-11-04 23:03:58 +00:00
Родитель b7eca451e7
Коммит d86906f807
4 изменённых файлов: 34 добавлений и 62 удалений

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

@ -196,6 +196,11 @@ namespace MetaData {
}
}
String *JS2Engine::allocStringPtr(const char *s)
{
return allocStringPtr(&meta->world.identifiers[widenCString(s)]);
}
String *JS2Engine::allocStringPtr(const String *s)
{
String *p = (String *)(JS2Object::alloc(sizeof(String)));
@ -343,7 +348,7 @@ namespace MetaData {
}
#define INIT_STRINGATOM(n) n##_StringAtom(allocStringPtr(#n))
#define INIT_STRINGATOM(n) n##_StringAtom(allocStringPtr(&world.identifiers[#n]))
JS2Engine::JS2Engine(World &world)
: pc(NULL),
@ -591,6 +596,7 @@ namespace MetaData {
if (bCon)
bCon->mark();
for (ActivationFrame *f = activationStack; (f < activationStackTop); f++) {
GCMARKOBJECT(f->topFrame);
if (f->bCon)
f->bCon->mark();
}

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

@ -184,7 +184,7 @@ public:
js2val allocString(const String &s) { return allocString(&s); }
js2val allocString(const char *s) { return STRING_TO_JS2VAL(allocStringPtr(s)); }
String *allocStringPtr(const String *s);
String *allocStringPtr(const char *s) { String &str = widenCString(s); return allocStringPtr(&str); }
String *allocStringPtr(const char *s);
js2val allocFloat(float32 x);
js2val pushFloat(float32 x) { js2val retval = allocFloat(x); push(retval); return retval; }

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

@ -714,7 +714,7 @@ namespace MetaData {
{
BlockStmtNode *b = checked_cast<BlockStmtNode *>(p);
BlockFrame *runtimeFrame = new BlockFrame(b->compileFrame);
env->addFrame(runtimeFrame);
env->addFrame(runtimeFrame); // XXX is this right? shouldn't this be the compile frame until execution occurs?
bCon->emitOp(ePushFrame, p->pos);
bCon->addFrame(runtimeFrame);
StmtNode *bp = b->statements;
@ -2377,7 +2377,17 @@ doUnary:
}
// need to mark all the frames in the environment - otherwise a marked frame that
// came initially from the bytecodeContainer may prevent the markChildren call
// from finding frames further down the list.
void Environment::mark()
{
Frame *pf = firstFrame;
while (pf) {
GCMARKOBJECT(pf)
pf = pf->nextFrame;
}
}
/************************************************************************************
@ -3636,7 +3646,8 @@ deleteClassProperty:
// XXX - maybe have a separate pool to allocate chunks
// that are meant to be never collected?
GCMARKOBJECT(publicNamespace);
GCMARKOBJECT(forbiddenMember);
forbiddenMember->mark();
GCMARKOBJECT(objectClass);
GCMARKOBJECT(undefinedClass);
GCMARKOBJECT(nullClass);
@ -3956,10 +3967,10 @@ deleteClassProperty:
GCMARKOBJECT(privateNamespace)
InstanceBindingIterator ib, iend;
for (ib = instanceReadBindings.begin(), iend = instanceReadBindings.end(); (ib != iend); ib++) {
GCMARKOBJECT(ib->second->content)
ib->second->content->mark();
}
for (ib = instanceWriteBindings.begin(), iend = instanceWriteBindings.end(); (ib != iend); ib++) {
GCMARKOBJECT(ib->second->content)
ib->second->content->mark();
}
}
@ -4105,10 +4116,10 @@ deleteClassProperty:
GCMARKOBJECT(pluralFrame)
StaticBindingIterator sbi, end;
for (sbi = staticReadBindings.begin(), end = staticReadBindings.end(); (sbi != end); sbi++) {
GCMARKOBJECT(sbi->second->content)
sbi->second->content->mark();
}
for (sbi = staticWriteBindings.begin(), end = staticWriteBindings.end(); (sbi != end); sbi++) {
GCMARKOBJECT(sbi->second->content)
sbi->second->content->mark();
}
if (temps) {
for (std::vector<js2val>::iterator i = temps->begin(), end = temps->end(); (i != end); i++)
@ -4188,20 +4199,10 @@ deleteClassProperty:
*
************************************************************************************/
bool InstanceMember::isMarked()
{
return type->isMarked();
}
// gc-mark all contained JS2Objects and visit contained structures to do likewise
void InstanceMember::mark()
{
type->mark();
}
// gc-mark all contained JS2Objects and visit contained structures to do likewise
void InstanceMember::markChildren()
{
type->markChildren();
GCMARKOBJECT(type);
}
@ -4213,26 +4214,13 @@ deleteClassProperty:
// An instance variable type could be future'd when a gc runs (i.e. validate
// has executed, but the pre-eval stage has yet to determine the actual type)
bool InstanceVariable::isMarked()
{
if (type != FUTURE_TYPE)
return type->isMarked();
else
return false;
}
void InstanceVariable::mark()
{
if (type != FUTURE_TYPE)
type->mark();
GCMARKOBJECT(type);
}
// gc-mark all contained JS2Objects and visit contained structures to do likewise
void InstanceVariable::markChildren()
{
if (type != FUTURE_TYPE)
type->markChildren();
}
/************************************************************************************
@ -4241,20 +4229,10 @@ deleteClassProperty:
*
************************************************************************************/
bool InstanceMethod::isMarked()
{
return fInst->isMarked();
}
// gc-mark all contained JS2Objects and visit contained structures to do likewise
void InstanceMethod::mark()
{
fInst->mark();
}
// gc-mark all contained JS2Objects and visit contained structures to do likewise
void InstanceMethod::markChildren()
{
fInst->markChildren();
GCMARKOBJECT(fInst);
}

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

@ -261,9 +261,7 @@ public:
MemberKind kind;
virtual bool isMarked() { return true; }
virtual void mark() { }
virtual void markChildren() { }
};
// A static member is either forbidden, a variable, a hoisted variable, a constructor method, or an accessor:
@ -295,9 +293,7 @@ public:
// uninitialised if the variable must be written before it can be read
bool immutable; // true if this variable's value may not be changed once set
virtual bool isMarked() { return (JS2VAL_IS_OBJECT(value) && JS2VAL_TO_OBJECT(value)->isMarked()); }
virtual void mark() { if (JS2VAL_IS_OBJECT(value)) JS2VAL_TO_OBJECT(value)->mark(); }
virtual void markChildren() { if (JS2VAL_IS_OBJECT(value)) JS2VAL_TO_OBJECT(value)->markChildren(); }
virtual void mark() { GCMARKVALUE(value); }
};
class HoistedVar : public StaticMember {
@ -307,9 +303,7 @@ public:
js2val value; // This variable's current value
bool hasFunctionInitializer; // true if this variable was created by a function statement
virtual bool isMarked() { return (JS2VAL_IS_OBJECT(value) && JS2VAL_TO_OBJECT(value)->isMarked()); }
virtual void mark() { if (JS2VAL_IS_OBJECT(value)) JS2VAL_TO_OBJECT(value)->mark(); }
virtual void markChildren() { if (JS2VAL_IS_OBJECT(value)) JS2VAL_TO_OBJECT(value)->markChildren(); }
virtual void mark() { GCMARKVALUE(value); }
};
class ConstructorMethod : public StaticMember {
@ -353,9 +347,7 @@ public:
JS2Class *type; // Type of values that may be stored in this variable
bool final; // true if this member may not be overridden in subclasses
virtual bool isMarked();
virtual void mark();
virtual void markChildren();
};
class InstanceVariable : public InstanceMember {
@ -365,9 +357,7 @@ public:
bool immutable; // true if this variable's value may not be changed once set
uint32 slotIndex; // The index into an instance's slot array in which this variable is stored
virtual bool isMarked();
virtual void mark();
virtual void markChildren();
};
class InstanceMethod : public InstanceMember {
@ -377,9 +367,7 @@ public:
Invokable *code; // This method itself (a callable object); null if this method is abstract
FixedInstance *fInst;
virtual bool isMarked();
virtual void mark();
virtual void markChildren();
};
class InstanceAccessor : public InstanceMember {
@ -865,7 +853,7 @@ public:
void instantiateFrame(Frame *pluralFrame, Frame *singularFrame);
void mark() { GCMARKOBJECT(firstFrame) }
void mark();
private:
Frame *firstFrame;