From de84afe2fe5008c1888c390aad1a542a38f44bc5 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 25 Apr 2009 11:47:41 -0600 Subject: [PATCH] adjust stack if necessary after non-tail-call in case where callee pops arguments --- src/compiler.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/compiler.cpp b/src/compiler.cpp index 6906be054f..29daef0e12 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -2486,6 +2486,20 @@ class CallEvent: public Event { padIndex, padding); } + if ((flags & Compiler::TailJump) == 0) { + unsigned footprint = c->arch->argumentFootprint(stackArgumentFootprint); + if (footprint > c->arch->stackAlignmentInWords()) { + Assembler::Register stack(c->arch->stack()); + ResolvedPromise adjustmentPromise + ((footprint - c->arch->stackAlignmentInWords()) * BytesPerWord); + Assembler::Constant adjustmentConstant(&adjustmentPromise); + c->assembler->apply + (Subtract, BytesPerWord, ConstantOperand, &adjustmentConstant, + BytesPerWord, RegisterOperand, &stack, + BytesPerWord, RegisterOperand, &stack); + } + } + clean(c, this, stackBefore, localsBefore, reads, popIndex); if (resultSize and live(result)) {