remove unused CallEvent::argumentStack variable, prepare to remove stack manipulation from NativeCallingConvention calls

This commit is contained in:
Joshua Warner 2014-05-01 20:27:45 -06:00 committed by Joshua Warner
parent d2e9911161
commit fe2962830c
3 changed files with 52 additions and 49 deletions

View File

@ -2482,14 +2482,6 @@ class MyCompiler: public Compiler {
va_end(a); va_end(a);
Stack* argumentStack = c.stack;
for (int i = index - 1; i >= 0; --i) {
argumentStack = compiler::stack(
&c,
static_cast<Value*>(RUNTIME_ARRAY_BODY(arguments)[i]),
argumentStack);
}
Value* result = value(&c, resultType); Value* result = value(&c, resultType);
appendCall(&c, appendCall(&c,
static_cast<Value*>(address), static_cast<Value*>(address),
@ -2498,7 +2490,6 @@ class MyCompiler: public Compiler {
traceHandler, traceHandler,
result, result,
resultType.size(), resultType.size(),
argumentStack,
util::Slice<ir::Value*>(RUNTIME_ARRAY_BODY(arguments), index)); util::Slice<ir::Value*>(RUNTIME_ARRAY_BODY(arguments), index));
return result; return result;
@ -2518,7 +2509,6 @@ class MyCompiler: public Compiler {
traceHandler, traceHandler,
result, result,
resultType.size(), resultType.size(),
c.stack,
arguments); arguments);
return result; return result;
} }

View File

@ -221,20 +221,27 @@ struct FixedSliceStack : public SliceStack<T> {
} }
}; };
Value* pushWordSlice(Context* c, Value* v, SliceStack<ir::Value*>& slice) Value* pushWordSlice(Context* c,
Value* v,
size_t stackBase UNUSED,
SliceStack<ir::Value*>& slice)
{ {
if (v) { if (v) {
v = maybeBuddySlice(c, v); v = maybeBuddySlice(c, v);
} }
size_t index UNUSED = slice.count;
Stack* s = stack(c, v, c->stack); Stack* s = stack(c, v, c->stack);
assert(c, index > 0); assert(c, slice.count < slice.capacity);
slice.push(v); slice.push(v);
// if (DebugFrame) { // if (DebugFrame) {
// fprintf(stderr, "push %p\n", v); // fprintf(stderr, "push %p\n", v);
// } // }
assert(c, s->index == index + stackBase);
if (v) { if (v) {
v->home = frameIndex(c, s->index + c->localFootprint); v->home = frameIndex(c, s->index + c->localFootprint);
} }
@ -246,6 +253,7 @@ Value* pushWordSlice(Context* c, Value* v, SliceStack<ir::Value*>& slice)
void pushSlice(Context* c, void pushSlice(Context* c,
unsigned footprint, unsigned footprint,
Value* v, Value* v,
size_t stackBase,
SliceStack<ir::Value*>& slice) SliceStack<ir::Value*>& slice)
{ {
assert(c, footprint); assert(c, footprint);
@ -255,7 +263,7 @@ void pushSlice(Context* c,
Value* low = v; Value* low = v;
if (bigEndian) { if (bigEndian) {
v = pushWordSlice(c, v, slice); v = pushWordSlice(c, v, stackBase, slice);
} }
Value* high; Value* high;
@ -264,16 +272,16 @@ void pushSlice(Context* c,
if (vm::TargetBytesPerWord == 4) { if (vm::TargetBytesPerWord == 4) {
low->maybeSplit(c); low->maybeSplit(c);
high = pushWordSlice(c, low->nextWord, slice); high = pushWordSlice(c, low->nextWord, stackBase, slice);
} else { } else {
high = pushWordSlice(c, 0, slice); high = pushWordSlice(c, 0, stackBase, slice);
} }
} else { } else {
high = 0; high = 0;
} }
if (not bigEndian) { if (not bigEndian) {
v = pushWordSlice(c, v, slice); v = pushWordSlice(c, v, stackBase, slice);
} }
if (high) { if (high) {
@ -292,7 +300,6 @@ class CallEvent: public Event {
TraceHandler* traceHandler, TraceHandler* traceHandler,
Value* result, Value* result,
unsigned resultSize, unsigned resultSize,
Stack* argumentStack,
util::Slice<ir::Value*> arguments) util::Slice<ir::Value*> arguments)
: Event(c), : Event(c),
address(address), address(address),
@ -314,18 +321,15 @@ class CallEvent: public Event {
assert(c, (flags & Compiler::TailJump) == 0); assert(c, (flags & Compiler::TailJump) == 0);
assert(c, stackArgumentFootprint == 0); assert(c, stackArgumentFootprint == 0);
Stack* s = argumentStack;
unsigned index = 0; unsigned index = 0;
unsigned argumentIndex = 0; unsigned argumentIndex = 0;
while (true) { while (true) {
assert(c, arguments[index] == s->value); Value* v = static_cast<Value*>(arguments[index]);
assert(c,
argumentIndex + 1 >= arguments.count || arguments[index + 1]
== s->next->value);
unsigned footprint unsigned footprint
= (argumentIndex + 1 < arguments.count and s->value->nextWord = (argumentIndex + 1 < arguments.count and v->nextWord
== s->next->value) == arguments[index + 1])
? 2 ? 2
: 1; : 1;
@ -338,9 +342,9 @@ class CallEvent: public Event {
<= c->arch->argumentRegisterCount()) <= c->arch->argumentRegisterCount())
{ {
int number = c->arch->argumentRegister(index); int number = c->arch->argumentRegister(index);
if (DebugReads) { if (DebugReads) {
fprintf(stderr, "reg %d arg read %p\n", number, s->value); fprintf(stderr, "reg %d arg read %p\n", number, v);
} }
targetMask = SiteMask::fixedRegisterMask(number); targetMask = SiteMask::fixedRegisterMask(number);
@ -353,19 +357,17 @@ class CallEvent: public Event {
unsigned frameIndex = index - c->arch->argumentRegisterCount(); unsigned frameIndex = index - c->arch->argumentRegisterCount();
if (DebugReads) { if (DebugReads) {
fprintf(stderr, "stack %d arg read %p\n", frameIndex, s->value); fprintf(stderr, "stack %d arg read %p\n", frameIndex, v);
} }
targetMask = SiteMask(1 << lir::MemoryOperand, 0, frameIndex); targetMask = SiteMask(1 << lir::MemoryOperand, 0, frameIndex);
} }
this->addRead(c, s->value, targetMask); this->addRead(c, v, targetMask);
++ index; ++ index;
if ((++argumentIndex) < arguments.count) { if ((++argumentIndex) >= arguments.count) {
s = s->next;
} else {
break; break;
} }
} }
@ -390,6 +392,7 @@ class CallEvent: public Event {
Stack* stack = stackBefore; Stack* stack = stackBefore;
if (callingConvention == ir::AvianCallingConvention) { if (callingConvention == ir::AvianCallingConvention) {
// assert(c, argumentStack = )
for (int i = stackArgumentFootprint - 1; i >= 0; --i) { for (int i = stackArgumentFootprint - 1; i >= 0; --i) {
Value* v = static_cast<Value*>(arguments[i]); Value* v = static_cast<Value*>(arguments[i]);
stack = stack->next; stack = stack->next;
@ -611,7 +614,6 @@ void appendCall(Context* c,
TraceHandler* traceHandler, TraceHandler* traceHandler,
Value* result, Value* result,
unsigned resultSize, unsigned resultSize,
Stack* argumentStack,
util::Slice<ir::Value*> arguments) util::Slice<ir::Value*> arguments)
{ {
append(c, append(c,
@ -622,7 +624,6 @@ void appendCall(Context* c,
traceHandler, traceHandler,
result, result,
resultSize, resultSize,
argumentStack,
arguments)); arguments));
} }
@ -1036,6 +1037,7 @@ appendCombine(Context* c, lir::TernaryOperation type,
if (thunk) { if (thunk) {
FixedSliceStack<ir::Value*, 6> slice; FixedSliceStack<ir::Value*, 6> slice;
Stack* oldStack = c->stack; Stack* oldStack = c->stack;
size_t stackBase = c->stack ? c->stack->index + 1 : 0;
bool threadParameter; bool threadParameter;
intptr_t handler = c->client->getThunk intptr_t handler = c->client->getThunk
@ -1047,17 +1049,21 @@ appendCombine(Context* c, lir::TernaryOperation type,
pushSlice(c, pushSlice(c,
ceilingDivide(secondSize, vm::TargetBytesPerWord), ceilingDivide(secondSize, vm::TargetBytesPerWord),
secondValue, secondValue,
stackBase,
slice);
pushSlice(c,
ceilingDivide(firstSize, vm::TargetBytesPerWord),
firstValue,
stackBase,
slice); slice);
pushSlice(
c, ceilingDivide(firstSize, vm::TargetBytesPerWord), firstValue, slice);
if (threadParameter) { if (threadParameter) {
++ stackSize; ++ stackSize;
pushSlice(c, 1, threadRegister(c), slice); pushSlice(c, 1, threadRegister(c), stackBase, slice);
} }
Stack* argumentStack = c->stack; // assert(c, c->stack == oldStack);
c->stack = oldStack; c->stack = oldStack;
appendCall(c, appendCall(c,
@ -1069,7 +1075,6 @@ appendCombine(Context* c, lir::TernaryOperation type,
0, 0,
resultValue, resultValue,
resultSize, resultSize,
argumentStack,
slice); slice);
} else { } else {
append append
@ -1176,12 +1181,16 @@ appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize,
if (thunk) { if (thunk) {
Stack* oldStack = c->stack; Stack* oldStack = c->stack;
size_t stackBase = c->stack ? c->stack->index + 1 : 0;
FixedSliceStack<ir::Value*, 2> slice; FixedSliceStack<ir::Value*, 2> slice;
pushSlice( pushSlice(c,
c, ceilingDivide(firstSize, vm::TargetBytesPerWord), firstValue, slice); ceilingDivide(firstSize, vm::TargetBytesPerWord),
firstValue,
stackBase,
slice);
Stack* argumentStack = c->stack; // assert(c, c->stack == oldStack);
c->stack = oldStack; c->stack = oldStack;
appendCall(c, appendCall(c,
@ -1194,7 +1203,6 @@ appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize,
0, 0,
resultValue, resultValue,
resultSize, resultSize,
argumentStack,
slice); slice);
} else { } else {
append(c, new(c->zone) append(c, new(c->zone)
@ -1536,6 +1544,7 @@ appendBranch(Context* c, lir::TernaryOperation type, unsigned size, Value* first
if (thunk) { if (thunk) {
FixedSliceStack<ir::Value*, 4> slice; FixedSliceStack<ir::Value*, 4> slice;
Stack* oldStack = c->stack; Stack* oldStack = c->stack;
size_t stackBase = c->stack ? c->stack->index + 1 : 0;
bool threadParameter; bool threadParameter;
intptr_t handler = c->client->getThunk intptr_t handler = c->client->getThunk
@ -1543,12 +1552,18 @@ appendBranch(Context* c, lir::TernaryOperation type, unsigned size, Value* first
assert(c, not threadParameter); assert(c, not threadParameter);
pushSlice( pushSlice(c,
c, ceilingDivide(size, vm::TargetBytesPerWord), secondValue, slice); ceilingDivide(size, vm::TargetBytesPerWord),
pushSlice( secondValue,
c, ceilingDivide(size, vm::TargetBytesPerWord), firstValue, slice); stackBase,
slice);
pushSlice(c,
ceilingDivide(size, vm::TargetBytesPerWord),
firstValue,
stackBase,
slice);
Stack* argumentStack = c->stack; // assert(c, c->stack == oldStack);
c->stack = oldStack; c->stack = oldStack;
Value* result Value* result
@ -1562,7 +1577,6 @@ appendBranch(Context* c, lir::TernaryOperation type, unsigned size, Value* first
0, 0,
result, result,
4, 4,
argumentStack,
slice); slice);
appendBranch(c, appendBranch(c,

View File

@ -120,7 +120,6 @@ void appendCall(Context* c,
TraceHandler* traceHandler, TraceHandler* traceHandler,
Value* result, Value* result,
unsigned resultSize, unsigned resultSize,
Stack* argumentStack,
util::Slice<ir::Value*> arguments); util::Slice<ir::Value*> arguments);
void void