mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +00:00
reserve stack space for arguments to native calls
This commit is contained in:
parent
c699725cf8
commit
61c708d7b2
@ -35,6 +35,8 @@ const bool DebugFrameMaps = false;
|
|||||||
|
|
||||||
const bool CheckArrayBounds = true;
|
const bool CheckArrayBounds = true;
|
||||||
|
|
||||||
|
const unsigned MaxNativeCallFootprint = 4;
|
||||||
|
|
||||||
class MyThread: public Thread {
|
class MyThread: public Thread {
|
||||||
public:
|
public:
|
||||||
class CallTrace {
|
class CallTrace {
|
||||||
@ -338,7 +340,9 @@ alignedFrameSize(MyThread* t, object method)
|
|||||||
return t->arch->alignFrameSize
|
return t->arch->alignFrameSize
|
||||||
(localSize(t, method)
|
(localSize(t, method)
|
||||||
- methodParameterFootprint(t, method)
|
- methodParameterFootprint(t, method)
|
||||||
+ codeMaxStack(t, methodCode(t, method)));
|
+ codeMaxStack(t, methodCode(t, method))
|
||||||
|
+ MaxNativeCallFootprint
|
||||||
|
- t->arch->argumentRegisterCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
@ -3898,7 +3902,7 @@ compile(MyThread* t, Context* context)
|
|||||||
unsigned footprint = methodParameterFootprint(t, context->method);
|
unsigned footprint = methodParameterFootprint(t, context->method);
|
||||||
unsigned locals = localSize(t, context->method);
|
unsigned locals = localSize(t, context->method);
|
||||||
c->init(codeLength(t, methodCode(t, context->method)), footprint, locals,
|
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))];
|
uint8_t stackMap[codeMaxStack(t, methodCode(t, context->method))];
|
||||||
Frame frame(context, stackMap);
|
Frame frame(context, stackMap);
|
||||||
|
@ -267,9 +267,9 @@ class Context {
|
|||||||
logicalCodeLength(0),
|
logicalCodeLength(0),
|
||||||
parameterFootprint(0),
|
parameterFootprint(0),
|
||||||
localFootprint(0),
|
localFootprint(0),
|
||||||
maxStackFootprint(0),
|
|
||||||
stackPadding(0),
|
stackPadding(0),
|
||||||
machineCodeSize(0),
|
machineCodeSize(0),
|
||||||
|
alignedFrameSize(0),
|
||||||
availableRegisterCount(arch->registerCount()),
|
availableRegisterCount(arch->registerCount()),
|
||||||
constantCompare(CompareNone),
|
constantCompare(CompareNone),
|
||||||
pass(ScanPass)
|
pass(ScanPass)
|
||||||
@ -304,9 +304,9 @@ class Context {
|
|||||||
unsigned logicalCodeLength;
|
unsigned logicalCodeLength;
|
||||||
unsigned parameterFootprint;
|
unsigned parameterFootprint;
|
||||||
unsigned localFootprint;
|
unsigned localFootprint;
|
||||||
unsigned maxStackFootprint;
|
|
||||||
unsigned stackPadding;
|
unsigned stackPadding;
|
||||||
unsigned machineCodeSize;
|
unsigned machineCodeSize;
|
||||||
|
unsigned alignedFrameSize;
|
||||||
unsigned availableRegisterCount;
|
unsigned availableRegisterCount;
|
||||||
ConstantCompare constantCompare;
|
ConstantCompare constantCompare;
|
||||||
Pass pass;
|
Pass pass;
|
||||||
@ -507,20 +507,11 @@ class Event {
|
|||||||
unsigned readCount;
|
unsigned readCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned
|
|
||||||
alignedFrameSize(Context* c)
|
|
||||||
{
|
|
||||||
return c->arch->alignFrameSize
|
|
||||||
(c->localFootprint
|
|
||||||
- c->parameterFootprint
|
|
||||||
+ c->maxStackFootprint);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
localOffset(Context* c, int v)
|
localOffset(Context* c, int v)
|
||||||
{
|
{
|
||||||
int parameterFootprint = c->parameterFootprint;
|
int parameterFootprint = c->parameterFootprint;
|
||||||
int frameSize = alignedFrameSize(c);
|
int frameSize = c->alignedFrameSize;
|
||||||
|
|
||||||
int offset = ((v < parameterFootprint) ?
|
int offset = ((v < parameterFootprint) ?
|
||||||
(frameSize
|
(frameSize
|
||||||
@ -1669,7 +1660,7 @@ class CallEvent: public Event {
|
|||||||
uint32_t mask = ~0;
|
uint32_t mask = ~0;
|
||||||
Stack* s = argumentStack;
|
Stack* s = argumentStack;
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
unsigned frameIndex = alignedFrameSize(c) + c->parameterFootprint;
|
unsigned frameIndex = c->alignedFrameSize + c->parameterFootprint;
|
||||||
for (unsigned i = 0; i < argumentCount; ++i) {
|
for (unsigned i = 0; i < argumentCount; ++i) {
|
||||||
Read* target;
|
Read* target;
|
||||||
if (index < c->arch->argumentRegisterCount()) {
|
if (index < c->arch->argumentRegisterCount()) {
|
||||||
@ -2806,7 +2797,7 @@ compile(Context* c)
|
|||||||
Block* firstBlock = block(c, c->firstEvent);
|
Block* firstBlock = block(c, c->firstEvent);
|
||||||
Block* block = firstBlock;
|
Block* block = firstBlock;
|
||||||
|
|
||||||
a->allocateFrame(alignedFrameSize(c));
|
a->allocateFrame(c->alignedFrameSize);
|
||||||
|
|
||||||
for (Event* e = c->firstEvent; e; e = e->next) {
|
for (Event* e = c->firstEvent; e; e = e->next) {
|
||||||
e->block = block;
|
e->block = block;
|
||||||
@ -3020,12 +3011,12 @@ class MyCompiler: public Compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void init(unsigned logicalCodeLength, unsigned parameterFootprint,
|
virtual void init(unsigned logicalCodeLength, unsigned parameterFootprint,
|
||||||
unsigned localFootprint, unsigned maxStackFootprint)
|
unsigned localFootprint, unsigned alignedFrameSize)
|
||||||
{
|
{
|
||||||
c.logicalCodeLength = logicalCodeLength;
|
c.logicalCodeLength = logicalCodeLength;
|
||||||
c.parameterFootprint = parameterFootprint;
|
c.parameterFootprint = parameterFootprint;
|
||||||
c.localFootprint = localFootprint;
|
c.localFootprint = localFootprint;
|
||||||
c.maxStackFootprint = maxStackFootprint;
|
c.alignedFrameSize = alignedFrameSize;
|
||||||
|
|
||||||
c.logicalCode = static_cast<LogicalInstruction**>
|
c.logicalCode = static_cast<LogicalInstruction**>
|
||||||
(c.zone->allocate(sizeof(LogicalInstruction*) * logicalCodeLength));
|
(c.zone->allocate(sizeof(LogicalInstruction*) * logicalCodeLength));
|
||||||
|
@ -40,7 +40,7 @@ class Compiler {
|
|||||||
virtual void restoreState(State* state) = 0;
|
virtual void restoreState(State* state) = 0;
|
||||||
|
|
||||||
virtual void init(unsigned logicalCodeSize, unsigned parameterFootprint,
|
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 visitLogicalIp(unsigned logicalIp) = 0;
|
||||||
virtual void startLogicalIp(unsigned logicalIp) = 0;
|
virtual void startLogicalIp(unsigned logicalIp) = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user