mirror of
https://github.com/corda/corda.git
synced 2025-02-02 09:18:13 +00:00
avoid unecessary mov instructions
This commit is contained in:
parent
11dea0ad8e
commit
0fe748c3a1
@ -641,6 +641,20 @@ syncStack(Context* c, Stack* start, unsigned count)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
syncStack(Context* c, Stack* start)
|
||||||
|
{
|
||||||
|
unsigned count = 0;
|
||||||
|
for (Stack* s = start;
|
||||||
|
s and s->operand->value->stackPosition(c) == 0;
|
||||||
|
s = s->next)
|
||||||
|
{
|
||||||
|
++ count;
|
||||||
|
}
|
||||||
|
|
||||||
|
syncStack(c, start, count);
|
||||||
|
}
|
||||||
|
|
||||||
class SyncStackEvent: public Event {
|
class SyncStackEvent: public Event {
|
||||||
public:
|
public:
|
||||||
SyncStackEvent(Context* c):
|
SyncStackEvent(Context* c):
|
||||||
@ -667,15 +681,7 @@ class SyncStackEvent: public Event {
|
|||||||
virtual void compile(Context* c) {
|
virtual void compile(Context* c) {
|
||||||
fprintf(stderr, "SyncEvent.compile\n");
|
fprintf(stderr, "SyncEvent.compile\n");
|
||||||
|
|
||||||
unsigned count = 0;
|
syncStack(c, stack);
|
||||||
for (Stack* s = stack;
|
|
||||||
s and s->operand->value->stackPosition(c) == 0;
|
|
||||||
s = s->next)
|
|
||||||
{
|
|
||||||
++ count;
|
|
||||||
}
|
|
||||||
|
|
||||||
syncStack(c, stack, count);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -814,11 +820,20 @@ class MoveEvent: public Event {
|
|||||||
if (src->target == 0) src->target = target(c, src);
|
if (src->target == 0) src->target = target(c, src);
|
||||||
|
|
||||||
if (src->target == 0) {
|
if (src->target == 0) {
|
||||||
|
if (type == Move
|
||||||
|
and size == BytesPerWord
|
||||||
|
and dst->event == next)
|
||||||
|
{
|
||||||
|
dst->value = src->value;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
src->target = freeRegister(c, size);
|
src->target = freeRegister(c, size);
|
||||||
|
}
|
||||||
} else if (type == Move
|
} else if (type == Move
|
||||||
and size == BytesPerWord
|
and size == BytesPerWord
|
||||||
and src->target->equals(c, src->value))
|
and src->target->equals(c, src->value))
|
||||||
{
|
{
|
||||||
|
dst->value = src->value;
|
||||||
return;
|
return;
|
||||||
} else if (src->value->type(c) == Memory
|
} else if (src->value->type(c) == Memory
|
||||||
and src->target->type(c) == Memory)
|
and src->target->type(c) == Memory)
|
||||||
@ -870,6 +885,10 @@ class DupEvent: public Event {
|
|||||||
if (target == 0) {
|
if (target == 0) {
|
||||||
if (dst->event) {
|
if (dst->event) {
|
||||||
target = dst->event->target(c, dst);
|
target = dst->event->target(c, dst);
|
||||||
|
if (target == 0 and dst->event == next) {
|
||||||
|
dst->value = src->value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (target == 0) {
|
if (target == 0) {
|
||||||
target = freeRegister(c, size);
|
target = freeRegister(c, size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user