reserve stack space for arguments to native calls

This commit is contained in:
Joel Dice 2008-09-28 13:00:52 -06:00
parent c699725cf8
commit 61c708d7b2
3 changed files with 14 additions and 19 deletions

View File

@ -35,6 +35,8 @@ const bool DebugFrameMaps = false;
const bool CheckArrayBounds = true;
const unsigned MaxNativeCallFootprint = 4;
class MyThread: public Thread {
public:
class CallTrace {
@ -338,7 +340,9 @@ alignedFrameSize(MyThread* t, object method)
return t->arch->alignFrameSize
(localSize(t, method)
- methodParameterFootprint(t, method)
+ codeMaxStack(t, methodCode(t, method)));
+ codeMaxStack(t, methodCode(t, method))
+ MaxNativeCallFootprint
- t->arch->argumentRegisterCount());
}
unsigned
@ -3898,7 +3902,7 @@ compile(MyThread* t, Context* context)
unsigned footprint = methodParameterFootprint(t, context->method);
unsigned locals = localSize(t, context->method);
c->init(codeLength(t, methodCode(t, context->method)), footprint, locals,
codeMaxStack(t, methodCode(t, context->method)));
alignedFrameSize(t, context->method));
uint8_t stackMap[codeMaxStack(t, methodCode(t, context->method))];
Frame frame(context, stackMap);

View File

@ -267,9 +267,9 @@ class Context {
logicalCodeLength(0),
parameterFootprint(0),
localFootprint(0),
maxStackFootprint(0),
stackPadding(0),
machineCodeSize(0),
alignedFrameSize(0),
availableRegisterCount(arch->registerCount()),
constantCompare(CompareNone),
pass(ScanPass)
@ -304,9 +304,9 @@ class Context {
unsigned logicalCodeLength;
unsigned parameterFootprint;
unsigned localFootprint;
unsigned maxStackFootprint;
unsigned stackPadding;
unsigned machineCodeSize;
unsigned alignedFrameSize;
unsigned availableRegisterCount;
ConstantCompare constantCompare;
Pass pass;
@ -507,20 +507,11 @@ class Event {
unsigned readCount;
};
unsigned
alignedFrameSize(Context* c)
{
return c->arch->alignFrameSize
(c->localFootprint
- c->parameterFootprint
+ c->maxStackFootprint);
}
int
localOffset(Context* c, int v)
{
int parameterFootprint = c->parameterFootprint;
int frameSize = alignedFrameSize(c);
int frameSize = c->alignedFrameSize;
int offset = ((v < parameterFootprint) ?
(frameSize
@ -1669,7 +1660,7 @@ class CallEvent: public Event {
uint32_t mask = ~0;
Stack* s = argumentStack;
unsigned index = 0;
unsigned frameIndex = alignedFrameSize(c) + c->parameterFootprint;
unsigned frameIndex = c->alignedFrameSize + c->parameterFootprint;
for (unsigned i = 0; i < argumentCount; ++i) {
Read* target;
if (index < c->arch->argumentRegisterCount()) {
@ -2806,7 +2797,7 @@ compile(Context* c)
Block* firstBlock = block(c, c->firstEvent);
Block* block = firstBlock;
a->allocateFrame(alignedFrameSize(c));
a->allocateFrame(c->alignedFrameSize);
for (Event* e = c->firstEvent; e; e = e->next) {
e->block = block;
@ -3020,12 +3011,12 @@ class MyCompiler: public Compiler {
}
virtual void init(unsigned logicalCodeLength, unsigned parameterFootprint,
unsigned localFootprint, unsigned maxStackFootprint)
unsigned localFootprint, unsigned alignedFrameSize)
{
c.logicalCodeLength = logicalCodeLength;
c.parameterFootprint = parameterFootprint;
c.localFootprint = localFootprint;
c.maxStackFootprint = maxStackFootprint;
c.alignedFrameSize = alignedFrameSize;
c.logicalCode = static_cast<LogicalInstruction**>
(c.zone->allocate(sizeof(LogicalInstruction*) * logicalCodeLength));

View File

@ -40,7 +40,7 @@ class Compiler {
virtual void restoreState(State* state) = 0;
virtual void init(unsigned logicalCodeSize, unsigned parameterFootprint,
unsigned localFootprint, unsigned maxStackFootprint) = 0;
unsigned localFootprint, unsigned alignedFrameSize) = 0;
virtual void visitLogicalIp(unsigned logicalIp) = 0;
virtual void startLogicalIp(unsigned logicalIp) = 0;