[Sablevm-developer] types of stack frames
Brought to you by:
egagnon
From: Chris P. <chr...@ma...> - 2004-04-01 21:53:24
|
Hi Etienne (and possibly David or Greg, but not sure), Can you please write about the types of stack frames / methods that might be on the stack in SableVM, and when they are pushed and popped? For one, I would like to know about pushing and popping native methods. I wrote a simple function to count Java stack frames, but it gives me more frames than those that are pushed directly with (PREPARE_)INVOKE<X> (as calculated by a more indirect method). I assume it's because some Java frames are pushed without (PREPARE_)INVOKE<X>. I would really like to know if it's possible to count frames pushed only with (PREPARE_)INVOKE<X> by simply looking at the stack, or whether I have to go in and increment a counter on every push and keep track of pops explicitly (which gets a little complicated because of exceptions). I would like to do this so that I can make some basic assertions about post-execution system properties of programs running with spmt. I'll take whatever you write and incorporate it into David's "stack_layout.txt" document. Thanks very much, Chris ======================================================================== inline static size_t _svmf_count_java_stack_frames (_svmt_JNIEnv *env) { _svmt_stack_frame *frame = env->stack.current_frame; _svmt_method_info *method = frame->method; jint count = 0; while (method != &env->vm->stack_bottom_method) { if (_svmf_is_set_flag (method->access_flags, SVM_ACC_INTERNAL) == JNI_FALSE && _svmf_is_set_flag (method->access_flags, SVM_ACC_NATIVE) == JNI_FALSE) { count++; } frame = (_svmt_stack_frame *) (((char *) frame) - frame->previous_offset); method = frame->method; } return count; } |