mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 06:38:36 +00:00
Fixed bit-rot in exception handling, removed unused locals.
This commit is contained in:
parent
6676b0784f
commit
61eb9f446d
@ -174,7 +174,7 @@ ICodeModule *ICodeGenerator::complete(JSType *resultType)
|
||||
parameterList,
|
||||
mPermanentRegister.size(),
|
||||
mInstructionMap,
|
||||
resultType);
|
||||
resultType, mExceptionRegister.first);
|
||||
if (pLabels) {
|
||||
uint32 i;
|
||||
uint32 parameterInits = pLabels->size() - 1; // there's an extra label at the end for the actual entryPoint
|
||||
@ -2423,11 +2423,11 @@ TypedRegister ICodeGenerator::genStmt(StmtNode *p, LabelSet *currentLabelSet)
|
||||
// Bind the incoming exception ...
|
||||
if (mExceptionRegister.first == NotABanana)
|
||||
mExceptionRegister = allocateRegister(&Any_Type);
|
||||
allocateVariable(c->name, mExceptionRegister);
|
||||
|
||||
genStmt(c->stmt);
|
||||
if (finallyLabel)
|
||||
jsr(finallyLabel);
|
||||
throwStmt(mExceptionRegister);
|
||||
c = c->next;
|
||||
}
|
||||
}
|
||||
@ -2568,7 +2568,8 @@ void ICodeGenerator::readICode(const char *fileName)
|
||||
theParameterList, /* ParameterList *parameters */
|
||||
icp.mMaxRegister,
|
||||
NULL, /* InstructionMap *instructionMap */
|
||||
resultType);
|
||||
resultType,
|
||||
NotABanana); /* exception register */
|
||||
thisClass->defineMethod(methodName, new JSFunction(icm));
|
||||
}
|
||||
}
|
||||
|
@ -131,13 +131,14 @@ namespace ICG {
|
||||
ParameterList *parameters,
|
||||
uint32 maxRegister,
|
||||
InstructionMap *instructionMap,
|
||||
JSType *resultType) :
|
||||
JSType *resultType, uint32 exceptionRegister) :
|
||||
its_iCode(iCode), itsVariables(variables), itsParameters(parameters),
|
||||
itsMaxRegister(maxRegister),
|
||||
mID(++sMaxID), mInstructionMap(instructionMap),
|
||||
mParameterInit(NULL),
|
||||
mEntryPoint(0),
|
||||
mResultType(resultType)
|
||||
mResultType(resultType),
|
||||
mExceptionRegister(exceptionRegister)
|
||||
{
|
||||
}
|
||||
|
||||
@ -163,6 +164,7 @@ namespace ICG {
|
||||
uint32 *mParameterInit;
|
||||
uint32 mEntryPoint;
|
||||
JSType *mResultType;
|
||||
uint32 mExceptionRegister;
|
||||
|
||||
static uint32 sMaxID;
|
||||
|
||||
@ -327,6 +329,12 @@ namespace ICG {
|
||||
return r;
|
||||
}
|
||||
|
||||
TypedRegister allocateVariable(const StringAtom& name, TypedRegister r)
|
||||
{
|
||||
variableList->add(name, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
TypedRegister allocateParameter(const StringAtom& name, bool isOptional)
|
||||
{
|
||||
return allocateParameter(name, isOptional, &Any_Type);
|
||||
|
@ -255,15 +255,6 @@ static JSValue add_Default(const JSValue& r1, const JSValue& r2)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
static JSValue add_String1(const JSValue& r1, const JSValue& r2)
|
||||
{
|
||||
JSValue num1(r1.toNumber());
|
||||
JSValue num2(r2.toNumber());
|
||||
return JSValue(num1.f64 + num2.f64);
|
||||
}
|
||||
*/
|
||||
|
||||
static JSValue subtract_Default(const JSValue& r1, const JSValue& r2)
|
||||
{
|
||||
JSValue num1(r1.toNumber());
|
||||
@ -970,7 +961,6 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
||||
if (getter) {
|
||||
if (getter->isNative()) {
|
||||
JSValues argv(1);
|
||||
JSValues::size_type i = 1;
|
||||
argv[0] = value;
|
||||
JSValue result = static_cast<JSNativeFunction*>(getter)->mCode(this, argv);
|
||||
if (dst(gp).first != NotARegister)
|
||||
@ -1078,7 +1068,6 @@ using JSString throughout.
|
||||
JSFunction* getter = inst->getter(src2(gs));
|
||||
if (getter->isNative()) {
|
||||
JSValues argv(1);
|
||||
JSValues::size_type i = 1;
|
||||
argv[0] = value;
|
||||
JSValue result = static_cast<JSNativeFunction*>(getter)->mCode(this, argv);
|
||||
if (dst(gs).first != NotARegister)
|
||||
@ -1122,7 +1111,6 @@ using JSString throughout.
|
||||
JSFunction* setter = inst->setter(src1(ss));
|
||||
if (setter->isNative()) {
|
||||
JSValues argv(2);
|
||||
JSValues::size_type i = 1;
|
||||
argv[0] = value;
|
||||
argv[1] = (*registers)[src2(ss).first];
|
||||
JSValue result = static_cast<JSNativeFunction*>(setter)->mCode(this, argv);
|
||||
@ -1583,9 +1571,13 @@ using JSString throughout.
|
||||
Linkage *pLinkage = mLinkage;
|
||||
for (; pLinkage != NULL; pLinkage = pLinkage->mNext) {
|
||||
if (!pLinkage->mActivation->catchStack.empty()) {
|
||||
mLinkage = pLinkage;
|
||||
mActivation = pLinkage->mActivation;
|
||||
Handler *h = mActivation->catchStack.back();
|
||||
mGlobal = pLinkage->mScope;
|
||||
mICode = pLinkage->mICode;
|
||||
registers = &mActivation->mRegisters;
|
||||
(*registers)[mICode->mExceptionRegister] = x->value;
|
||||
Handler *h = mActivation->catchStack.back();
|
||||
if (h->catchTarget) {
|
||||
mPC = mICode->its_iCode->begin() + h->catchTarget->mOffset;
|
||||
}
|
||||
@ -1593,7 +1585,7 @@ using JSString throughout.
|
||||
ASSERT(h->finallyTarget);
|
||||
mPC = mICode->its_iCode->begin() + h->finallyTarget->mOffset;
|
||||
}
|
||||
mLinkage = pLinkage;
|
||||
endPC = mICode->its_iCode->end();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ ICodeModule *ICodeGenerator::complete(JSType *resultType)
|
||||
parameterList,
|
||||
mPermanentRegister.size(),
|
||||
mInstructionMap,
|
||||
resultType);
|
||||
resultType, mExceptionRegister.first);
|
||||
if (pLabels) {
|
||||
uint32 i;
|
||||
uint32 parameterInits = pLabels->size() - 1; // there's an extra label at the end for the actual entryPoint
|
||||
@ -2423,11 +2423,11 @@ TypedRegister ICodeGenerator::genStmt(StmtNode *p, LabelSet *currentLabelSet)
|
||||
// Bind the incoming exception ...
|
||||
if (mExceptionRegister.first == NotABanana)
|
||||
mExceptionRegister = allocateRegister(&Any_Type);
|
||||
allocateVariable(c->name, mExceptionRegister);
|
||||
|
||||
genStmt(c->stmt);
|
||||
if (finallyLabel)
|
||||
jsr(finallyLabel);
|
||||
throwStmt(mExceptionRegister);
|
||||
c = c->next;
|
||||
}
|
||||
}
|
||||
@ -2568,7 +2568,8 @@ void ICodeGenerator::readICode(const char *fileName)
|
||||
theParameterList, /* ParameterList *parameters */
|
||||
icp.mMaxRegister,
|
||||
NULL, /* InstructionMap *instructionMap */
|
||||
resultType);
|
||||
resultType,
|
||||
NotABanana); /* exception register */
|
||||
thisClass->defineMethod(methodName, new JSFunction(icm));
|
||||
}
|
||||
}
|
||||
|
@ -131,13 +131,14 @@ namespace ICG {
|
||||
ParameterList *parameters,
|
||||
uint32 maxRegister,
|
||||
InstructionMap *instructionMap,
|
||||
JSType *resultType) :
|
||||
JSType *resultType, uint32 exceptionRegister) :
|
||||
its_iCode(iCode), itsVariables(variables), itsParameters(parameters),
|
||||
itsMaxRegister(maxRegister),
|
||||
mID(++sMaxID), mInstructionMap(instructionMap),
|
||||
mParameterInit(NULL),
|
||||
mEntryPoint(0),
|
||||
mResultType(resultType)
|
||||
mResultType(resultType),
|
||||
mExceptionRegister(exceptionRegister)
|
||||
{
|
||||
}
|
||||
|
||||
@ -163,6 +164,7 @@ namespace ICG {
|
||||
uint32 *mParameterInit;
|
||||
uint32 mEntryPoint;
|
||||
JSType *mResultType;
|
||||
uint32 mExceptionRegister;
|
||||
|
||||
static uint32 sMaxID;
|
||||
|
||||
@ -327,6 +329,12 @@ namespace ICG {
|
||||
return r;
|
||||
}
|
||||
|
||||
TypedRegister allocateVariable(const StringAtom& name, TypedRegister r)
|
||||
{
|
||||
variableList->add(name, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
TypedRegister allocateParameter(const StringAtom& name, bool isOptional)
|
||||
{
|
||||
return allocateParameter(name, isOptional, &Any_Type);
|
||||
|
@ -255,15 +255,6 @@ static JSValue add_Default(const JSValue& r1, const JSValue& r2)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
static JSValue add_String1(const JSValue& r1, const JSValue& r2)
|
||||
{
|
||||
JSValue num1(r1.toNumber());
|
||||
JSValue num2(r2.toNumber());
|
||||
return JSValue(num1.f64 + num2.f64);
|
||||
}
|
||||
*/
|
||||
|
||||
static JSValue subtract_Default(const JSValue& r1, const JSValue& r2)
|
||||
{
|
||||
JSValue num1(r1.toNumber());
|
||||
@ -970,7 +961,6 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
||||
if (getter) {
|
||||
if (getter->isNative()) {
|
||||
JSValues argv(1);
|
||||
JSValues::size_type i = 1;
|
||||
argv[0] = value;
|
||||
JSValue result = static_cast<JSNativeFunction*>(getter)->mCode(this, argv);
|
||||
if (dst(gp).first != NotARegister)
|
||||
@ -1078,7 +1068,6 @@ using JSString throughout.
|
||||
JSFunction* getter = inst->getter(src2(gs));
|
||||
if (getter->isNative()) {
|
||||
JSValues argv(1);
|
||||
JSValues::size_type i = 1;
|
||||
argv[0] = value;
|
||||
JSValue result = static_cast<JSNativeFunction*>(getter)->mCode(this, argv);
|
||||
if (dst(gs).first != NotARegister)
|
||||
@ -1122,7 +1111,6 @@ using JSString throughout.
|
||||
JSFunction* setter = inst->setter(src1(ss));
|
||||
if (setter->isNative()) {
|
||||
JSValues argv(2);
|
||||
JSValues::size_type i = 1;
|
||||
argv[0] = value;
|
||||
argv[1] = (*registers)[src2(ss).first];
|
||||
JSValue result = static_cast<JSNativeFunction*>(setter)->mCode(this, argv);
|
||||
@ -1583,9 +1571,13 @@ using JSString throughout.
|
||||
Linkage *pLinkage = mLinkage;
|
||||
for (; pLinkage != NULL; pLinkage = pLinkage->mNext) {
|
||||
if (!pLinkage->mActivation->catchStack.empty()) {
|
||||
mLinkage = pLinkage;
|
||||
mActivation = pLinkage->mActivation;
|
||||
Handler *h = mActivation->catchStack.back();
|
||||
mGlobal = pLinkage->mScope;
|
||||
mICode = pLinkage->mICode;
|
||||
registers = &mActivation->mRegisters;
|
||||
(*registers)[mICode->mExceptionRegister] = x->value;
|
||||
Handler *h = mActivation->catchStack.back();
|
||||
if (h->catchTarget) {
|
||||
mPC = mICode->its_iCode->begin() + h->catchTarget->mOffset;
|
||||
}
|
||||
@ -1593,7 +1585,7 @@ using JSString throughout.
|
||||
ASSERT(h->finallyTarget);
|
||||
mPC = mICode->its_iCode->begin() + h->finallyTarget->mOffset;
|
||||
}
|
||||
mLinkage = pLinkage;
|
||||
endPC = mICode->its_iCode->end();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user