[Sablevm-developer] Re: SableVM
Brought to you by:
egagnon
From: Prof. E. M. G. <eti...@uq...> - 2003-03-27 18:46:55
|
Hi Christian, I am CC'ing the sablevm-developer ML, as my answer might also help others. Christian ROY wrote: > I'm curious about something. I'm currently using marking to determine > what elements of the stack are reference types. I've come accross a > behavior I'd like to have clarified. Before a method is invoked the object > refrerence is pushed onto the stack and so are the arguments. When the new > method begins it creates it own stack frame and sets its local from > the previous values of the old stack frame. So the object reference is > placed in local[0] and the arguments in local[1] ... to local[n]. How do > you distinguish which of these arguments are references and which are not? There is a bitmap used to indicate which of the "parameter" locals are references. Look at src/libsablevm/types.h: ... struct _svmt_method_info_struct { ... jint java_args_count; /* int,ref,boolean,... = 1; double, long = 2 */ _svmt_gc_map_node *parameters_gc_map; ... This is not sufficient for tracing all locals, as you also have to consider locals which are not parameters. The reference-yet-not-parameter locals are all grouped together, just after the parameter locals. See: ... struct _svmt_method_frame_info_struct { ... /* number of non-parameter reference local variables */ jint non_parameter_ref_locals_count; ... Please look at src/libsablevm/gc_copying.c for an example of how to use them, e.g. /* method formal parameters */ { jint i; jint count = parameters_gc_map->size; for (i = 0; i < count; i++) { if (_svmf_get_bit (parameters_gc_map->bits, i)) { locals[i].reference = _svmf_copy_object (env, locals[i].reference, pto_space_tail); } } } /* other ref locals */ { jint i; jint start = method->java_args_count; jint end = start + non_parameter_ref_locals_count; for (i = start; i < end; i++) { locals[i].reference = _svmf_copy_object (env, locals[i].reference, pto_space_tail); } } I hope this helps. Etienne -- Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/ |