[m-rev.] for review: fix .maxstack output and update IL instruction set

Tyson Dowd trd at cs.mu.OZ.AU
Wed Jul 4 18:27:08 AEST 2001


On 30-May-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 28-May-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > +:- func get_stack_difference(ilds__instr) = int.
> > +get_stack_difference(end_block(_, _)) 				= 0.
> > +get_stack_difference(comment(_)) 				= 0.
> ...
> 
> A comment explaining the intended meaning of this function would be very
> helpful.
> 
> What are the units that this is measured in?  Bits?  Bytes?  Words? 
> (What's a word in the context?)  Objects?  Stack items?  Something else?

Ok, I've added a comment.  It's in "stack items" (which are variable
sized in terms of bits). 

For the record the runtime seems to use the maxstack number to
allocate JIT structures that describe the stack, such as arrays of types
of the stack variables (not to pre-allocate the stack "size" itself).

> > +	% Remove the params, and remove "this" if it is an instance
> > +	% method, but add the return type (if there is one).
> > +:- func get_methodref_stack_difference(methodref) = int.
> > +get_methodref_stack_difference(MethodRef) = Diff :-
> > +	( 
> > +		MethodRef = methoddef(CallConv, RetType, _, Params) 
> > +	; 
> > +		MethodRef = local_method(CallConv, RetType, _, Params)
> > +	),
> > +	InstanceDiff = ( CallConv = call_conv(yes, _) -> -1 ; 0 ),
> > +	RetDiff = ( RetType = void -> 0 ; 1),
> > +	Diff = -(length(Params)) + InstanceDiff + RetDiff.
> > +
> > +	% Remove the params, and remove "this" if it is an instance
> > +	% method, but add the return type (if there is one).
> > +:- func get_signature_stack_difference(signature) = int.
> > +get_signature_stack_difference(signature(CallConv, RetType, Params)) = Diff :-
> > +	InstanceDiff = ( CallConv = call_conv(yes, _) -> -1 ; 0 ),
> > +	RetDiff = ( RetType = void -> 0 ; 1),
> > +	Diff = -(length(Params)) + InstanceDiff + RetDiff.
> 
> I found this code a bit confusing.  The names and comments of these
> functions are potentially misleading, IMHO.  The functions don't actually
> remove anything, they just return a count of what is added/removed.
> Also, a signature or methodref by itself doesn't add or remove anything;
> this is just counting what is added/removed when a signature or methodref
> is used in a call/calli instruction.
> 
> I think it might help to name the functions get_call_stack_difference
> and get_calli_stack_difference, and to change the comments to say
> "A `call(i)' instruction will ...", to make it clear that the comment
> is about what the call/calli instruction does, not about what the
> get_*_stack_difference function does.

These are good comments, I have done this.

(diff coming when I have network access).

Tyson.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list