зеркало из https://github.com/mozilla/gecko-dev.git
Removing variables.
This commit is contained in:
Родитель
f07ec29168
Коммит
07efe443fa
|
@ -86,7 +86,7 @@ namespace ICG {
|
|||
*/
|
||||
markMaxRegister();
|
||||
|
||||
return new ICodeModule(iCode, maxRegister, maxVariable);
|
||||
return new ICodeModule(iCode, maxRegister);
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
|
|
|
@ -78,14 +78,11 @@ namespace ICG {
|
|||
|
||||
class ICodeModule {
|
||||
public:
|
||||
ICodeModule(InstructionStream *iCode, uint32 maxRegister,
|
||||
uint32 maxVariable) :
|
||||
its_iCode(iCode), itsMaxRegister(maxRegister),
|
||||
itsMaxVariable(maxVariable) { }
|
||||
ICodeModule(InstructionStream *iCode, uint32 maxRegister) :
|
||||
its_iCode(iCode), itsMaxRegister(maxRegister) { }
|
||||
|
||||
InstructionStream *its_iCode;
|
||||
uint32 itsMaxRegister;
|
||||
uint32 itsMaxVariable;
|
||||
};
|
||||
|
||||
/****************************************************************/
|
||||
|
@ -103,11 +100,7 @@ namespace ICG {
|
|||
|
||||
void markMaxRegister() \
|
||||
{ if (topRegister > maxRegister) maxRegister = topRegister; }
|
||||
void markMaxVariable(uint32 variableIndex) \
|
||||
{ if (variableIndex > maxVariable) maxVariable = variableIndex; }
|
||||
|
||||
Register topRegister;
|
||||
Register registerBase;
|
||||
Register getRegister() \
|
||||
{ return topRegister++; }
|
||||
void resetTopRegister() \
|
||||
|
@ -116,9 +109,10 @@ namespace ICG {
|
|||
|
||||
ICodeOp getBranchOp() \
|
||||
{ ASSERT(!iCode->empty()); return iCode->back()->getBranchOp(); }
|
||||
|
||||
|
||||
Register topRegister;
|
||||
Register registerBase;
|
||||
uint32 maxRegister;
|
||||
uint32 maxVariable;
|
||||
|
||||
void setLabel(Label *label);
|
||||
void setLabel(InstructionStream *stream, Label *label);
|
||||
|
@ -127,8 +121,7 @@ namespace ICG {
|
|||
void branchConditional(Label *label, Register condition);
|
||||
|
||||
public:
|
||||
ICodeGenerator() : topRegister(0), registerBase(0), maxRegister(0),
|
||||
maxVariable(0) \
|
||||
ICodeGenerator() : topRegister(0), registerBase(0), maxRegister(0)
|
||||
{ iCode = new InstructionStream(); }
|
||||
|
||||
virtual ~ICodeGenerator() { if (iCode) delete iCode; }
|
||||
|
@ -150,11 +143,8 @@ namespace ICG {
|
|||
|
||||
Register compare(ICodeOp op, Register source1, Register source2);
|
||||
|
||||
Register loadVariable(uint32 frameIndex);
|
||||
Register loadImmediate(double value);
|
||||
|
||||
void saveVariable(uint32 frameIndex, Register value);
|
||||
|
||||
|
||||
Register newObject();
|
||||
Register newArray();
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ namespace Interpreter {
|
|||
|
||||
// initial activation.
|
||||
JSActivation* activation = new JSActivation(iCode, args);
|
||||
JSValues* locals = &activation->mLocals;
|
||||
JSValues* registers = &activation->mRegisters;
|
||||
|
||||
InstructionIterator begin_pc = iCode->its_iCode->begin();
|
||||
|
@ -78,7 +77,6 @@ namespace Interpreter {
|
|||
ICodeModule* target =
|
||||
(*registers)[op2(call)].function->getICode();
|
||||
activation = new JSActivation(target, activation, op3(call));
|
||||
locals = &activation->mLocals;
|
||||
registers = &activation->mRegisters;
|
||||
begin_pc = pc = target->its_iCode->begin();
|
||||
}
|
||||
|
@ -95,7 +93,6 @@ namespace Interpreter {
|
|||
frames.pop();
|
||||
activation = frame->itsActivation;
|
||||
registers = &activation->mRegisters;
|
||||
locals = &activation->mLocals;
|
||||
(*registers)[frame->itsResult] = result;
|
||||
pc = frame->itsReturnPC;
|
||||
begin_pc = frame->itsBasePC;
|
||||
|
@ -165,18 +162,6 @@ namespace Interpreter {
|
|||
(*registers)[dst(li)] = JSValue(src1(li));
|
||||
}
|
||||
break;
|
||||
case LOAD_VAR:
|
||||
{
|
||||
LoadVar* lv = static_cast<LoadVar*>(instruction);
|
||||
(*registers)[dst(lv)] = (*locals)[src1(lv)];
|
||||
}
|
||||
break;
|
||||
case SAVE_VAR:
|
||||
{
|
||||
SaveVar* sv = static_cast<SaveVar*>(instruction);
|
||||
(*locals)[dst(sv)] = (*registers)[src1(sv)];
|
||||
}
|
||||
break;
|
||||
case BRANCH:
|
||||
{
|
||||
GenericBranch* bra =
|
||||
|
|
|
@ -176,23 +176,23 @@ namespace JSTypes {
|
|||
*/
|
||||
struct JSActivation : public gc_base {
|
||||
JSValues mRegisters;
|
||||
JSValues mLocals;
|
||||
|
||||
JSActivation(ICodeModule* iCode, const JSValues& args)
|
||||
: mRegisters(iCode->itsMaxRegister + 1), mLocals(args)
|
||||
: mRegisters(iCode->itsMaxRegister + 1)
|
||||
{
|
||||
// ensure that locals array is large enough.
|
||||
uint32 localsSize = iCode->itsMaxVariable + 1;
|
||||
if (localsSize > mLocals.size())
|
||||
mLocals.resize(localsSize);
|
||||
// copy arg list to initial registers.
|
||||
JSValues::iterator dest = mRegisters.begin();
|
||||
for (JSValues::const_iterator src = args.begin(),
|
||||
end = args.end(); src != end; ++src, ++dest) {
|
||||
*dest = *src;
|
||||
}
|
||||
}
|
||||
|
||||
JSActivation(ICodeModule* iCode, JSActivation* caller,
|
||||
const RegisterList& list)
|
||||
: mRegisters(iCode->itsMaxRegister + 1),
|
||||
mLocals(iCode->itsMaxVariable + 1)
|
||||
: mRegisters(iCode->itsMaxRegister + 1)
|
||||
{
|
||||
// copy caller's parameter list in to locals.
|
||||
// copy caller's parameter list to initial registers.
|
||||
JSValues::iterator dest = mRegisters.begin();
|
||||
const JSValues& params = caller->mRegisters;
|
||||
for (RegisterList::const_iterator src = list.begin(),
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace ICG {
|
|||
*/
|
||||
markMaxRegister();
|
||||
|
||||
return new ICodeModule(iCode, maxRegister, maxVariable);
|
||||
return new ICodeModule(iCode, maxRegister);
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
|
|
|
@ -78,14 +78,11 @@ namespace ICG {
|
|||
|
||||
class ICodeModule {
|
||||
public:
|
||||
ICodeModule(InstructionStream *iCode, uint32 maxRegister,
|
||||
uint32 maxVariable) :
|
||||
its_iCode(iCode), itsMaxRegister(maxRegister),
|
||||
itsMaxVariable(maxVariable) { }
|
||||
ICodeModule(InstructionStream *iCode, uint32 maxRegister) :
|
||||
its_iCode(iCode), itsMaxRegister(maxRegister) { }
|
||||
|
||||
InstructionStream *its_iCode;
|
||||
uint32 itsMaxRegister;
|
||||
uint32 itsMaxVariable;
|
||||
};
|
||||
|
||||
/****************************************************************/
|
||||
|
@ -103,11 +100,7 @@ namespace ICG {
|
|||
|
||||
void markMaxRegister() \
|
||||
{ if (topRegister > maxRegister) maxRegister = topRegister; }
|
||||
void markMaxVariable(uint32 variableIndex) \
|
||||
{ if (variableIndex > maxVariable) maxVariable = variableIndex; }
|
||||
|
||||
Register topRegister;
|
||||
Register registerBase;
|
||||
Register getRegister() \
|
||||
{ return topRegister++; }
|
||||
void resetTopRegister() \
|
||||
|
@ -116,9 +109,10 @@ namespace ICG {
|
|||
|
||||
ICodeOp getBranchOp() \
|
||||
{ ASSERT(!iCode->empty()); return iCode->back()->getBranchOp(); }
|
||||
|
||||
|
||||
Register topRegister;
|
||||
Register registerBase;
|
||||
uint32 maxRegister;
|
||||
uint32 maxVariable;
|
||||
|
||||
void setLabel(Label *label);
|
||||
void setLabel(InstructionStream *stream, Label *label);
|
||||
|
@ -127,8 +121,7 @@ namespace ICG {
|
|||
void branchConditional(Label *label, Register condition);
|
||||
|
||||
public:
|
||||
ICodeGenerator() : topRegister(0), registerBase(0), maxRegister(0),
|
||||
maxVariable(0) \
|
||||
ICodeGenerator() : topRegister(0), registerBase(0), maxRegister(0)
|
||||
{ iCode = new InstructionStream(); }
|
||||
|
||||
virtual ~ICodeGenerator() { if (iCode) delete iCode; }
|
||||
|
@ -150,11 +143,8 @@ namespace ICG {
|
|||
|
||||
Register compare(ICodeOp op, Register source1, Register source2);
|
||||
|
||||
Register loadVariable(uint32 frameIndex);
|
||||
Register loadImmediate(double value);
|
||||
|
||||
void saveVariable(uint32 frameIndex, Register value);
|
||||
|
||||
|
||||
Register newObject();
|
||||
Register newArray();
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ namespace Interpreter {
|
|||
|
||||
// initial activation.
|
||||
JSActivation* activation = new JSActivation(iCode, args);
|
||||
JSValues* locals = &activation->mLocals;
|
||||
JSValues* registers = &activation->mRegisters;
|
||||
|
||||
InstructionIterator begin_pc = iCode->its_iCode->begin();
|
||||
|
@ -78,7 +77,6 @@ namespace Interpreter {
|
|||
ICodeModule* target =
|
||||
(*registers)[op2(call)].function->getICode();
|
||||
activation = new JSActivation(target, activation, op3(call));
|
||||
locals = &activation->mLocals;
|
||||
registers = &activation->mRegisters;
|
||||
begin_pc = pc = target->its_iCode->begin();
|
||||
}
|
||||
|
@ -95,7 +93,6 @@ namespace Interpreter {
|
|||
frames.pop();
|
||||
activation = frame->itsActivation;
|
||||
registers = &activation->mRegisters;
|
||||
locals = &activation->mLocals;
|
||||
(*registers)[frame->itsResult] = result;
|
||||
pc = frame->itsReturnPC;
|
||||
begin_pc = frame->itsBasePC;
|
||||
|
@ -165,18 +162,6 @@ namespace Interpreter {
|
|||
(*registers)[dst(li)] = JSValue(src1(li));
|
||||
}
|
||||
break;
|
||||
case LOAD_VAR:
|
||||
{
|
||||
LoadVar* lv = static_cast<LoadVar*>(instruction);
|
||||
(*registers)[dst(lv)] = (*locals)[src1(lv)];
|
||||
}
|
||||
break;
|
||||
case SAVE_VAR:
|
||||
{
|
||||
SaveVar* sv = static_cast<SaveVar*>(instruction);
|
||||
(*locals)[dst(sv)] = (*registers)[src1(sv)];
|
||||
}
|
||||
break;
|
||||
case BRANCH:
|
||||
{
|
||||
GenericBranch* bra =
|
||||
|
|
|
@ -176,23 +176,23 @@ namespace JSTypes {
|
|||
*/
|
||||
struct JSActivation : public gc_base {
|
||||
JSValues mRegisters;
|
||||
JSValues mLocals;
|
||||
|
||||
JSActivation(ICodeModule* iCode, const JSValues& args)
|
||||
: mRegisters(iCode->itsMaxRegister + 1), mLocals(args)
|
||||
: mRegisters(iCode->itsMaxRegister + 1)
|
||||
{
|
||||
// ensure that locals array is large enough.
|
||||
uint32 localsSize = iCode->itsMaxVariable + 1;
|
||||
if (localsSize > mLocals.size())
|
||||
mLocals.resize(localsSize);
|
||||
// copy arg list to initial registers.
|
||||
JSValues::iterator dest = mRegisters.begin();
|
||||
for (JSValues::const_iterator src = args.begin(),
|
||||
end = args.end(); src != end; ++src, ++dest) {
|
||||
*dest = *src;
|
||||
}
|
||||
}
|
||||
|
||||
JSActivation(ICodeModule* iCode, JSActivation* caller,
|
||||
const RegisterList& list)
|
||||
: mRegisters(iCode->itsMaxRegister + 1),
|
||||
mLocals(iCode->itsMaxVariable + 1)
|
||||
: mRegisters(iCode->itsMaxRegister + 1)
|
||||
{
|
||||
// copy caller's parameter list in to locals.
|
||||
// copy caller's parameter list to initial registers.
|
||||
JSValues::iterator dest = mRegisters.begin();
|
||||
const JSValues& params = caller->mRegisters;
|
||||
for (RegisterList::const_iterator src = list.begin(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче