1 /* src/vm/jit/alpha/patcher.c - Alpha 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 2449 2005-05-11 13:34:47Z twisti $
36 #include "vm/jit/alpha/types.h"
37 #include "vm/builtin.h"
39 #include "vm/initialize.h"
40 #include "vm/options.h"
41 #include "vm/references.h"
42 #include "vm/jit/asmpart.h"
43 #include "vm/jit/helper.h"
46 /* patcher_get_putstatic *******************************************************
50 <patched call position>
51 a73bff98 ldq t11,-104(pv)
52 a2590000 ldl a2,0(t11)
54 *******************************************************************************/
56 bool patcher_get_putstatic(u1 *sp)
66 /* get stuff from the stack */
68 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
69 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
70 mcode = *((u4 *) (sp + 1 * 8));
71 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 8));
72 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
74 /* calculate and set the new return address */
77 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
79 #if defined(USE_THREADS)
80 /* enter a monitor on the patching position */
82 builtin_monitorenter(o);
84 /* check if the position has already been patched */
87 builtin_monitorexit(o);
93 /* get the fieldinfo */
95 if (!(fi = helper_resolve_fieldinfo(uf)))
98 /* check if the field's class is initialized */
100 if (!fi->class->initialized)
101 if (!initialize_class(fi->class))
104 /* patch back original code */
106 *((u4 *) ra) = mcode;
108 /* if we show disassembly, we have to skip the nop */
113 /* get the offset from machine instruction */
115 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
117 /* patch the field value's address */
119 *((ptrint *) (pv + offset)) = (ptrint) &(fi->value);
121 /* synchronize instruction cache */
123 asm_sync_instruction_cache();
125 #if defined(USE_THREADS)
126 /* this position has been patched */
128 o->vftbl = (vftbl_t *) 1;
130 /* leave the monitor on the patching position */
132 builtin_monitorexit(o);
139 /* patcher_get_putfield ********************************************************
143 <patched call position>
144 a2af0020 ldl a5,32(s6)
146 *******************************************************************************/
148 bool patcher_get_putfield(u1 *sp)
151 java_objectheader *o;
153 unresolved_field *uf;
157 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
158 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
159 mcode = *((u4 *) (sp + 1 * 8));
160 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 8));
161 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
163 /* calculate and set the new return address */
166 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
168 #if defined(USE_THREADS)
169 /* enter a monitor on the patching position */
171 builtin_monitorenter(o);
173 /* check if the position has already been patched */
176 builtin_monitorexit(o);
182 /* get the fieldinfo */
184 if (!(fi = helper_resolve_fieldinfo(uf)))
187 /* patch back original code */
189 *((u4 *) ra) = mcode;
191 /* if we show disassembly, we have to skip the nop */
196 /* patch the field's offset */
198 *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff);
200 /* synchronize instruction cache */
202 asm_sync_instruction_cache();
204 #if defined(USE_THREADS)
205 /* this position has been patched */
207 o->vftbl = (vftbl_t *) 1;
209 /* leave the monitor on the patching position */
211 builtin_monitorexit(o);
218 /* patcher_builtin_new *********************************************************
222 a61bff80 ldq a0,-128(pv)
223 <patched call postition>
224 a77bff78 ldq pv,-136(pv)
227 *******************************************************************************/
229 bool patcher_builtin_new(u1 *sp)
232 java_objectheader *o;
234 constant_classref *cr;
239 /* get stuff from the stack */
241 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
242 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
243 mcode = *((u4 *) (sp + 1 * 8));
244 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
245 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
247 /* calculate and set the new return address */
250 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
252 #if defined(USE_THREADS)
253 /* enter a monitor on the patching position */
255 builtin_monitorenter(o);
257 /* check if the position has already been patched */
260 builtin_monitorexit(o);
266 /* get the classinfo */
268 if (!(c = helper_resolve_classinfo(cr)))
271 /* patch back original code */
273 *((u4 *) (ra + 4)) = mcode;
275 /* get the offset from machine instruction */
277 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
279 /* patch the classinfo pointer */
281 *((ptrint *) (pv + offset)) = (ptrint) c;
283 /* if we show disassembly, we have to skip the nop */
288 /* get the offset from machine instruction */
290 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
292 /* patch new function address */
294 *((ptrint *) (pv + offset)) = (ptrint) BUILTIN_new;
296 /* synchronize instruction cache */
298 asm_sync_instruction_cache();
300 #if defined(USE_THREADS)
301 /* this position has been patched */
303 o->vftbl = (vftbl_t *) 1;
305 /* leave the monitor on the patching position */
307 builtin_monitorexit(o);
314 /* patcher_builtin_newarray ****************************************************
318 a63bff88 ldq a1,-120(pv)
319 <patched call position>
320 a77bff80 ldq pv,-128(pv)
323 *******************************************************************************/
325 bool patcher_builtin_newarray(u1 *sp)
328 java_objectheader *o;
330 constant_classref *cr;
335 /* get stuff from the stack */
337 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
338 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
339 mcode = *((u4 *) (sp + 1 * 8));
340 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
341 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
343 /* calculate and set the new return address */
346 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
348 #if defined(USE_THREADS)
349 /* enter a monitor on the patching position */
351 builtin_monitorenter(o);
353 /* check if the position has already been patched */
356 builtin_monitorexit(o);
362 /* get the classinfo */
364 if (!(c = helper_resolve_classinfo(cr)))
367 /* patch back original code */
369 *((u4 *) (ra + 4)) = mcode;
371 /* get the offset from machine instruction */
373 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
375 /* patch the class' vftbl pointer */
377 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
379 /* if we show disassembly, we have to skip the nop */
384 /* get the offset from machine instruction */
386 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
388 /* patch new function address */
390 *((ptrint *) (pv + offset)) = (ptrint) BUILTIN_newarray;
392 /* synchronize instruction cache */
394 asm_sync_instruction_cache();
396 #if defined(USE_THREADS)
397 /* this position has been patched */
399 o->vftbl = (vftbl_t *) 1;
401 /* leave the monitor on the patching position */
403 builtin_monitorexit(o);
410 /* patcher_builtin_multianewarray **********************************************
414 <patched call position>
415 221f0002 lda a0,2(zero)
416 a63bff80 ldq a1,-128(pv)
418 a77bff78 ldq pv,-136(pv)
421 *******************************************************************************/
423 bool patcher_builtin_multianewarray(u1 *sp)
426 java_objectheader *o;
428 constant_classref *cr;
433 /* get stuff from the stack */
435 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
436 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
437 mcode = *((u4 *) (sp + 1 * 8));
438 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
439 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
441 /* calculate and set the new return address */
444 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
446 #if defined(USE_THREADS)
447 /* enter a monitor on the patching position */
449 builtin_monitorenter(o);
451 /* check if the position has already been patched */
454 builtin_monitorexit(o);
460 /* get the classinfo */
462 if (!(c = helper_resolve_classinfo(cr)))
465 /* patch back original code */
467 *((u4 *) ra) = mcode;
469 /* if we show disassembly, we have to skip the nop */
474 /* get the offset from machine instruction */
476 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
478 /* patch the class' vftbl pointer */
480 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
482 /* synchronize instruction cache */
484 asm_sync_instruction_cache();
486 #if defined(USE_THREADS)
487 /* this position has been patched */
489 o->vftbl = (vftbl_t *) 1;
491 /* leave the monitor on the patching position */
493 builtin_monitorexit(o);
500 /* patcher_builtin_arraycheckcast **********************************************
504 a63bfe60 ldq a1,-416(pv)
505 <patched call position>
506 a77bfe58 ldq pv,-424(pv)
509 *******************************************************************************/
511 bool patcher_builtin_arraycheckcast(u1 *sp)
514 java_objectheader *o;
516 constant_classref *cr;
521 /* get stuff from the stack */
523 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
524 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
525 mcode = *((u4 *) (sp + 1 * 8));
526 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
527 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
529 /* calculate and set the new return address */
532 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
534 #if defined(USE_THREADS)
535 /* enter a monitor on the patching position */
537 builtin_monitorenter(o);
539 /* check if the position has already been patched */
542 builtin_monitorexit(o);
548 /* get the classinfo */
550 if (!(c = helper_resolve_classinfo(cr)))
553 /* patch back original code */
555 *((u4 *) (ra + 4)) = mcode;
557 /* get the offset from machine instruction */
559 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
561 /* patch the class' vftbl pointer */
563 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
565 /* if we show disassembly, we have to skip the nop */
570 /* get the offset from machine instruction */
572 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
574 /* patch new function address */
576 *((ptrint *) (pv + offset)) = (ptrint) BUILTIN_arraycheckcast;
578 /* synchronize instruction cache */
580 asm_sync_instruction_cache();
582 #if defined(USE_THREADS)
583 /* this position has been patched */
585 o->vftbl = (vftbl_t *) 1;
587 /* leave the monitor on the patching position */
589 builtin_monitorexit(o);
596 /* patcher_builtin_arrayinstanceof *********************************************
600 a63bfeb0 ldq a1,-336(pv)
601 <patched call position>
602 a77bfea8 ldq pv,-344(pv)
605 *******************************************************************************/
607 bool patcher_builtin_arrayinstanceof(u1 *sp)
610 java_objectheader *o;
612 constant_classref *cr;
617 /* get stuff from the stack */
619 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
620 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
621 mcode = *((u4 *) (sp + 1 * 8));
622 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
623 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
625 /* calculate and set the new return address */
628 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
630 #if defined(USE_THREADS)
631 /* enter a monitor on the patching position */
633 builtin_monitorenter(o);
635 /* check if the position has already been patched */
638 builtin_monitorexit(o);
644 /* get the classinfo */
646 if (!(c = helper_resolve_classinfo(cr)))
649 /* patch back original code */
651 *((u4 *) (ra + 4)) = mcode;
653 /* get the offset from machine instruction */
655 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
657 /* patch the class' vftbl pointer */
659 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
661 /* if we show disassembly, we have to skip the nop */
666 /* get the offset from machine instruction */
668 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
670 /* patch new function address */
672 *((ptrint *) (pv + offset)) = (ptrint) BUILTIN_arrayinstanceof;
674 /* synchronize instruction cache */
676 asm_sync_instruction_cache();
678 #if defined(USE_THREADS)
679 /* this position has been patched */
681 o->vftbl = (vftbl_t *) 1;
683 /* leave the monitor on the patching position */
685 builtin_monitorexit(o);
692 /* patcher_invokestatic_special ************************************************
696 <patched call position>
697 a77bffa8 ldq pv,-88(pv)
700 ******************************************************************************/
702 bool patcher_invokestatic_special(u1 *sp)
705 java_objectheader *o;
707 unresolved_method *um;
712 /* get stuff from the stack */
714 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
715 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
716 mcode = *((u4 *) (sp + 1 * 8));
717 um = (unresolved_method *) *((ptrint *) (sp + 0 * 8));
718 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
720 /* calculate and set the new return address */
723 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
725 #if defined(USE_THREADS)
726 /* enter a monitor on the patching position */
728 builtin_monitorenter(o);
730 /* check if the position has already been patched */
733 builtin_monitorexit(o);
739 /* get the fieldinfo */
741 if (!(m = helper_resolve_methodinfo(um)))
744 /* patch back original code */
746 *((u4 *) ra) = mcode;
748 /* if we show disassembly, we have to skip the nop */
753 /* get the offset from machine instruction */
755 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
757 /* patch stubroutine */
759 *((ptrint *) (pv + offset)) = (ptrint) m->stubroutine;
761 /* synchronize instruction cache */
763 asm_sync_instruction_cache();
765 #if defined(USE_THREADS)
766 /* this position has been patched */
768 o->vftbl = (vftbl_t *) 1;
770 /* leave the monitor on the patching position */
772 builtin_monitorexit(o);
779 /* patcher_invokevirtual *******************************************************
783 <patched call position>
784 a7900000 ldq at,0(a0)
785 a77c0100 ldq pv,256(at)
788 *******************************************************************************/
790 bool patcher_invokevirtual(u1 *sp)
793 java_objectheader *o;
795 unresolved_method *um;
798 /* get stuff from the stack */
800 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
801 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
802 mcode = *((u4 *) (sp + 1 * 8));
803 um = (unresolved_method *) *((ptrint *) (sp + 0 * 8));
805 /* calculate and set the new return address */
808 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
810 #if defined(USE_THREADS)
811 /* enter a monitor on the patching position */
813 builtin_monitorenter(o);
815 /* check if the position has already been patched */
818 builtin_monitorexit(o);
824 /* get the fieldinfo */
826 if (!(m = helper_resolve_methodinfo(um)))
829 /* patch back original code */
831 *((u4 *) ra) = mcode;
833 /* if we show disassembly, we have to skip the nop */
838 /* patch vftbl index */
840 *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, table[0]) +
841 sizeof(methodptr) * m->vftblindex) & 0x0000ffff);
843 /* synchronize instruction cache */
845 asm_sync_instruction_cache();
847 #if defined(USE_THREADS)
848 /* this position has been patched */
850 o->vftbl = (vftbl_t *) 1;
852 /* leave the monitor on the patching position */
854 builtin_monitorexit(o);
861 /* patcher_invokeinterface *****************************************************
865 <patched call position>
866 a7900000 ldq at,0(a0)
867 a79cffa0 ldq at,-96(at)
868 a77c0018 ldq pv,24(at)
871 *******************************************************************************/
873 bool patcher_invokeinterface(u1 *sp)
876 java_objectheader *o;
878 unresolved_method *um;
881 /* get stuff from the stack */
883 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
884 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
885 mcode = *((u4 *) (sp + 1 * 8));
886 um = (unresolved_method *) *((ptrint *) (sp + 0 * 8));
888 /* calculate and set the new return address */
891 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
893 #if defined(USE_THREADS)
894 /* enter a monitor on the patching position */
896 builtin_monitorenter(o);
898 /* check if the position has already been patched */
901 builtin_monitorexit(o);
907 /* get the fieldinfo */
909 if (!(m = helper_resolve_methodinfo(um)))
912 /* patch back original code */
914 *((u4 *) ra) = mcode;
916 /* if we show disassembly, we have to skip the nop */
921 /* patch interfacetable index */
923 *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
924 sizeof(methodptr*) * m->class->index) & 0x0000ffff);
926 /* patch method offset */
928 *((s4 *) (ra + 4 + 4)) |=
929 (s4) ((sizeof(methodptr) * (m - m->class->methods)) & 0x0000ffff);
931 /* synchronize instruction cache */
933 asm_sync_instruction_cache();
935 #if defined(USE_THREADS)
936 /* this position has been patched */
938 o->vftbl = (vftbl_t *) 1;
940 /* leave the monitor on the patching position */
942 builtin_monitorexit(o);
949 /* patcher_checkcast_instanceof_flags ******************************************
953 <patched call position>
955 *******************************************************************************/
957 bool patcher_checkcast_instanceof_flags(u1 *sp)
960 java_objectheader *o;
962 constant_classref *cr;
967 /* get stuff from the stack */
969 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
970 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
971 mcode = *((u4 *) (sp + 1 * 8));
972 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
973 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
975 /* calculate and set the new return address */
978 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
980 #if defined(USE_THREADS)
981 /* enter a monitor on the patching position */
983 builtin_monitorenter(o);
985 /* check if the position has already been patched */
988 builtin_monitorexit(o);
994 /* get the fieldinfo */
996 if (!(c = helper_resolve_classinfo(cr)))
999 /* patch back original code */
1001 *((u4 *) ra) = mcode;
1003 /* if we show disassembly, we have to skip the nop */
1005 if (showdisassemble)
1008 /* get the offset from machine instruction */
1010 offset = (s2) (*((u4 *) ra) & 0x0000ffff);
1012 /* patch class flags */
1014 *((s4 *) (pv + offset)) = (s4) c->flags;
1016 /* synchronize instruction cache */
1018 asm_sync_instruction_cache();
1020 #if defined(USE_THREADS)
1021 /* this position has been patched */
1023 o->vftbl = (vftbl_t *) 1;
1025 /* leave the monitor on the patching position */
1027 builtin_monitorexit(o);
1034 /* patcher_checkcast_instanceof_interface **************************************
1038 <patched call position>
1039 a78e0000 ldq at,0(s5)
1040 a3bc001c ldl gp,28(at)
1041 23bdfffd lda gp,-3(gp)
1042 efa0002e ble gp,0x00000200002bf6b0
1043 a7bcffe8 ldq gp,-24(at)
1045 *******************************************************************************/
1047 bool patcher_checkcast_instanceof_interface(u1 *sp)
1050 java_objectheader *o;
1052 constant_classref *cr;
1055 /* get stuff from the stack */
1057 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
1058 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
1059 mcode = *((u4 *) (sp + 1 * 8));
1060 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
1062 /* calculate and set the new return address */
1065 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
1067 #if defined(USE_THREADS)
1068 /* enter a monitor on the patching position */
1070 builtin_monitorenter(o);
1072 /* check if the position has already been patched */
1075 builtin_monitorexit(o);
1081 /* get the fieldinfo */
1083 if (!(c = helper_resolve_classinfo(cr)))
1086 /* patch back original code */
1088 *((u4 *) ra) = mcode;
1090 /* if we show disassembly, we have to skip the nop */
1092 if (showdisassemble)
1095 /* patch super class index */
1097 *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff);
1099 *((s4 *) (ra + 4 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
1100 c->index * sizeof(methodptr*)) & 0x0000ffff);
1102 /* synchronize instruction cache */
1104 asm_sync_instruction_cache();
1106 #if defined(USE_THREADS)
1107 /* this position has been patched */
1109 o->vftbl = (vftbl_t *) 1;
1111 /* leave the monitor on the patching position */
1113 builtin_monitorexit(o);
1120 /* patcher_checkcast_instanceof_class ******************************************
1124 <patched call position>
1125 a7940000 ldq at,0(a4)
1126 a7bbff28 ldq gp,-216(pv)
1128 *******************************************************************************/
1130 bool patcher_checkcast_instanceof_class(u1 *sp)
1133 java_objectheader *o;
1135 constant_classref *cr;
1140 /* get stuff from the stack */
1142 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
1143 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
1144 mcode = *((u4 *) (sp + 1 * 8));
1145 cr = (constant_classref *) *((ptrint *) (sp + 0 * 8));
1146 pv = (u1 *) *((ptrint *) (sp - 2 * 8));
1148 /* calculate and set the new return address */
1151 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
1153 #if defined(USE_THREADS)
1154 /* enter a monitor on the patching position */
1156 builtin_monitorenter(o);
1158 /* check if the position has already been patched */
1161 builtin_monitorexit(o);
1167 /* get the fieldinfo */
1169 if (!(c = helper_resolve_classinfo(cr)))
1172 /* patch back original code */
1174 *((u4 *) ra) = mcode;
1176 /* if we show disassembly, we have to skip the nop */
1178 if (showdisassemble)
1181 /* get the offset from machine instruction */
1183 offset = (s2) (*((u4 *) (ra + 4)) & 0x0000ffff);
1185 /* patch super class' vftbl */
1187 *((ptrint *) (pv + offset)) = (ptrint) c->vftbl;
1189 /* synchronize instruction cache */
1191 asm_sync_instruction_cache();
1193 #if defined(USE_THREADS)
1194 /* this position has been patched */
1196 o->vftbl = (vftbl_t *) 1;
1198 /* leave the monitor on the patching position */
1200 builtin_monitorexit(o);
1207 /* patcher_clinit **************************************************************
1211 *******************************************************************************/
1213 bool patcher_clinit(u1 *sp)
1216 java_objectheader *o;
1220 /* get stuff from the stack */
1222 ra = (u1 *) *((ptrint *) (sp + 3 * 8));
1223 o = (java_objectheader *) *((ptrint *) (sp + 2 * 8));
1224 mcode = *((u4 *) (sp + 1 * 8));
1225 c = (classinfo *) *((ptrint *) (sp + 0 * 8));
1227 /* calculate and set the new return address */
1230 *((ptrint *) (sp + 3 * 8)) = (ptrint) ra;
1232 #if defined(USE_THREADS)
1233 /* enter a monitor on the patching position */
1235 builtin_monitorenter(o);
1237 /* check if the position has already been patched */
1240 builtin_monitorexit(o);
1246 /* check if the class is initialized */
1248 if (!c->initialized)
1249 if (!initialize_class(c))
1252 /* patch back original code */
1254 *((u4 *) ra) = mcode;
1256 /* synchronize instruction cache */
1258 asm_sync_instruction_cache();
1260 #if defined(USE_THREADS)
1261 /* this position has been patched */
1263 o->vftbl = (vftbl_t *) 1;
1265 /* leave the monitor on the patching position */
1267 builtin_monitorexit(o);
1275 * These are local overrides for various environment variables in Emacs.
1276 * Please do not remove this and leave it at the end of the file, where
1277 * Emacs will automagically detect them.
1278 * ---------------------------------------------------------------------
1281 * indent-tabs-mode: t
1285 * vim:noexpandtab:sw=4:ts=4: