diff options
author | Lars Knoll <lars.knoll@digia.com> | 2012-12-16 23:00:01 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2012-12-17 10:00:19 +0100 |
commit | fb070c2d8c845bf062ab30ac19dd6cf1a7f37ec5 (patch) | |
tree | 0548c2524ecb3c9e26a19174d51f4ef34764edad /qv4isel_masm.cpp | |
parent | 6cf74ab25d021f11341483141125389dd6b83f4e (diff) |
Fix return value corruption in masm codegeneration
In some cases, the first argument for runtime calls and the
return value where being placed in the same location on the
stack leading to corrupted return values. This mainly
happens when no local variable are defined, but other
functions are being called.
Change-Id: I93f1e518ce2998f62fb9f38c538dd718f41e522d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'qv4isel_masm.cpp')
-rw-r--r-- | qv4isel_masm.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/qv4isel_masm.cpp b/qv4isel_masm.cpp index 298d0b51f1..0b2b5b2f1f 100644 --- a/qv4isel_masm.cpp +++ b/qv4isel_masm.cpp @@ -94,7 +94,7 @@ Assembler::Pointer Assembler::loadTempAddress(RegisterID reg, IR::Temp *t) loadPtr(Address(ContextRegister, offsetof(ExecutionContext, locals)), reg); offset = t->index * sizeof(Value); } else { - const int arg = _function->maxNumberOfArguments + t->index - _function->locals.size(); + const int arg = _function->maxNumberOfArguments + t->index - _function->locals.size() + 1; // StackFrameRegister points to its old value on the stack, so even for the first temp we need to // subtract at least sizeof(Value). offset = - sizeof(Value) * (arg + 1); @@ -387,7 +387,7 @@ void InstructionSelection::run(VM::Function *vmFunction, IR::Function *function) Assembler* oldAssembler = _asm; _asm = new Assembler(_function); - int locals = (_function->tempCount - _function->locals.size() + _function->maxNumberOfArguments); + int locals = (_function->tempCount - _function->locals.size() + _function->maxNumberOfArguments) + 1; locals = (locals + 1) & ~1; _asm->enterStandardStackFrame(locals); |