1 /* src/vm/jit/powerpc/patcher.c - PowerPC 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 2683 2005-06-14 17:20:56Z twisti $
36 #include "vm/jit/powerpc/types.h"
38 #include "mm/memory.h"
39 #include "native/native.h"
40 #include "vm/builtin.h"
42 #include "vm/initialize.h"
43 #include "vm/options.h"
44 #include "vm/references.h"
45 #include "vm/jit/asmpart.h"
46 #include "vm/jit/helper.h"
47 #include "vm/jit/patcher.h"
50 /* patcher_get_putstatic *******************************************************
54 <patched call position>
55 816dffc8 lwz r11,-56(r13)
56 80ab0000 lwz r5,0(r11)
58 *******************************************************************************/
60 bool patcher_get_putstatic(u1 *sp)
70 /* get stuff from the stack */
72 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
73 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
74 mcode = *((u4 *) (sp + 1 * 4));
75 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 4));
76 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
78 /* calculate and set the new return address */
81 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
85 /* get the fieldinfo */
87 if (!(fi = helper_resolve_fieldinfo(uf))) {
93 /* check if the field's class is initialized */
95 if (!fi->class->initialized) {
96 if (!initialize_class(fi->class)) {
103 /* patch back original code */
105 *((u4 *) ra) = mcode;
107 /* if we show disassembly, we have to skip the nop */
112 /* get the offset from machine instruction */
114 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
116 /* patch the field value's address */
118 *((ptrint *) (pv + offset)) = (ptrint) &(fi->value);
120 /* synchronize instruction cache */
122 asm_cacheflush(ra, 4);
124 PATCHER_MARK_PATCHED_MONITOREXIT;
130 /* patcher_get_putfield ********************************************************
134 <patched call position>
135 811f0014 lwz r8,20(r31)
137 *******************************************************************************/
139 bool patcher_get_putfield(u1 *sp)
142 java_objectheader *o;
144 unresolved_field *uf;
148 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
149 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
150 mcode = *((u4 *) (sp + 1 * 4));
151 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 4));
152 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
154 /* calculate and set the new return address */
157 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
159 PATCHER_MONITORENTER;
161 /* get the fieldinfo */
163 if (!(fi = helper_resolve_fieldinfo(uf))) {
169 /* patch back original code */
171 *((u4 *) ra) = mcode;
173 /* if we show disassembly, we have to skip the nop */
178 /* patch the field's offset */
180 *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff);
182 /* if the field has type long, we need to patch the second move too */
184 if (fi->type == TYPE_LNG)
185 *((u4 *) (ra + 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
187 /* synchronize instruction cache */
189 asm_cacheflush(ra, 8);
191 PATCHER_MARK_PATCHED_MONITOREXIT;
197 /* patcher_builtin_new *********************************************************
201 806dffc4 lwz r3,-60(r13)
202 <patched call postition>
203 81adffc0 lwz r13,-64(r13)
207 *******************************************************************************/
209 bool patcher_builtin_new(u1 *sp)
212 java_objectheader *o;
214 constant_classref *cr;
219 /* get stuff from the stack */
221 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
222 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
223 mcode = *((u4 *) (sp + 1 * 4));
224 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
225 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
227 /* calculate and set the new return address */
230 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
232 PATCHER_MONITORENTER;
234 /* get the classinfo */
236 if (!(c = helper_resolve_classinfo(cr))) {
242 /* patch back original code */
244 *((u4 *) (ra + 4)) = mcode;
246 /* get the offset from machine instruction */
248 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
250 /* patch the classinfo pointer */
252 *((ptrint *) (pv + offset)) = (ptrint) c;
254 /* if we show disassembly, we have to skip the nop */
259 /* get the offset from machine instruction */
261 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
263 /* patch new function address */
265 *((ptrint *) (pv + offset)) = (ptrint) BUILTIN_new;
267 /* synchronize instruction cache */
269 asm_cacheflush(ra + 4, 4);
271 PATCHER_MARK_PATCHED_MONITOREXIT;
277 /* patcher_builtin_newarray ****************************************************
281 808dffc8 lwz r4,-56(r13)
282 <patched call position>
283 81adffc4 lwz r13,-60(r13)
287 *******************************************************************************/
289 bool patcher_builtin_newarray(u1 *sp)
292 java_objectheader *o;
294 constant_classref *cr;
299 /* get stuff from the stack */
301 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
302 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
303 mcode = *((u4 *) (sp + 1 * 4));
304 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
305 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
307 /* calculate and set the new return address */
310 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
312 PATCHER_MONITORENTER;
314 /* get the classinfo */
316 if (!(c = helper_resolve_classinfo(cr))) {
322 /* patch back original code */
324 *((u4 *) (ra + 4)) = mcode;
326 /* get the offset from machine instruction */
328 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
330 /* patch the class' vftbl pointer */
332 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
334 /* if we show disassembly, we have to skip the nop */
339 /* get the offset from machine instruction */
341 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
343 /* patch new function address */
345 *((ptrint *) (pv + offset)) = (ptrint) BUILTIN_newarray;
347 /* synchronize instruction cache */
349 asm_cacheflush(ra, 4);
351 PATCHER_MARK_PATCHED_MONITOREXIT;
357 /* patcher_builtin_multianewarray **********************************************
361 <patched call position>
363 808dffc0 lwz r4,-64(r13)
364 38a10038 addi r5,r1,56
365 81adffbc lwz r13,-68(r13)
369 *******************************************************************************/
371 bool patcher_builtin_multianewarray(u1 *sp)
374 java_objectheader *o;
376 constant_classref *cr;
381 /* get stuff from the stack */
383 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
384 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
385 mcode = *((u4 *) (sp + 1 * 4));
386 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
387 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
389 /* calculate and set the new return address */
392 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
394 PATCHER_MONITORENTER;
396 /* get the classinfo */
398 if (!(c = helper_resolve_classinfo(cr))) {
404 /* patch back original code */
406 *((u4 *) ra) = mcode;
408 /* if we show disassembly, we have to skip the nop */
413 /* get the offset from machine instruction */
415 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
417 /* patch the class' vftbl pointer */
419 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
421 /* synchronize instruction cache */
423 asm_cacheflush(ra, 4);
425 PATCHER_MARK_PATCHED_MONITOREXIT;
431 /* patcher_builtin_arraycheckcast **********************************************
435 808dffd8 lwz r4,-40(r13)
436 <patched call position>
437 81adffd4 lwz r13,-44(r13)
441 *******************************************************************************/
443 bool patcher_builtin_arraycheckcast(u1 *sp)
446 java_objectheader *o;
448 constant_classref *cr;
453 /* get stuff from the stack */
455 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
456 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
457 mcode = *((u4 *) (sp + 1 * 4));
458 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
459 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
461 /* calculate and set the new return address */
464 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
466 PATCHER_MONITORENTER;
468 /* get the classinfo */
470 if (!(c = helper_resolve_classinfo(cr))) {
476 /* patch back original code */
478 *((u4 *) (ra + 4)) = mcode;
480 /* get the offset from machine instruction */
482 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
484 /* patch the class' vftbl pointer */
486 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
488 /* if we show disassembly, we have to skip the nop */
493 /* get the offset from machine instruction */
495 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
497 /* patch new function address */
499 *((ptrint *) (pv + offset)) = (ptrint) BUILTIN_arraycheckcast;
501 /* synchronize instruction cache */
503 asm_cacheflush(ra + 4, 4);
505 PATCHER_MARK_PATCHED_MONITOREXIT;
511 /* patcher_builtin_arrayinstanceof *********************************************
515 808dff50 lwz r4,-176(r13)
516 <patched call position>
517 81adff4c lwz r13,-180(r13)
521 *******************************************************************************/
523 bool patcher_builtin_arrayinstanceof(u1 *sp)
526 java_objectheader *o;
528 constant_classref *cr;
533 /* get stuff from the stack */
535 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
536 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
537 mcode = *((u4 *) (sp + 1 * 4));
538 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
539 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
541 /* calculate and set the new return address */
544 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
546 PATCHER_MONITORENTER;
548 /* get the classinfo */
550 if (!(c = helper_resolve_classinfo(cr))) {
556 /* patch back original code */
558 *((u4 *) (ra + 4)) = mcode;
560 /* get the offset from machine instruction */
562 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
564 /* patch the class' vftbl pointer */
566 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
568 /* if we show disassembly, we have to skip the nop */
573 /* get the offset from machine instruction */
575 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
577 /* patch new function address */
579 *((ptrint *) (pv + offset)) = (ptrint) BUILTIN_arrayinstanceof;
581 /* synchronize instruction cache */
583 asm_cacheflush(ra + 4, 4);
585 PATCHER_MARK_PATCHED_MONITOREXIT;
591 /* patcher_invokestatic_special ************************************************
595 <patched call position>
596 81adffd8 lwz r13,-40(r13)
600 ******************************************************************************/
602 bool patcher_invokestatic_special(u1 *sp)
605 java_objectheader *o;
607 unresolved_method *um;
612 /* get stuff from the stack */
614 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
615 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
616 mcode = *((u4 *) (sp + 1 * 4));
617 um = (unresolved_method *) *((ptrint *) (sp + 0 * 4));
618 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
620 /* calculate and set the new return address */
623 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
625 PATCHER_MONITORENTER;
627 /* get the fieldinfo */
629 if (!(m = helper_resolve_methodinfo(um))) {
635 /* patch back original code */
637 *((u4 *) ra) = mcode;
639 /* if we show disassembly, we have to skip the nop */
644 /* get the offset from machine instruction */
646 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
648 /* patch stubroutine */
650 *((ptrint *) (pv + offset)) = (ptrint) m->stubroutine;
652 /* synchronize instruction cache */
654 asm_cacheflush(ra, 4);
656 PATCHER_MARK_PATCHED_MONITOREXIT;
662 /* patcher_invokevirtual *******************************************************
666 <patched call position>
667 81830000 lwz r12,0(r3)
668 81ac0088 lwz r13,136(r12)
672 *******************************************************************************/
674 bool patcher_invokevirtual(u1 *sp)
677 java_objectheader *o;
679 unresolved_method *um;
682 /* get stuff from the stack */
684 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
685 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
686 mcode = *((u4 *) (sp + 1 * 4));
687 um = (unresolved_method *) *((ptrint *) (sp + 0 * 4));
689 /* calculate and set the new return address */
692 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
694 PATCHER_MONITORENTER;
696 /* get the fieldinfo */
698 if (!(m = helper_resolve_methodinfo(um))) {
704 /* patch back original code */
706 *((u4 *) ra) = mcode;
708 /* if we show disassembly, we have to skip the nop */
713 /* patch vftbl index */
715 *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, table[0]) +
716 sizeof(methodptr) * m->vftblindex) & 0x0000ffff);
718 /* synchronize instruction cache */
720 asm_cacheflush(ra, 2 * 4);
722 PATCHER_MARK_PATCHED_MONITOREXIT;
728 /* patcher_invokeinterface *****************************************************
732 <patched call position>
733 81830000 lwz r12,0(r3)
734 818cffd0 lwz r12,-48(r12)
735 81ac000c lwz r13,12(r12)
739 *******************************************************************************/
741 bool patcher_invokeinterface(u1 *sp)
744 java_objectheader *o;
746 unresolved_method *um;
749 /* get stuff from the stack */
751 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
752 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
753 mcode = *((u4 *) (sp + 1 * 4));
754 um = (unresolved_method *) *((ptrint *) (sp + 0 * 4));
756 /* calculate and set the new return address */
759 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
761 PATCHER_MONITORENTER;
763 /* get the fieldinfo */
765 if (!(m = helper_resolve_methodinfo(um))) {
771 /* patch back original code */
773 *((u4 *) ra) = mcode;
775 /* if we show disassembly, we have to skip the nop */
780 /* patch interfacetable index */
782 *((s4 *) (ra + 1 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
783 sizeof(methodptr*) * m->class->index) & 0x0000ffff);
785 /* patch method offset */
787 *((s4 *) (ra + 2 * 4)) |=
788 (s4) ((sizeof(methodptr) * (m - m->class->methods)) & 0x0000ffff);
790 /* synchronize instruction cache */
792 asm_cacheflush(ra, 3 * 4);
794 PATCHER_MARK_PATCHED_MONITOREXIT;
800 /* patcher_checkcast_instanceof_flags ******************************************
804 <patched call position>
806 *******************************************************************************/
808 bool patcher_checkcast_instanceof_flags(u1 *sp)
811 java_objectheader *o;
813 constant_classref *cr;
818 /* get stuff from the stack */
820 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
821 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
822 mcode = *((u4 *) (sp + 1 * 4));
823 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
824 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
826 /* calculate and set the new return address */
829 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
831 PATCHER_MONITORENTER;
833 /* get the fieldinfo */
835 if (!(c = helper_resolve_classinfo(cr))) {
841 /* patch back original code */
843 *((u4 *) ra) = mcode;
845 /* synchronize instruction cache */
847 asm_cacheflush(ra, 4);
849 /* if we show disassembly, we have to skip the nop */
854 /* get the offset from machine instruction */
856 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
858 /* patch class flags */
860 *((s4 *) (pv + offset)) = (s4) c->flags;
862 PATCHER_MARK_PATCHED_MONITOREXIT;
868 /* patcher_checkcast_instanceof_interface **************************************
872 <patched call position>
874 *******************************************************************************/
876 bool patcher_checkcast_instanceof_interface(u1 *sp)
879 java_objectheader *o;
881 constant_classref *cr;
884 /* get stuff from the stack */
886 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
887 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
888 mcode = *((u4 *) (sp + 1 * 4));
889 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
891 /* calculate and set the new return address */
894 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
896 PATCHER_MONITORENTER;
898 /* get the fieldinfo */
900 if (!(c = helper_resolve_classinfo(cr))) {
906 /* patch back original code */
908 *((u4 *) ra) = mcode;
910 /* if we show disassembly, we have to skip the nop */
915 /* patch super class index */
917 *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff);
919 *((s4 *) (ra + 4 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
920 c->index * sizeof(methodptr*)) & 0x0000ffff);
922 /* synchronize instruction cache */
924 asm_cacheflush(ra, 5 * 4);
926 PATCHER_MARK_PATCHED_MONITOREXIT;
932 /* patcher_checkcast_class *****************************************************
936 <patched call position>
938 *******************************************************************************/
940 bool patcher_checkcast_class(u1 *sp)
943 java_objectheader *o;
945 constant_classref *cr;
950 /* get stuff from the stack */
952 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
953 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
954 mcode = *((u4 *) (sp + 1 * 4));
955 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
956 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
958 /* calculate and set the new return address */
961 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
963 PATCHER_MONITORENTER;
965 /* get the fieldinfo */
967 if (!(c = helper_resolve_classinfo(cr))) {
973 /* patch back original code */
975 *((u4 *) ra) = mcode;
977 /* synchronize instruction cache */
979 asm_cacheflush(ra, 4);
981 /* if we show disassembly, we have to skip the nop */
986 /* get the offset from machine instruction */
988 offset = (s2) (*((u4 *) (ra + 2 * 4)) & 0x0000ffff);
990 /* patch super class' vftbl */
992 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
994 PATCHER_MARK_PATCHED_MONITOREXIT;
1000 /* patcher_instanceof_class ****************************************************
1004 <patched call position>
1006 *******************************************************************************/
1008 bool patcher_instanceof_class(u1 *sp)
1011 java_objectheader *o;
1013 constant_classref *cr;
1018 /* get stuff from the stack */
1020 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
1021 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
1022 mcode = *((u4 *) (sp + 1 * 4));
1023 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
1024 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
1026 /* calculate and set the new return address */
1029 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
1031 PATCHER_MONITORENTER;
1033 /* get the fieldinfo */
1035 if (!(c = helper_resolve_classinfo(cr))) {
1036 PATCHER_MONITOREXIT;
1041 /* patch back original code */
1043 *((u4 *) ra) = mcode;
1045 /* synchronize instruction cache */
1047 asm_cacheflush(ra, 4);
1049 /* if we show disassembly, we have to skip the nop */
1051 if (showdisassemble)
1054 /* get the offset from machine instruction */
1056 offset = (s2) (*((u4 *) (ra + 1 * 4)) & 0x0000ffff);
1058 /* patch super class' vftbl */
1060 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
1062 PATCHER_MARK_PATCHED_MONITOREXIT;
1068 /* patcher_clinit **************************************************************
1072 *******************************************************************************/
1074 bool patcher_clinit(u1 *sp)
1077 java_objectheader *o;
1081 /* get stuff from the stack */
1083 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
1084 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
1085 mcode = *((u4 *) (sp + 1 * 4));
1086 c = (classinfo *) *((ptrint *) (sp + 0 * 4));
1088 /* calculate and set the new return address */
1091 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
1093 PATCHER_MONITORENTER;
1095 /* check if the class is initialized */
1097 if (!c->initialized) {
1098 if (!initialize_class(c)) {
1099 PATCHER_MONITOREXIT;
1105 /* patch back original code */
1107 *((u4 *) ra) = mcode;
1109 /* synchronize instruction cache */
1111 asm_cacheflush(ra, 4);
1113 PATCHER_MARK_PATCHED_MONITOREXIT;
1119 /* patcher_resolve_native ******************************************************
1123 *******************************************************************************/
1125 bool patcher_resolve_native(u1 *sp)
1128 java_objectheader *o;
1135 /* get stuff from the stack */
1137 ra = (u1 *) *((ptrint *) (sp + 3 * 4));
1138 o = (java_objectheader *) *((ptrint *) (sp + 2 * 4));
1139 mcode = *((u4 *) (sp + 1 * 4));
1140 m = (methodinfo *) *((ptrint *) (sp + 0 * 4));
1141 pv = (u1 *) *((ptrint *) (sp - 2 * 4));
1143 /* calculate and set the new return address */
1146 *((ptrint *) (sp + 3 * 4)) = (ptrint) ra;
1148 PATCHER_MONITORENTER;
1150 /* resolve native function */
1152 if (!(f = native_resolve_function(m))) {
1153 PATCHER_MONITOREXIT;
1158 /* patch back original code */
1160 *((u4 *) ra) = mcode;
1162 /* synchronize instruction cache */
1164 asm_cacheflush(ra, 4);
1166 /* if we show disassembly, we have to skip the nop */
1168 if (showdisassemble)
1171 /* get the offset from machine instruction */
1173 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
1175 /* patch native function pointer */
1177 *((ptrint *) (pv + offset)) = (ptrint) f;
1179 PATCHER_MARK_PATCHED_MONITOREXIT;
1186 * These are local overrides for various environment variables in Emacs.
1187 * Please do not remove this and leave it at the end of the file, where
1188 * Emacs will automagically detect them.
1189 * ---------------------------------------------------------------------
1192 * indent-tabs-mode: t
1196 * vim:noexpandtab:sw=4:ts=4: