Update non-optimizing compiler for new PowerPC calling convention
parent
1fc02ab69d
commit
6fb134f1aa
|
@ -17,17 +17,15 @@ big-endian on
|
|||
: temp-reg 6 ;
|
||||
: xt-reg 11 ;
|
||||
|
||||
: param-save-size 8 bootstrap-cells ;
|
||||
|
||||
: local@
|
||||
bootstrap-cells reserved-area-size param-save-size + + ;
|
||||
|
||||
: array-save 0 local@ ;
|
||||
: scan-save 1 local@ ;
|
||||
: xt-save 2 local@ ;
|
||||
: factor-area-size 4 bootstrap-cells ;
|
||||
|
||||
: stack-frame
|
||||
3 local@ 4 bootstrap-cells align ;
|
||||
factor-area-size c-area-size + 4 bootstrap-cells align ;
|
||||
|
||||
: next-save stack-frame bootstrap-cell - ;
|
||||
: xt-save stack-frame 2 bootstrap-cells - ;
|
||||
: scan-save stack-frame 3 bootstrap-cells - ;
|
||||
: array-save stack-frame 4 bootstrap-cells - ;
|
||||
|
||||
[
|
||||
temp-reg quot-reg quot-array@ LWZ ! load array
|
||||
|
@ -35,10 +33,12 @@ big-endian on
|
|||
] { } make jit-setup set
|
||||
|
||||
[
|
||||
1 1 stack-frame neg STWU ! store back link
|
||||
0 MFLR ! load return address into r0
|
||||
temp-reg 1 array-save STW ! save array
|
||||
0 MFLR
|
||||
1 1 stack-frame neg ADDI
|
||||
xt-reg 1 xt-save STW ! save XT
|
||||
xt-reg 1 factor-area-size neg ADDI
|
||||
xt-reg 1 next-save STW ! save forward chain pointer
|
||||
temp-reg 1 array-save STW ! save array
|
||||
0 1 lr-save stack-frame + STW ! save return address
|
||||
] { } make jit-prolog set
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: parser layouts system ;
|
||||
IN: bootstrap.ppc
|
||||
|
||||
: reserved-area-size 2 bootstrap-cells ;
|
||||
: c-area-size 10 bootstrap-cells ;
|
||||
: lr-save bootstrap-cell ;
|
||||
|
||||
"resource:core/cpu/ppc/bootstrap.factor" run-file
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: parser layouts system ;
|
||||
IN: bootstrap.ppc
|
||||
|
||||
: reserved-area-size 6 bootstrap-cells ;
|
||||
: c-area-size 14 bootstrap-cells ;
|
||||
: lr-save 2 bootstrap-cells ;
|
||||
|
||||
"resource:core/cpu/ppc/bootstrap.factor" run-file
|
||||
|
|
|
@ -12,15 +12,9 @@ void iterate_callstack(CELL top, CELL bottom, CELL base, CALLSTACK_ITER iterator
|
|||
{
|
||||
CELL delta = (bottom - base);
|
||||
|
||||
#ifdef CALLSTACK_UP_P
|
||||
F_STACK_FRAME *frame = (F_STACK_FRAME *)bottom - 1;
|
||||
#define ITERATING_P (CELL)frame >= top
|
||||
#else
|
||||
F_STACK_FRAME *frame = (F_STACK_FRAME *)top;
|
||||
#define ITERATING_P (CELL)frame < bottom
|
||||
#endif
|
||||
|
||||
while(ITERATING_P)
|
||||
while((CELL)frame >= top)
|
||||
{
|
||||
F_STACK_FRAME *next = REBASE_FRAME_SUCCESSOR(frame,delta);
|
||||
iterator(frame);
|
||||
|
@ -55,7 +49,6 @@ called by continuation implementation, and user code shouldn't
|
|||
be calling it at all, so we leave it as it is for now. */
|
||||
F_STACK_FRAME *capture_start(void)
|
||||
{
|
||||
#ifdef CALLSTACK_UP_P
|
||||
F_STACK_FRAME *frame = stack_chain->callstack_bottom - 1;
|
||||
while(frame >= stack_chain->callstack_top
|
||||
&& FRAME_SUCCESSOR(frame) >= stack_chain->callstack_top)
|
||||
|
@ -63,9 +56,6 @@ F_STACK_FRAME *capture_start(void)
|
|||
frame = FRAME_SUCCESSOR(frame);
|
||||
}
|
||||
return frame + 1;
|
||||
#else
|
||||
return FRAME_SUCCESSOR(stack_chain->callstack_top);
|
||||
#endif
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(callstack)
|
||||
|
@ -152,13 +142,8 @@ CELL frame_scan(F_STACK_FRAME *frame)
|
|||
|
||||
void stack_frame_to_array(F_STACK_FRAME *frame)
|
||||
{
|
||||
#ifdef CALLSTACK_UP_P
|
||||
set_array_nth(array,frame_index++,frame_executing(frame));
|
||||
set_array_nth(array,frame_index++,frame_scan(frame));
|
||||
#else
|
||||
set_array_nth(array,frame_index--,frame_scan(frame));
|
||||
set_array_nth(array,frame_index--,frame_executing(frame));
|
||||
#endif
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(callstack_to_array)
|
||||
|
@ -174,11 +159,7 @@ DEFINE_PRIMITIVE(callstack_to_array)
|
|||
|
||||
/* frame_count is equal to the total length now */
|
||||
|
||||
#ifdef CALLSTACK_UP_P
|
||||
frame_index = 0;
|
||||
#else
|
||||
frame_index = frame_count - 1;
|
||||
#endif
|
||||
|
||||
iterate_callstack_object(stack,stack_frame_to_array);
|
||||
|
||||
|
@ -187,7 +168,6 @@ DEFINE_PRIMITIVE(callstack_to_array)
|
|||
|
||||
F_STACK_FRAME *innermost_stack_frame(F_CALLSTACK *callstack)
|
||||
{
|
||||
#ifdef CALLSTACK_UP_P
|
||||
CELL top = (CELL)(callstack + 1);
|
||||
CELL bottom = top + untag_fixnum_fast(callstack->length);
|
||||
CELL base = callstack->bottom;
|
||||
|
@ -200,9 +180,6 @@ F_STACK_FRAME *innermost_stack_frame(F_CALLSTACK *callstack)
|
|||
frame = REBASE_FRAME_SUCCESSOR(frame,delta);
|
||||
|
||||
return frame;
|
||||
#else
|
||||
return FIRST_STACK_FRAME(callstack);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Some primitives implementing a limited form of callstack mutation.
|
||||
|
@ -244,26 +221,17 @@ DEFINE_PRIMITIVE(set_innermost_stack_frame_quot)
|
|||
|
||||
CELL scan = inner->scan - inner->array;
|
||||
|
||||
#ifdef CALLSTACK_UP_P
|
||||
CELL top = (CELL)(callstack + 1);
|
||||
CELL bottom = top + untag_fixnum_fast(callstack->length);
|
||||
CELL base = callstack->bottom;
|
||||
CELL delta = (bottom - base);
|
||||
|
||||
F_STACK_FRAME *next = REBASE_FRAME_SUCCESSOR(inner,delta);
|
||||
CELL offset = *(XT *)(next + 1) - inner->xt;
|
||||
#else
|
||||
CELL offset = inner->return_address - inner->xt;
|
||||
#endif
|
||||
CELL offset = FRAME_RETURN_ADDRESS(inner,delta) - inner->xt;
|
||||
|
||||
inner->array = quot->array;
|
||||
inner->scan = quot->array + scan;
|
||||
|
||||
inner->xt = quot->xt;
|
||||
|
||||
#ifdef CALLSTACK_UP_P
|
||||
*(XT *)(next + 1) = quot->xt + offset;
|
||||
#else
|
||||
inner->return_address = quot->xt + offset;
|
||||
#endif
|
||||
FRAME_RETURN_ADDRESS(inner,delta) = quot->xt + offset;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ F_FASTCALL void save_callstack_bottom(F_STACK_FRAME *callstack_bottom);
|
|||
|
||||
#define FIRST_STACK_FRAME(stack) (F_STACK_FRAME *)((stack) + 1)
|
||||
|
||||
#define FRAME_SUCCESSOR(frame) (frame)->next
|
||||
#define REBASE_FRAME_SUCCESSOR(frame,delta) (F_STACK_FRAME *)((CELL)FRAME_SUCCESSOR(frame) + delta)
|
||||
|
||||
typedef void (*CALLSTACK_ITER)(F_STACK_FRAME *frame);
|
||||
|
|
|
@ -146,8 +146,6 @@ DEF(void,primitive_execute,(void)):
|
|||
subi r14,r14,4 /* pop word from data stack */
|
||||
bctr /* go */
|
||||
|
||||
#define SCAN_SAVE (RESERVED_SIZE + PARAM_SIZE + 4)
|
||||
|
||||
/* We pass a function pointer to memcpy in r6 to work around a Mac OS X ABI
|
||||
limitation which would otherwise require us to do a bizzaro PC-relative
|
||||
trampoline to retrieve the function address */
|
||||
|
@ -159,8 +157,6 @@ DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, voi
|
|||
blrl /* go */
|
||||
lwz r1,0(r1) /* tear down fake stack frame */
|
||||
lwz r0,LR_SAVE(r1) /* we have restored the stack; load return address */
|
||||
/* load quotation scan pointer */
|
||||
lwz r5,SCAN_SAVE(r1)
|
||||
mtlr r0 /* prepare to return to restored callstack */
|
||||
blr /* go */
|
||||
|
||||
|
|
20
vm/cpu-ppc.h
20
vm/cpu-ppc.h
|
@ -1,3 +1,21 @@
|
|||
typedef struct _F_STACK_FRAME
|
||||
{
|
||||
/* In compiled quotation frames, the quot->array slot.
|
||||
In compiled word frames, unused. */
|
||||
CELL array;
|
||||
|
||||
/* In compiled quotation frames, position within the array.
|
||||
In compiled word frames, unused. */
|
||||
CELL scan;
|
||||
|
||||
/* In all compiled frames, the XT on entry. */
|
||||
XT xt;
|
||||
|
||||
/* Pointer to the next stack frame; frames are chained from
|
||||
the bottom on up */
|
||||
struct _F_STACK_FRAME *next;
|
||||
} F_STACK_FRAME;
|
||||
|
||||
#define FACTOR_CPU_STRING "ppc"
|
||||
#define F_FASTCALL
|
||||
|
||||
|
@ -13,5 +31,3 @@ void set_callstack(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *me
|
|||
void throw_impl(CELL quot, F_STACK_FRAME *rewind);
|
||||
void lazy_jit_compile(CELL quot);
|
||||
void flush_icache(CELL start, CELL len);
|
||||
|
||||
#define FRAME_SUCCESSOR(frame) (frame)->previous
|
||||
|
|
|
@ -16,9 +16,7 @@ typedef struct _F_STACK_FRAME
|
|||
XT xt;
|
||||
} F_STACK_FRAME;
|
||||
|
||||
#define CALLSTACK_UP_P
|
||||
|
||||
#define FRAME_SUCCESSOR(frame) (frame)->next
|
||||
#define FRAME_RETURN_ADDRESS(frame,delta) *(XT *)(REBASE_FRAME_SUCCESSOR(frame,delta) + 1)
|
||||
|
||||
INLINE void flush_icache(CELL start, CELL len) {}
|
||||
|
||||
|
|
|
@ -186,12 +186,7 @@ void fixup_stack_frame(F_STACK_FRAME *frame)
|
|||
frame->scan = scan + frame->array;
|
||||
}
|
||||
|
||||
#ifdef CALLSTACK_UP_P
|
||||
F_STACK_FRAME *next = REBASE_FRAME_SUCCESSOR(frame,delta);
|
||||
code_fixup((XT *)(next + 1));
|
||||
#else
|
||||
code_fixup(&frame->return_address);
|
||||
#endif
|
||||
code_fixup(&FRAME_RETURN_ADDRESS(frame,delta));
|
||||
}
|
||||
|
||||
void fixup_callstack_object(F_CALLSTACK *stack)
|
||||
|
|
|
@ -1,29 +1,4 @@
|
|||
typedef struct _F_STACK_FRAME
|
||||
{
|
||||
struct _F_STACK_FRAME *previous;
|
||||
|
||||
/* Callee stores our LR here */
|
||||
XT return_address;
|
||||
|
||||
/* ===== 32 bytes saved register area ===== */
|
||||
CELL padding5[8];
|
||||
|
||||
/* ===== 16 byte local variable area ===== */
|
||||
|
||||
/* In compiled quotation frames, the quot->array slot.
|
||||
In compiled word frames, unused. */
|
||||
CELL array;
|
||||
|
||||
/* In compiled quotation frames, position within the array.
|
||||
In compiled word frames, unused. */
|
||||
CELL scan;
|
||||
|
||||
/* In all compiled frames, the XT on entry. */
|
||||
XT xt;
|
||||
|
||||
/* ===== 12 byte padding to make it 16 byte aligned ===== */
|
||||
CELL padding6[3];
|
||||
} F_STACK_FRAME;
|
||||
#define FRAME_RETURN_ADDRESS(frame,delta) *((XT *)(REBASE_FRAME_SUCCESSOR(frame,delta) + 1) + 1)
|
||||
|
||||
#define UAP_PROGRAM_COUNTER(ucontext) \
|
||||
(((ucontext_t *)(ucontext))->uc_mcontext.uc_regs->gregs[PT_NIP])
|
||||
|
|
|
@ -1,34 +1,4 @@
|
|||
typedef struct _F_STACK_FRAME {
|
||||
/* ===== 24 bytes reserved ===== */
|
||||
struct _F_STACK_FRAME *previous;
|
||||
|
||||
CELL padding1;
|
||||
|
||||
/* Callee stores our LR here */
|
||||
XT return_address;
|
||||
|
||||
CELL padding2;
|
||||
CELL padding3;
|
||||
CELL padding4;
|
||||
/* ===== 32 bytes saved register area ===== */
|
||||
CELL padding5[8];
|
||||
|
||||
/* ===== 16 byte local variable area ===== */
|
||||
|
||||
/* In compiled quotation frames, the quot->array slot.
|
||||
In compiled word frames, unused. */
|
||||
CELL array;
|
||||
|
||||
/* In compiled quotation frames, position within the array.
|
||||
In compiled word frames, unused. */
|
||||
CELL scan;
|
||||
|
||||
/* In all compiled frames, the XT on entry. */
|
||||
XT xt;
|
||||
|
||||
/* ===== 12 byte padding to make it 16 byte aligned ===== */
|
||||
CELL padding6[3];
|
||||
} F_STACK_FRAME;
|
||||
#define FRAME_RETURN_ADDRESS(frame,delta) *((XT *)(REBASE_FRAME_SUCCESSOR(frame,delta) + 1) + 2)
|
||||
|
||||
#define MACH_EXC_STATE_TYPE ppc_exception_state_t
|
||||
#define MACH_EXC_STATE_FLAVOR PPC_EXCEPTION_STATE
|
||||
|
|
Loading…
Reference in New Issue