- u1 *ra;
- java_objectheader *o;
- u8 mcode;
- unresolved_field *uf;
- fieldinfo *fi;
- s4 offset;
- void *beginJavaStack;
-
- /* get stuff from the stack */
-
- ra = (u1 *) *((ptrint *) (sp + 3 * 8));
- o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
- mcode = *((u8 *) (sp + 1 * 8));
- uf = (unresolved_field *) *((ptrint *) (sp + 0 * 8));
-
- beginJavaStack= (void*)(sp + 3 * 8);
-
- *dontfillinexceptionstacktrace=true;
-
- /* calculate and set the new return address */
-
- ra = ra - 5;
- *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
-
-#if defined(USE_THREADS)
- /* enter a monitor on the patching position */
-
- printf("monitorenter before: %p\n", THREADOBJECT);
- builtin_monitorenter(o);
- printf("monitorenter after : %p\n", THREADOBJECT);
-
- /* check if the position has already been patched */
-
- if (o->vftbl) {
- builtin_monitorexit(o);
-
- return true;
- }
-#endif
-
- /* get the fieldinfo */
-
- if (!(fi = helper_resolve_fieldinfo(uf))) {
- *dontfillinexceptionstacktrace=false;
- return false;
- }
-
- /* check if the field's class is initialized */
-
- *dontfillinexceptionstacktrace=false;
- if (!fi->class->initialized) {
- bool init;
- {
- /*struct native_stackframeinfo {
- void *oldThreadspecificHeadValue;
- void **addressOfThreadspecificHead;
- methodinfo *method;
- void *beginOfJavaStackframe; only used if != 0
- void *returnToFromNative;
- }*/
- /* more or less the same as the above sfi setup is done in the assembler code by the prepare/remove functions*/
- native_stackframeinfo sfi;
- sfi.returnToFromNative=(void*)ra;
- sfi.beginOfJavaStackframe=beginJavaStack;
- sfi.method=0; /*internal*/
- sfi.addressOfThreadspecificHead=builtin_asm_get_stackframeinfo();
- sfi.oldThreadspecificHeadValue=*(sfi.addressOfThreadspecificHead);
- *(sfi.addressOfThreadspecificHead)=&sfi;
-
- init=initialize_class(fi->class);
-
- *(sfi.addressOfThreadspecificHead)=sfi.oldThreadspecificHeadValue;
- }
- if (!init)
- {
- return false;
- }
- }
-
- *dontfillinexceptionstacktrace=false;
-
- /* patch back original code */
-
- *((u8 *) ra) = mcode;
-
- /* if we show disassembly, we have to skip the nop's */
-
- if (showdisassemble)
- ra = ra + 5;
-
- /* get RIP offset from machine instruction */
-
- offset = *((u4 *) (ra + 3));
-
- /* patch the field value's address (+ 7: is the size of the RIP move) */