I would ignore the thread initialization as that's special case stuff... Just focus on when a thread is running.
After you take a look at the doc I sent you (specifically read the stuff about registers first, then register windows, then stacks, and then trap handling), create some small function calls in C, then disassemble them and study the code the compiler produces. Play around with the number of args and local variables and see what it does for the values! The stuff you're asking about isn't trivial or obvious. I'll add a little more, with the save instruction (which is really just an add with a register window move), the negative value which is added (i.e. negative because it's an add and the stack grows down in memory from high to low), hence we want the resulting stack pointer to be smaller, is based on the size of a register frame + the space for the local variables (+ a bit of padding). This is compiled in because the compiler knows how many local variables there are (and the size of the register frame). Anyway, keep firing with the questions. Cheers, Greg Brian Xu - Sun Microsystems - Beijing China wrote: > max at bruningsystems.com ??: >> Brian Xu - Sun Microsystems - Beijing China wrote: >> >>> Greg Price ??: >>> >>>> >>> I still have the question that who produces those 'bias area' and when? >>> >>> >>> >> When the stack pointer is initialized for a thread when the thread is >> created, >> the bias is subtracted to get an initial stack pointer value. Again, >> see the code >> in thread_load() which is (at least) one place where the stack >> pointer is initialized. >> > I saw the code you referred. It is only about the thread init. then > how about the following calls in the thread? >>> It is obvious that before or just after the 'save' instruction, the >>> %sp has been moved to the bottom of the bias. so it must be the >>> 'call' or the 'save' instruction that does it. I want to know. >>> >>> >> No. The save instruction doesn't need to do anything with the stack >> pointer as far as the >> bias is concerned. The bias is already "in" the stack pointer when >> the save is executed. >> The call also does not need to do anything with the stack pointer. >> It is only when code >> needs to access/store data on the stack, and when the thread is >> initialized, that the >> bias value needs to be used. >> > I think it is only the case for the first call in the thread. For the > following calls, there must somewhere that implicitly modify the %sp. > > Thanks, > Brian >> max >> >> _______________________________________________ >> mdb-discuss mailing list >> mdb-discuss at opensolaris.org >> >