At 11:57 AM -0600 4/1/01, Victor B. Putz wrote:
>I'm attempting to port the SmallEiffel Eiffel compiler to the PalmOS
>platform.  Most everything is going well, but the Garbage Collector
>needs a bit of help--I have to write a routine which will look at the
>application stack and processor registers to see if any pointers to
>GC'able objects are located therein.
>
>For other architectures, this procedure consists of:
>
>1) Push the registers onto the stack
>2) Start at the top or bottom of the stack with a pointer to a pointer
>3) Increment (or decrement) the pointer-to-pointer, and send the
>dereferenced contents to a marking function
>4) Marking function determines if the dereferenced pointer points to a
>GC-able object and marks it if that's the case.
>
>How do I do this in the PalmOS platform?  I tried getting the stack
>parameters with SysGetStackInfo, but I'm not sure how to check the
>registers... and since pointers are 32-bit, is stepping through the
>stack with a "pointer to a pointer" really a good idea?  Are stack
>pushes aligned to 16 or 32 bits?
>
>Any help would be, well... helpful.  It's just not right without the
>garbage collector.

Victor,

I don't think that implementing a garbage collections scheme is the 
right thing on a Palm device.  The dynamic heap from which memory 
allocations are performed is just too constrained.  If you have 
filled up the heap, even if it's largely recoverable garbage, there's 
no way for another process (or even the OS) to force a garbage 
collection if it needs some of that space.

As for the specific problems you're facing, I think that the 
SmallEiffel examples provided for the other operating systems should 
be sufficient.  They have (fairly portable) facilities for getting 
the current stack bounds (by taking the addresses of variables on the 
stack), as well as for putting the registers onto the stack (using 
setjmp).  Pointer addresses can be stored on 16-bit boundaries, so 
you need to walk the heap taking that into account.

Fortunately, Eiffel's garbage collection is portable to the extent 
that you don't need to know the Palm OS Memory Manager's data 
structure format.  However, know that some day (I have no idea when) 
I may be modifying Palm OS Emulator to check for accesses to various 
parts of the stack.  Some applications have bugs that cause them to 
overwrite parts of the stack, leading to crashes.  It would be nice 
if the Emulator detected those bugs and reported them as stack 
overwrites, as opposed to a generic crash.  When that facility is 
added, your "walk the stack" algorithm maybe flagged as making 
improper memory accesses.
-- 

-- Keith Rollin
-- Palm OS Emulator engineer

P.S. Check out the new e-mail address.  [EMAIL PROTECTED] will work 
for a while, but anyone mailing me needs to update to the new one 
eventually.

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to