* patcher_get_putstatic: Replaced c->initialized by
[cacao.git] / src / vm / jit / alpha / patcher.c
1 /* src/vm/jit/alpha/patcher.c - Alpha code patching functions
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Christian Thalinger
28
29    Changes:
30
31    $Id: patcher.c 3868 2005-12-03 15:25:18Z twisti $
32
33 */
34
35
36 #include "config.h"
37 #include "vm/types.h"
38
39 #include "mm/memory.h"
40 #include "native/native.h"
41 #include "vm/builtin.h"
42 #include "vm/field.h"
43 #include "vm/initialize.h"
44 #include "vm/options.h"
45 #include "vm/references.h"
46 #include "vm/resolve.h"
47 #include "vm/jit/asmpart.h"
48 #include "vm/jit/patcher.h"
49
50
51 /* patcher_get_putstatic *******************************************************
52
53    Machine code:
54
55    <patched call position>
56    a73bff98    ldq     t11,-104(pv)
57    a2590000    ldl     a2,0(t11)
58
59 *******************************************************************************/
60
61 bool patcher_get_putstatic(u1 *sp)
62 {
63         u1                *ra;
64         java_objectheader *o;
65         u4                 mcode;
66         unresolved_field  *uf;
67         s4                 disp;
68         u1                *pv;
69         fieldinfo         *fi;
70
71         /* get stuff from the stack */
72
73         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
74         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
75         mcode =                       *((u4 *)     (sp + 3 * 8));
76         uf    = (unresolved_field *)  *((ptrint *) (sp + 2 * 8));
77         disp  =                       *((s4 *)     (sp + 1 * 8));
78         pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
79
80         /* calculate and set the new return address */
81
82         ra = ra - 1 * 4;
83         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
84
85         PATCHER_MONITORENTER;
86
87         /* get the fieldinfo */
88
89         if (!(fi = resolve_field_eager(uf))) {
90                 PATCHER_MONITOREXIT;
91
92                 return false;
93         }
94
95         /* check if the field's class is initialized */
96
97         if (!(fi->class->state & CLASS_INITIALIZED)) {
98                 if (!initialize_class(fi->class)) {
99                         PATCHER_MONITOREXIT;
100
101                         return false;
102                 }
103         }
104
105         /* patch back original code */
106
107         *((u4 *) ra) = mcode;
108
109         /* synchronize instruction cache */
110
111         asm_sync_instruction_cache();
112
113         /* patch the field value's address */
114
115         *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
116
117         PATCHER_MARK_PATCHED_MONITOREXIT;
118
119         return true;
120 }
121
122
123 /* patcher_get_putfield ********************************************************
124
125    Machine code:
126
127    <patched call position>
128    a2af0020    ldl     a5,32(s6)
129
130 *******************************************************************************/
131
132 bool patcher_get_putfield(u1 *sp)
133 {
134         u1                *ra;
135         java_objectheader *o;
136         u4                 mcode;
137         unresolved_field  *uf;
138         fieldinfo         *fi;
139
140         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
141         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
142         mcode =                       *((u4 *)     (sp + 3 * 8));
143         uf    = (unresolved_field *)  *((ptrint *) (sp + 2 * 8));
144
145         /* calculate and set the new return address */
146
147         ra = ra - 1 * 4;
148         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
149
150         PATCHER_MONITORENTER;
151
152         /* get the fieldinfo */
153
154         if (!(fi = resolve_field_eager(uf))) {
155                 PATCHER_MONITOREXIT;
156
157                 return false;
158         }
159
160         /* patch back original code */
161
162         *((u4 *) ra) = mcode;
163
164         /* if we show disassembly, we have to skip the nop */
165
166         if (opt_showdisassemble)
167                 ra = ra + 4;
168
169         /* patch the field's offset */
170
171         *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff);
172
173         /* synchronize instruction cache */
174
175         asm_sync_instruction_cache();
176
177         PATCHER_MARK_PATCHED_MONITOREXIT;
178
179         return true;
180 }
181
182
183 /* patcher_aconst **************************************************************
184
185    Machine code:
186
187    <patched call postition>
188    a61bff80    ldq     a0,-128(pv)
189
190 *******************************************************************************/
191
192 bool patcher_aconst(u1 *sp)
193 {
194         u1                *ra;
195         java_objectheader *o;
196         u4                 mcode;
197         constant_classref *cr;
198         s4                 disp;
199         u1                *pv;
200         classinfo         *c;
201
202         /* get stuff from the stack */
203
204         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
205         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
206         mcode =                       *((u4 *)     (sp + 3 * 8));
207         cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
208         disp  =                       *((s4 *)     (sp + 1 * 8));
209         pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
210
211         /* calculate and set the new return address */
212
213         ra = ra - 1 * 4;
214         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
215
216         PATCHER_MONITORENTER;
217
218         /* get the classinfo */
219
220         if (!(c = resolve_classref_eager(cr))) {
221                 PATCHER_MONITOREXIT;
222
223                 return false;
224         }
225
226         /* patch back original code */
227
228         *((u4 *) ra) = mcode;
229
230         /* synchronize instruction cache */
231
232         asm_sync_instruction_cache();
233
234         /* patch the classinfo pointer */
235
236         *((ptrint *) (pv + disp)) = (ptrint) c;
237
238         PATCHER_MARK_PATCHED_MONITOREXIT;
239
240         return true;
241 }
242
243
244 /* patcher_builtin_multianewarray **********************************************
245
246    Machine code:
247
248    <patched call position>
249    a63bff80    ldq     a1,-128(pv)
250    47de0412    mov     sp,a2
251    a77bff78    ldq     pv,-136(pv)
252    6b5b4000    jsr     (pv)
253
254 *******************************************************************************/
255
256 bool patcher_builtin_multianewarray(u1 *sp)
257 {
258         u1                *ra;
259         java_objectheader *o;
260         u4                 mcode;
261         constant_classref *cr;
262         s4                 disp;
263         u1                *pv;
264         classinfo         *c;
265
266         /* get stuff from the stack */
267
268         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
269         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
270         mcode =                       *((u4 *)     (sp + 3 * 8));
271         cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
272         disp  =                       *((s4 *)     (sp + 1 * 8));
273         pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
274
275         /* calculate and set the new return address */
276
277         ra = ra - 1 * 4;
278         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
279
280         PATCHER_MONITORENTER;
281
282         /* get the classinfo */
283
284         if (!(c = resolve_classref_eager(cr))) {
285                 PATCHER_MONITOREXIT;
286
287                 return false;
288         }
289
290         /* patch back original code */
291
292         *((u4 *) ra) = mcode;
293
294         /* synchronize instruction cache */
295
296         asm_sync_instruction_cache();
297
298         /* patch the classinfo pointer */
299
300         *((ptrint *) (pv + disp)) = (ptrint) c;
301
302         PATCHER_MARK_PATCHED_MONITOREXIT;
303
304         return true;
305 }
306
307
308 /* patcher_builtin_arraycheckcast **********************************************
309
310    Machine code:
311
312    <patched call position>
313    a63bfe60    ldq     a1,-416(pv)
314    a77bfe58    ldq     pv,-424(pv)
315    6b5b4000    jsr     (pv)
316
317 *******************************************************************************/
318
319 bool patcher_builtin_arraycheckcast(u1 *sp)
320 {
321         u1                *ra;
322         java_objectheader *o;
323         u4                 mcode;
324         constant_classref *cr;
325         s4                 disp;
326         u1                *pv;
327         classinfo         *c;
328
329         /* get stuff from the stack */
330
331         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
332         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
333         mcode =                       *((u4 *)     (sp + 3 * 8));
334         cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
335         disp  =                       *((s4 *)     (sp + 1 * 8));
336         pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
337
338         /* calculate and set the new return address */
339
340         ra = ra - 1 * 4;
341         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
342
343         PATCHER_MONITORENTER;
344
345         /* get the classinfo */
346
347         if (!(c = resolve_classref_eager(cr))) {
348                 PATCHER_MONITOREXIT;
349
350                 return false;
351         }
352
353         /* patch back original code */
354
355         *((u4 *) ra) = mcode;
356
357         /* synchronize instruction cache */
358
359         asm_sync_instruction_cache();
360
361         /* patch the classinfo pointer */
362
363         *((ptrint *) (pv + disp)) = (ptrint) c;
364
365         PATCHER_MARK_PATCHED_MONITOREXIT;
366
367         return true;
368 }
369
370
371 /* patcher_invokestatic_special ************************************************
372
373    Machine code:
374
375    <patched call position>
376    a77bffa8    ldq     pv,-88(pv)
377    6b5b4000    jsr     (pv)
378
379 ******************************************************************************/
380
381 bool patcher_invokestatic_special(u1 *sp)
382 {
383         u1                *ra;
384         java_objectheader *o;
385         u4                 mcode;
386         unresolved_method *um;
387         s4                 disp;
388         u1                *pv;
389         methodinfo        *m;
390
391         /* get stuff from the stack */
392
393         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
394         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
395         mcode =                       *((u4 *)     (sp + 3 * 8));
396         um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
397         disp  =                       *((s4 *)     (sp + 1 * 8));
398         pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
399
400         /* calculate and set the new return address */
401
402         ra = ra - 1 * 4;
403         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
404
405         PATCHER_MONITORENTER;
406
407         /* get the fieldinfo */
408
409         if (!(m = resolve_method_eager(um))) {
410                 PATCHER_MONITOREXIT;
411
412                 return false;
413         }
414
415         /* patch back original code */
416
417         *((u4 *) ra) = mcode;
418
419         /* synchronize instruction cache */
420
421         asm_sync_instruction_cache();
422
423         /* patch stubroutine */
424
425         *((ptrint *) (pv + disp)) = (ptrint) m->stubroutine;
426
427         PATCHER_MARK_PATCHED_MONITOREXIT;
428
429         return true;
430 }
431
432
433 /* patcher_invokevirtual *******************************************************
434
435    Machine code:
436
437    <patched call position>
438    a7900000    ldq     at,0(a0)
439    a77c0100    ldq     pv,256(at)
440    6b5b4000    jsr     (pv)
441
442 *******************************************************************************/
443
444 bool patcher_invokevirtual(u1 *sp)
445 {
446         u1                *ra;
447         java_objectheader *o;
448         u4                 mcode;
449         unresolved_method *um;
450         methodinfo        *m;
451
452         /* get stuff from the stack */
453
454         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
455         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
456         mcode =                       *((u4 *)     (sp + 3 * 8));
457         um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
458
459         /* calculate and set the new return address */
460
461         ra = ra - 1 * 4;
462         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
463
464         PATCHER_MONITORENTER;
465
466         /* get the fieldinfo */
467
468         if (!(m = resolve_method_eager(um))) {
469                 PATCHER_MONITOREXIT;
470
471                 return false;
472         }
473
474         /* patch back original code */
475
476         *((u4 *) ra) = mcode;
477
478         /* if we show disassembly, we have to skip the nop */
479
480         if (opt_showdisassemble)
481                 ra = ra + 4;
482
483         /* patch vftbl index */
484
485         *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, table[0]) +
486                                                                  sizeof(methodptr) * m->vftblindex) & 0x0000ffff);
487
488         /* synchronize instruction cache */
489
490         asm_sync_instruction_cache();
491
492         PATCHER_MARK_PATCHED_MONITOREXIT;
493
494         return true;
495 }
496
497
498 /* patcher_invokeinterface *****************************************************
499
500    Machine code:
501
502    <patched call position>
503    a7900000    ldq     at,0(a0)
504    a79cffa0    ldq     at,-96(at)
505    a77c0018    ldq     pv,24(at)
506    6b5b4000    jsr     (pv)
507
508 *******************************************************************************/
509
510 bool patcher_invokeinterface(u1 *sp)
511 {
512         u1                *ra;
513         java_objectheader *o;
514         u4                 mcode;
515         unresolved_method *um;
516         methodinfo        *m;
517
518         /* get stuff from the stack */
519
520         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
521         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
522         mcode =                       *((u4 *)     (sp + 3 * 8));
523         um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
524
525         /* calculate and set the new return address */
526
527         ra = ra - 1 * 4;
528         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
529
530         PATCHER_MONITORENTER;
531
532         /* get the fieldinfo */
533
534         if (!(m = resolve_method_eager(um))) {
535                 PATCHER_MONITOREXIT;
536
537                 return false;
538         }
539
540         /* patch back original code */
541
542         *((u4 *) ra) = mcode;
543
544         /* if we show disassembly, we have to skip the nop */
545
546         if (opt_showdisassemble)
547                 ra = ra + 4;
548
549         /* patch interfacetable index */
550
551         *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
552                                                                  sizeof(methodptr*) * m->class->index) & 0x0000ffff);
553
554         /* patch method offset */
555
556         *((s4 *) (ra + 4 + 4)) |=
557                 (s4) ((sizeof(methodptr) * (m - m->class->methods)) & 0x0000ffff);
558
559         /* synchronize instruction cache */
560
561         asm_sync_instruction_cache();
562
563         PATCHER_MARK_PATCHED_MONITOREXIT;
564
565         return true;
566 }
567
568
569 /* patcher_checkcast_instanceof_flags ******************************************
570
571    Machine code:
572
573    <patched call position>
574
575 *******************************************************************************/
576
577 bool patcher_checkcast_instanceof_flags(u1 *sp)
578 {
579         u1                *ra;
580         java_objectheader *o;
581         u4                 mcode;
582         constant_classref *cr;
583         s4                 disp;
584         u1                *pv;
585         classinfo         *c;
586
587         /* get stuff from the stack */
588
589         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
590         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
591         mcode =                       *((u4 *)     (sp + 3 * 8));
592         cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
593         disp  =                       *((s4 *)     (sp + 1 * 8));
594         pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
595
596         /* calculate and set the new return address */
597
598         ra = ra - 1 * 4;
599         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
600
601         PATCHER_MONITORENTER;
602
603         /* get the fieldinfo */
604
605         if (!(c = resolve_classref_eager(cr))) {
606                 PATCHER_MONITOREXIT;
607
608                 return false;
609         }
610
611         /* patch back original code */
612
613         *((u4 *) ra) = mcode;
614
615         /* synchronize instruction cache */
616
617         asm_sync_instruction_cache();
618
619         /* patch class flags */
620
621         *((s4 *) (pv + disp)) = (s4) c->flags;
622
623         PATCHER_MARK_PATCHED_MONITOREXIT;
624
625         return true;
626 }
627
628
629 /* patcher_checkcast_instanceof_interface **************************************
630
631    Machine code:
632
633    <patched call position>
634    a78e0000    ldq     at,0(s5)
635    a3bc001c    ldl     gp,28(at)
636    23bdfffd    lda     gp,-3(gp)
637    efa0002e    ble     gp,0x00000200002bf6b0
638    a7bcffe8    ldq     gp,-24(at)
639
640 *******************************************************************************/
641
642 bool patcher_checkcast_instanceof_interface(u1 *sp)
643 {
644         u1                *ra;
645         java_objectheader *o;
646         u4                 mcode;
647         constant_classref *cr;
648         classinfo         *c;
649
650         /* get stuff from the stack */
651
652         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
653         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
654         mcode =                       *((u4 *)     (sp + 3 * 8));
655         cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
656
657         /* calculate and set the new return address */
658
659         ra = ra - 1 * 4;
660         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
661
662         PATCHER_MONITORENTER;
663
664         /* get the fieldinfo */
665
666         if (!(c = resolve_classref_eager(cr))) {
667                 PATCHER_MONITOREXIT;
668
669                 return false;
670         }
671
672         /* patch back original code */
673
674         *((u4 *) ra) = mcode;
675
676         /* if we show disassembly, we have to skip the nop */
677
678         if (opt_showdisassemble)
679                 ra = ra + 4;
680
681         /* patch super class index */
682
683         *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff);
684
685         *((s4 *) (ra + 4 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
686                                                                          c->index * sizeof(methodptr*)) & 0x0000ffff);
687
688         /* synchronize instruction cache */
689
690         asm_sync_instruction_cache();
691
692         PATCHER_MARK_PATCHED_MONITOREXIT;
693
694         return true;
695 }
696
697
698 /* patcher_checkcast_instanceof_class ******************************************
699
700    Machine code:
701
702    <patched call position>
703    a7940000    ldq     at,0(a4)
704    a7bbff28    ldq     gp,-216(pv)
705
706 *******************************************************************************/
707
708 bool patcher_checkcast_instanceof_class(u1 *sp)
709 {
710         u1                *ra;
711         java_objectheader *o;
712         u4                 mcode;
713         constant_classref *cr;
714         s4                 disp;
715         u1                *pv;
716         classinfo         *c;
717
718         /* get stuff from the stack */
719
720         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
721         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
722         mcode =                       *((u4 *)     (sp + 3 * 8));
723         cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
724         disp  =                       *((s4 *)     (sp + 1 * 8));
725         pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
726
727         /* calculate and set the new return address */
728
729         ra = ra - 1 * 4;
730         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
731
732         PATCHER_MONITORENTER;
733
734         /* get the fieldinfo */
735
736         if (!(c = resolve_classref_eager(cr))) {
737                 PATCHER_MONITOREXIT;
738
739                 return false;
740         }
741
742         /* patch back original code */
743
744         *((u4 *) ra) = mcode;
745
746         /* synchronize instruction cache */
747
748         asm_sync_instruction_cache();
749
750         /* patch super class' vftbl */
751
752         *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
753
754         PATCHER_MARK_PATCHED_MONITOREXIT;
755
756         return true;
757 }
758
759
760 /* patcher_clinit **************************************************************
761
762    XXX
763
764 *******************************************************************************/
765
766 bool patcher_clinit(u1 *sp)
767 {
768         u1                *ra;
769         java_objectheader *o;
770         u4                 mcode;
771         classinfo         *c;
772
773         /* get stuff from the stack */
774
775         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
776         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
777         mcode =                       *((u4 *)     (sp + 3 * 8));
778         c     = (classinfo *)         *((ptrint *) (sp + 2 * 8));
779
780         /* calculate and set the new return address */
781
782         ra = ra - 1 * 4;
783         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
784
785         PATCHER_MONITORENTER;
786
787         /* check if the class is initialized */
788
789         if (!(c->state & CLASS_INITIALIZED)) {
790                 if (!initialize_class(c)) {
791                         PATCHER_MONITOREXIT;
792
793                         return false;
794                 }
795         }
796
797         /* patch back original code */
798
799         *((u4 *) ra) = mcode;
800
801         /* synchronize instruction cache */
802
803         asm_sync_instruction_cache();
804
805         PATCHER_MARK_PATCHED_MONITOREXIT;
806
807         return true;
808 }
809
810
811 /* patcher_athrow_areturn ******************************************************
812
813    Machine code:
814
815    <patched call position>
816
817 *******************************************************************************/
818
819 #ifdef ENABLE_VERIFIER
820 bool patcher_athrow_areturn(u1 *sp)
821 {
822         u1                *ra;
823         java_objectheader *o;
824         u4                 mcode;
825         unresolved_class  *uc;
826         classinfo         *c;
827
828         /* get stuff from the stack */
829
830         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
831         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
832         mcode =                       *((u4 *)     (sp + 3 * 8));
833         uc    = (unresolved_class *)  *((ptrint *) (sp + 2 * 8));
834
835         /* calculate and set the new return address */
836
837         ra = ra - 1 * 4;
838         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
839
840         PATCHER_MONITORENTER;
841
842         /* resolve the class */
843
844         if (!resolve_class(uc, resolveEager, false, &c)) {
845                 PATCHER_MONITOREXIT;
846
847                 return false;
848         }
849
850         /* patch back original code */
851
852         *((u4 *) ra) = mcode;
853
854         /* synchronize instruction cache */
855
856         asm_sync_instruction_cache();
857
858         PATCHER_MARK_PATCHED_MONITOREXIT;
859
860         return true;
861 }
862 #endif /* ENABLE_VERIFIER */
863
864
865 /* patcher_resolve_native ******************************************************
866
867    XXX
868
869 *******************************************************************************/
870
871 #if !defined(ENABLE_STATICVM)
872 bool patcher_resolve_native(u1 *sp)
873 {
874         u1                *ra;
875         java_objectheader *o;
876         u4                 mcode;
877         methodinfo        *m;
878         s4                 disp;
879         u1                *pv;
880         functionptr        f;
881
882         /* get stuff from the stack */
883
884         ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
885         o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
886         mcode =                       *((u4 *)     (sp + 3 * 8));
887         m     = (methodinfo *)        *((ptrint *) (sp + 2 * 8));
888         disp  =                       *((s4 *)     (sp + 1 * 8));
889         pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
890
891         /* calculate and set the new return address */
892
893         ra = ra - 1 * 4;
894         *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
895
896         PATCHER_MONITORENTER;
897
898         /* resolve native function */
899
900         if (!(f = native_resolve_function(m))) {
901                 PATCHER_MONITOREXIT;
902
903                 return false;
904         }
905
906         /* patch back original code */
907
908         *((u4 *) ra) = mcode;
909
910         /* synchronize instruction cache */
911
912         asm_sync_instruction_cache();
913
914         /* patch native function pointer */
915
916         *((ptrint *) (pv + disp)) = (ptrint) f;
917
918         PATCHER_MARK_PATCHED_MONITOREXIT;
919
920         return true;
921 }
922 #endif /* !defined(ENABLE_STATICVM) */
923
924
925 /*
926  * These are local overrides for various environment variables in Emacs.
927  * Please do not remove this and leave it at the end of the file, where
928  * Emacs will automagically detect them.
929  * ---------------------------------------------------------------------
930  * Local variables:
931  * mode: c
932  * indent-tabs-mode: t
933  * c-basic-offset: 4
934  * tab-width: 4
935  * End:
936  * vim:noexpandtab:sw=4:ts=4:
937  */