- u1 *ra;
- java_objectheader *o;
- u8 mcode;
- unresolved_field *uf;
- s4 disp;
- fieldinfo *fi;
- s4 offset;
-
- /* get stuff from the stack */
-
- ra = (u1 *) *((ptrint *) (sp + 4 * 8));
- o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
- mcode = *((u8 *) (sp + 2 * 8));
- uf = (unresolved_field *) *((ptrint *) (sp + 1 * 8));
- disp = *((s4 *) (sp + 0 * 8));
-
- /* calculate and set the new return address */
-
- ra = ra - 5;
- *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
- PATCHER_MONITORENTER;
-
- /* get the fieldinfo */
-
- if (!(fi = resolve_field_eager(uf))) {
- PATCHER_MONITOREXIT;
-
- return false;
- }
-
- /* check if the field's class is initialized */
-
- if (!(fi->class->state & CLASS_INITIALIZED)) {
- if (!initialize_class(fi->class)) {
- PATCHER_MONITOREXIT;
-
- return false;
- }
- }
-
- /* patch back original code */
-
- *((u8 *) ra) = mcode;
-
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_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) */
-
- *((ptrint *) (ra + 7 + offset)) = (ptrint) &(fi->value);
-
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
- return true;