1%def op_aget(load="ldr", shift="2", data_offset="MIRROR_INT_ARRAY_DATA_OFFSET", wide="0", is_object="0"): 2/* 3 * Array get. vAA <- vBB[vCC]. 4 * 5 * for: aget, aget-boolean, aget-byte, aget-char, aget-short, aget-wide, aget-object 6 * 7 */ 8 FETCH_B w2, 1, 0 // w2<- BB 9 lsr w9, wINST, #8 // w9<- AA 10 FETCH_B w3, 1, 1 // w3<- CC 11 GET_VREG w0, w2 // w0<- vBB (array object) 12 GET_VREG w1, w3 // w1<- vCC (requested index) 13 cbz x0, common_errNullObject // bail if null array object. 14 ldr w3, [x0, #MIRROR_ARRAY_LENGTH_OFFSET] // w3<- arrayObj->length 15 add x0, x0, w1, uxtw #$shift // w0<- arrayObj + index*width 16 cmp w1, w3 // compare unsigned index, length 17 bcs common_errArrayIndex // index >= length, bail 18 FETCH_ADVANCE_INST 2 // advance rPC, load rINST 19 GET_INST_OPCODE x10 // extract opcode from wINST 20 .if $wide 21 ldr x2, [x0, #$data_offset] // x2<- vBB[vCC] 22 SET_VREG_WIDE x2, w9 23 GOTO_OPCODE x10 // jump to next instruction 24 .elseif $is_object 25 $load w2, [x0, #$data_offset] // w2<- vBB[vCC] 26 cbnz wMR, 2f 271: 28 SET_VREG_OBJECT w2, w9 // vAA<- w2 29 GOTO_OPCODE x10 // jump to next instruction 302: 31 bl art_quick_read_barrier_mark_reg02 32 b 1b 33 .else 34 $load w2, [x0, #$data_offset] // w2<- vBB[vCC] 35 SET_VREG w2, w9 // vAA<- w2 36 GOTO_OPCODE x10 // jump to next instruction 37 .endif 38 39%def op_aget_boolean(): 40% op_aget(load="ldrb", shift="0", data_offset="MIRROR_BOOLEAN_ARRAY_DATA_OFFSET", is_object="0") 41 42%def op_aget_byte(): 43% op_aget(load="ldrsb", shift="0", data_offset="MIRROR_BYTE_ARRAY_DATA_OFFSET", is_object="0") 44 45%def op_aget_char(): 46% op_aget(load="ldrh", shift="1", data_offset="MIRROR_CHAR_ARRAY_DATA_OFFSET", is_object="0") 47 48%def op_aget_object(): 49% op_aget(load="ldr", shift="2", data_offset="MIRROR_OBJECT_ARRAY_DATA_OFFSET", is_object="1") 50 51%def op_aget_short(): 52% op_aget(load="ldrsh", shift="1", data_offset="MIRROR_SHORT_ARRAY_DATA_OFFSET", is_object="0") 53 54%def op_aget_wide(): 55% op_aget(load="ldr", shift="3", data_offset="MIRROR_WIDE_ARRAY_DATA_OFFSET", wide="1", is_object="0") 56 57%def op_aput(store="str", shift="2", data_offset="MIRROR_INT_ARRAY_DATA_OFFSET", wide="0", is_object="0"): 58/* 59 * Array put. vBB[vCC] <- vAA. 60 * 61 * for: aput, aput-boolean, aput-byte, aput-char, aput-short, aput-wide, aput-object 62 * 63 */ 64 FETCH_B w2, 1, 0 // w2<- BB 65 lsr w9, wINST, #8 // w9<- AA 66 FETCH_B w3, 1, 1 // w3<- CC 67 GET_VREG w0, w2 // w0<- vBB (array object) 68 GET_VREG w1, w3 // w1<- vCC (requested index) 69 cbz w0, common_errNullObject // bail if null 70 ldr w3, [x0, #MIRROR_ARRAY_LENGTH_OFFSET] // w3<- arrayObj->length 71 .if !$is_object 72 add x0, x0, w1, uxtw #$shift // w0<- arrayObj + index*width 73 .endif 74 cmp w1, w3 // compare unsigned index, length 75 bcs common_errArrayIndex // index >= length, bail 76 .if $is_object 77 EXPORT_PC // Export PC before overwriting it. 78 .endif 79 FETCH_ADVANCE_INST 2 // advance rPC, load rINST 80 .if $wide 81 GET_VREG_WIDE x2, w9 // x2<- vAA 82 .else 83 GET_VREG w2, w9 // w2<- vAA 84 .endif 85 .if $wide 86 $store x2, [x0, #$data_offset] // vBB[vCC]<- x2 87 .elseif $is_object 88 bl art_quick_aput_obj 89 .else 90 $store w2, [x0, #$data_offset] // vBB[vCC]<- w2 91 .endif 92 GET_INST_OPCODE ip // extract opcode from rINST 93 GOTO_OPCODE ip // jump to next instruction 94 95%def op_aput_boolean(): 96% op_aput(store="strb", shift="0", data_offset="MIRROR_BOOLEAN_ARRAY_DATA_OFFSET", wide="0", is_object="0") 97 98%def op_aput_byte(): 99% op_aput(store="strb", shift="0", data_offset="MIRROR_BYTE_ARRAY_DATA_OFFSET", wide="0", is_object="0") 100 101%def op_aput_char(): 102% op_aput(store="strh", shift="1", data_offset="MIRROR_CHAR_ARRAY_DATA_OFFSET", wide="0", is_object="0") 103 104%def op_aput_short(): 105% op_aput(store="strh", shift="1", data_offset="MIRROR_SHORT_ARRAY_DATA_OFFSET", wide="0", is_object="0") 106 107%def op_aput_wide(): 108% op_aput(store="str", shift="3", data_offset="MIRROR_WIDE_ARRAY_DATA_OFFSET", wide="1", is_object="0") 109 110%def op_aput_object(): 111% op_aput(store="str", shift="2", data_offset="MIRROR_INT_ARRAY_DATA_OFFSET", wide="0", is_object="1") 112 113%def op_array_length(): 114 /* 115 * Return the length of an array. 116 */ 117 lsr w1, wINST, #12 // w1<- B 118 ubfx w2, wINST, #8, #4 // w2<- A 119 GET_VREG w0, w1 // w0<- vB (object ref) 120 cbz w0, common_errNullObject // bail if null 121 FETCH_ADVANCE_INST 1 // advance rPC, load rINST 122 ldr w3, [x0, #MIRROR_ARRAY_LENGTH_OFFSET] // w3<- array length 123 GET_INST_OPCODE ip // extract opcode from rINST 124 SET_VREG w3, w2 // vB<- length 125 GOTO_OPCODE ip // jump to next instruction 126 127%def op_fill_array_data(): 128 /* fill-array-data vAA, +BBBBBBBB */ 129 EXPORT_PC 130 FETCH w0, 1 // x0<- 000000000000bbbb (lo) 131 FETCH_S x1, 2 // x1<- ssssssssssssBBBB (hi) 132 lsr w3, wINST, #8 // w3<- AA 133 orr x0, x0, x1, lsl #16 // x0<- ssssssssBBBBbbbb 134 GET_VREG w1, w3 // w1<- vAA (array object) 135 add x0, xPC, x0, lsl #1 // x0<- PC + ssssssssBBBBbbbb*2 (array data off.) 136 bl art_quick_handle_fill_data 137 FETCH_ADVANCE_INST 3 // advance rPC, load rINST 138 GET_INST_OPCODE ip // extract opcode from rINST 139 GOTO_OPCODE ip // jump to next instruction 140 141%def op_filled_new_array(helper="nterp_filled_new_array"): 142/* 143 * Create a new array with elements filled from registers. 144 * 145 * for: filled-new-array, filled-new-array/range 146 */ 147 /* op vB, {vD, vE, vF, vG, vA}, class@CCCC */ 148 /* op {vCCCC..v(CCCC+AA-1)}, type@BBBB */ 149 EXPORT_PC 150 mov x0, xSELF 151 ldr x1, [sp] 152 mov x2, xFP 153 mov x3, xPC 154 bl $helper 155 FETCH_ADVANCE_INST 3 // advance rPC, load rINST 156 GET_INST_OPCODE ip // extract opcode from rINST 157 GOTO_OPCODE ip // jump to next instruction 158 159%def op_filled_new_array_range(): 160% op_filled_new_array(helper="nterp_filled_new_array_range") 161 162%def op_new_array(): 163 b NterpNewArray 164