1 /* src/vm/jit/x86_64/patcher.c - x86_64 code patching functions
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
31 $Id: patcher.c 2765 2005-06-21 10:40:28Z twisti $
36 #include "vm/jit/x86_64/types.h"
38 #include "mm/memory.h"
39 #include "native/native.h"
40 #include "vm/builtin.h"
41 #include "vm/exceptions.h"
43 #include "vm/initialize.h"
44 #include "vm/options.h"
45 #include "vm/references.h"
46 #include "vm/jit/helper.h"
47 #include "vm/jit/patcher.h"
50 bool helper_initialize_class(void* beginOfJavaStack,classinfo *c,u1 *ra)
52 if (!c->initialized) {
53 native_stackframeinfo sfi;
56 /* more or less the same as the above sfi setup is done in the assembler code by the prepare/remove functions*/
57 sfi.returnToFromNative = (functionptr) (ptrint) ra;
58 sfi.beginOfJavaStackframe = beginOfJavaStack;
59 sfi.method = NULL; /*internal*/
60 sfi.addressOfThreadspecificHead = builtin_asm_get_stackframeinfo();
61 sfi.oldThreadspecificHeadValue = *(sfi.addressOfThreadspecificHead);
62 *(sfi.addressOfThreadspecificHead) = &sfi;
64 /*printf("calling static initializer (helper_initialize_class), returnaddress=%p for class %s\n",ra,c->name->text);*/
66 init=initialize_class(c);
68 *(sfi.addressOfThreadspecificHead) = sfi.oldThreadspecificHeadValue;
78 /* patcher_get_putstatic *******************************************************
82 <patched call position>
83 4d 8b 15 86 fe ff ff mov -378(%rip),%r10
85 *******************************************************************************/
87 bool patcher_get_putstatic(u1 *sp)
97 /* get stuff from the stack */
99 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
100 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
101 mcode = *((u8 *) (sp + 1 * 8));
102 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 8));
104 beginJavaStack= (void*)(sp + 3 * 8);
106 /* calculate and set the new return address */
109 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
111 PATCHER_MONITORENTER;
113 /* get the fieldinfo */
115 if (!(fi = helper_resolve_fieldinfo(uf))) {
121 /* check if the field's class is initialized */
123 if (!helper_initialize_class(beginJavaStack, fi->class, ra + 5)) {
129 /* patch back original code */
131 *((u8 *) ra) = mcode;
133 /* if we show disassembly, we have to skip the nop's */
138 /* get RIP offset from machine instruction */
140 offset = *((u4 *) (ra + 3));
142 /* patch the field value's address (+ 7: is the size of the RIP move) */
144 *((ptrint *) (ra + 7 + offset)) = (ptrint) &(fi->value);
146 PATCHER_MARK_PATCHED_MONITOREXIT;
152 /* patcher_get_putfield ********************************************************
156 <patched call position>
157 45 8b 8f 00 00 00 00 mov 0x0(%r15),%r9d
159 *******************************************************************************/
161 bool patcher_get_putfield(u1 *sp)
164 java_objectheader *o;
166 unresolved_field *uf;
170 /* get stuff from the stack */
172 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
173 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
174 mcode = *((u8 *) (sp + 1 * 8));
175 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 8));
177 /* calculate and set the new return address */
180 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
182 PATCHER_MONITORENTER;
184 /* get the fieldinfo */
186 if (!(fi = helper_resolve_fieldinfo(uf))) {
192 /* patch back original code */
194 *((u8 *) ra) = mcode;
196 /* if we show disassembly, we have to skip the nop's */
201 /* patch the field's offset: we check for the field type, because the */
202 /* instructions have different lengths */
204 if (IS_INT_LNG_TYPE(fi->type)) {
205 /* check for special case: %rsp or %r12 as base register */
210 *((u4 *) (ra + 4)) = (u4) (fi->offset);
212 *((u4 *) (ra + 3)) = (u4) (fi->offset);
215 /* check for special case: %rsp or %r12 as base register */
220 *((u4 *) (ra + 6)) = (u4) (fi->offset);
222 *((u4 *) (ra + 5)) = (u4) (fi->offset);
225 PATCHER_MARK_PATCHED_MONITOREXIT;
231 /* patcher_putfieldconst *******************************************************
235 <patched call position>
236 49 c7 87 10 00 00 00 00 00 00 00 movq $0x0,0x10(%r15)
238 *******************************************************************************/
240 bool patcher_putfieldconst(u1 *sp)
243 java_objectheader *o;
245 unresolved_field *uf;
248 /* get stuff from the stack */
250 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
251 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
252 mcode = *((u8 *) (sp + 1 * 8));
253 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 8));
255 /* calculate and set the new return address */
258 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
260 PATCHER_MONITORENTER;
262 /* get the fieldinfo */
264 if (!(fi = helper_resolve_fieldinfo(uf))) {
270 /* patch back original code */
272 *((u8 *) ra) = mcode;
274 /* if we show disassembly, we have to skip the nop's */
279 /* patch the field's offset */
281 if (IS_2_WORD_TYPE(fi->type) || IS_ADR_TYPE(fi->type)) {
282 /* handle special case when the base register is %r12 */
284 if (*(ra + 2) == 0x84) {
285 *((u4 *) (ra + 4)) = (u4) (fi->offset);
286 *((u4 *) (ra + 12 + 4)) = (u4) (fi->offset + 4);
289 *((u4 *) (ra + 3)) = (u4) (fi->offset);
290 *((u4 *) (ra + 11 + 3)) = (u4) (fi->offset + 4);
294 /* handle special case when the base register is %r12 */
296 if (*(ra + 2) == 0x84)
297 *((u4 *) (ra + 4)) = (u4) (fi->offset);
299 *((u4 *) (ra + 3)) = (u4) (fi->offset);
302 PATCHER_MARK_PATCHED_MONITOREXIT;
308 /* patcher_builtin_new *********************************************************
312 48 bf a0 f0 92 00 00 00 00 00 mov $0x92f0a0,%rdi
313 <patched call position>
314 48 b8 00 00 00 00 00 00 00 00 mov $0x0,%rax
317 *******************************************************************************/
319 bool patcher_builtin_new(u1 *sp)
322 java_objectheader *o;
324 constant_classref *cr;
326 void *beginJavaStack;
327 /* get stuff from the stack */
329 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
330 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
331 mcode = *((u8 *) (sp + 1 * 8));
332 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
333 beginJavaStack = (void*) (sp+3*8);
335 /* calculate and set the new return address */
338 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
340 PATCHER_MONITORENTER;
342 /* get the classinfo */
344 if (!(c = helper_resolve_classinfo(cr))) {
350 if (!helper_initialize_class(beginJavaStack, c, ra + 5)) {
356 /* patch back original code */
358 *((u8 *) (ra + 10)) = mcode;
360 /* patch the classinfo pointer */
362 *((ptrint *) (ra + 2)) = (ptrint) c;
364 /* if we show disassembly, we have to skip the nop's */
369 /* patch new function address */
371 *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_new;
373 PATCHER_MARK_PATCHED_MONITOREXIT;
379 /* patcher_builtin_newarray ****************************************************
383 48 be 88 13 9b 00 00 00 00 00 mov $0x9b1388,%rsi
384 <patched call position>
385 48 b8 00 00 00 00 00 00 00 00 mov $0x0,%rax
388 *******************************************************************************/
390 bool patcher_builtin_newarray(u1 *sp)
393 java_objectheader *o;
395 constant_classref *cr;
398 /* get stuff from the stack */
400 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
401 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
402 mcode = *((u8 *) (sp + 1 * 8));
403 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
405 /* calculate and set the new return address */
408 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
410 PATCHER_MONITORENTER;
412 /* get the classinfo */
414 if (!(c = helper_resolve_classinfo(cr))) {
420 /* patch back original code */
422 *((u8 *) (ra + 10)) = mcode;
424 /* patch the class' vftbl pointer */
426 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
428 /* if we show disassembly, we have to skip the nop's */
433 /* patch new function address */
435 *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_newarray;
437 PATCHER_MARK_PATCHED_MONITOREXIT;
443 /* patcher_builtin_multianewarray **********************************************
447 <patched call position>
448 48 bf 02 00 00 00 00 00 00 00 mov $0x2,%rdi
449 48 be 30 40 b2 00 00 00 00 00 mov $0xb24030,%rsi
450 48 89 e2 mov %rsp,%rdx
451 48 b8 7c 96 4b 00 00 00 00 00 mov $0x4b967c,%rax
454 *******************************************************************************/
456 bool patcher_builtin_multianewarray(u1 *sp)
459 java_objectheader *o;
461 constant_classref *cr;
464 /* get stuff from the stack */
466 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
467 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
468 mcode = *((u8 *) (sp + 1 * 8));
469 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
471 /* calculate and set the new return address */
474 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
476 PATCHER_MONITORENTER;
478 /* get the classinfo */
480 if (!(c = helper_resolve_classinfo(cr))) {
486 /* patch back original code */
488 *((u8 *) ra) = mcode;
490 /* if we show disassembly, we have to skip the nop's */
495 /* patch the class' vftbl pointer */
497 *((ptrint *) (ra + 10 + 2)) = (ptrint) c->vftbl;
499 /* patch new function address */
501 *((ptrint *) (ra + 10 + 10 + 3 + 2)) = (ptrint) BUILTIN_multianewarray;
503 PATCHER_MARK_PATCHED_MONITOREXIT;
509 /* patcher_builtin_arraycheckcast **********************************************
513 48 be b8 3f b2 00 00 00 00 00 mov $0xb23fb8,%rsi
514 <patched call position>
515 48 b8 00 00 00 00 00 00 00 00 mov $0x0,%rax
518 *******************************************************************************/
520 bool patcher_builtin_arraycheckcast(u1 *sp)
523 java_objectheader *o;
525 constant_classref *cr;
528 /* get stuff from the stack */
530 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
531 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
532 mcode = *((u8 *) (sp + 1 * 8));
533 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
535 /* calculate and set the new return address */
538 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
540 PATCHER_MONITORENTER;
542 /* get the classinfo */
544 if (!(c = helper_resolve_classinfo(cr))) {
550 /* patch back original code */
552 *((u8 *) (ra + 10)) = mcode;
554 /* patch the class' vftbl pointer */
556 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
558 /* if we show disassembly, we have to skip the nop's */
563 /* patch new function address */
565 *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_arraycheckcast;
567 PATCHER_MARK_PATCHED_MONITOREXIT;
573 /* patcher_builtin_arrayinstanceof *********************************************
577 48 be 30 3c b2 00 00 00 00 00 mov $0xb23c30,%rsi
578 <patched call position>
579 48 b8 00 00 00 00 00 00 00 00 mov $0x0,%rax
582 *******************************************************************************/
584 bool patcher_builtin_arrayinstanceof(u1 *sp)
587 java_objectheader *o;
589 constant_classref *cr;
592 /* get stuff from the stack */
594 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
595 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
596 mcode = *((u8 *) (sp + 1 * 8));
597 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
599 /* calculate and set the new return address */
602 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
604 PATCHER_MONITORENTER;
606 /* get the classinfo */
608 if (!(c = helper_resolve_classinfo(cr))) {
614 /* patch back original code */
616 *((u8 *) (ra + 10)) = mcode;
618 /* patch the class' vftbl pointer */
620 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
622 /* if we show disassembly, we have to skip the nop's */
627 /* patch new function address */
629 *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_arrayinstanceof;
631 PATCHER_MARK_PATCHED_MONITOREXIT;
637 /* patcher_invokestatic_special ************************************************
641 *******************************************************************************/
643 bool patcher_invokestatic_special(u1 *sp)
646 java_objectheader *o;
648 unresolved_method *um;
651 /* get stuff from the stack */
653 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
654 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
655 mcode = *((u8 *) (sp + 1 * 8));
656 um = (unresolved_method *) *((ptrint *) (sp + 0 * 8));
658 /* calculate and set the new return address */
661 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
663 PATCHER_MONITORENTER;
665 /* get the fieldinfo */
667 if (!(m = helper_resolve_methodinfo(um))) {
672 /* patch back original code */
674 *((u8 *) ra) = mcode;
676 /* if we show disassembly, we have to skip the nop's */
681 /* patch stubroutine */
683 *((ptrint *) (ra + 2)) = (ptrint) m->stubroutine;
685 PATCHER_MARK_PATCHED_MONITOREXIT;
691 /* patcher_invokevirtual *******************************************************
695 *******************************************************************************/
697 bool patcher_invokevirtual(u1 *sp)
700 java_objectheader *o;
702 unresolved_method *um;
705 /* get stuff from the stack */
707 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
708 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
709 mcode = *((u8 *) (sp + 1 * 8));
710 um = (unresolved_method *) *((ptrint *) (sp + 0 * 8));
712 /* calculate and set the new return address */
715 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
717 PATCHER_MONITORENTER;
719 /* get the fieldinfo */
721 if (!(m = helper_resolve_methodinfo(um))) {
727 /* patch back original code */
729 *((u8 *) ra) = mcode;
731 /* if we show disassembly, we have to skip the nop's */
736 /* patch vftbl index */
738 *((s4 *) (ra + 3 + 3)) = (s4) (OFFSET(vftbl_t, table[0]) +
739 sizeof(methodptr) * m->vftblindex);
741 PATCHER_MARK_PATCHED_MONITOREXIT;
747 /* patcher_invokeinterface *****************************************************
751 *******************************************************************************/
753 bool patcher_invokeinterface(u1 *sp)
756 java_objectheader *o;
758 unresolved_method *um;
761 /* get stuff from the stack */
763 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
764 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
765 mcode = *((u8 *) (sp + 1 * 8));
766 um = (unresolved_method *) *((ptrint *) (sp + 0 * 8));
768 /* calculate and set the new return address */
771 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
773 PATCHER_MONITORENTER;
775 /* get the fieldinfo */
777 if (!(m = helper_resolve_methodinfo(um))) {
783 /* patch back original code */
785 *((u8 *) ra) = mcode;
787 /* if we show disassembly, we have to skip the nop's */
792 /* patch interfacetable index */
794 *((s4 *) (ra + 3 + 3)) = (s4) (OFFSET(vftbl_t, interfacetable[0]) -
795 sizeof(methodptr) * m->class->index);
797 /* patch method offset */
799 *((s4 *) (ra + 3 + 7 + 3)) =
800 (s4) (sizeof(methodptr) * (m - m->class->methods));
802 PATCHER_MARK_PATCHED_MONITOREXIT;
808 /* patcher_checkcast_instanceof_flags ******************************************
812 *******************************************************************************/
814 bool patcher_checkcast_instanceof_flags(u1 *sp)
817 java_objectheader *o;
819 constant_classref *cr;
822 /* get stuff from the stack */
824 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
825 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
826 mcode = *((u8 *) (sp + 1 * 8));
827 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
829 /* calculate and set the new return address */
832 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
834 PATCHER_MONITORENTER;
836 /* get the fieldinfo */
838 if (!(c = helper_resolve_classinfo(cr))) {
844 /* patch back original code */
846 *((u8 *) ra) = mcode;
848 /* if we show disassembly, we have to skip the nop's */
853 /* patch class flags */
855 *((s4 *) (ra + 2)) = (s4) c->flags;
857 PATCHER_MARK_PATCHED_MONITOREXIT;
863 /* patcher_checkcast_instanceof_interface **************************************
867 *******************************************************************************/
869 bool patcher_checkcast_instanceof_interface(u1 *sp)
872 java_objectheader *o;
874 constant_classref *cr;
877 /* get stuff from the stack */
879 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
880 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
881 mcode = *((u8 *) (sp + 1 * 8));
882 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
884 /* calculate and set the new return address */
887 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
889 PATCHER_MONITORENTER;
891 /* get the fieldinfo */
893 if (!(c = helper_resolve_classinfo(cr))) {
899 /* patch back original code */
901 *((u8 *) ra) = mcode;
903 /* if we show disassembly, we have to skip the nop's */
908 /* patch super class index */
910 *((s4 *) (ra + 7 + 3)) = (s4) c->index;
912 *((s4 *) (ra + 7 + 7 + 3 + 6 + 3)) =
913 (s4) (OFFSET(vftbl_t, interfacetable[0]) -
914 c->index * sizeof(methodptr*));
916 PATCHER_MARK_PATCHED_MONITOREXIT;
922 /* patcher_checkcast_class *****************************************************
926 *******************************************************************************/
928 bool patcher_checkcast_class(u1 *sp)
931 java_objectheader *o;
933 constant_classref *cr;
936 /* get stuff from the stack */
938 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
939 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
940 mcode = *((u8 *) (sp + 1 * 8));
941 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
943 /* calculate and set the new return address */
946 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
948 PATCHER_MONITORENTER;
950 /* get the fieldinfo */
952 if (!(c = helper_resolve_classinfo(cr))) {
958 /* patch back original code */
960 *((u8 *) ra) = mcode;
962 /* if we show disassembly, we have to skip the nop's */
967 /* patch super class' vftbl */
969 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
970 *((ptrint *) (ra + 10 + 7 + 7 + 3 + 2)) = (ptrint) c->vftbl;
972 PATCHER_MARK_PATCHED_MONITOREXIT;
978 /* patcher_instanceof_class ****************************************************
982 *******************************************************************************/
984 bool patcher_instanceof_class(u1 *sp)
987 java_objectheader *o;
989 constant_classref *cr;
992 /* get stuff from the stack */
994 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
995 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
996 mcode = *((u8 *) (sp + 1 * 8));
997 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
999 /* calculate and set the new return address */
1002 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
1004 PATCHER_MONITORENTER;
1006 /* get the fieldinfo */
1008 if (!(c = helper_resolve_classinfo(cr))) {
1009 PATCHER_MONITOREXIT;
1014 /* patch back original code */
1016 *((u8 *) ra) = mcode;
1018 /* if we show disassembly, we have to skip the nop's */
1020 if (showdisassemble)
1023 /* patch super class' vftbl */
1025 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
1027 PATCHER_MARK_PATCHED_MONITOREXIT;
1033 /* patcher_clinit **************************************************************
1037 *******************************************************************************/
1039 bool patcher_clinit(u1 *sp)
1042 java_objectheader *o;
1045 void *beginJavaStack;
1047 /* get stuff from the stack */
1049 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
1050 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
1051 mcode = *((u8 *) (sp + 1 * 8));
1052 c = (classinfo *) *((ptrint *) (sp + 0 * 8));
1054 beginJavaStack = (void*) (sp + 3 * 8);
1056 /* calculate and set the new return address */
1059 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
1061 PATCHER_MONITORENTER;
1063 /* check if the class is initialized */
1065 if (!helper_initialize_class(beginJavaStack, c, ra + 5)) {
1066 PATCHER_MONITOREXIT;
1071 /* patch back original code */
1073 *((u8 *) ra) = mcode;
1075 PATCHER_MARK_PATCHED_MONITOREXIT;
1081 /* patcher_resolve_native ******************************************************
1085 *******************************************************************************/
1087 bool patcher_resolve_native(u1 *sp)
1090 java_objectheader *o;
1094 void *beginJavaStack;
1096 /* get stuff from the stack */
1098 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
1099 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
1100 mcode = *((u8 *) (sp + 1 * 8));
1101 m = (methodinfo *) *((ptrint *) (sp + 0 * 8));
1103 beginJavaStack = (void*) (sp + 3 * 8);
1105 /* calculate and set the new return address */
1108 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
1110 PATCHER_MONITORENTER;
1112 /* resolve native function */
1114 if (!(f = native_resolve_function(m))) {
1115 PATCHER_MONITOREXIT;
1120 /* patch back original code */
1122 *((u8 *) ra) = mcode;
1124 /* if we show disassembly, we have to skip the nop's */
1126 if (showdisassemble)
1129 /* patch native function pointer */
1131 *((ptrint *) (ra + 2)) = (ptrint) f;
1133 PATCHER_MARK_PATCHED_MONITOREXIT;
1140 * These are local overrides for various environment variables in Emacs.
1141 * Please do not remove this and leave it at the end of the file, where
1142 * Emacs will automagically detect them.
1143 * ---------------------------------------------------------------------
1146 * indent-tabs-mode: t
1150 * vim:noexpandtab:sw=4:ts=4: