1 /* src/vm/jit/i386/patcher.c - i386 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 3871 2005-12-05 18:12:35Z twisti $
39 #include "mm/memory.h"
40 #include "native/native.h"
41 #include "vm/builtin.h"
44 #include "vm/initialize.h"
45 #include "vm/options.h"
46 #include "vm/resolve.h"
47 #include "vm/references.h"
48 #include "vm/jit/patcher.h"
51 /* patcher_get_putstatic *******************************************************
55 <patched call position>
56 b8 00 00 00 00 mov $0x00000000,%eax
58 *******************************************************************************/
60 bool patcher_get_putstatic(u1 *sp)
68 /* get stuff from the stack */
70 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
71 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
72 mcode = *((u8 *) (sp + 1 * 4));
73 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 4));
75 /* calculate and set the new return address */
78 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
82 /* get the fieldinfo */
84 if (!(fi = resolve_field_eager(uf))) {
90 /* check if the field's class is initialized */
92 if (!(fi->class->state & CLASS_INITIALIZED)) {
93 if (!initialize_class(fi->class)) {
100 /* patch back original code */
102 *((u4 *) (ra + 0)) = (u4) mcode;
103 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
105 /* if we show disassembly, we have to skip the nop's */
107 if (opt_showdisassemble)
110 /* patch the field value's address */
112 *((ptrint *) (ra + 1)) = (ptrint) &(fi->value);
114 PATCHER_MARK_PATCHED_MONITOREXIT;
120 /* patcher_getfield ************************************************************
124 <patched call position>
125 8b 88 00 00 00 00 mov 0x00000000(%eax),%ecx
127 *******************************************************************************/
129 bool patcher_getfield(u1 *sp)
132 java_objectheader *o;
134 unresolved_field *uf;
137 /* get stuff from the stack */
139 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
140 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
141 mcode = *((u8 *) (sp + 1 * 4));
142 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 4));
144 /* calculate and set the new return address */
147 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
149 PATCHER_MONITORENTER;
151 /* get the fieldinfo */
153 if (!(fi = resolve_field_eager(uf))) {
159 /* patch back original code */
161 *((u4 *) (ra + 0)) = (u4) mcode;
162 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
164 /* if we show disassembly, we have to skip the nop's */
166 if (opt_showdisassemble)
169 /* patch the field's offset */
171 *((u4 *) (ra + 2)) = (u4) (fi->offset);
173 /* if the field has type long, we need to patch the second move too */
175 if (fi->type == TYPE_LNG)
176 *((u4 *) (ra + 6 + 2)) = (u4) (fi->offset + 4);
178 PATCHER_MARK_PATCHED_MONITOREXIT;
184 /* patcher_putfield ************************************************************
188 <patched call position>
189 8b 88 00 00 00 00 mov 0x00000000(%eax),%ecx
191 *******************************************************************************/
193 bool patcher_putfield(u1 *sp)
196 java_objectheader *o;
198 unresolved_field *uf;
201 /* get stuff from the stack */
203 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
204 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
205 mcode = *((u8 *) (sp + 1 * 4));
206 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 4));
208 /* calculate and set the new return address */
211 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
213 PATCHER_MONITORENTER;
215 /* get the fieldinfo */
217 if (!(fi = resolve_field_eager(uf))) {
223 /* patch back original code */
225 *((u4 *) (ra + 0)) = (u4) mcode;
226 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
228 /* if we show disassembly, we have to skip the nop's */
230 if (opt_showdisassemble)
233 /* patch the field's offset */
235 if (fi->type != TYPE_LNG) {
236 *((u4 *) (ra + 2)) = (u4) (fi->offset);
239 /* long code is very special:
241 * 8b 8c 24 00 00 00 00 mov 0x00000000(%esp),%ecx
242 * 8b 94 24 00 00 00 00 mov 0x00000000(%esp),%edx
243 * 89 8d 00 00 00 00 mov %ecx,0x00000000(%ebp)
244 * 89 95 00 00 00 00 mov %edx,0x00000000(%ebp)
247 *((u4 *) (ra + 7 + 7 + 2)) = (u4) (fi->offset);
248 *((u4 *) (ra + 7 + 7 + 6 + 2)) = (u4) (fi->offset + 4);
251 PATCHER_MARK_PATCHED_MONITOREXIT;
257 /* patcher_putfieldconst *******************************************************
261 <patched call position>
262 c7 85 00 00 00 00 7b 00 00 00 movl $0x7b,0x0(%ebp)
264 *******************************************************************************/
266 bool patcher_putfieldconst(u1 *sp)
269 java_objectheader *o;
271 unresolved_field *uf;
274 /* get stuff from the stack */
276 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
277 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
278 mcode = *((u8 *) (sp + 1 * 4));
279 uf = (unresolved_field *) *((ptrint *) (sp + 0 * 4));
281 /* calculate and set the new return address */
284 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
286 PATCHER_MONITORENTER;
288 /* get the fieldinfo */
290 if (!(fi = resolve_field_eager(uf))) {
296 /* patch back original code */
298 *((u4 *) (ra + 0)) = (u4) mcode;
299 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
301 /* if we show disassembly, we have to skip the nop's */
303 if (opt_showdisassemble)
306 /* patch the field's offset */
308 if (!IS_2_WORD_TYPE(fi->type)) {
309 *((u4 *) (ra + 2)) = (u4) (fi->offset);
312 /* long/double code is different:
314 * c7 80 00 00 00 00 c8 01 00 00 movl $0x1c8,0x0(%eax)
315 * c7 80 04 00 00 00 00 00 00 00 movl $0x0,0x4(%eax)
318 *((u4 *) (ra + 2)) = (u4) (fi->offset);
319 *((u4 *) (ra + 10 + 2)) = (u4) (fi->offset + 4);
322 PATCHER_MARK_PATCHED_MONITOREXIT;
328 /* patcher_aconst **************************************************************
332 <patched call postition>
333 c7 04 24 00 00 00 00 movl $0x0000000,(%esp)
334 b8 00 00 00 00 mov $0x0000000,%eax
336 *******************************************************************************/
338 bool patcher_aconst(u1 *sp)
341 java_objectheader *o;
343 constant_classref *cr;
346 /* get stuff from the stack */
348 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
349 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
350 mcode = *((u8 *) (sp + 1 * 4));
351 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
353 /* calculate and set the new return address */
356 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
358 PATCHER_MONITORENTER;
360 /* get the classinfo */
362 if (!(c = resolve_classref_eager(cr))) {
368 /* patch back original code */
370 *((u4 *) (ra + 0)) = (u4) mcode;
371 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
373 /* if we show disassembly, we have to skip the nop's */
375 if (opt_showdisassemble)
378 /* patch the classinfo pointer */
380 *((ptrint *) (ra + 1)) = (ptrint) c;
382 PATCHER_MARK_PATCHED_MONITOREXIT;
388 /* patcher_builtin_multianewarray **********************************************
392 <patched call position>
393 c7 04 24 02 00 00 00 movl $0x2,(%esp)
394 c7 44 24 04 00 00 00 00 movl $0x00000000,0x4(%esp)
396 83 c0 0c add $0xc,%eax
397 89 44 24 08 mov %eax,0x8(%esp)
398 b8 00 00 00 00 mov $0x00000000,%eax
401 *******************************************************************************/
403 bool patcher_builtin_multianewarray(u1 *sp)
406 java_objectheader *o;
408 constant_classref *cr;
411 /* get stuff from the stack */
413 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
414 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
415 mcode = *((u8 *) (sp + 1 * 4));
416 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
418 /* calculate and set the new return address */
421 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
423 PATCHER_MONITORENTER;
425 /* get the classinfo */
427 if (!(c = resolve_classref_eager(cr))) {
433 /* patch back original code */
435 *((u4 *) (ra + 0)) = (u4) mcode;
436 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
438 /* if we show disassembly, we have to skip the nop's */
440 if (opt_showdisassemble)
443 /* patch the classinfo pointer */
445 *((ptrint *) (ra + 7 + 4)) = (ptrint) c;
447 /* patch new function address */
449 *((ptrint *) (ra + 7 + 8 + 2 + 3 + 4 + 1)) = (ptrint) BUILTIN_multianewarray;
451 PATCHER_MARK_PATCHED_MONITOREXIT;
457 /* patcher_builtin_arraycheckcast **********************************************
461 <patched call position>
462 c7 44 24 04 00 00 00 00 movl $0x00000000,0x4(%esp)
463 ba 00 00 00 00 mov $0x00000000,%edx
466 *******************************************************************************/
468 bool patcher_builtin_arraycheckcast(u1 *sp)
471 java_objectheader *o;
473 constant_classref *cr;
476 /* get stuff from the stack */
478 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
479 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
480 mcode = *((u8 *) (sp + 1 * 4));
481 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
483 /* calculate and set the new return address */
486 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
488 PATCHER_MONITORENTER;
490 /* get the classinfo */
492 if (!(c = resolve_classref_eager(cr))) {
498 /* patch back original code */
500 *((u4 *) (ra + 0)) = (u4) mcode;
501 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
503 /* if we show disassembly, we have to skip the nop's */
505 if (opt_showdisassemble)
508 /* patch the classinfo pointer */
510 *((ptrint *) (ra + 4)) = (ptrint) c;
512 /* patch new function address */
514 *((ptrint *) (ra + 8 + 1)) = (ptrint) BUILTIN_arraycheckcast;
516 PATCHER_MARK_PATCHED_MONITOREXIT;
522 /* patcher_invokestatic_special ************************************************
526 <patched call position>
527 b9 00 00 00 00 mov $0x00000000,%ecx
530 *******************************************************************************/
532 bool patcher_invokestatic_special(u1 *sp)
535 java_objectheader *o;
537 unresolved_method *um;
540 /* get stuff from the stack */
542 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
543 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
544 mcode = *((u8 *) (sp + 1 * 4));
545 um = (unresolved_method *) *((ptrint *) (sp + 0 * 4));
547 /* calculate and set the new return address */
550 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
552 PATCHER_MONITORENTER;
554 /* get the fieldinfo */
556 if (!(m = resolve_method_eager(um))) {
562 /* patch back original code */
564 *((u4 *) (ra + 0)) = (u4) mcode;
565 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
567 /* if we show disassembly, we have to skip the nop's */
569 if (opt_showdisassemble)
572 /* patch stubroutine */
574 *((ptrint *) (ra + 1)) = (ptrint) m->stubroutine;
576 PATCHER_MARK_PATCHED_MONITOREXIT;
582 /* patcher_invokevirtual *******************************************************
586 <patched call position>
587 8b 08 mov (%eax),%ecx
588 8b 81 00 00 00 00 mov 0x00000000(%ecx),%eax
591 *******************************************************************************/
593 bool patcher_invokevirtual(u1 *sp)
596 java_objectheader *o;
598 unresolved_method *um;
601 /* get stuff from the stack */
603 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
604 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
605 mcode = *((u8 *) (sp + 1 * 4));
606 um = (unresolved_method *) *((ptrint *) (sp + 0 * 4));
608 /* calculate and set the new return address */
611 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
613 PATCHER_MONITORENTER;
615 /* get the fieldinfo */
617 if (!(m = resolve_method_eager(um))) {
623 /* patch back original code */
625 *((u4 *) (ra + 0)) = (u4) mcode;
626 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
628 /* if we show disassembly, we have to skip the nop's */
630 if (opt_showdisassemble)
633 /* patch vftbl index */
635 *((s4 *) (ra + 2 + 2)) = (s4) (OFFSET(vftbl_t, table[0]) +
636 sizeof(methodptr) * m->vftblindex);
638 PATCHER_MARK_PATCHED_MONITOREXIT;
644 /* patcher_invokeinterface *****************************************************
648 <patched call position>
649 8b 00 mov (%eax),%eax
650 8b 88 00 00 00 00 mov 0x00000000(%eax),%ecx
651 8b 81 00 00 00 00 mov 0x00000000(%ecx),%eax
654 *******************************************************************************/
656 bool patcher_invokeinterface(u1 *sp)
659 java_objectheader *o;
661 unresolved_method *um;
664 /* get stuff from the stack */
666 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
667 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
668 mcode = *((u8 *) (sp + 1 * 4));
669 um = (unresolved_method *) *((ptrint *) (sp + 0 * 4));
671 /* calculate and set the new return address */
674 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
676 PATCHER_MONITORENTER;
678 /* get the fieldinfo */
680 if (!(m = resolve_method_eager(um))) {
686 /* patch back original code */
688 *((u4 *) (ra + 0)) = (u4) mcode;
689 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
691 /* if we show disassembly, we have to skip the nop's */
693 if (opt_showdisassemble)
696 /* patch interfacetable index */
698 *((s4 *) (ra + 2 + 2)) = (s4) (OFFSET(vftbl_t, interfacetable[0]) -
699 sizeof(methodptr) * m->class->index);
701 /* patch method offset */
703 *((s4 *) (ra + 2 + 6 + 2)) =
704 (s4) (sizeof(methodptr) * (m - m->class->methods));
706 PATCHER_MARK_PATCHED_MONITOREXIT;
712 /* patcher_checkcast_instanceof_flags ******************************************
716 <patched call position>
717 b9 00 00 00 00 mov $0x00000000,%ecx
719 *******************************************************************************/
721 bool patcher_checkcast_instanceof_flags(u1 *sp)
724 java_objectheader *o;
726 constant_classref *cr;
729 /* get stuff from the stack */
731 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
732 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
733 mcode = *((u8 *) (sp + 1 * 4));
734 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
736 /* calculate and set the new return address */
739 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
741 PATCHER_MONITORENTER;
743 /* get the fieldinfo */
745 if (!(c = resolve_classref_eager(cr))) {
751 /* patch back original code */
753 *((u4 *) (ra + 0)) = (u4) mcode;
754 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
756 /* if we show disassembly, we have to skip the nop's */
758 if (opt_showdisassemble)
761 /* patch class flags */
763 *((s4 *) (ra + 1)) = (s4) c->flags;
765 PATCHER_MARK_PATCHED_MONITOREXIT;
771 /* patcher_checkcast_instanceof_interface **************************************
775 <patched call position>
776 8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
777 81 ea 00 00 00 00 sub $0x00000000,%edx
779 0f 8e 00 00 00 00 jle 0x00000000
780 8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
782 *******************************************************************************/
784 bool patcher_checkcast_instanceof_interface(u1 *sp)
787 java_objectheader *o;
789 constant_classref *cr;
792 /* get stuff from the stack */
794 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
795 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
796 mcode = *((u8 *) (sp + 1 * 4));
797 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
799 /* calculate and set the new return address */
802 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
804 PATCHER_MONITORENTER;
806 /* get the fieldinfo */
808 if (!(c = resolve_classref_eager(cr))) {
814 /* patch back original code */
816 *((u4 *) (ra + 0)) = (u4) mcode;
817 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
819 /* if we show disassembly, we have to skip the nop's */
821 if (opt_showdisassemble)
824 /* patch super class index */
826 *((s4 *) (ra + 6 + 2)) = (s4) c->index;
828 *((s4 *) (ra + 6 + 6 + 2 + 6 + 2)) =
829 (s4) (OFFSET(vftbl_t, interfacetable[0]) -
830 c->index * sizeof(methodptr*));
832 PATCHER_MARK_PATCHED_MONITOREXIT;
838 /* patcher_checkcast_class *****************************************************
842 <patched call position>
843 ba 00 00 00 00 mov $0x00000000,%edx
844 8b 89 00 00 00 00 mov 0x00000000(%ecx),%ecx
845 8b 92 00 00 00 00 mov 0x00000000(%edx),%edx
847 ba 00 00 00 00 mov $0x00000000,%edx
849 *******************************************************************************/
851 bool patcher_checkcast_class(u1 *sp)
854 java_objectheader *o;
856 constant_classref *cr;
859 /* get stuff from the stack */
861 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
862 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
863 mcode = *((u8 *) (sp + 1 * 4));
864 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
866 /* calculate and set the new return address */
869 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
871 PATCHER_MONITORENTER;
873 /* get the fieldinfo */
875 if (!(c = resolve_classref_eager(cr))) {
881 /* patch back original code */
883 *((u4 *) (ra + 0)) = (u4) mcode;
884 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
886 /* if we show disassembly, we have to skip the nop's */
888 if (opt_showdisassemble)
891 /* patch super class' vftbl */
893 *((ptrint *) (ra + 1)) = (ptrint) c->vftbl;
894 *((ptrint *) (ra + 5 + 6 + 6 + 2 + 1)) = (ptrint) c->vftbl;
896 PATCHER_MARK_PATCHED_MONITOREXIT;
902 /* patcher_instanceof_class ****************************************************
906 <patched call position>
907 b9 00 00 00 00 mov $0x0,%ecx
908 8b 40 14 mov 0x14(%eax),%eax
909 8b 51 18 mov 0x18(%ecx),%edx
910 8b 49 14 mov 0x14(%ecx),%ecx
912 *******************************************************************************/
914 bool patcher_instanceof_class(u1 *sp)
917 java_objectheader *o;
919 constant_classref *cr;
922 /* get stuff from the stack */
924 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
925 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
926 mcode = *((u8 *) (sp + 1 * 4));
927 cr = (constant_classref *) *((ptrint *) (sp + 0 * 4));
929 /* calculate and set the new return address */
932 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
934 PATCHER_MONITORENTER;
936 /* get the fieldinfo */
938 if (!(c = resolve_classref_eager(cr))) {
944 /* patch back original code */
946 *((u4 *) (ra + 0)) = (u4) mcode;
947 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
949 /* if we show disassembly, we have to skip the nop's */
951 if (opt_showdisassemble)
954 /* patch super class' vftbl */
956 *((ptrint *) (ra + 1)) = (ptrint) c->vftbl;
958 PATCHER_MARK_PATCHED_MONITOREXIT;
964 /* patcher_clinit **************************************************************
966 Is used int PUT/GETSTATIC and native stub.
970 <patched call position>
972 *******************************************************************************/
974 bool patcher_clinit(u1 *sp)
977 java_objectheader *o;
981 /* get stuff from the stack */
983 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
984 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
985 mcode = *((u8 *) (sp + 1 * 4));
986 c = (classinfo *) *((ptrint *) (sp + 0 * 4));
988 /* calculate and set the new return address */
991 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
993 PATCHER_MONITORENTER;
995 /* check if the class is initialized */
997 if (!(c->state & CLASS_INITIALIZED)) {
998 if (!initialize_class(c)) {
1005 /* patch back original code */
1007 *((u4 *) (ra + 0)) = (u4) mcode;
1008 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
1010 PATCHER_MARK_PATCHED_MONITOREXIT;
1016 /* patcher_athrow_areturn ******************************************************
1020 <patched call position>
1022 *******************************************************************************/
1024 #ifdef ENABLE_VERIFIER
1025 bool patcher_athrow_areturn(u1 *sp)
1028 java_objectheader *o;
1030 unresolved_class *uc;
1033 /* get stuff from the stack */
1035 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
1036 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
1037 mcode = *((u8 *) (sp + 1 * 4));
1038 uc = (unresolved_class *) *((ptrint *) (sp + 0 * 4));
1040 /* calculate and set the new return address */
1043 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
1045 PATCHER_MONITORENTER;
1047 /* resolve the class */
1049 if (!resolve_class(uc, resolveEager, false, &c)) {
1050 PATCHER_MONITOREXIT;
1055 /* patch back original code */
1057 *((u4 *) (ra + 0)) = (u4) mcode;
1058 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
1060 PATCHER_MARK_PATCHED_MONITOREXIT;
1064 #endif /* ENABLE_VERIFIER */
1067 /* patcher_resolve_native ******************************************************
1069 Is used in native stub.
1073 <patched call position>
1074 c7 44 24 04 28 90 01 40 movl $0x40019028,0x4(%esp)
1076 *******************************************************************************/
1078 #if !defined(ENABLE_STATICVM)
1079 bool patcher_resolve_native(u1 *sp)
1082 java_objectheader *o;
1087 /* get stuff from the stack */
1089 ra = (u1 *) *((ptrint *) (sp + 4 * 4));
1090 o = (java_objectheader *) *((ptrint *) (sp + 3 * 4));
1091 mcode = *((u8 *) (sp + 1 * 4));
1092 m = (methodinfo *) *((ptrint *) (sp + 0 * 4));
1094 /* calculate and set the new return address */
1097 *((ptrint *) (sp + 4 * 4)) = (ptrint) ra;
1099 PATCHER_MONITORENTER;
1101 /* resolve native function */
1103 if (!(f = native_resolve_function(m))) {
1104 PATCHER_MONITOREXIT;
1109 /* patch back original code */
1111 *((u4 *) (ra + 0)) = (u4) mcode;
1112 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
1114 /* if we show disassembly, we have to skip the nop's */
1116 if (opt_showdisassemble)
1119 /* patch native function pointer */
1121 *((ptrint *) (ra + 4)) = (ptrint) f;
1123 PATCHER_MARK_PATCHED_MONITOREXIT;
1127 #endif /* !defined(ENABLE_STATICVM) */
1131 * These are local overrides for various environment variables in Emacs.
1132 * Please do not remove this and leave it at the end of the file, where
1133 * Emacs will automagically detect them.
1134 * ---------------------------------------------------------------------
1137 * indent-tabs-mode: t
1141 * vim:noexpandtab:sw=4:ts=4: