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 3484 2005-10-21 13:43:51Z twisti $
39 #include "mm/memory.h"
40 #include "native/native.h"
41 #include "vm/builtin.h"
43 #include "vm/initialize.h"
44 #include "vm/options.h"
45 #include "vm/resolve.h"
46 #include "vm/references.h"
47 #include "vm/jit/asmpart.h"
48 #include "vm/jit/patcher.h"
51 /* patcher_get_putstatic *******************************************************
55 <patched call position>
56 816dffc8 lwz r11,-56(r13)
57 80ab0000 lwz r5,0(r11)
59 *******************************************************************************/
61 bool patcher_get_putstatic(u1 *sp)
71 /* get stuff from the stack */
73 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
74 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
75 mcode = *((u4 *) (sp + 3 * 4));
76 uf = (unresolved_field *) *((ptrint *) (sp + 2 * 4));
77 disp = *((s4 *) (sp + 1 * 4));
78 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
80 /* calculate and set the new return address */
83 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
87 /* get the fieldinfo */
89 if (!(fi = resolve_field_eager(uf))) {
95 /* check if the field's class is initialized */
97 if (!fi->class->initialized) {
98 if (!initialize_class(fi->class)) {
105 /* patch back original code */
107 *((u4 *) ra) = mcode;
109 /* synchronize instruction cache */
111 asm_cacheflush(ra, 4);
113 /* patch the field value's address */
115 *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
117 PATCHER_MARK_PATCHED_MONITOREXIT;
123 /* patcher_get_putfield ********************************************************
127 <patched call position>
128 811f0014 lwz r8,20(r31)
130 *******************************************************************************/
132 bool patcher_get_putfield(u1 *sp)
135 java_objectheader *o;
137 unresolved_field *uf;
141 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
142 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
143 mcode = *((u4 *) (sp + 3 * 4));
144 uf = (unresolved_field *) *((ptrint *) (sp + 2 * 4));
145 pv = (u1 *) *((ptrint *) (sp + 1 * 4));
147 /* calculate and set the new return address */
150 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
152 PATCHER_MONITORENTER;
154 /* get the fieldinfo */
156 if (!(fi = resolve_field_eager(uf))) {
162 /* patch back original code */
164 *((u4 *) ra) = mcode;
166 /* if we show disassembly, we have to skip the nop */
168 if (opt_showdisassemble)
171 /* patch the field's offset */
173 if (fi->type == TYPE_LNG) {
174 /* if the field has type long, we have to patch two instructions */
176 *((u4 *) ra) |= (s2) ((fi->offset + 4) & 0x0000ffff);
177 *((u4 *) (ra + 4)) |= (s2) (fi->offset & 0x0000ffff);
180 *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff);
183 /* synchronize instruction cache */
185 asm_cacheflush(ra, 8);
187 PATCHER_MARK_PATCHED_MONITOREXIT;
193 /* patcher_builtin_new *********************************************************
197 806dffc4 lwz r3,-60(r13)
198 <patched call postition>
199 81adffc0 lwz r13,-64(r13)
203 NOTICE: Only the displacement for the function address is passed,
204 but the address of the classinfo pointer is one below (above, in
205 addresses speaking). This is for sure.
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 + 5 * 4));
222 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
223 mcode = *((u4 *) (sp + 3 * 4));
224 cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
225 disp = *((s4 *) (sp + 1 * 4));
226 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
228 /* calculate and set the new return address */
231 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
233 PATCHER_MONITORENTER;
235 /* get the classinfo */
237 if (!(c = resolve_classref_eager_nonabstract(cr))) {
243 /* patch back original code */
245 *((u4 *) (ra + 4)) = mcode;
247 /* synchronize instruction cache */
249 asm_cacheflush(ra + 4, 4);
251 /* patch the classinfo pointer */
253 *((ptrint *) (pv + (disp + SIZEOF_VOID_P))) = (ptrint) c;
255 /* patch new function address */
257 *((ptrint *) (pv + disp)) = (ptrint) BUILTIN_new;
259 PATCHER_MARK_PATCHED_MONITOREXIT;
265 /* patcher_builtin_newarray ****************************************************
269 808dffc8 lwz r4,-56(r13)
270 <patched call position>
271 81adffc4 lwz r13,-60(r13)
275 NOTICE: Only the displacement for the function address is passed,
276 but the address of the vftbl pointer is one below (above, in
277 addresses speaking). This is for sure.
279 *******************************************************************************/
281 bool patcher_builtin_newarray(u1 *sp)
284 java_objectheader *o;
286 constant_classref *cr;
291 /* get stuff from the stack */
293 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
294 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
295 mcode = *((u4 *) (sp + 3 * 4));
296 cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
297 disp = *((s4 *) (sp + 1 * 4));
298 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
300 /* calculate and set the new return address */
303 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
305 PATCHER_MONITORENTER;
307 /* get the classinfo */
309 if (!(c = resolve_classref_eager(cr))) {
315 /* patch back original code */
317 *((u4 *) (ra + 4)) = mcode;
319 /* synchronize instruction cache */
321 asm_cacheflush(ra + 4, 4);
323 /* patch the class' vftbl pointer */
325 *((ptrint *) (pv + (disp + SIZEOF_VOID_P))) = (ptrint) c->vftbl;
327 /* patch new function address */
329 *((ptrint *) (pv + disp)) = (ptrint) BUILTIN_newarray;
331 PATCHER_MARK_PATCHED_MONITOREXIT;
337 /* patcher_builtin_multianewarray **********************************************
341 <patched call position>
342 808dffc0 lwz r4,-64(r13)
343 38a10038 addi r5,r1,56
344 81adffbc lwz r13,-68(r13)
348 *******************************************************************************/
350 bool patcher_builtin_multianewarray(u1 *sp)
353 java_objectheader *o;
355 constant_classref *cr;
360 /* get stuff from the stack */
362 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
363 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
364 mcode = *((u4 *) (sp + 3 * 4));
365 cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
366 disp = *((s4 *) (sp + 1 * 4));
367 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
369 /* calculate and set the new return address */
372 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
374 PATCHER_MONITORENTER;
376 /* get the classinfo */
378 if (!(c = resolve_classref_eager(cr))) {
384 /* patch back original code */
386 *((u4 *) ra) = mcode;
388 /* synchronize instruction cache */
390 asm_cacheflush(ra, 4);
392 /* patch the class' vftbl pointer */
394 *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
396 PATCHER_MARK_PATCHED_MONITOREXIT;
402 /* patcher_builtin_arraycheckcast **********************************************
406 <patched call position>
407 808dffd8 lwz r4,-40(r13)
408 81adffd4 lwz r13,-44(r13)
412 NOTICE: Only the displacement of the vftbl pointer address is
413 passed, but the address of the function pointer is one above
414 (below, in addresses speaking). This is for sure.
416 *******************************************************************************/
418 bool patcher_builtin_arraycheckcast(u1 *sp)
421 java_objectheader *o;
423 constant_classref *cr;
428 /* get stuff from the stack */
430 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
431 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
432 mcode = *((u4 *) (sp + 3 * 4));
433 cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
434 disp = *((s4 *) (sp + 1 * 4));
435 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
437 /* calculate and set the new return address */
440 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
442 PATCHER_MONITORENTER;
444 /* get the classinfo */
446 if (!(c = resolve_classref_eager(cr))) {
452 /* patch back original code */
454 *((u4 *) ra) = mcode;
456 /* synchronize instruction cache */
458 asm_cacheflush(ra, 4);
460 /* patch the class' vftbl pointer */
462 *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
464 /* patch new function address */
466 *((ptrint *) (pv + (disp - SIZEOF_VOID_P))) =
467 (ptrint) BUILTIN_arraycheckcast;
469 PATCHER_MARK_PATCHED_MONITOREXIT;
475 /* patcher_builtin_arrayinstanceof *********************************************
479 808dff50 lwz r4,-176(r13)
480 <patched call position>
481 81adff4c lwz r13,-180(r13)
485 NOTICE: Only the displacement for the function address is passed,
486 but the address of the vftbl pointer is one below (above, in
487 addresses speaking). This is for sure.
489 *******************************************************************************/
491 bool patcher_builtin_arrayinstanceof(u1 *sp)
494 java_objectheader *o;
496 constant_classref *cr;
501 /* get stuff from the stack */
503 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
504 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
505 mcode = *((u4 *) (sp + 3 * 4));
506 cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
507 disp = *((s4 *) (sp + 1 * 4));
508 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
510 /* calculate and set the new return address */
513 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
515 PATCHER_MONITORENTER;
517 /* get the classinfo */
519 if (!(c = resolve_classref_eager(cr))) {
525 /* patch back original code */
527 *((u4 *) (ra + 4)) = mcode;
529 /* synchronize instruction cache */
531 asm_cacheflush(ra + 4, 4);
533 /* patch the class' vftbl pointer */
535 *((ptrint *) (pv + (disp + SIZEOF_VOID_P))) = (ptrint) c->vftbl;
537 /* patch new function address */
539 *((ptrint *) (pv + disp)) = (ptrint) BUILTIN_arrayinstanceof;
541 PATCHER_MARK_PATCHED_MONITOREXIT;
547 /* patcher_invokestatic_special ************************************************
551 <patched call position>
552 81adffd8 lwz r13,-40(r13)
556 ******************************************************************************/
558 bool patcher_invokestatic_special(u1 *sp)
561 java_objectheader *o;
563 unresolved_method *um;
568 /* get stuff from the stack */
570 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
571 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
572 mcode = *((u4 *) (sp + 3 * 4));
573 um = (unresolved_method *) *((ptrint *) (sp + 2 * 4));
574 disp = *((s4 *) (sp + 1 * 4));
575 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
577 /* calculate and set the new return address */
580 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
582 PATCHER_MONITORENTER;
584 /* get the fieldinfo */
586 if (!(m = resolve_method_eager(um))) {
592 /* patch back original code */
594 *((u4 *) ra) = mcode;
596 /* synchronize instruction cache */
598 asm_cacheflush(ra, 4);
600 /* patch stubroutine */
602 *((ptrint *) (pv + disp)) = (ptrint) m->stubroutine;
604 PATCHER_MARK_PATCHED_MONITOREXIT;
610 /* patcher_invokevirtual *******************************************************
614 <patched call position>
615 81830000 lwz r12,0(r3)
616 81ac0088 lwz r13,136(r12)
620 *******************************************************************************/
622 bool patcher_invokevirtual(u1 *sp)
625 java_objectheader *o;
627 unresolved_method *um;
630 /* get stuff from the stack */
632 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
633 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
634 mcode = *((u4 *) (sp + 3 * 4));
635 um = (unresolved_method *) *((ptrint *) (sp + 2 * 4));
637 /* calculate and set the new return address */
640 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
642 PATCHER_MONITORENTER;
644 /* get the fieldinfo */
646 if (!(m = resolve_method_eager(um))) {
652 /* patch back original code */
654 *((u4 *) ra) = mcode;
656 /* if we show disassembly, we have to skip the nop */
658 if (opt_showdisassemble)
661 /* patch vftbl index */
663 *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, table[0]) +
664 sizeof(methodptr) * m->vftblindex) & 0x0000ffff);
666 /* synchronize instruction cache */
668 asm_cacheflush(ra, 2 * 4);
670 PATCHER_MARK_PATCHED_MONITOREXIT;
676 /* patcher_invokeinterface *****************************************************
680 <patched call position>
681 81830000 lwz r12,0(r3)
682 818cffd0 lwz r12,-48(r12)
683 81ac000c lwz r13,12(r12)
687 *******************************************************************************/
689 bool patcher_invokeinterface(u1 *sp)
692 java_objectheader *o;
694 unresolved_method *um;
697 /* get stuff from the stack */
699 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
700 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
701 mcode = *((u4 *) (sp + 3 * 4));
702 um = (unresolved_method *) *((ptrint *) (sp + 2 * 4));
704 /* calculate and set the new return address */
707 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
709 PATCHER_MONITORENTER;
711 /* get the fieldinfo */
713 if (!(m = resolve_method_eager(um))) {
719 /* patch back original code */
721 *((u4 *) ra) = mcode;
723 /* if we show disassembly, we have to skip the nop */
725 if (opt_showdisassemble)
728 /* patch interfacetable index */
730 *((s4 *) (ra + 1 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
731 sizeof(methodptr*) * m->class->index) & 0x0000ffff);
733 /* patch method offset */
735 *((s4 *) (ra + 2 * 4)) |=
736 (s4) ((sizeof(methodptr) * (m - m->class->methods)) & 0x0000ffff);
738 /* synchronize instruction cache */
740 asm_cacheflush(ra, 3 * 4);
742 PATCHER_MARK_PATCHED_MONITOREXIT;
748 /* patcher_checkcast_instanceof_flags ******************************************
752 <patched call position>
753 818dff7c lwz r12,-132(r13)
755 *******************************************************************************/
757 bool patcher_checkcast_instanceof_flags(u1 *sp)
760 java_objectheader *o;
762 constant_classref *cr;
767 /* get stuff from the stack */
769 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
770 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
771 mcode = *((u4 *) (sp + 3 * 4));
772 cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
773 disp = *((s4 *) (sp + 1 * 4));
774 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
776 /* calculate and set the new return address */
779 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
781 PATCHER_MONITORENTER;
783 /* get the fieldinfo */
785 if (!(c = resolve_classref_eager(cr))) {
791 /* patch back original code */
793 *((u4 *) ra) = mcode;
795 /* synchronize instruction cache */
797 asm_cacheflush(ra, 4);
799 /* patch class flags */
801 *((s4 *) (pv + disp)) = (s4) c->flags;
803 PATCHER_MARK_PATCHED_MONITOREXIT;
809 /* patcher_checkcast_instanceof_interface **************************************
813 <patched call position>
814 81870000 lwz r12,0(r7)
815 800c0010 lwz r0,16(r12)
816 34000000 addic. r0,r0,0
817 408101fc ble- 0x3002e518
818 800c0000 lwz r0,0(r12)
820 *******************************************************************************/
822 bool patcher_checkcast_instanceof_interface(u1 *sp)
825 java_objectheader *o;
827 constant_classref *cr;
830 /* get stuff from the stack */
832 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
833 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
834 mcode = *((u4 *) (sp + 3 * 4));
835 cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
837 /* calculate and set the new return address */
840 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
842 PATCHER_MONITORENTER;
844 /* get the fieldinfo */
846 if (!(c = resolve_classref_eager(cr))) {
852 /* patch back original code */
854 *((u4 *) ra) = mcode;
856 /* if we show disassembly, we have to skip the nop */
858 if (opt_showdisassemble)
861 /* patch super class index */
863 *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff);
865 *((s4 *) (ra + 4 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
866 c->index * sizeof(methodptr*)) & 0x0000ffff);
868 /* synchronize instruction cache */
870 asm_cacheflush(ra, 5 * 4);
872 PATCHER_MARK_PATCHED_MONITOREXIT;
878 /* patcher_checkcast_class *****************************************************
882 <patched call position>
883 81870000 lwz r12,0(r7)
884 800c0014 lwz r0,20(r12)
885 818dff78 lwz r12,-136(r13)
887 *******************************************************************************/
889 bool patcher_checkcast_class(u1 *sp)
892 java_objectheader *o;
894 constant_classref *cr;
899 /* get stuff from the stack */
901 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
902 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
903 mcode = *((u4 *) (sp + 3 * 4));
904 cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
905 disp = *((s4 *) (sp + 1 * 4));
906 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
908 /* calculate and set the new return address */
911 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
913 PATCHER_MONITORENTER;
915 /* get the fieldinfo */
917 if (!(c = resolve_classref_eager(cr))) {
923 /* patch back original code */
925 *((u4 *) ra) = mcode;
927 /* synchronize instruction cache */
929 asm_cacheflush(ra, 4);
931 /* patch super class' vftbl */
933 *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
935 PATCHER_MARK_PATCHED_MONITOREXIT;
941 /* patcher_instanceof_class ****************************************************
945 <patched call position>
946 817d0000 lwz r11,0(r29)
947 818dff8c lwz r12,-116(r13)
949 *******************************************************************************/
951 bool patcher_instanceof_class(u1 *sp)
954 java_objectheader *o;
956 constant_classref *cr;
961 /* get stuff from the stack */
963 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
964 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
965 mcode = *((u4 *) (sp + 3 * 4));
966 cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
967 disp = *((s4 *) (sp + 1 * 4));
968 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
970 /* calculate and set the new return address */
973 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
975 PATCHER_MONITORENTER;
977 /* get the fieldinfo */
979 if (!(c = resolve_classref_eager(cr))) {
985 /* patch back original code */
987 *((u4 *) ra) = mcode;
989 /* synchronize instruction cache */
991 asm_cacheflush(ra, 4);
993 /* patch super class' vftbl */
995 *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
997 PATCHER_MARK_PATCHED_MONITOREXIT;
1003 /* patcher_clinit **************************************************************
1007 *******************************************************************************/
1009 bool patcher_clinit(u1 *sp)
1012 java_objectheader *o;
1016 /* get stuff from the stack */
1018 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
1019 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
1020 mcode = *((u4 *) (sp + 3 * 4));
1021 c = (classinfo *) *((ptrint *) (sp + 2 * 4));
1023 /* calculate and set the new return address */
1026 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
1028 PATCHER_MONITORENTER;
1030 /* check if the class is initialized */
1032 if (!c->initialized) {
1033 if (!initialize_class(c)) {
1034 PATCHER_MONITOREXIT;
1040 /* patch back original code */
1042 *((u4 *) ra) = mcode;
1044 /* synchronize instruction cache */
1046 asm_cacheflush(ra, 4);
1048 PATCHER_MARK_PATCHED_MONITOREXIT;
1054 /* patcher_athrow_areturn ******************************************************
1058 <patched call position>
1060 *******************************************************************************/
1062 bool patcher_athrow_areturn(u1 *sp)
1065 java_objectheader *o;
1067 unresolved_class *uc;
1070 /* get stuff from the stack */
1072 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
1073 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
1074 mcode = *((u4 *) (sp + 3 * 4));
1075 uc = (unresolved_class *) *((ptrint *) (sp + 2 * 4));
1077 /* calculate and set the new return address */
1080 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
1082 PATCHER_MONITORENTER;
1084 /* resolve the class */
1086 if (!resolve_class(uc, resolveEager, false, &c)) {
1087 PATCHER_MONITOREXIT;
1092 /* patch back original code */
1094 *((u4 *) ra) = mcode;
1096 /* synchronize instruction cache */
1098 asm_cacheflush(ra, 4);
1100 PATCHER_MARK_PATCHED_MONITOREXIT;
1106 /* patcher_resolve_native ******************************************************
1110 *******************************************************************************/
1112 #if !defined(ENABLE_STATICVM)
1113 bool patcher_resolve_native(u1 *sp)
1116 java_objectheader *o;
1123 /* get stuff from the stack */
1125 ra = (u1 *) *((ptrint *) (sp + 5 * 4));
1126 o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
1127 mcode = *((u4 *) (sp + 3 * 4));
1128 m = (methodinfo *) *((ptrint *) (sp + 2 * 4));
1129 disp = *((s4 *) (sp + 1 * 4));
1130 pv = (u1 *) *((ptrint *) (sp + 0 * 4));
1132 /* calculate and set the new return address */
1135 *((ptrint *) (sp + 5 * 4)) = (ptrint) ra;
1137 PATCHER_MONITORENTER;
1139 /* resolve native function */
1141 if (!(f = native_resolve_function(m))) {
1142 PATCHER_MONITOREXIT;
1147 /* patch back original code */
1149 *((u4 *) ra) = mcode;
1151 /* synchronize instruction cache */
1153 asm_cacheflush(ra, 4);
1155 /* patch native function pointer */
1157 *((ptrint *) (pv + disp)) = (ptrint) f;
1159 PATCHER_MARK_PATCHED_MONITOREXIT;
1163 #endif /* !defined(ENABLE_STATICVM) */
1167 * These are local overrides for various environment variables in Emacs.
1168 * Please do not remove this and leave it at the end of the file, where
1169 * Emacs will automagically detect them.
1170 * ---------------------------------------------------------------------
1173 * indent-tabs-mode: t
1177 * vim:noexpandtab:sw=4:ts=4: