forked from openjdk/jdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplateTable_arm.cpp
More file actions
4435 lines (3550 loc) · 137 KB
/
Copy pathtemplateTable_arm.cpp
File metadata and controls
4435 lines (3550 loc) · 137 KB
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
/*
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "asm/macroAssembler.inline.hpp"
#include "gc/shared/barrierSetAssembler.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/tlab_globals.hpp"
#include "interpreter/interp_masm.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/interpreterRuntime.hpp"
#include "interpreter/templateTable.hpp"
#include "memory/universe.hpp"
#include "oops/cpCache.hpp"
#include "oops/klass.inline.hpp"
#include "oops/methodData.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/oop.inline.hpp"
#include "prims/jvmtiExport.hpp"
#include "prims/methodHandles.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubRoutines.hpp"
#include "runtime/synchronizer.hpp"
#include "utilities/powerOfTwo.hpp"
#define __ _masm->
//----------------------------------------------------------------------------------------------------
// Address computation
// local variables
static inline Address iaddress(int n) {
return Address(Rlocals, Interpreter::local_offset_in_bytes(n));
}
static inline Address laddress(int n) { return iaddress(n + 1); }
static inline Address haddress(int n) { return iaddress(n + 0); }
static inline Address faddress(int n) { return iaddress(n); }
static inline Address daddress(int n) { return laddress(n); }
static inline Address aaddress(int n) { return iaddress(n); }
void TemplateTable::get_local_base_addr(Register r, Register index) {
__ sub(r, Rlocals, AsmOperand(index, lsl, Interpreter::logStackElementSize));
}
Address TemplateTable::load_iaddress(Register index, Register scratch) {
return Address(Rlocals, index, lsl, Interpreter::logStackElementSize, basic_offset, sub_offset);
}
Address TemplateTable::load_aaddress(Register index, Register scratch) {
return load_iaddress(index, scratch);
}
Address TemplateTable::load_faddress(Register index, Register scratch) {
#ifdef __SOFTFP__
return load_iaddress(index, scratch);
#else
get_local_base_addr(scratch, index);
return Address(scratch);
#endif // __SOFTFP__
}
Address TemplateTable::load_daddress(Register index, Register scratch) {
get_local_base_addr(scratch, index);
return Address(scratch, Interpreter::local_offset_in_bytes(1));
}
// At top of Java expression stack which may be different than SP.
// It isn't for category 1 objects.
static inline Address at_tos() {
return Address(Rstack_top, Interpreter::expr_offset_in_bytes(0));
}
static inline Address at_tos_p1() {
return Address(Rstack_top, Interpreter::expr_offset_in_bytes(1));
}
static inline Address at_tos_p2() {
return Address(Rstack_top, Interpreter::expr_offset_in_bytes(2));
}
// Loads double/long local into R0_tos_lo/R1_tos_hi with two
// separate ldr instructions (supports nonadjacent values).
// Used for longs in all modes, and for doubles in SOFTFP mode.
void TemplateTable::load_category2_local(Register Rlocal_index, Register tmp) {
const Register Rlocal_base = tmp;
assert_different_registers(Rlocal_index, tmp);
get_local_base_addr(Rlocal_base, Rlocal_index);
__ ldr(R0_tos_lo, Address(Rlocal_base, Interpreter::local_offset_in_bytes(1)));
__ ldr(R1_tos_hi, Address(Rlocal_base, Interpreter::local_offset_in_bytes(0)));
}
// Stores R0_tos_lo/R1_tos_hi to double/long local with two
// separate str instructions (supports nonadjacent values).
// Used for longs in all modes, and for doubles in SOFTFP mode
void TemplateTable::store_category2_local(Register Rlocal_index, Register tmp) {
const Register Rlocal_base = tmp;
assert_different_registers(Rlocal_index, tmp);
get_local_base_addr(Rlocal_base, Rlocal_index);
__ str(R0_tos_lo, Address(Rlocal_base, Interpreter::local_offset_in_bytes(1)));
__ str(R1_tos_hi, Address(Rlocal_base, Interpreter::local_offset_in_bytes(0)));
}
// Returns address of Java array element using temp register as address base.
Address TemplateTable::get_array_elem_addr(BasicType elemType, Register array, Register index, Register temp) {
int logElemSize = exact_log2(type2aelembytes(elemType));
__ add_ptr_scaled_int32(temp, array, index, logElemSize);
return Address(temp, arrayOopDesc::base_offset_in_bytes(elemType));
}
// Returns address of Java array element using temp register as offset from array base
Address TemplateTable::get_array_elem_addr_same_base(BasicType elemType, Register array, Register index, Register temp) {
int logElemSize = exact_log2(type2aelembytes(elemType));
if (logElemSize == 0) {
__ add(temp, index, arrayOopDesc::base_offset_in_bytes(elemType));
} else {
__ mov(temp, arrayOopDesc::base_offset_in_bytes(elemType));
__ add_ptr_scaled_int32(temp, temp, index, logElemSize);
}
return Address(array, temp);
}
//----------------------------------------------------------------------------------------------------
// Condition conversion
AsmCondition convNegCond(TemplateTable::Condition cc) {
switch (cc) {
case TemplateTable::equal : return ne;
case TemplateTable::not_equal : return eq;
case TemplateTable::less : return ge;
case TemplateTable::less_equal : return gt;
case TemplateTable::greater : return le;
case TemplateTable::greater_equal: return lt;
}
ShouldNotReachHere();
return nv;
}
//----------------------------------------------------------------------------------------------------
// Miscelaneous helper routines
// Store an oop (or NULL) at the address described by obj.
// Blows all volatile registers R0-R3, Rtemp, LR).
// Also destroys new_val and obj.base().
static void do_oop_store(InterpreterMacroAssembler* _masm,
Address obj,
Register new_val,
Register tmp1,
Register tmp2,
Register tmp3,
bool is_null,
DecoratorSet decorators = 0) {
assert_different_registers(obj.base(), new_val, tmp1, tmp2, tmp3, noreg);
if (is_null) {
__ store_heap_oop_null(obj, new_val, tmp1, tmp2, tmp3, decorators);
} else {
__ store_heap_oop(obj, new_val, tmp1, tmp2, tmp3, decorators);
}
}
static void do_oop_load(InterpreterMacroAssembler* _masm,
Register dst,
Address obj,
DecoratorSet decorators = 0) {
__ load_heap_oop(dst, obj, noreg, noreg, noreg, decorators);
}
Address TemplateTable::at_bcp(int offset) {
assert(_desc->uses_bcp(), "inconsistent uses_bcp information");
return Address(Rbcp, offset);
}
// Blows volatile registers R0-R3, Rtemp, LR.
void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
Register temp_reg, bool load_bc_into_bc_reg/*=true*/,
int byte_no) {
assert_different_registers(bc_reg, temp_reg);
if (!RewriteBytecodes) return;
Label L_patch_done;
switch (bc) {
case Bytecodes::_fast_aputfield:
case Bytecodes::_fast_bputfield:
case Bytecodes::_fast_zputfield:
case Bytecodes::_fast_cputfield:
case Bytecodes::_fast_dputfield:
case Bytecodes::_fast_fputfield:
case Bytecodes::_fast_iputfield:
case Bytecodes::_fast_lputfield:
case Bytecodes::_fast_sputfield:
{
// We skip bytecode quickening for putfield instructions when
// the put_code written to the constant pool cache is zero.
// This is required so that every execution of this instruction
// calls out to InterpreterRuntime::resolve_get_put to do
// additional, required work.
assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
assert(load_bc_into_bc_reg, "we use bc_reg as temp");
__ get_cache_and_index_and_bytecode_at_bcp(bc_reg, temp_reg, temp_reg, byte_no, 1, sizeof(u2));
__ mov(bc_reg, bc);
__ cbz(temp_reg, L_patch_done); // test if bytecode is zero
}
break;
default:
assert(byte_no == -1, "sanity");
// the pair bytecodes have already done the load.
if (load_bc_into_bc_reg) {
__ mov(bc_reg, bc);
}
}
if (__ can_post_breakpoint()) {
Label L_fast_patch;
// if a breakpoint is present we can't rewrite the stream directly
__ ldrb(temp_reg, at_bcp(0));
__ cmp(temp_reg, Bytecodes::_breakpoint);
__ b(L_fast_patch, ne);
if (bc_reg != R3) {
__ mov(R3, bc_reg);
}
__ mov(R1, Rmethod);
__ mov(R2, Rbcp);
// Let breakpoint table handling rewrite to quicker bytecode
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::set_original_bytecode_at), R1, R2, R3);
__ b(L_patch_done);
__ bind(L_fast_patch);
}
#ifdef ASSERT
Label L_okay;
__ ldrb(temp_reg, at_bcp(0));
__ cmp(temp_reg, (int)Bytecodes::java_code(bc));
__ b(L_okay, eq);
__ cmp(temp_reg, bc_reg);
__ b(L_okay, eq);
__ stop("patching the wrong bytecode");
__ bind(L_okay);
#endif
// patch bytecode
__ strb(bc_reg, at_bcp(0));
__ bind(L_patch_done);
}
//----------------------------------------------------------------------------------------------------
// Individual instructions
void TemplateTable::nop() {
transition(vtos, vtos);
// nothing to do
}
void TemplateTable::shouldnotreachhere() {
transition(vtos, vtos);
__ stop("shouldnotreachhere bytecode");
}
void TemplateTable::aconst_null() {
transition(vtos, atos);
__ mov(R0_tos, 0);
}
void TemplateTable::iconst(int value) {
transition(vtos, itos);
__ mov_slow(R0_tos, value);
}
void TemplateTable::lconst(int value) {
transition(vtos, ltos);
assert((value == 0) || (value == 1), "unexpected long constant");
__ mov(R0_tos, value);
__ mov(R1_tos_hi, 0);
}
void TemplateTable::fconst(int value) {
transition(vtos, ftos);
const int zero = 0; // 0.0f
const int one = 0x3f800000; // 1.0f
const int two = 0x40000000; // 2.0f
switch(value) {
case 0: __ mov(R0_tos, zero); break;
case 1: __ mov(R0_tos, one); break;
case 2: __ mov(R0_tos, two); break;
default: ShouldNotReachHere(); break;
}
#ifndef __SOFTFP__
__ fmsr(S0_tos, R0_tos);
#endif // !__SOFTFP__
}
void TemplateTable::dconst(int value) {
transition(vtos, dtos);
const int one_lo = 0; // low part of 1.0
const int one_hi = 0x3ff00000; // high part of 1.0
if (value == 0) {
#ifdef __SOFTFP__
__ mov(R0_tos_lo, 0);
__ mov(R1_tos_hi, 0);
#else
__ mov(R0_tmp, 0);
__ fmdrr(D0_tos, R0_tmp, R0_tmp);
#endif // __SOFTFP__
} else if (value == 1) {
__ mov(R0_tos_lo, one_lo);
__ mov_slow(R1_tos_hi, one_hi);
#ifndef __SOFTFP__
__ fmdrr(D0_tos, R0_tos_lo, R1_tos_hi);
#endif // !__SOFTFP__
} else {
ShouldNotReachHere();
}
}
void TemplateTable::bipush() {
transition(vtos, itos);
__ ldrsb(R0_tos, at_bcp(1));
}
void TemplateTable::sipush() {
transition(vtos, itos);
__ ldrsb(R0_tmp, at_bcp(1));
__ ldrb(R1_tmp, at_bcp(2));
__ orr(R0_tos, R1_tmp, AsmOperand(R0_tmp, lsl, BitsPerByte));
}
void TemplateTable::ldc(bool wide) {
transition(vtos, vtos);
Label fastCase, Condy, Done;
const Register Rindex = R1_tmp;
const Register Rcpool = R2_tmp;
const Register Rtags = R3_tmp;
const Register RtagType = R3_tmp;
if (wide) {
__ get_unsigned_2_byte_index_at_bcp(Rindex, 1);
} else {
__ ldrb(Rindex, at_bcp(1));
}
__ get_cpool_and_tags(Rcpool, Rtags);
const int base_offset = ConstantPool::header_size() * wordSize;
const int tags_offset = Array<u1>::base_offset_in_bytes();
// get const type
__ add(Rtemp, Rtags, tags_offset);
__ ldrb(RtagType, Address(Rtemp, Rindex));
volatile_barrier(MacroAssembler::LoadLoad, Rtemp);
// unresolved class - get the resolved class
__ cmp(RtagType, JVM_CONSTANT_UnresolvedClass);
// unresolved class in error (resolution failed) - call into runtime
// so that the same error from first resolution attempt is thrown.
__ cond_cmp(RtagType, JVM_CONSTANT_UnresolvedClassInError, ne);
// resolved class - need to call vm to get java mirror of the class
__ cond_cmp(RtagType, JVM_CONSTANT_Class, ne);
__ b(fastCase, ne);
// slow case - call runtime
__ mov(R1, wide);
call_VM(R0_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), R1);
__ push(atos);
__ b(Done);
// int, float, String
__ bind(fastCase);
__ cmp(RtagType, JVM_CONSTANT_Integer);
__ cond_cmp(RtagType, JVM_CONSTANT_Float, ne);
__ b(Condy, ne);
// itos, ftos
__ add(Rtemp, Rcpool, AsmOperand(Rindex, lsl, LogBytesPerWord));
__ ldr_u32(R0_tos, Address(Rtemp, base_offset));
// floats and ints are placed on stack in the same way, so
// we can use push(itos) to transfer float value without VFP
__ push(itos);
__ b(Done);
__ bind(Condy);
condy_helper(Done);
__ bind(Done);
}
// Fast path for caching oop constants.
void TemplateTable::fast_aldc(bool wide) {
transition(vtos, atos);
int index_size = wide ? sizeof(u2) : sizeof(u1);
Label resolved;
// We are resolved if the resolved reference cache entry contains a
// non-null object (CallSite, etc.)
assert_different_registers(R0_tos, R2_tmp);
__ get_index_at_bcp(R2_tmp, 1, R0_tos, index_size);
__ load_resolved_reference_at_index(R0_tos, R2_tmp);
__ cbnz(R0_tos, resolved);
address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc);
// first time invocation - must resolve first
__ mov(R1, (int)bytecode());
__ call_VM(R0_tos, entry, R1);
__ bind(resolved);
{ // Check for the null sentinel.
// If we just called the VM, that already did the mapping for us,
// but it's harmless to retry.
Label notNull;
Register result = R0;
Register tmp = R1;
Register rarg = R2;
// Stash null_sentinel address to get its value later
__ mov_slow(rarg, (uintptr_t)Universe::the_null_sentinel_addr());
__ ldr(tmp, Address(rarg));
__ resolve_oop_handle(tmp);
__ cmp(result, tmp);
__ b(notNull, ne);
__ mov(result, 0); // NULL object reference
__ bind(notNull);
}
if (VerifyOops) {
__ verify_oop(R0_tos);
}
}
void TemplateTable::ldc2_w() {
transition(vtos, vtos);
const Register Rtags = R2_tmp;
const Register Rindex = R3_tmp;
const Register Rcpool = R4_tmp;
const Register Rbase = R5_tmp;
__ get_unsigned_2_byte_index_at_bcp(Rindex, 1);
__ get_cpool_and_tags(Rcpool, Rtags);
const int base_offset = ConstantPool::header_size() * wordSize;
const int tags_offset = Array<u1>::base_offset_in_bytes();
__ add(Rbase, Rcpool, AsmOperand(Rindex, lsl, LogBytesPerWord));
// get type from tags
__ add(Rtemp, Rtags, tags_offset);
__ ldrb(Rtemp, Address(Rtemp, Rindex));
Label Done, NotLong, NotDouble;
__ cmp(Rtemp, JVM_CONSTANT_Double);
__ b(NotDouble, ne);
#ifdef __SOFTFP__
__ ldr(R0_tos_lo, Address(Rbase, base_offset + 0 * wordSize));
__ ldr(R1_tos_hi, Address(Rbase, base_offset + 1 * wordSize));
#else // !__SOFTFP__
__ ldr_double(D0_tos, Address(Rbase, base_offset));
#endif // __SOFTFP__
__ push(dtos);
__ b(Done);
__ bind(NotDouble);
__ cmp(Rtemp, JVM_CONSTANT_Long);
__ b(NotLong, ne);
__ ldr(R0_tos_lo, Address(Rbase, base_offset + 0 * wordSize));
__ ldr(R1_tos_hi, Address(Rbase, base_offset + 1 * wordSize));
__ push(ltos);
__ b(Done);
__ bind(NotLong);
condy_helper(Done);
__ bind(Done);
}
void TemplateTable::condy_helper(Label& Done)
{
Register obj = R0_tmp;
Register rtmp = R1_tmp;
Register flags = R2_tmp;
Register off = R3_tmp;
__ mov(rtmp, (int) bytecode());
__ call_VM(obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc), rtmp);
__ get_vm_result_2(flags, rtmp);
// VMr = obj = base address to find primitive value to push
// VMr2 = flags = (tos, off) using format of CPCE::_flags
__ mov(off, flags);
__ logical_shift_left( off, off, 32 - ConstantPoolCacheEntry::field_index_bits);
__ logical_shift_right(off, off, 32 - ConstantPoolCacheEntry::field_index_bits);
const Address field(obj, off);
__ logical_shift_right(flags, flags, ConstantPoolCacheEntry::tos_state_shift);
// Make sure we don't need to mask flags after the above shift
ConstantPoolCacheEntry::verify_tos_state_shift();
switch (bytecode()) {
case Bytecodes::_ldc:
case Bytecodes::_ldc_w:
{
// tos in (itos, ftos, stos, btos, ctos, ztos)
Label notIntFloat, notShort, notByte, notChar, notBool;
__ cmp(flags, itos);
__ cond_cmp(flags, ftos, ne);
__ b(notIntFloat, ne);
__ ldr(R0_tos, field);
__ push(itos);
__ b(Done);
__ bind(notIntFloat);
__ cmp(flags, stos);
__ b(notShort, ne);
__ ldrsh(R0_tos, field);
__ push(stos);
__ b(Done);
__ bind(notShort);
__ cmp(flags, btos);
__ b(notByte, ne);
__ ldrsb(R0_tos, field);
__ push(btos);
__ b(Done);
__ bind(notByte);
__ cmp(flags, ctos);
__ b(notChar, ne);
__ ldrh(R0_tos, field);
__ push(ctos);
__ b(Done);
__ bind(notChar);
__ cmp(flags, ztos);
__ b(notBool, ne);
__ ldrsb(R0_tos, field);
__ push(ztos);
__ b(Done);
__ bind(notBool);
break;
}
case Bytecodes::_ldc2_w:
{
Label notLongDouble;
__ cmp(flags, ltos);
__ cond_cmp(flags, dtos, ne);
__ b(notLongDouble, ne);
__ add(rtmp, obj, wordSize);
__ ldr(R0_tos_lo, Address(obj, off));
__ ldr(R1_tos_hi, Address(rtmp, off));
__ push(ltos);
__ b(Done);
__ bind(notLongDouble);
break;
}
default:
ShouldNotReachHere();
}
__ stop("bad ldc/condy");
}
void TemplateTable::locals_index(Register reg, int offset) {
__ ldrb(reg, at_bcp(offset));
}
void TemplateTable::iload() {
iload_internal();
}
void TemplateTable::nofast_iload() {
iload_internal(may_not_rewrite);
}
void TemplateTable::iload_internal(RewriteControl rc) {
transition(vtos, itos);
if ((rc == may_rewrite) && __ rewrite_frequent_pairs()) {
Label rewrite, done;
const Register next_bytecode = R1_tmp;
const Register target_bytecode = R2_tmp;
// get next byte
__ ldrb(next_bytecode, at_bcp(Bytecodes::length_for(Bytecodes::_iload)));
// if _iload, wait to rewrite to iload2. We only want to rewrite the
// last two iloads in a pair. Comparing against fast_iload means that
// the next bytecode is neither an iload or a caload, and therefore
// an iload pair.
__ cmp(next_bytecode, Bytecodes::_iload);
__ b(done, eq);
__ cmp(next_bytecode, Bytecodes::_fast_iload);
__ mov(target_bytecode, Bytecodes::_fast_iload2);
__ b(rewrite, eq);
// if _caload, rewrite to fast_icaload
__ cmp(next_bytecode, Bytecodes::_caload);
__ mov(target_bytecode, Bytecodes::_fast_icaload);
__ b(rewrite, eq);
// rewrite so iload doesn't check again.
__ mov(target_bytecode, Bytecodes::_fast_iload);
// rewrite
// R2: fast bytecode
__ bind(rewrite);
patch_bytecode(Bytecodes::_iload, target_bytecode, Rtemp, false);
__ bind(done);
}
// Get the local value into tos
const Register Rlocal_index = R1_tmp;
locals_index(Rlocal_index);
Address local = load_iaddress(Rlocal_index, Rtemp);
__ ldr_s32(R0_tos, local);
}
void TemplateTable::fast_iload2() {
transition(vtos, itos);
const Register Rlocal_index = R1_tmp;
locals_index(Rlocal_index);
Address local = load_iaddress(Rlocal_index, Rtemp);
__ ldr_s32(R0_tos, local);
__ push(itos);
locals_index(Rlocal_index, 3);
local = load_iaddress(Rlocal_index, Rtemp);
__ ldr_s32(R0_tos, local);
}
void TemplateTable::fast_iload() {
transition(vtos, itos);
const Register Rlocal_index = R1_tmp;
locals_index(Rlocal_index);
Address local = load_iaddress(Rlocal_index, Rtemp);
__ ldr_s32(R0_tos, local);
}
void TemplateTable::lload() {
transition(vtos, ltos);
const Register Rlocal_index = R2_tmp;
locals_index(Rlocal_index);
load_category2_local(Rlocal_index, R3_tmp);
}
void TemplateTable::fload() {
transition(vtos, ftos);
const Register Rlocal_index = R2_tmp;
// Get the local value into tos
locals_index(Rlocal_index);
Address local = load_faddress(Rlocal_index, Rtemp);
#ifdef __SOFTFP__
__ ldr(R0_tos, local);
#else
__ ldr_float(S0_tos, local);
#endif // __SOFTFP__
}
void TemplateTable::dload() {
transition(vtos, dtos);
const Register Rlocal_index = R2_tmp;
locals_index(Rlocal_index);
#ifdef __SOFTFP__
load_category2_local(Rlocal_index, R3_tmp);
#else
__ ldr_double(D0_tos, load_daddress(Rlocal_index, Rtemp));
#endif // __SOFTFP__
}
void TemplateTable::aload() {
transition(vtos, atos);
const Register Rlocal_index = R1_tmp;
locals_index(Rlocal_index);
Address local = load_aaddress(Rlocal_index, Rtemp);
__ ldr(R0_tos, local);
}
void TemplateTable::locals_index_wide(Register reg) {
assert_different_registers(reg, Rtemp);
__ ldrb(Rtemp, at_bcp(2));
__ ldrb(reg, at_bcp(3));
__ orr(reg, reg, AsmOperand(Rtemp, lsl, 8));
}
void TemplateTable::wide_iload() {
transition(vtos, itos);
const Register Rlocal_index = R2_tmp;
locals_index_wide(Rlocal_index);
Address local = load_iaddress(Rlocal_index, Rtemp);
__ ldr_s32(R0_tos, local);
}
void TemplateTable::wide_lload() {
transition(vtos, ltos);
const Register Rlocal_index = R2_tmp;
const Register Rlocal_base = R3_tmp;
locals_index_wide(Rlocal_index);
load_category2_local(Rlocal_index, R3_tmp);
}
void TemplateTable::wide_fload() {
transition(vtos, ftos);
const Register Rlocal_index = R2_tmp;
locals_index_wide(Rlocal_index);
Address local = load_faddress(Rlocal_index, Rtemp);
#ifdef __SOFTFP__
__ ldr(R0_tos, local);
#else
__ ldr_float(S0_tos, local);
#endif // __SOFTFP__
}
void TemplateTable::wide_dload() {
transition(vtos, dtos);
const Register Rlocal_index = R2_tmp;
locals_index_wide(Rlocal_index);
#ifdef __SOFTFP__
load_category2_local(Rlocal_index, R3_tmp);
#else
__ ldr_double(D0_tos, load_daddress(Rlocal_index, Rtemp));
#endif // __SOFTFP__
}
void TemplateTable::wide_aload() {
transition(vtos, atos);
const Register Rlocal_index = R2_tmp;
locals_index_wide(Rlocal_index);
Address local = load_aaddress(Rlocal_index, Rtemp);
__ ldr(R0_tos, local);
}
void TemplateTable::index_check(Register array, Register index) {
// Pop ptr into array
__ pop_ptr(array);
index_check_without_pop(array, index);
}
void TemplateTable::index_check_without_pop(Register array, Register index) {
assert_different_registers(array, index, Rtemp);
// check array
__ null_check(array, Rtemp, arrayOopDesc::length_offset_in_bytes());
// check index
__ ldr_s32(Rtemp, Address(array, arrayOopDesc::length_offset_in_bytes()));
__ cmp_32(index, Rtemp);
if (index != R4_ArrayIndexOutOfBounds_index) {
// convention with generate_ArrayIndexOutOfBounds_handler()
__ mov(R4_ArrayIndexOutOfBounds_index, index, hs);
}
__ mov(R1, array, hs);
__ b(Interpreter::_throw_ArrayIndexOutOfBoundsException_entry, hs);
}
void TemplateTable::iaload() {
transition(itos, itos);
const Register Rarray = R1_tmp;
const Register Rindex = R0_tos;
index_check(Rarray, Rindex);
Address addr = get_array_elem_addr_same_base(T_INT, Rarray, Rindex, Rtemp);
__ access_load_at(T_INT, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
}
void TemplateTable::laload() {
transition(itos, ltos);
const Register Rarray = R1_tmp;
const Register Rindex = R0_tos;
index_check(Rarray, Rindex);
Address addr = get_array_elem_addr_same_base(T_LONG, Rarray, Rindex, Rtemp);
__ access_load_at(T_LONG, IN_HEAP | IS_ARRAY, addr, noreg /* ltos */, noreg, noreg, noreg);
}
void TemplateTable::faload() {
transition(itos, ftos);
const Register Rarray = R1_tmp;
const Register Rindex = R0_tos;
index_check(Rarray, Rindex);
Address addr = get_array_elem_addr_same_base(T_FLOAT, Rarray, Rindex, Rtemp);
__ access_load_at(T_FLOAT, IN_HEAP | IS_ARRAY, addr, noreg /* ftos */, noreg, noreg, noreg);
}
void TemplateTable::daload() {
transition(itos, dtos);
const Register Rarray = R1_tmp;
const Register Rindex = R0_tos;
index_check(Rarray, Rindex);
Address addr = get_array_elem_addr_same_base(T_DOUBLE, Rarray, Rindex, Rtemp);
__ access_load_at(T_DOUBLE, IN_HEAP | IS_ARRAY, addr, noreg /* dtos */, noreg, noreg, noreg);
}
void TemplateTable::aaload() {
transition(itos, atos);
const Register Rarray = R1_tmp;
const Register Rindex = R0_tos;
index_check(Rarray, Rindex);
do_oop_load(_masm, R0_tos, get_array_elem_addr_same_base(T_OBJECT, Rarray, Rindex, Rtemp), IS_ARRAY);
}
void TemplateTable::baload() {
transition(itos, itos);
const Register Rarray = R1_tmp;
const Register Rindex = R0_tos;
index_check(Rarray, Rindex);
Address addr = get_array_elem_addr_same_base(T_BYTE, Rarray, Rindex, Rtemp);
__ access_load_at(T_BYTE, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
}
void TemplateTable::caload() {
transition(itos, itos);
const Register Rarray = R1_tmp;
const Register Rindex = R0_tos;
index_check(Rarray, Rindex);
Address addr = get_array_elem_addr_same_base(T_CHAR, Rarray, Rindex, Rtemp);
__ access_load_at(T_CHAR, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
}
// iload followed by caload frequent pair
void TemplateTable::fast_icaload() {
transition(vtos, itos);
const Register Rlocal_index = R1_tmp;
const Register Rarray = R1_tmp;
const Register Rindex = R4_tmp; // index_check prefers index on R4
assert_different_registers(Rlocal_index, Rindex);
assert_different_registers(Rarray, Rindex);
// load index out of locals
locals_index(Rlocal_index);
Address local = load_iaddress(Rlocal_index, Rtemp);
__ ldr_s32(Rindex, local);
// get array element
index_check(Rarray, Rindex);
Address addr = get_array_elem_addr_same_base(T_CHAR, Rarray, Rindex, Rtemp);
__ access_load_at(T_CHAR, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
}
void TemplateTable::saload() {
transition(itos, itos);
const Register Rarray = R1_tmp;
const Register Rindex = R0_tos;
index_check(Rarray, Rindex);
Address addr = get_array_elem_addr_same_base(T_SHORT, Rarray, Rindex, Rtemp);
__ access_load_at(T_SHORT, IN_HEAP | IS_ARRAY, addr, R0_tos, noreg, noreg, noreg);
}
void TemplateTable::iload(int n) {
transition(vtos, itos);
__ ldr_s32(R0_tos, iaddress(n));
}
void TemplateTable::lload(int n) {
transition(vtos, ltos);
__ ldr(R0_tos_lo, laddress(n));
__ ldr(R1_tos_hi, haddress(n));
}
void TemplateTable::fload(int n) {
transition(vtos, ftos);
#ifdef __SOFTFP__
__ ldr(R0_tos, faddress(n));
#else
__ ldr_float(S0_tos, faddress(n));
#endif // __SOFTFP__
}
void TemplateTable::dload(int n) {
transition(vtos, dtos);
#ifdef __SOFTFP__
__ ldr(R0_tos_lo, laddress(n));
__ ldr(R1_tos_hi, haddress(n));
#else
__ ldr_double(D0_tos, daddress(n));
#endif // __SOFTFP__
}
void TemplateTable::aload(int n) {
transition(vtos, atos);
__ ldr(R0_tos, aaddress(n));
}
void TemplateTable::aload_0() {
aload_0_internal();
}
void TemplateTable::nofast_aload_0() {
aload_0_internal(may_not_rewrite);
}
void TemplateTable::aload_0_internal(RewriteControl rc) {
transition(vtos, atos);
// According to bytecode histograms, the pairs:
//
// _aload_0, _fast_igetfield
// _aload_0, _fast_agetfield
// _aload_0, _fast_fgetfield
//
// occur frequently. If RewriteFrequentPairs is set, the (slow) _aload_0
// bytecode checks if the next bytecode is either _fast_igetfield,
// _fast_agetfield or _fast_fgetfield and then rewrites the
// current bytecode into a pair bytecode; otherwise it rewrites the current
// bytecode into _fast_aload_0 that doesn't do the pair check anymore.
//