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
|
%def field(helper=""):
/*
* General field read / write (iget-* iput-* sget-* sput-*).
*/
.extern $helper
mov x0, xPC // arg0: Instruction* inst
mov x1, xINST // arg1: uint16_t inst_data
add x2, xFP, #OFF_FP_SHADOWFRAME // arg2: ShadowFrame* sf
mov x3, xSELF // arg3: Thread* self
PREFETCH_INST 2 // prefetch next opcode
bl $helper
cbz x0, MterpPossibleException
ADVANCE 2
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
%def op_check_cast():
/*
* Check to see if a cast from one class to another is allowed.
*/
/* check-cast vAA, class//BBBB */
EXPORT_PC
FETCH w0, 1 // w0<- BBBB
lsr w1, wINST, #8 // w1<- AA
VREG_INDEX_TO_ADDR x1, w1 // w1<- &object
ldr x2, [xFP, #OFF_FP_METHOD] // w2<- method
mov x3, xSELF // w3<- self
bl MterpCheckCast // (index, &obj, method, self)
PREFETCH_INST 2
cbnz w0, MterpPossibleException
ADVANCE 2
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
%def op_iget(is_object=False, is_wide=False, load="ldr", helper="MterpIGetU32"):
// Fast-path which gets the field offset from thread-local cache.
add x0, xSELF, #THREAD_INTERPRETER_CACHE_OFFSET // cache address
ubfx x1, xPC, #2, #THREAD_INTERPRETER_CACHE_SIZE_LOG2 // entry index
add x0, x0, x1, lsl #4 // entry address within the cache
ldp x0, x1, [x0] // entry key (pc) and value (offset)
lsr w2, wINST, #12 // B
GET_VREG w2, w2 // object we're operating on
cmp x0, xPC
% slow_path_label = add_helper(lambda: field(helper))
b.ne ${slow_path_label} // cache miss
cbz w2, common_errNullObject // null object
% if is_wide:
ldr x0, [x2, x1] // x0<- obj.field
% else:
${load} w0, [x2, x1] // w0<- obj.field
% #endif
% if is_object:
UNPOISON_HEAP_REF w0
#if defined(USE_READ_BARRIER)
# if defined(USE_BAKER_READ_BARRIER)
ldr w1, [xSELF, #THREAD_IS_GC_MARKING_OFFSET]
cbnz w1, .L_${opcode}_mark // GC is active.
.L_${opcode}_marked:
# else
bl artReadBarrierMark // x0 <- artReadBarrierMark(x0)
# endif
#endif
% #endif
ubfx w2, wINST, #8, #4 // w2<- A
FETCH_ADVANCE_INST 2 // advance rPC, load rINST
% if is_object:
SET_VREG_OBJECT w0, w2 // fp[A]<- w0
% elif is_wide:
SET_VREG_WIDE x0, w2 // fp[A]<- x0
% else:
SET_VREG w0, w2 // fp[A]<- w0
% #endif
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
% if is_object:
#if defined(USE_READ_BARRIER) && defined(USE_BAKER_READ_BARRIER)
.L_${opcode}_mark:
bl artReadBarrierMark // x0 <- artReadBarrierMark(x0)
b .L_${opcode}_marked
#endif
% #endif
%def op_iget_boolean():
% op_iget(load="ldrb", helper="MterpIGetU8")
%def op_iget_boolean_quick():
% op_iget_quick(load="ldrb")
%def op_iget_byte():
% op_iget(load="ldrsb", helper="MterpIGetI8")
%def op_iget_byte_quick():
% op_iget_quick(load="ldrsb")
%def op_iget_char():
% op_iget(load="ldrh", helper="MterpIGetU16")
%def op_iget_char_quick():
% op_iget_quick(load="ldrh")
%def op_iget_object():
% op_iget(is_object=True, helper="MterpIGetObj")
%def op_iget_object_quick():
/* For: iget-object-quick */
/* op vA, vB, offset//CCCC */
lsr w2, wINST, #12 // w2<- B
FETCH w1, 1 // w1<- field byte offset
EXPORT_PC
GET_VREG w0, w2 // w0<- object we're operating on
bl artIGetObjectFromMterp // (obj, offset)
ldr x3, [xSELF, #THREAD_EXCEPTION_OFFSET]
ubfx w2, wINST, #8, #4 // w2<- A
PREFETCH_INST 2
cbnz w3, MterpPossibleException // bail out
SET_VREG_OBJECT w0, w2 // fp[A]<- w0
ADVANCE 2 // advance rPC
GET_INST_OPCODE ip // extract opcode from wINST
GOTO_OPCODE ip // jump to next instruction
%def op_iget_quick(load="ldr", extend=""):
/* For: iget-quick, iget-boolean-quick, iget-byte-quick, iget-char-quick, iget-short-quick */
/* op vA, vB, offset//CCCC */
lsr w2, wINST, #12 // w2<- B
FETCH w1, 1 // w1<- field byte offset
GET_VREG w3, w2 // w3<- object we're operating on
ubfx w2, wINST, #8, #4 // w2<- A
cbz w3, common_errNullObject // object was null
$load w0, [x3, x1] // w0<- obj.field
FETCH_ADVANCE_INST 2 // advance rPC, load rINST
$extend
SET_VREG w0, w2 // fp[A]<- w0
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
%def op_iget_short():
% op_iget(load="ldrsh", helper="MterpIGetI16")
%def op_iget_short_quick():
% op_iget_quick(load="ldrsh")
%def op_iget_wide():
% op_iget(is_wide=True, helper="MterpIGetU64")
%def op_iget_wide_quick():
/* iget-wide-quick vA, vB, offset//CCCC */
lsr w2, wINST, #12 // w2<- B
FETCH w4, 1 // w4<- field byte offset
GET_VREG w3, w2 // w3<- object we're operating on
ubfx w2, wINST, #8, #4 // w2<- A
cbz w3, common_errNullObject // object was null
ldr x0, [x3, x4] // x0<- obj.field
FETCH_ADVANCE_INST 2 // advance rPC, load wINST
SET_VREG_WIDE x0, w2
GET_INST_OPCODE ip // extract opcode from wINST
GOTO_OPCODE ip // jump to next instruction
%def op_instance_of():
/*
* Check to see if an object reference is an instance of a class.
*
* Most common situation is a non-null object, being compared against
* an already-resolved class.
*/
/* instance-of vA, vB, class//CCCC */
EXPORT_PC
FETCH w0, 1 // w0<- CCCC
lsr w1, wINST, #12 // w1<- B
VREG_INDEX_TO_ADDR x1, w1 // w1<- &object
ldr x2, [xFP, #OFF_FP_METHOD] // w2<- method
mov x3, xSELF // w3<- self
bl MterpInstanceOf // (index, &obj, method, self)
ldr x1, [xSELF, #THREAD_EXCEPTION_OFFSET]
ubfx w2, wINST, #8, #4 // w2<- A
PREFETCH_INST 2
cbnz x1, MterpException
ADVANCE 2 // advance rPC
SET_VREG w0, w2 // vA<- w0
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
%def op_iput(helper="MterpIPutU32"):
% field(helper=helper)
%def op_iput_boolean():
% op_iput(helper="MterpIPutU8")
%def op_iput_boolean_quick():
% op_iput_quick(store="strb")
%def op_iput_byte():
% op_iput(helper="MterpIPutI8")
%def op_iput_byte_quick():
% op_iput_quick(store="strb")
%def op_iput_char():
% op_iput(helper="MterpIPutU16")
%def op_iput_char_quick():
% op_iput_quick(store="strh")
%def op_iput_object():
% op_iput(helper="MterpIPutObj")
%def op_iput_object_quick():
EXPORT_PC
add x0, xFP, #OFF_FP_SHADOWFRAME
mov x1, xPC
mov w2, wINST
bl MterpIputObjectQuick
cbz w0, MterpException
FETCH_ADVANCE_INST 2 // advance rPC, load rINST
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
%def op_iput_quick(store="str"):
/* For: iput-quick, iput-object-quick */
/* op vA, vB, offset//CCCC */
lsr w2, wINST, #12 // w2<- B
FETCH w1, 1 // w1<- field byte offset
GET_VREG w3, w2 // w3<- fp[B], the object pointer
ubfx w2, wINST, #8, #4 // w2<- A
cbz w3, common_errNullObject // object was null
GET_VREG w0, w2 // w0<- fp[A]
FETCH_ADVANCE_INST 2 // advance rPC, load rINST
$store w0, [x3, x1] // obj.field<- w0
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
%def op_iput_short():
% op_iput(helper="MterpIPutI16")
%def op_iput_short_quick():
% op_iput_quick(store="strh")
%def op_iput_wide():
% op_iput(helper="MterpIPutU64")
%def op_iput_wide_quick():
/* iput-wide-quick vA, vB, offset//CCCC */
lsr w2, wINST, #12 // w2<- B
FETCH w3, 1 // w3<- field byte offset
GET_VREG w2, w2 // w2<- fp[B], the object pointer
ubfx w0, wINST, #8, #4 // w0<- A
cbz w2, common_errNullObject // object was null
GET_VREG_WIDE x0, w0 // x0<- fp[A]
FETCH_ADVANCE_INST 2 // advance rPC, load wINST
str x0, [x2, x3] // obj.field<- x0
GET_INST_OPCODE ip // extract opcode from wINST
GOTO_OPCODE ip // jump to next instruction
%def op_new_instance():
/*
* Create a new instance of a class.
*/
/* new-instance vAA, class//BBBB */
EXPORT_PC
add x0, xFP, #OFF_FP_SHADOWFRAME
mov x1, xSELF
mov w2, wINST
bl MterpNewInstance // (shadow_frame, self, inst_data)
cbz w0, MterpPossibleException
FETCH_ADVANCE_INST 2 // advance rPC, load rINST
GET_INST_OPCODE ip // extract opcode from rINST
GOTO_OPCODE ip // jump to next instruction
%def op_sget(helper="MterpSGetU32"):
% field(helper=helper)
%def op_sget_boolean():
% op_sget(helper="MterpSGetU8")
%def op_sget_byte():
% op_sget(helper="MterpSGetI8")
%def op_sget_char():
% op_sget(helper="MterpSGetU16")
%def op_sget_object():
% op_sget(helper="MterpSGetObj")
%def op_sget_short():
% op_sget(helper="MterpSGetI16")
%def op_sget_wide():
% op_sget(helper="MterpSGetU64")
%def op_sput(helper="MterpSPutU32"):
% field(helper=helper)
%def op_sput_boolean():
% op_sput(helper="MterpSPutU8")
%def op_sput_byte():
% op_sput(helper="MterpSPutI8")
%def op_sput_char():
% op_sput(helper="MterpSPutU16")
%def op_sput_object():
% op_sput(helper="MterpSPutObj")
%def op_sput_short():
% op_sput(helper="MterpSPutI16")
%def op_sput_wide():
% op_sput(helper="MterpSPutU64")
|