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 3173 2005-09-12 08:09:53Z 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 /* patcher_get_putstatic *******************************************************
54 <patched call position>
55 4d 8b 15 86 fe ff ff mov -378(%rip),%r10
56 49 8b 32 mov (%r10),%rsi
58 *******************************************************************************/
60 bool patcher_get_putstatic(u1 *sp)
70 /* get stuff from the stack */
72 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
73 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
74 mcode = *((u8 *) (sp + 2 * 8));
75 uf = (unresolved_field *) *((ptrint *) (sp + 1 * 8));
76 disp = *((s4 *) (sp + 0 * 8));
78 /* calculate and set the new return address */
81 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
85 /* get the fieldinfo */
87 if (!(fi = helper_resolve_fieldinfo(uf))) {
93 /* check if the field's class is initialized */
95 if (!initialize_class(fi->class)) {
101 /* patch back original code */
103 *((u8 *) ra) = mcode;
105 /* if we show disassembly, we have to skip the nop's */
107 if (opt_showdisassemble)
110 /* get RIP offset from machine instruction */
112 offset = *((u4 *) (ra + 3));
114 /* patch the field value's address (+ 7: is the size of the RIP move) */
116 *((ptrint *) (ra + 7 + offset)) = (ptrint) &(fi->value);
118 PATCHER_MARK_PATCHED_MONITOREXIT;
124 /* patcher_get_putfield ********************************************************
128 <patched call position>
129 45 8b 8f 00 00 00 00 mov 0x0(%r15),%r9d
131 *******************************************************************************/
133 bool patcher_get_putfield(u1 *sp)
136 java_objectheader *o;
138 unresolved_field *uf;
142 /* get stuff from the stack */
144 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
145 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
146 mcode = *((u8 *) (sp + 2 * 8));
147 uf = (unresolved_field *) *((ptrint *) (sp + 1 * 8));
149 /* calculate and set the new return address */
152 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
154 PATCHER_MONITORENTER;
156 /* get the fieldinfo */
158 if (!(fi = helper_resolve_fieldinfo(uf))) {
164 /* patch back original code (instruction code is smaller than 8 bytes) */
166 *((u4 *) (ra + 0)) = (u4) mcode;
167 *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
169 /* if we show disassembly, we have to skip the nop's */
171 if (opt_showdisassemble)
174 /* patch the field's offset: we check for the field type, because the */
175 /* instructions have different lengths */
177 if (IS_INT_LNG_TYPE(fi->type)) {
178 /* check for special case: %rsp or %r12 as base register */
183 *((u4 *) (ra + 4)) = (u4) (fi->offset);
185 *((u4 *) (ra + 3)) = (u4) (fi->offset);
188 /* check for special case: %rsp or %r12 as base register */
193 *((u4 *) (ra + 6)) = (u4) (fi->offset);
195 *((u4 *) (ra + 5)) = (u4) (fi->offset);
198 PATCHER_MARK_PATCHED_MONITOREXIT;
204 /* patcher_putfieldconst *******************************************************
208 <patched call position>
209 41 c7 85 00 00 00 00 7b 00 00 00 movl $0x7b,0x0(%r13)
211 *******************************************************************************/
213 bool patcher_putfieldconst(u1 *sp)
216 java_objectheader *o;
218 unresolved_field *uf;
221 /* get stuff from the stack */
223 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
224 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
225 mcode = *((u8 *) (sp + 2 * 8));
226 uf = (unresolved_field *) *((ptrint *) (sp + 1 * 8));
228 /* calculate and set the new return address */
231 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
233 PATCHER_MONITORENTER;
235 /* get the fieldinfo */
237 if (!(fi = helper_resolve_fieldinfo(uf))) {
243 /* patch back original code */
245 *((u8 *) ra) = mcode;
247 /* if we show disassembly, we have to skip the nop's */
249 if (opt_showdisassemble)
252 /* patch the field's offset */
254 if (IS_2_WORD_TYPE(fi->type) || IS_ADR_TYPE(fi->type)) {
255 /* handle special case when the base register is %r12 */
257 if (*(ra + 2) == 0x84) {
258 *((u4 *) (ra + 4)) = (u4) (fi->offset);
259 *((u4 *) (ra + 12 + 4)) = (u4) (fi->offset + 4);
262 *((u4 *) (ra + 3)) = (u4) (fi->offset);
263 *((u4 *) (ra + 11 + 3)) = (u4) (fi->offset + 4);
267 /* handle special case when the base register is %r12 */
269 if (*(ra + 2) == 0x84)
270 *((u4 *) (ra + 4)) = (u4) (fi->offset);
272 *((u4 *) (ra + 3)) = (u4) (fi->offset);
275 PATCHER_MARK_PATCHED_MONITOREXIT;
281 /* patcher_builtin_new *********************************************************
285 48 bf a0 f0 92 00 00 00 00 00 mov $0x92f0a0,%rdi
286 <patched call position>
287 48 b8 00 00 00 00 00 00 00 00 mov $0x0,%rax
290 *******************************************************************************/
292 bool patcher_builtin_new(u1 *sp)
295 java_objectheader *o;
297 constant_classref *cr;
300 /* get stuff from the stack */
302 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
303 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
304 mcode = *((u8 *) (sp + 2 * 8));
305 cr = (constant_classref *) *((ptrint *) (sp + 1 * 8));
307 /* calculate and set the new return address */
310 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
312 PATCHER_MONITORENTER;
314 /* get the classinfo */
316 if (!(c = helper_resolve_classinfo(cr))) {
322 if (!initialize_class(c)) {
328 /* patch back original code */
330 *((u8 *) (ra + 10)) = mcode;
332 /* patch the classinfo pointer */
334 *((ptrint *) (ra + 2)) = (ptrint) c;
336 /* if we show disassembly, we have to skip the nop's */
338 if (opt_showdisassemble)
341 /* patch new function address */
343 *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_new;
345 PATCHER_MARK_PATCHED_MONITOREXIT;
351 /* patcher_builtin_newarray ****************************************************
355 48 be 88 13 9b 00 00 00 00 00 mov $0x9b1388,%rsi
356 <patched call position>
357 48 b8 00 00 00 00 00 00 00 00 mov $0x0,%rax
360 *******************************************************************************/
362 bool patcher_builtin_newarray(u1 *sp)
365 java_objectheader *o;
367 constant_classref *cr;
370 /* get stuff from the stack */
372 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
373 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
374 mcode = *((u8 *) (sp + 2 * 8));
375 cr = (constant_classref *) *((ptrint *) (sp + 1 * 8));
377 /* calculate and set the new return address */
380 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
382 PATCHER_MONITORENTER;
384 /* get the classinfo */
386 if (!(c = helper_resolve_classinfo(cr))) {
392 /* patch back original code */
394 *((u8 *) (ra + 10)) = mcode;
396 /* patch the class' vftbl pointer */
398 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
400 /* if we show disassembly, we have to skip the nop's */
402 if (opt_showdisassemble)
405 /* patch new function address */
407 *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_newarray;
409 PATCHER_MARK_PATCHED_MONITOREXIT;
415 /* patcher_builtin_multianewarray **********************************************
419 <patched call position>
420 48 bf 02 00 00 00 00 00 00 00 mov $0x2,%rdi
421 48 be 30 40 b2 00 00 00 00 00 mov $0xb24030,%rsi
422 48 89 e2 mov %rsp,%rdx
423 48 b8 7c 96 4b 00 00 00 00 00 mov $0x4b967c,%rax
426 *******************************************************************************/
428 bool patcher_builtin_multianewarray(u1 *sp)
431 java_objectheader *o;
433 constant_classref *cr;
436 /* get stuff from the stack */
438 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
439 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
440 mcode = *((u8 *) (sp + 2 * 8));
441 cr = (constant_classref *) *((ptrint *) (sp + 1 * 8));
443 /* calculate and set the new return address */
446 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
448 PATCHER_MONITORENTER;
450 /* get the classinfo */
452 if (!(c = helper_resolve_classinfo(cr))) {
458 /* patch back original code */
460 *((u8 *) ra) = mcode;
462 /* if we show disassembly, we have to skip the nop's */
464 if (opt_showdisassemble)
467 /* patch the class' vftbl pointer */
469 *((ptrint *) (ra + 10 + 2)) = (ptrint) c->vftbl;
471 /* patch new function address */
473 *((ptrint *) (ra + 10 + 10 + 3 + 2)) = (ptrint) BUILTIN_multianewarray;
475 PATCHER_MARK_PATCHED_MONITOREXIT;
481 /* patcher_builtin_arraycheckcast **********************************************
485 <patched call position>
486 48 be b8 3f b2 00 00 00 00 00 mov $0xb23fb8,%rsi
487 48 b8 00 00 00 00 00 00 00 00 mov $0x0,%rax
490 *******************************************************************************/
492 bool patcher_builtin_arraycheckcast(u1 *sp)
495 java_objectheader *o;
497 constant_classref *cr;
500 /* get stuff from the stack */
502 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
503 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
504 mcode = *((u8 *) (sp + 2 * 8));
505 cr = (constant_classref *) *((ptrint *) (sp + 1 * 8));
507 /* calculate and set the new return address */
510 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
512 PATCHER_MONITORENTER;
514 /* get the classinfo */
516 if (!(c = helper_resolve_classinfo(cr))) {
522 /* patch back original code */
524 *((u8 *) ra) = mcode;
526 /* if we show disassembly, we have to skip the nop's */
528 if (opt_showdisassemble)
531 /* patch the class' vftbl pointer */
533 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
535 /* patch new function address */
537 *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_arraycheckcast;
539 PATCHER_MARK_PATCHED_MONITOREXIT;
545 /* patcher_builtin_arrayinstanceof *********************************************
549 48 be 30 3c b2 00 00 00 00 00 mov $0xb23c30,%rsi
550 <patched call position>
551 48 b8 00 00 00 00 00 00 00 00 mov $0x0,%rax
554 *******************************************************************************/
556 bool patcher_builtin_arrayinstanceof(u1 *sp)
559 java_objectheader *o;
561 constant_classref *cr;
564 /* get stuff from the stack */
566 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
567 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
568 mcode = *((u8 *) (sp + 2 * 8));
569 cr = (constant_classref *) *((ptrint *) (sp + 1 * 8));
571 /* calculate and set the new return address */
574 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
576 PATCHER_MONITORENTER;
578 /* get the classinfo */
580 if (!(c = helper_resolve_classinfo(cr))) {
586 /* patch back original code */
588 *((u8 *) (ra + 10)) = mcode;
590 /* patch the class' vftbl pointer */
592 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
594 /* if we show disassembly, we have to skip the nop's */
596 if (opt_showdisassemble)
599 /* patch new function address */
601 *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_arrayinstanceof;
603 PATCHER_MARK_PATCHED_MONITOREXIT;
609 /* patcher_invokestatic_special ************************************************
613 <patched call position>
614 49 ba 00 00 00 00 00 00 00 00 mov $0x0,%r10
617 *******************************************************************************/
619 bool patcher_invokestatic_special(u1 *sp)
622 java_objectheader *o;
624 unresolved_method *um;
627 /* get stuff from the stack */
629 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
630 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
631 mcode = *((u8 *) (sp + 2 * 8));
632 um = (unresolved_method *) *((ptrint *) (sp + 1 * 8));
634 /* calculate and set the new return address */
637 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
639 PATCHER_MONITORENTER;
641 /* get the fieldinfo */
643 if (!(m = helper_resolve_methodinfo(um))) {
648 /* patch back original code */
650 *((u8 *) ra) = mcode;
652 /* if we show disassembly, we have to skip the nop's */
654 if (opt_showdisassemble)
657 /* patch stubroutine */
659 *((ptrint *) (ra + 2)) = (ptrint) m->stubroutine;
661 PATCHER_MARK_PATCHED_MONITOREXIT;
667 /* patcher_invokevirtual *******************************************************
671 <patched call position>
672 4c 8b 17 mov (%rdi),%r10
673 49 8b 82 00 00 00 00 mov 0x0(%r10),%rax
676 *******************************************************************************/
678 bool patcher_invokevirtual(u1 *sp)
681 java_objectheader *o;
683 unresolved_method *um;
686 /* get stuff from the stack */
688 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
689 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
690 mcode = *((u8 *) (sp + 2 * 8));
691 um = (unresolved_method *) *((ptrint *) (sp + 1 * 8));
693 /* calculate and set the new return address */
696 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
698 PATCHER_MONITORENTER;
700 /* get the fieldinfo */
702 if (!(m = helper_resolve_methodinfo(um))) {
708 /* patch back original code */
710 *((u8 *) ra) = mcode;
712 /* if we show disassembly, we have to skip the nop's */
714 if (opt_showdisassemble)
717 /* patch vftbl index */
719 *((s4 *) (ra + 3 + 3)) = (s4) (OFFSET(vftbl_t, table[0]) +
720 sizeof(methodptr) * m->vftblindex);
722 PATCHER_MARK_PATCHED_MONITOREXIT;
728 /* patcher_invokeinterface *****************************************************
732 <patched call position>
733 4c 8b 17 mov (%rdi),%r10
734 4d 8b 92 00 00 00 00 mov 0x0(%r10),%r10
735 49 8b 82 00 00 00 00 mov 0x0(%r10),%rax
738 *******************************************************************************/
740 bool patcher_invokeinterface(u1 *sp)
743 java_objectheader *o;
745 unresolved_method *um;
748 /* get stuff from the stack */
750 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
751 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
752 mcode = *((u8 *) (sp + 2 * 8));
753 um = (unresolved_method *) *((ptrint *) (sp + 1 * 8));
755 /* calculate and set the new return address */
758 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
760 PATCHER_MONITORENTER;
762 /* get the fieldinfo */
764 if (!(m = helper_resolve_methodinfo(um))) {
770 /* patch back original code */
772 *((u8 *) ra) = mcode;
774 /* if we show disassembly, we have to skip the nop's */
776 if (opt_showdisassemble)
779 /* patch interfacetable index */
781 *((s4 *) (ra + 3 + 3)) = (s4) (OFFSET(vftbl_t, interfacetable[0]) -
782 sizeof(methodptr) * m->class->index);
784 /* patch method offset */
786 *((s4 *) (ra + 3 + 7 + 3)) =
787 (s4) (sizeof(methodptr) * (m - m->class->methods));
789 PATCHER_MARK_PATCHED_MONITOREXIT;
795 /* patcher_checkcast_instanceof_flags ******************************************
799 <patched call position>
800 41 ba 00 00 00 00 mov $0x0,%r10d
801 41 81 e2 00 02 00 00 and $0x200,%r10d
802 0f 84 35 00 00 00 je 0x00002aaaaab01479
804 *******************************************************************************/
806 bool patcher_checkcast_instanceof_flags(u1 *sp)
809 java_objectheader *o;
811 constant_classref *cr;
814 /* get stuff from the stack */
816 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
817 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
818 mcode = *((u8 *) (sp + 2 * 8));
819 cr = (constant_classref *) *((ptrint *) (sp + 1 * 8));
821 /* calculate and set the new return address */
824 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
826 PATCHER_MONITORENTER;
828 /* get the fieldinfo */
830 if (!(c = helper_resolve_classinfo(cr))) {
836 /* patch back original code */
838 *((u8 *) ra) = mcode;
840 /* if we show disassembly, we have to skip the nop's */
842 if (opt_showdisassemble)
845 /* patch class flags */
847 *((s4 *) (ra + 2)) = (s4) c->flags;
849 PATCHER_MARK_PATCHED_MONITOREXIT;
855 /* patcher_checkcast_instanceof_interface **************************************
859 <patched call position>
860 45 8b 9a 1c 00 00 00 mov 0x1c(%r10),%r11d
861 49 81 eb 00 00 00 00 sub $0x0,%r11
862 4d 85 db test %r11,%r11
863 0f 8e 94 04 00 00 jle 0x00002aaaaab018f8
864 4d 8b 9a 00 00 00 00 mov 0x0(%r10),%r11
866 *******************************************************************************/
868 bool patcher_checkcast_instanceof_interface(u1 *sp)
871 java_objectheader *o;
873 constant_classref *cr;
876 /* get stuff from the stack */
878 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
879 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
880 mcode = *((u8 *) (sp + 2 * 8));
881 cr = (constant_classref *) *((ptrint *) (sp + 1 * 8));
883 /* calculate and set the new return address */
886 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
888 PATCHER_MONITORENTER;
890 /* get the fieldinfo */
892 if (!(c = helper_resolve_classinfo(cr))) {
898 /* patch back original code */
900 *((u8 *) ra) = mcode;
902 /* if we show disassembly, we have to skip the nop's */
904 if (opt_showdisassemble)
907 /* patch super class index */
909 *((s4 *) (ra + 7 + 3)) = (s4) c->index;
911 *((s4 *) (ra + 7 + 7 + 3 + 6 + 3)) =
912 (s4) (OFFSET(vftbl_t, interfacetable[0]) -
913 c->index * sizeof(methodptr*));
915 PATCHER_MARK_PATCHED_MONITOREXIT;
921 /* patcher_checkcast_class *****************************************************
925 <patched call position>
926 49 bb 00 00 00 00 00 00 00 00 mov $0x0,%r11
927 45 8b 92 20 00 00 00 mov 0x20(%r10),%r10d
928 45 8b 9b 20 00 00 00 mov 0x20(%r11),%r11d
929 4d 29 da sub %r11,%r10
930 49 bb 00 00 00 00 00 00 00 00 mov $0x0,%r11
932 *******************************************************************************/
934 bool patcher_checkcast_class(u1 *sp)
937 java_objectheader *o;
939 constant_classref *cr;
942 /* get stuff from the stack */
944 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
945 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
946 mcode = *((u8 *) (sp + 2 * 8));
947 cr = (constant_classref *) *((ptrint *) (sp + 1 * 8));
949 /* calculate and set the new return address */
952 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
954 PATCHER_MONITORENTER;
956 /* get the fieldinfo */
958 if (!(c = helper_resolve_classinfo(cr))) {
964 /* patch back original code */
966 *((u8 *) ra) = mcode;
968 /* if we show disassembly, we have to skip the nop's */
970 if (opt_showdisassemble)
973 /* patch super class' vftbl */
975 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
976 *((ptrint *) (ra + 10 + 7 + 7 + 3 + 2)) = (ptrint) c->vftbl;
978 PATCHER_MARK_PATCHED_MONITOREXIT;
984 /* patcher_instanceof_class ****************************************************
988 <patched call position>
989 49 ba 00 00 00 00 00 00 00 00 mov $0x0,%r10
991 *******************************************************************************/
993 bool patcher_instanceof_class(u1 *sp)
996 java_objectheader *o;
998 constant_classref *cr;
1001 /* get stuff from the stack */
1003 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
1004 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
1005 mcode = *((u8 *) (sp + 2 * 8));
1006 cr = (constant_classref *) *((ptrint *) (sp + 1 * 8));
1008 /* calculate and set the new return address */
1011 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
1013 PATCHER_MONITORENTER;
1015 /* get the fieldinfo */
1017 if (!(c = helper_resolve_classinfo(cr))) {
1018 PATCHER_MONITOREXIT;
1023 /* patch back original code */
1025 *((u8 *) ra) = mcode;
1027 /* if we show disassembly, we have to skip the nop's */
1029 if (opt_showdisassemble)
1032 /* patch super class' vftbl */
1034 *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
1036 PATCHER_MARK_PATCHED_MONITOREXIT;
1042 /* patcher_clinit **************************************************************
1044 May be used for GET/PUTSTATIC and in native stub.
1048 <patched call position>
1049 4d 8b 15 92 ff ff ff mov -110(%rip),%r10
1050 49 89 1a mov %rbx,(%r10)
1052 *******************************************************************************/
1054 bool patcher_clinit(u1 *sp)
1057 java_objectheader *o;
1061 /* get stuff from the stack */
1063 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
1064 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
1065 mcode = *((u8 *) (sp + 2 * 8));
1066 c = (classinfo *) *((ptrint *) (sp + 1 * 8));
1068 /* calculate and set the new return address */
1071 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
1073 PATCHER_MONITORENTER;
1075 /* check if the class is initialized */
1077 if (!initialize_class(c)) {
1078 PATCHER_MONITOREXIT;
1083 /* patch back original code */
1085 *((u8 *) ra) = mcode;
1087 PATCHER_MARK_PATCHED_MONITOREXIT;
1093 /* patcher_resolve_native ******************************************************
1097 <patched call position>
1098 48 b8 00 00 00 00 00 00 00 00 mov $0x0,%rax
1099 48 ff d0 callq *%rax
1101 *******************************************************************************/
1103 #if !defined(ENABLE_STATICVM)
1104 bool patcher_resolve_native(u1 *sp)
1107 java_objectheader *o;
1112 /* get stuff from the stack */
1114 ra = (u1 *) *((ptrint *) (sp + 4 * 8));
1115 o = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
1116 mcode = *((u8 *) (sp + 2 * 8));
1117 m = (methodinfo *) *((ptrint *) (sp + 1 * 8));
1119 /* calculate and set the new return address */
1122 *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
1124 PATCHER_MONITORENTER;
1126 /* resolve native function */
1128 if (!(f = native_resolve_function(m))) {
1129 PATCHER_MONITOREXIT;
1134 /* patch back original code */
1136 *((u8 *) ra) = mcode;
1138 /* if we show disassembly, we have to skip the nop's */
1140 if (opt_showdisassemble)
1143 /* patch native function pointer */
1145 *((ptrint *) (ra + 2)) = (ptrint) f;
1147 PATCHER_MARK_PATCHED_MONITOREXIT;
1151 #endif /* !defined(ENABLE_STATICVM) */
1155 * These are local overrides for various environment variables in Emacs.
1156 * Please do not remove this and leave it at the end of the file, where
1157 * Emacs will automagically detect them.
1158 * ---------------------------------------------------------------------
1161 * indent-tabs-mode: t
1165 * vim:noexpandtab:sw=4:ts=4: