forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterpret-run.cc
2696 lines (2313 loc) · 53.7 KB
/
interpret-run.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// interpret-run.cc - Code to interpret bytecode
/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* This file is meant only to be included in interpret.cc, it should not be
* compiled directly. */
using namespace java::lang::reflect;
pc_t pc = NULL;
// FRAME_DESC registers this particular invocation as the top-most
// interpreter frame. This lets the stack tracing code (for
// Throwable) print information about the method being interpreted
// rather than about the interpreter itself. FRAME_DESC has a
// destructor so it cleans up automatically when the interpreter
// returns.
java::lang::Thread *thread = java::lang::Thread::currentThread();
#ifdef __GCJ_DEBUG
_Jv_InterpFrame frame_desc (meth, thread, NULL, &pc);
#else
_Jv_InterpFrame frame_desc (meth, thread);
#endif
#ifdef DIRECT_THREADED
ThreadCountAdjuster adj (meth, &frame_desc);
#endif // DIRECT_THREADED
_Jv_word stack[meth->max_stack];
_Jv_word *sp = stack;
_Jv_word locals[meth->max_locals];
#ifdef __GCJ_DEBUG
// This is the information needed to get and set local variables with
// proper type checking.
frame_desc.locals = locals;
char locals_type[meth->max_locals];
frame_desc.locals_type = locals_type;
// Set all slots as invalid until they are written to.
memset (locals_type, 'x', meth->max_locals);
// We need to set the local variable types for the method arguments since
// they are valid at invocation.
_Jv_Method *method = meth->get_method ();
int type_ctr = 0;
// If the method is non-static, we need to set the type for the "this" pointer.
if ((method->accflags & java::lang::reflect::Modifier::STATIC) == 0)
{
if (args)
{
// Set the "this" pointer for this frame.
_Jv_word *this_ptr = reinterpret_cast<_Jv_word *> (args);
frame_desc.obj_ptr = this_ptr[0].o;
}
frame_desc.locals_type[0] = 'o';
type_ctr++;
}
// Now parse the method signature to set the types of the other arguments.
int sig_len = method->signature->len ();
char *signature = method->signature->chars ();
for (int i = 1; signature[i] != ')' && i <= sig_len; i++)
{
if (signature[i] == 'Z' || signature[i] == 'B' || signature[i] == 'C'
|| signature[i] == 'S' || signature[i] == 'I')
{
frame_desc.locals_type[type_ctr] = 'i';
type_ctr++;
continue;
}
else if (signature[i] == 'F')
{
frame_desc.locals_type[type_ctr] = 'f';
type_ctr++;
continue;
}
else if (signature[i] == 'J')
{
frame_desc.locals_type[type_ctr] = 'l';
frame_desc.locals_type[type_ctr+1] = 'x';
type_ctr += 2;
continue;
}
else if (signature[i] == 'D')
{
frame_desc.locals_type[type_ctr] = 'd';
frame_desc.locals_type[type_ctr+1] = 'x';
type_ctr += 2;
continue;
}
else if (signature[i] == 'L')
{
frame_desc.locals_type[type_ctr] = 'o';
type_ctr++;
while (signature[i] != ';')
i++;
continue;
}
else if (signature[i] == '[')
{
frame_desc.locals_type[type_ctr] = 'o';
type_ctr++;
// Ignore multi-dimensional arrays.
while (signature[i] == '[')
i++;
// Check for an object array
if (signature[i] == 'L')
{
while (signature[i] != ';')
i++;
}
continue;
}
}
#endif /* __GCJ_DEBUG */
#define INSN_LABEL(op) &&insn_##op
static const void *const insn_target[] =
{
INSN_LABEL(nop),
INSN_LABEL(aconst_null),
INSN_LABEL(iconst_m1),
INSN_LABEL(iconst_0),
INSN_LABEL(iconst_1),
INSN_LABEL(iconst_2),
INSN_LABEL(iconst_3),
INSN_LABEL(iconst_4),
INSN_LABEL(iconst_5),
INSN_LABEL(lconst_0),
INSN_LABEL(lconst_1),
INSN_LABEL(fconst_0),
INSN_LABEL(fconst_1),
INSN_LABEL(fconst_2),
INSN_LABEL(dconst_0),
INSN_LABEL(dconst_1),
INSN_LABEL(bipush),
INSN_LABEL(sipush),
INSN_LABEL(ldc),
INSN_LABEL(ldc_w),
INSN_LABEL(ldc2_w),
INSN_LABEL(iload),
INSN_LABEL(lload),
INSN_LABEL(fload),
INSN_LABEL(dload),
INSN_LABEL(aload),
INSN_LABEL(iload_0),
INSN_LABEL(iload_1),
INSN_LABEL(iload_2),
INSN_LABEL(iload_3),
INSN_LABEL(lload_0),
INSN_LABEL(lload_1),
INSN_LABEL(lload_2),
INSN_LABEL(lload_3),
INSN_LABEL(fload_0),
INSN_LABEL(fload_1),
INSN_LABEL(fload_2),
INSN_LABEL(fload_3),
INSN_LABEL(dload_0),
INSN_LABEL(dload_1),
INSN_LABEL(dload_2),
INSN_LABEL(dload_3),
INSN_LABEL(aload_0),
INSN_LABEL(aload_1),
INSN_LABEL(aload_2),
INSN_LABEL(aload_3),
INSN_LABEL(iaload),
INSN_LABEL(laload),
INSN_LABEL(faload),
INSN_LABEL(daload),
INSN_LABEL(aaload),
INSN_LABEL(baload),
INSN_LABEL(caload),
INSN_LABEL(saload),
INSN_LABEL(istore),
INSN_LABEL(lstore),
INSN_LABEL(fstore),
INSN_LABEL(dstore),
INSN_LABEL(astore),
INSN_LABEL(istore_0),
INSN_LABEL(istore_1),
INSN_LABEL(istore_2),
INSN_LABEL(istore_3),
INSN_LABEL(lstore_0),
INSN_LABEL(lstore_1),
INSN_LABEL(lstore_2),
INSN_LABEL(lstore_3),
INSN_LABEL(fstore_0),
INSN_LABEL(fstore_1),
INSN_LABEL(fstore_2),
INSN_LABEL(fstore_3),
INSN_LABEL(dstore_0),
INSN_LABEL(dstore_1),
INSN_LABEL(dstore_2),
INSN_LABEL(dstore_3),
INSN_LABEL(astore_0),
INSN_LABEL(astore_1),
INSN_LABEL(astore_2),
INSN_LABEL(astore_3),
INSN_LABEL(iastore),
INSN_LABEL(lastore),
INSN_LABEL(fastore),
INSN_LABEL(dastore),
INSN_LABEL(aastore),
INSN_LABEL(bastore),
INSN_LABEL(castore),
INSN_LABEL(sastore),
INSN_LABEL(pop),
INSN_LABEL(pop2),
INSN_LABEL(dup),
INSN_LABEL(dup_x1),
INSN_LABEL(dup_x2),
INSN_LABEL(dup2),
INSN_LABEL(dup2_x1),
INSN_LABEL(dup2_x2),
INSN_LABEL(swap),
INSN_LABEL(iadd),
INSN_LABEL(ladd),
INSN_LABEL(fadd),
INSN_LABEL(dadd),
INSN_LABEL(isub),
INSN_LABEL(lsub),
INSN_LABEL(fsub),
INSN_LABEL(dsub),
INSN_LABEL(imul),
INSN_LABEL(lmul),
INSN_LABEL(fmul),
INSN_LABEL(dmul),
INSN_LABEL(idiv),
INSN_LABEL(ldiv),
INSN_LABEL(fdiv),
INSN_LABEL(ddiv),
INSN_LABEL(irem),
INSN_LABEL(lrem),
INSN_LABEL(frem),
INSN_LABEL(drem),
INSN_LABEL(ineg),
INSN_LABEL(lneg),
INSN_LABEL(fneg),
INSN_LABEL(dneg),
INSN_LABEL(ishl),
INSN_LABEL(lshl),
INSN_LABEL(ishr),
INSN_LABEL(lshr),
INSN_LABEL(iushr),
INSN_LABEL(lushr),
INSN_LABEL(iand),
INSN_LABEL(land),
INSN_LABEL(ior),
INSN_LABEL(lor),
INSN_LABEL(ixor),
INSN_LABEL(lxor),
INSN_LABEL(iinc),
INSN_LABEL(i2l),
INSN_LABEL(i2f),
INSN_LABEL(i2d),
INSN_LABEL(l2i),
INSN_LABEL(l2f),
INSN_LABEL(l2d),
INSN_LABEL(f2i),
INSN_LABEL(f2l),
INSN_LABEL(f2d),
INSN_LABEL(d2i),
INSN_LABEL(d2l),
INSN_LABEL(d2f),
INSN_LABEL(i2b),
INSN_LABEL(i2c),
INSN_LABEL(i2s),
INSN_LABEL(lcmp),
INSN_LABEL(fcmpl),
INSN_LABEL(fcmpg),
INSN_LABEL(dcmpl),
INSN_LABEL(dcmpg),
INSN_LABEL(ifeq),
INSN_LABEL(ifne),
INSN_LABEL(iflt),
INSN_LABEL(ifge),
INSN_LABEL(ifgt),
INSN_LABEL(ifle),
INSN_LABEL(if_icmpeq),
INSN_LABEL(if_icmpne),
INSN_LABEL(if_icmplt),
INSN_LABEL(if_icmpge),
INSN_LABEL(if_icmpgt),
INSN_LABEL(if_icmple),
INSN_LABEL(if_acmpeq),
INSN_LABEL(if_acmpne),
INSN_LABEL(goto),
INSN_LABEL(jsr),
INSN_LABEL(ret),
INSN_LABEL(tableswitch),
INSN_LABEL(lookupswitch),
INSN_LABEL(ireturn),
INSN_LABEL(lreturn),
INSN_LABEL(freturn),
INSN_LABEL(dreturn),
INSN_LABEL(areturn),
INSN_LABEL(return),
INSN_LABEL(getstatic),
INSN_LABEL(putstatic),
INSN_LABEL(getfield),
INSN_LABEL(putfield),
INSN_LABEL(invokevirtual),
INSN_LABEL(invokespecial),
INSN_LABEL(invokestatic),
INSN_LABEL(invokeinterface),
INSN_LABEL(breakpoint),
INSN_LABEL(new),
INSN_LABEL(newarray),
INSN_LABEL(anewarray),
INSN_LABEL(arraylength),
INSN_LABEL(athrow),
INSN_LABEL(checkcast),
INSN_LABEL(instanceof),
INSN_LABEL(monitorenter),
INSN_LABEL(monitorexit),
#ifdef DIRECT_THREADED
0, // wide
#else
INSN_LABEL(wide),
#endif
INSN_LABEL(multianewarray),
INSN_LABEL(ifnull),
INSN_LABEL(ifnonnull),
INSN_LABEL(goto_w),
INSN_LABEL(jsr_w),
#ifdef DIRECT_THREADED
INSN_LABEL (ldc_class)
#else
0
#endif
};
#ifdef DIRECT_THREADED
#ifdef __GCJ_DEBUG
#undef NEXT_INSN
#define NEXT_INSN \
do \
{ \
pc_t insn = pc++; \
if (JVMTI_REQUESTED_EVENT (SingleStep)) \
{ \
JNIEnv *env = _Jv_GetCurrentJNIEnv (); \
jmethodID method = meth->self; \
jlocation loc = meth->insn_index (insn); \
_Jv_JVMTI_PostEvent (JVMTI_EVENT_SINGLE_STEP, thread, \
env, method, loc); \
} \
goto *(insn->insn); \
} \
while (0)
// We fail to rewrite a breakpoint if there is another thread
// currently executing this method. This is a bug, but there's
// nothing else we can do that doesn't cause a data race.
#undef REWRITE_INSN
#define REWRITE_INSN(INSN,SLOT,VALUE) \
do \
{ \
_Jv_MutexLock (&rewrite_insn_mutex); \
if (meth->thread_count <= 1) \
{ \
if (pc[-2].insn == breakpoint_insn->insn) \
{ \
using namespace ::gnu::gcj::jvmti; \
jlocation location = meth->insn_index (pc - 2); \
_Jv_RewriteBreakpointInsn (meth->self, location, (pc_t) INSN); \
} \
else \
pc[-2].insn = INSN; \
\
pc[-1].SLOT = VALUE; \
} \
_Jv_MutexUnlock (&rewrite_insn_mutex); \
} \
while (0)
#undef INTERP_REPORT_EXCEPTION
#define INTERP_REPORT_EXCEPTION(Jthrowable) REPORT_EXCEPTION (Jthrowable)
#else // !__GCJ_DEBUG
#undef NEXT_INSN
#define NEXT_INSN goto *((pc++)->insn)
// Rewriting a multi-word instruction in the presence of multiple
// threads is a data race if a thread reads part of an instruction
// while some other thread is rewriting that instruction. We detect
// more than one thread executing a method and don't rewrite the
// instruction. A thread entering a method blocks on
// rewrite_insn_mutex until the write is complete.
#define REWRITE_INSN(INSN,SLOT,VALUE) \
do { \
_Jv_MutexLock (&rewrite_insn_mutex); \
if (meth->thread_count <= 1) \
{ \
pc[-2].insn = INSN; \
pc[-1].SLOT = VALUE; \
} \
_Jv_MutexUnlock (&rewrite_insn_mutex); \
} \
while (0)
#undef INTERP_REPORT_EXCEPTION
#define INTERP_REPORT_EXCEPTION(Jthrowable) /* not needed when not debugging */
#endif // !__GCJ_DEBUG
#define INTVAL() ((pc++)->int_val)
#define AVAL() ((pc++)->datum)
#define GET1S() INTVAL ()
#define GET2S() INTVAL ()
#define GET1U() INTVAL ()
#define GET2U() INTVAL ()
#define AVAL1U() AVAL ()
#define AVAL2U() AVAL ()
#define AVAL2UP() AVAL ()
#define SKIP_GOTO ++pc
#define GOTO_VAL() (insn_slot *) pc->datum
#define PCVAL(unionval) unionval.p
#define AMPAMP(label) &&label
// Compile if we must. NOTE: Double-check locking.
if (meth->prepared == NULL)
{
_Jv_MutexLock (&compile_mutex);
if (meth->prepared == NULL)
meth->compile (insn_target);
_Jv_MutexUnlock (&compile_mutex);
}
// If we're only compiling, stop here
if (args == NULL)
return;
pc = (insn_slot *) meth->prepared;
#else
#ifdef __GCJ_DEBUG
#define NEXT_INSN \
do \
{ \
if (JVMTI_REQUESTED_EVENT (SingleStep)) \
{ \
JNIEnv *env = _Jv_GetCurrentJNIEnv (); \
jmethodID method = meth->self; \
jlocation loc = meth->insn_index (pc); \
_Jv_JVMTI_PostEvent (JVMTI_EVENT_SINGLE_STEP, thread, \
env, method, loc); \
} \
goto *(insn_target[*pc++])
#else
#define NEXT_INSN goto *(insn_target[*pc++])
#endif
#define GET1S() get1s (pc++)
#define GET2S() (pc += 2, get2s (pc- 2))
#define GET1U() get1u (pc++)
#define GET2U() (pc += 2, get2u (pc - 2))
// Note that these could be more efficient when not handling 'ldc
// class'.
#define AVAL1U() \
({ int index = get1u (pc++); \
_Jv_Linker::resolve_pool_entry (meth->defining_class, index).o; })
#define AVAL2U() \
({ int index = get2u (pc); pc += 2; \
_Jv_Linker::resolve_pool_entry (meth->defining_class, index).o; })
// Note that we don't need to resolve the pool entry here as class
// constants are never wide.
#define AVAL2UP() ({ int index = get2u (pc); pc += 2; &pool_data[index]; })
#define SKIP_GOTO pc += 2
#define GOTO_VAL() pc - 1 + get2s (pc)
#define PCVAL(unionval) unionval.i
#define AMPAMP(label) NULL
pc = meth->bytecode ();
#endif /* DIRECT_THREADED */
#define TAKE_GOTO pc = GOTO_VAL ()
/* Go straight at it! the ffi raw format matches the internal
stack representation exactly. At least, that's the idea.
*/
memcpy ((void*) locals, (void*) args, meth->args_raw_size);
_Jv_word *pool_data = meth->defining_class->constants.data;
/* These three are temporaries for common code used by several
instructions. */
void (*fun)();
_Jv_ResolvedMethod* rmeth;
int tmpval;
try
{
// We keep nop around. It is used if we're interpreting the
// bytecodes and not doing direct threading.
insn_nop:
NEXT_INSN;
/* The first few instructions here are ordered according to their
frequency, in the hope that this will improve code locality a
little. */
insn_aload_0: // 0x2a
LOADA (0);
NEXT_INSN;
insn_iload: // 0x15
LOADI (GET1U ());
NEXT_INSN;
insn_iload_1: // 0x1b
LOADI (1);
NEXT_INSN;
insn_invokevirtual: // 0xb6
{
SAVE_PC();
int index = GET2U ();
/* _Jv_Linker::resolve_pool_entry returns immediately if the
* value already is resolved. If we want to clutter up the
* code here to gain a little performance, then we can check
* the corresponding bit JV_CONSTANT_ResolvedFlag in the tag
* directly. For now, I don't think it is worth it. */
rmeth = (_Jv_Linker::resolve_pool_entry (meth->defining_class,
index)).rmethod;
sp -= rmeth->stack_item_count;
if (rmeth->method->accflags & Modifier::FINAL)
{
// We can't rely on NULLCHECK working if the method is final.
if (! sp[0].o)
throw_null_pointer_exception ();
// Final methods might not appear in the vtable.
fun = (void (*)()) rmeth->method->ncode;
}
else
{
NULLCHECK (sp[0].o);
jobject rcv = sp[0].o;
_Jv_VTable *table = *(_Jv_VTable**) rcv;
fun = (void (*)()) table->get_method (rmeth->method->index);
}
#ifdef DIRECT_THREADED
// Rewrite instruction so that we use a faster pre-resolved
// method.
REWRITE_INSN (&&invokevirtual_resolved, datum, rmeth);
#endif /* DIRECT_THREADED */
}
goto perform_invoke;
#ifdef DIRECT_THREADED
invokevirtual_resolved:
{
SAVE_PC();
rmeth = (_Jv_ResolvedMethod *) AVAL ();
sp -= rmeth->stack_item_count;
if (rmeth->method->accflags & Modifier::FINAL)
{
// We can't rely on NULLCHECK working if the method is final.
if (! sp[0].o)
throw_null_pointer_exception ();
// Final methods might not appear in the vtable.
fun = (void (*)()) rmeth->method->ncode;
}
else
{
NULLCHECK (sp[0].o);
jobject rcv = sp[0].o;
_Jv_VTable *table = *(_Jv_VTable**) rcv;
fun = (void (*)()) table->get_method (rmeth->method->index);
}
}
goto perform_invoke;
#endif /* DIRECT_THREADED */
perform_invoke:
{
/* here goes the magic again... */
ffi_cif *cif = &rmeth->cif;
INTERP_FFI_RAW_TYPE *raw = (INTERP_FFI_RAW_TYPE *) sp;
_Jv_value rvalue;
#if FFI_NATIVE_RAW_API
/* We assume that this is only implemented if it's correct */
/* to use it here. On a 64 bit machine, it never is. */
ffi_raw_call (cif, fun, (void*)&rvalue, raw);
#else
ffi_java_raw_call (cif, fun, (void*)&rvalue, raw);
#endif
int rtype = cif->rtype->type;
/* the likelyhood of object, int, or void return is very high,
* so those are checked before the switch */
if (rtype == FFI_TYPE_POINTER)
{
PUSHA (rvalue.object_value);
}
else if (rtype == FFI_TYPE_SINT32)
{
PUSHI (rvalue.int_value);
}
else if (rtype == FFI_TYPE_VOID)
{
/* skip */
}
else
{
switch (rtype)
{
case FFI_TYPE_SINT8:
PUSHI ((jbyte)(rvalue.int_value & 0xff));
break;
case FFI_TYPE_SINT16:
PUSHI ((jshort)(rvalue.int_value & 0xffff));
break;
case FFI_TYPE_UINT16:
PUSHI (rvalue.int_value & 0xffff);
break;
case FFI_TYPE_FLOAT:
PUSHF (rvalue.float_value);
break;
case FFI_TYPE_DOUBLE:
PUSHD (rvalue.double_value);
break;
case FFI_TYPE_SINT64:
PUSHL (rvalue.long_value);
break;
default:
throw_internal_error ("unknown return type in invokeXXX");
}
}
}
NEXT_INSN;
insn_aconst_null:
PUSHA (NULL);
NEXT_INSN;
insn_iconst_m1:
PUSHI (-1);
NEXT_INSN;
insn_iconst_0:
PUSHI (0);
NEXT_INSN;
insn_iconst_1:
PUSHI (1);
NEXT_INSN;
insn_iconst_2:
PUSHI (2);
NEXT_INSN;
insn_iconst_3:
PUSHI (3);
NEXT_INSN;
insn_iconst_4:
PUSHI (4);
NEXT_INSN;
insn_iconst_5:
PUSHI (5);
NEXT_INSN;
insn_lconst_0:
PUSHL (0);
NEXT_INSN;
insn_lconst_1:
PUSHL (1);
NEXT_INSN;
insn_fconst_0:
PUSHF (0);
NEXT_INSN;
insn_fconst_1:
PUSHF (1);
NEXT_INSN;
insn_fconst_2:
PUSHF (2);
NEXT_INSN;
insn_dconst_0:
PUSHD (0);
NEXT_INSN;
insn_dconst_1:
PUSHD (1);
NEXT_INSN;
insn_bipush:
// For direct threaded, bipush and sipush are the same.
#ifndef DIRECT_THREADED
PUSHI (GET1S ());
NEXT_INSN;
#endif /* DIRECT_THREADED */
insn_sipush:
PUSHI (GET2S ());
NEXT_INSN;
insn_ldc:
// For direct threaded, ldc and ldc_w are the same.
#ifndef DIRECT_THREADED
PUSHA ((jobject) AVAL1U ());
NEXT_INSN;
#endif /* DIRECT_THREADED */
insn_ldc_w:
PUSHA ((jobject) AVAL2U ());
NEXT_INSN;
#ifdef DIRECT_THREADED
// For direct threaded we have a separate 'ldc class' operation.
insn_ldc_class:
{
SAVE_PC();
// We could rewrite the instruction at this point.
int index = INTVAL ();
jobject k = (_Jv_Linker::resolve_pool_entry (meth->defining_class,
index)).o;
PUSHA (k);
}
NEXT_INSN;
#endif /* DIRECT_THREADED */
insn_ldc2_w:
{
void *where = AVAL2UP ();
memcpy (sp, where, 2*sizeof (_Jv_word));
sp += 2;
}
NEXT_INSN;
insn_lload:
LOADL (GET1U ());
NEXT_INSN;
insn_fload:
LOADF (GET1U ());
NEXT_INSN;
insn_dload:
LOADD (GET1U ());
NEXT_INSN;
insn_aload:
LOADA (GET1U ());
NEXT_INSN;
insn_iload_0:
LOADI (0);
NEXT_INSN;
insn_iload_2:
LOADI (2);
NEXT_INSN;
insn_iload_3:
LOADI (3);
NEXT_INSN;
insn_lload_0:
LOADL (0);
NEXT_INSN;
insn_lload_1:
LOADL (1);
NEXT_INSN;
insn_lload_2:
LOADL (2);
NEXT_INSN;
insn_lload_3:
LOADL (3);
NEXT_INSN;
insn_fload_0:
LOADF (0);
NEXT_INSN;
insn_fload_1:
LOADF (1);
NEXT_INSN;
insn_fload_2:
LOADF (2);
NEXT_INSN;
insn_fload_3:
LOADF (3);
NEXT_INSN;
insn_dload_0:
LOADD (0);
NEXT_INSN;
insn_dload_1:
LOADD (1);
NEXT_INSN;
insn_dload_2:
LOADD (2);
NEXT_INSN;
insn_dload_3:
LOADD (3);
NEXT_INSN;
insn_aload_1:
LOADA(1);
NEXT_INSN;
insn_aload_2:
LOADA(2);
NEXT_INSN;
insn_aload_3:
LOADA(3);
NEXT_INSN;
insn_iaload:
{
jint index = POPI();
jintArray arr = (jintArray) POPA();
NULLARRAYCHECK (arr);
ARRAYBOUNDSCHECK (arr, index);
PUSHI( elements(arr)[index] );
}
NEXT_INSN;
insn_laload:
{
jint index = POPI();
jlongArray arr = (jlongArray) POPA();
NULLARRAYCHECK (arr);
ARRAYBOUNDSCHECK (arr, index);
PUSHL( elements(arr)[index] );
}
NEXT_INSN;
insn_faload:
{
jint index = POPI();
jfloatArray arr = (jfloatArray) POPA();
NULLARRAYCHECK (arr);
ARRAYBOUNDSCHECK (arr, index);
PUSHF( elements(arr)[index] );
}
NEXT_INSN;
insn_daload:
{
jint index = POPI();
jdoubleArray arr = (jdoubleArray) POPA();
NULLARRAYCHECK (arr);
ARRAYBOUNDSCHECK (arr, index);
PUSHD( elements(arr)[index] );
}
NEXT_INSN;
insn_aaload:
{
jint index = POPI();
jobjectArray arr = (jobjectArray) POPA();
NULLARRAYCHECK (arr);
ARRAYBOUNDSCHECK (arr, index);
PUSHA( elements(arr)[index] );
}
NEXT_INSN;
insn_baload:
{
jint index = POPI();
jbyteArray arr = (jbyteArray) POPA();
NULLARRAYCHECK (arr);
ARRAYBOUNDSCHECK (arr, index);
PUSHI( elements(arr)[index] );
}
NEXT_INSN;
insn_caload:
{
jint index = POPI();
jcharArray arr = (jcharArray) POPA();
NULLARRAYCHECK (arr);
ARRAYBOUNDSCHECK (arr, index);
PUSHI( elements(arr)[index] );
}
NEXT_INSN;
insn_saload:
{
jint index = POPI();
jshortArray arr = (jshortArray) POPA();
NULLARRAYCHECK (arr);
ARRAYBOUNDSCHECK (arr, index);
PUSHI( elements(arr)[index] );
}
NEXT_INSN;
insn_istore:
STOREI (GET1U ());
NEXT_INSN;
insn_lstore:
STOREL (GET1U ());
NEXT_INSN;
insn_fstore:
STOREF (GET1U ());
NEXT_INSN;
insn_dstore:
STORED (GET1U ());
NEXT_INSN;
insn_astore:
STOREA (GET1U ());
NEXT_INSN;
insn_istore_0:
STOREI (0);
NEXT_INSN;
insn_istore_1:
STOREI (1);
NEXT_INSN;
insn_istore_2:
STOREI (2);
NEXT_INSN;
insn_istore_3:
STOREI (3);
NEXT_INSN;
insn_lstore_0:
STOREL (0);
NEXT_INSN;
insn_lstore_1:
STOREL (1);
NEXT_INSN;
insn_lstore_2:
STOREL (2);
NEXT_INSN;
insn_lstore_3:
STOREL (3);
NEXT_INSN;
insn_fstore_0:
STOREF (0);
NEXT_INSN;
insn_fstore_1:
STOREF (1);
NEXT_INSN;
insn_fstore_2:
STOREF (2);
NEXT_INSN;