Re: Porting to Darwin
Brian de Alwis <[email protected]> Mon, 16 Jun 2008 22:35:31 -0700 (PDT)
| Newsgroups | gmane.comp.lang.smalltalk.strongtalk |
|---|---|
| Message-ID | <b5482cb7-2fba-442a-80b3-6921fd7f97df@k30g2000hse.googlegroups.com> |
I'm only able to work on this in spurts, which makes for rather slow
going. Hyungyip Kim is right: according to the apple docs and other
webpages I've found, the 16-byte stack alignment is necessary for SSE.
What I've done right now is hack MacroAssembler::call_C to align the
stack before the call like the following:
void MacroAssembler::call_C(Register entry) {
set_last_Delta_frame_before_call();
- call(entry);
+#ifdef ALIGN_STACK
+ // align stack to N-byte boundary; assumes esp grows down
+ // which is true on intel. Assumes ebx is preserved across
+ // the call
+ pushl(ebx);
+ movl(ebx,esp); // remember unaligned esp
+ subl(esp,4); // add space for unaligned esp
+ andl(esp, -ALIGN_STACK); // with the subl, we have at least 4 bytes
avail
+ addl(esp,4);
+ pushl(ebx);
+ call(entry);
+ popl(ebx);
+ movl(esp,ebx); // restore stack pointer prior to alignment
+ popl(ebx);
+#else
+ call(entry);
+#endif
reset_last_Delta_frame();
}
This allows execution to progress a bit further, but the VM crashes as
the program counter (PC) obtained from the last_frame (that is
frame::_pc) of the delta process is out of range. This frame is being
spoofed up from the following constructor (vm/runtime/frame.hpp lines
72--76):
frame(oop* sp, int* fp) {
_sp = sp;
_fp = fp;
_pc = (char*) sp[-1];
}
That last line is returning a pointer with address 0x89, which I
suspect indicates that the stack layout assumed of the delta processes
is different from the reality.
(gdb) down
#0 frame::frame (this=0xb0102da4, sp=0xb0102e60, fp=0xb0102e6c) at
frame.hpp:76
76 _pc = (char*) sp[-1];
(gdb) p sp[-1]
$7 = (oopDesc *) 0x89
(gdb) p sp[0]
$8 = (oopDesc *) 0x10a1b29
Those sp and fp values don't match the values I see for the frames in
gdb though.
I need to figure out more about the delta processes and what they're
recording on the stack.
Brian.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Strongtalk-general" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/strongtalk-general?hl=en
-~----------~----~----~----~------~----~------~--~---