зеркало из https://github.com/mozilla/gecko-dev.git
Fixed gc-ing in frames.
This commit is contained in:
Родитель
b7eca451e7
Коммит
d86906f807
|
@ -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 *JS2Engine::allocStringPtr(const String *s)
|
||||||
{
|
{
|
||||||
String *p = (String *)(JS2Object::alloc(sizeof(String)));
|
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)
|
JS2Engine::JS2Engine(World &world)
|
||||||
: pc(NULL),
|
: pc(NULL),
|
||||||
|
@ -591,6 +596,7 @@ namespace MetaData {
|
||||||
if (bCon)
|
if (bCon)
|
||||||
bCon->mark();
|
bCon->mark();
|
||||||
for (ActivationFrame *f = activationStack; (f < activationStackTop); f++) {
|
for (ActivationFrame *f = activationStack; (f < activationStackTop); f++) {
|
||||||
|
GCMARKOBJECT(f->topFrame);
|
||||||
if (f->bCon)
|
if (f->bCon)
|
||||||
f->bCon->mark();
|
f->bCon->mark();
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ public:
|
||||||
js2val allocString(const String &s) { return allocString(&s); }
|
js2val allocString(const String &s) { return allocString(&s); }
|
||||||
js2val allocString(const char *s) { return STRING_TO_JS2VAL(allocStringPtr(s)); }
|
js2val allocString(const char *s) { return STRING_TO_JS2VAL(allocStringPtr(s)); }
|
||||||
String *allocStringPtr(const String *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 allocFloat(float32 x);
|
||||||
js2val pushFloat(float32 x) { js2val retval = allocFloat(x); push(retval); return retval; }
|
js2val pushFloat(float32 x) { js2val retval = allocFloat(x); push(retval); return retval; }
|
||||||
|
|
|
@ -714,7 +714,7 @@ namespace MetaData {
|
||||||
{
|
{
|
||||||
BlockStmtNode *b = checked_cast<BlockStmtNode *>(p);
|
BlockStmtNode *b = checked_cast<BlockStmtNode *>(p);
|
||||||
BlockFrame *runtimeFrame = new BlockFrame(b->compileFrame);
|
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->emitOp(ePushFrame, p->pos);
|
||||||
bCon->addFrame(runtimeFrame);
|
bCon->addFrame(runtimeFrame);
|
||||||
StmtNode *bp = b->statements;
|
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
|
// XXX - maybe have a separate pool to allocate chunks
|
||||||
// that are meant to be never collected?
|
// that are meant to be never collected?
|
||||||
GCMARKOBJECT(publicNamespace);
|
GCMARKOBJECT(publicNamespace);
|
||||||
GCMARKOBJECT(forbiddenMember);
|
forbiddenMember->mark();
|
||||||
|
|
||||||
GCMARKOBJECT(objectClass);
|
GCMARKOBJECT(objectClass);
|
||||||
GCMARKOBJECT(undefinedClass);
|
GCMARKOBJECT(undefinedClass);
|
||||||
GCMARKOBJECT(nullClass);
|
GCMARKOBJECT(nullClass);
|
||||||
|
@ -3956,10 +3967,10 @@ deleteClassProperty:
|
||||||
GCMARKOBJECT(privateNamespace)
|
GCMARKOBJECT(privateNamespace)
|
||||||
InstanceBindingIterator ib, iend;
|
InstanceBindingIterator ib, iend;
|
||||||
for (ib = instanceReadBindings.begin(), iend = instanceReadBindings.end(); (ib != iend); ib++) {
|
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++) {
|
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)
|
GCMARKOBJECT(pluralFrame)
|
||||||
StaticBindingIterator sbi, end;
|
StaticBindingIterator sbi, end;
|
||||||
for (sbi = staticReadBindings.begin(), end = staticReadBindings.end(); (sbi != end); sbi++) {
|
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++) {
|
for (sbi = staticWriteBindings.begin(), end = staticWriteBindings.end(); (sbi != end); sbi++) {
|
||||||
GCMARKOBJECT(sbi->second->content)
|
sbi->second->content->mark();
|
||||||
}
|
}
|
||||||
if (temps) {
|
if (temps) {
|
||||||
for (std::vector<js2val>::iterator i = temps->begin(), end = temps->end(); (i != end); i++)
|
for (std::vector<js2val>::iterator i = temps->begin(), end = temps->end(); (i != end); i++)
|
||||||
|
@ -4188,20 +4199,10 @@ deleteClassProperty:
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
bool InstanceMember::isMarked()
|
// gc-mark all contained JS2Objects and visit contained structures to do likewise
|
||||||
{
|
|
||||||
return type->isMarked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InstanceMember::mark()
|
void InstanceMember::mark()
|
||||||
{
|
{
|
||||||
type->mark();
|
GCMARKOBJECT(type);
|
||||||
}
|
|
||||||
|
|
||||||
// gc-mark all contained JS2Objects and visit contained structures to do likewise
|
|
||||||
void InstanceMember::markChildren()
|
|
||||||
{
|
|
||||||
type->markChildren();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4213,26 +4214,13 @@ deleteClassProperty:
|
||||||
|
|
||||||
// An instance variable type could be future'd when a gc runs (i.e. validate
|
// 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)
|
// 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()
|
void InstanceVariable::mark()
|
||||||
{
|
{
|
||||||
if (type != FUTURE_TYPE)
|
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()
|
// gc-mark all contained JS2Objects and visit contained structures to do likewise
|
||||||
{
|
|
||||||
return fInst->isMarked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InstanceMethod::mark()
|
void InstanceMethod::mark()
|
||||||
{
|
{
|
||||||
fInst->mark();
|
GCMARKOBJECT(fInst);
|
||||||
}
|
|
||||||
|
|
||||||
// gc-mark all contained JS2Objects and visit contained structures to do likewise
|
|
||||||
void InstanceMethod::markChildren()
|
|
||||||
{
|
|
||||||
fInst->markChildren();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -261,9 +261,7 @@ public:
|
||||||
|
|
||||||
MemberKind kind;
|
MemberKind kind;
|
||||||
|
|
||||||
virtual bool isMarked() { return true; }
|
|
||||||
virtual void mark() { }
|
virtual void mark() { }
|
||||||
virtual void markChildren() { }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A static member is either forbidden, a variable, a hoisted variable, a constructor method, or an accessor:
|
// 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
|
// 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
|
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() { GCMARKVALUE(value); }
|
||||||
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(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class HoistedVar : public StaticMember {
|
class HoistedVar : public StaticMember {
|
||||||
|
@ -307,9 +303,7 @@ public:
|
||||||
js2val value; // This variable's current value
|
js2val value; // This variable's current value
|
||||||
bool hasFunctionInitializer; // true if this variable was created by a function statement
|
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() { GCMARKVALUE(value); }
|
||||||
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(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConstructorMethod : public StaticMember {
|
class ConstructorMethod : public StaticMember {
|
||||||
|
@ -353,9 +347,7 @@ public:
|
||||||
JS2Class *type; // Type of values that may be stored in this variable
|
JS2Class *type; // Type of values that may be stored in this variable
|
||||||
bool final; // true if this member may not be overridden in subclasses
|
bool final; // true if this member may not be overridden in subclasses
|
||||||
|
|
||||||
virtual bool isMarked();
|
|
||||||
virtual void mark();
|
virtual void mark();
|
||||||
virtual void markChildren();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class InstanceVariable : public InstanceMember {
|
class InstanceVariable : public InstanceMember {
|
||||||
|
@ -365,9 +357,7 @@ public:
|
||||||
bool immutable; // true if this variable's value may not be changed once set
|
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
|
uint32 slotIndex; // The index into an instance's slot array in which this variable is stored
|
||||||
|
|
||||||
virtual bool isMarked();
|
|
||||||
virtual void mark();
|
virtual void mark();
|
||||||
virtual void markChildren();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class InstanceMethod : public InstanceMember {
|
class InstanceMethod : public InstanceMember {
|
||||||
|
@ -377,9 +367,7 @@ public:
|
||||||
Invokable *code; // This method itself (a callable object); null if this method is abstract
|
Invokable *code; // This method itself (a callable object); null if this method is abstract
|
||||||
FixedInstance *fInst;
|
FixedInstance *fInst;
|
||||||
|
|
||||||
virtual bool isMarked();
|
|
||||||
virtual void mark();
|
virtual void mark();
|
||||||
virtual void markChildren();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class InstanceAccessor : public InstanceMember {
|
class InstanceAccessor : public InstanceMember {
|
||||||
|
@ -865,7 +853,7 @@ public:
|
||||||
|
|
||||||
void instantiateFrame(Frame *pluralFrame, Frame *singularFrame);
|
void instantiateFrame(Frame *pluralFrame, Frame *singularFrame);
|
||||||
|
|
||||||
void mark() { GCMARKOBJECT(firstFrame) }
|
void mark();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Frame *firstFrame;
|
Frame *firstFrame;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче