1 /* 2 * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2014, Red Hat Inc. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 #include "precompiled.hpp" 27 #include "asm/macroAssembler.inline.hpp" 28 #include "compiler/disassembler.hpp" 29 #include "compiler/compilerDefinitions.inline.hpp" 30 #include "gc/shared/barrierSetAssembler.hpp" 31 #include "gc/shared/collectedHeap.hpp" 32 #include "gc/shared/tlab_globals.hpp" 33 #include "interpreter/interpreter.hpp" 34 #include "interpreter/interpreterRuntime.hpp" 35 #include "interpreter/interp_masm.hpp" 36 #include "interpreter/templateTable.hpp" 37 #include "memory/universe.hpp" 38 #include "oops/methodData.hpp" 39 #include "oops/method.inline.hpp" 40 #include "oops/objArrayKlass.hpp" 41 #include "oops/oop.inline.hpp" 42 #include "oops/resolvedFieldEntry.hpp" 43 #include "oops/resolvedIndyEntry.hpp" 44 #include "oops/resolvedMethodEntry.hpp" 45 #include "prims/jvmtiExport.hpp" 46 #include "prims/methodHandles.hpp" 47 #include "runtime/frame.inline.hpp" 48 #include "runtime/sharedRuntime.hpp" 49 #include "runtime/stubRoutines.hpp" 50 #include "runtime/synchronizer.hpp" 51 #include "utilities/powerOfTwo.hpp" 52 53 #define __ Disassembler::hook<InterpreterMacroAssembler>(__FILE__, __LINE__, _masm)-> 54 55 // Address computation: local variables 56 57 static inline Address iaddress(int n) { 58 return Address(rlocals, Interpreter::local_offset_in_bytes(n)); 59 } 60 61 static inline Address laddress(int n) { 62 return iaddress(n + 1); 63 } 64 65 static inline Address faddress(int n) { 66 return iaddress(n); 67 } 68 69 static inline Address daddress(int n) { 70 return laddress(n); 71 } 72 73 static inline Address aaddress(int n) { 74 return iaddress(n); 75 } 76 77 static inline Address iaddress(Register r) { 78 return Address(rlocals, r, Address::lsl(3)); 79 } 80 81 static inline Address laddress(Register r, Register scratch, 82 InterpreterMacroAssembler* _masm) { 83 __ lea(scratch, Address(rlocals, r, Address::lsl(3))); 84 return Address(scratch, Interpreter::local_offset_in_bytes(1)); 85 } 86 87 static inline Address faddress(Register r) { 88 return iaddress(r); 89 } 90 91 static inline Address daddress(Register r, Register scratch, 92 InterpreterMacroAssembler* _masm) { 93 return laddress(r, scratch, _masm); 94 } 95 96 static inline Address aaddress(Register r) { 97 return iaddress(r); 98 } 99 100 static inline Address at_rsp() { 101 return Address(esp, 0); 102 } 103 104 // At top of Java expression stack which may be different than esp(). It 105 // isn't for category 1 objects. 106 static inline Address at_tos () { 107 return Address(esp, Interpreter::expr_offset_in_bytes(0)); 108 } 109 110 static inline Address at_tos_p1() { 111 return Address(esp, Interpreter::expr_offset_in_bytes(1)); 112 } 113 114 static inline Address at_tos_p2() { 115 return Address(esp, Interpreter::expr_offset_in_bytes(2)); 116 } 117 118 static inline Address at_tos_p3() { 119 return Address(esp, Interpreter::expr_offset_in_bytes(3)); 120 } 121 122 static inline Address at_tos_p4() { 123 return Address(esp, Interpreter::expr_offset_in_bytes(4)); 124 } 125 126 static inline Address at_tos_p5() { 127 return Address(esp, Interpreter::expr_offset_in_bytes(5)); 128 } 129 130 // Condition conversion 131 static Assembler::Condition j_not(TemplateTable::Condition cc) { 132 switch (cc) { 133 case TemplateTable::equal : return Assembler::NE; 134 case TemplateTable::not_equal : return Assembler::EQ; 135 case TemplateTable::less : return Assembler::GE; 136 case TemplateTable::less_equal : return Assembler::GT; 137 case TemplateTable::greater : return Assembler::LE; 138 case TemplateTable::greater_equal: return Assembler::LT; 139 } 140 ShouldNotReachHere(); 141 return Assembler::EQ; 142 } 143 144 145 // Miscellaneous helper routines 146 // Store an oop (or null) at the Address described by obj. 147 // If val == noreg this means store a null 148 static void do_oop_store(InterpreterMacroAssembler* _masm, 149 Address dst, 150 Register val, 151 DecoratorSet decorators) { 152 assert(val == noreg || val == r0, "parameter is just for looks"); 153 __ store_heap_oop(dst, val, r10, r11, r3, decorators); 154 } 155 156 static void do_oop_load(InterpreterMacroAssembler* _masm, 157 Address src, 158 Register dst, 159 DecoratorSet decorators) { 160 __ load_heap_oop(dst, src, r10, r11, decorators); 161 } 162 163 Address TemplateTable::at_bcp(int offset) { 164 assert(_desc->uses_bcp(), "inconsistent uses_bcp information"); 165 return Address(rbcp, offset); 166 } 167 168 void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg, 169 Register temp_reg, bool load_bc_into_bc_reg/*=true*/, 170 int byte_no) 171 { 172 if (!RewriteBytecodes) return; 173 Label L_patch_done; 174 175 switch (bc) { 176 case Bytecodes::_fast_vputfield: 177 case Bytecodes::_fast_aputfield: 178 case Bytecodes::_fast_bputfield: 179 case Bytecodes::_fast_zputfield: 180 case Bytecodes::_fast_cputfield: 181 case Bytecodes::_fast_dputfield: 182 case Bytecodes::_fast_fputfield: 183 case Bytecodes::_fast_iputfield: 184 case Bytecodes::_fast_lputfield: 185 case Bytecodes::_fast_sputfield: 186 { 187 // We skip bytecode quickening for putfield instructions when 188 // the put_code written to the constant pool cache is zero. 189 // This is required so that every execution of this instruction 190 // calls out to InterpreterRuntime::resolve_get_put to do 191 // additional, required work. 192 assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); 193 assert(load_bc_into_bc_reg, "we use bc_reg as temp"); 194 __ load_field_entry(temp_reg, bc_reg); 195 if (byte_no == f1_byte) { 196 __ lea(temp_reg, Address(temp_reg, in_bytes(ResolvedFieldEntry::get_code_offset()))); 197 } else { 198 __ lea(temp_reg, Address(temp_reg, in_bytes(ResolvedFieldEntry::put_code_offset()))); 199 } 200 // Load-acquire the bytecode to match store-release in ResolvedFieldEntry::fill_in() 201 __ ldarb(temp_reg, temp_reg); 202 __ movw(bc_reg, bc); 203 __ cbzw(temp_reg, L_patch_done); // don't patch 204 } 205 break; 206 default: 207 assert(byte_no == -1, "sanity"); 208 // the pair bytecodes have already done the load. 209 if (load_bc_into_bc_reg) { 210 __ movw(bc_reg, bc); 211 } 212 } 213 214 if (JvmtiExport::can_post_breakpoint()) { 215 Label L_fast_patch; 216 // if a breakpoint is present we can't rewrite the stream directly 217 __ load_unsigned_byte(temp_reg, at_bcp(0)); 218 __ cmpw(temp_reg, Bytecodes::_breakpoint); 219 __ br(Assembler::NE, L_fast_patch); 220 // Let breakpoint table handling rewrite to quicker bytecode 221 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::set_original_bytecode_at), rmethod, rbcp, bc_reg); 222 __ b(L_patch_done); 223 __ bind(L_fast_patch); 224 } 225 226 #ifdef ASSERT 227 Label L_okay; 228 __ load_unsigned_byte(temp_reg, at_bcp(0)); 229 __ cmpw(temp_reg, (int) Bytecodes::java_code(bc)); 230 __ br(Assembler::EQ, L_okay); 231 __ cmpw(temp_reg, bc_reg); 232 __ br(Assembler::EQ, L_okay); 233 __ stop("patching the wrong bytecode"); 234 __ bind(L_okay); 235 #endif 236 237 // patch bytecode 238 __ strb(bc_reg, at_bcp(0)); 239 __ bind(L_patch_done); 240 } 241 242 243 // Individual instructions 244 245 void TemplateTable::nop() { 246 transition(vtos, vtos); 247 // nothing to do 248 } 249 250 void TemplateTable::shouldnotreachhere() { 251 transition(vtos, vtos); 252 __ stop("shouldnotreachhere bytecode"); 253 } 254 255 void TemplateTable::aconst_null() 256 { 257 transition(vtos, atos); 258 __ mov(r0, 0); 259 } 260 261 void TemplateTable::iconst(int value) 262 { 263 transition(vtos, itos); 264 __ mov(r0, value); 265 } 266 267 void TemplateTable::lconst(int value) 268 { 269 __ mov(r0, value); 270 } 271 272 void TemplateTable::fconst(int value) 273 { 274 transition(vtos, ftos); 275 switch (value) { 276 case 0: 277 __ fmovs(v0, 0.0); 278 break; 279 case 1: 280 __ fmovs(v0, 1.0); 281 break; 282 case 2: 283 __ fmovs(v0, 2.0); 284 break; 285 default: 286 ShouldNotReachHere(); 287 break; 288 } 289 } 290 291 void TemplateTable::dconst(int value) 292 { 293 transition(vtos, dtos); 294 switch (value) { 295 case 0: 296 __ fmovd(v0, 0.0); 297 break; 298 case 1: 299 __ fmovd(v0, 1.0); 300 break; 301 case 2: 302 __ fmovd(v0, 2.0); 303 break; 304 default: 305 ShouldNotReachHere(); 306 break; 307 } 308 } 309 310 void TemplateTable::bipush() 311 { 312 transition(vtos, itos); 313 __ load_signed_byte32(r0, at_bcp(1)); 314 } 315 316 void TemplateTable::sipush() 317 { 318 transition(vtos, itos); 319 __ load_unsigned_short(r0, at_bcp(1)); 320 __ revw(r0, r0); 321 __ asrw(r0, r0, 16); 322 } 323 324 void TemplateTable::ldc(LdcType type) 325 { 326 transition(vtos, vtos); 327 Label call_ldc, notFloat, notClass, notInt, Done; 328 329 if (is_ldc_wide(type)) { 330 __ get_unsigned_2_byte_index_at_bcp(r1, 1); 331 } else { 332 __ load_unsigned_byte(r1, at_bcp(1)); 333 } 334 __ get_cpool_and_tags(r2, r0); 335 336 const int base_offset = ConstantPool::header_size() * wordSize; 337 const int tags_offset = Array<u1>::base_offset_in_bytes(); 338 339 // get type 340 __ add(r3, r1, tags_offset); 341 __ lea(r3, Address(r0, r3)); 342 __ ldarb(r3, r3); 343 344 // unresolved class - get the resolved class 345 __ cmp(r3, (u1)JVM_CONSTANT_UnresolvedClass); 346 __ br(Assembler::EQ, call_ldc); 347 348 // unresolved class in error state - call into runtime to throw the error 349 // from the first resolution attempt 350 __ cmp(r3, (u1)JVM_CONSTANT_UnresolvedClassInError); 351 __ br(Assembler::EQ, call_ldc); 352 353 // resolved class - need to call vm to get java mirror of the class 354 __ cmp(r3, (u1)JVM_CONSTANT_Class); 355 __ br(Assembler::NE, notClass); 356 357 __ bind(call_ldc); 358 __ mov(c_rarg1, is_ldc_wide(type) ? 1 : 0); 359 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), c_rarg1); 360 __ push_ptr(r0); 361 __ verify_oop(r0); 362 __ b(Done); 363 364 __ bind(notClass); 365 __ cmp(r3, (u1)JVM_CONSTANT_Float); 366 __ br(Assembler::NE, notFloat); 367 // ftos 368 __ adds(r1, r2, r1, Assembler::LSL, 3); 369 __ ldrs(v0, Address(r1, base_offset)); 370 __ push_f(); 371 __ b(Done); 372 373 __ bind(notFloat); 374 375 __ cmp(r3, (u1)JVM_CONSTANT_Integer); 376 __ br(Assembler::NE, notInt); 377 378 // itos 379 __ adds(r1, r2, r1, Assembler::LSL, 3); 380 __ ldrw(r0, Address(r1, base_offset)); 381 __ push_i(r0); 382 __ b(Done); 383 384 __ bind(notInt); 385 condy_helper(Done); 386 387 __ bind(Done); 388 } 389 390 // Fast path for caching oop constants. 391 void TemplateTable::fast_aldc(LdcType type) 392 { 393 transition(vtos, atos); 394 395 Register result = r0; 396 Register tmp = r1; 397 Register rarg = r2; 398 399 int index_size = is_ldc_wide(type) ? sizeof(u2) : sizeof(u1); 400 401 Label resolved; 402 403 // We are resolved if the resolved reference cache entry contains a 404 // non-null object (String, MethodType, etc.) 405 assert_different_registers(result, tmp); 406 __ get_cache_index_at_bcp(tmp, 1, index_size); 407 __ load_resolved_reference_at_index(result, tmp); 408 __ cbnz(result, resolved); 409 410 address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc); 411 412 // first time invocation - must resolve first 413 __ mov(rarg, (int)bytecode()); 414 __ call_VM(result, entry, rarg); 415 416 __ bind(resolved); 417 418 { // Check for the null sentinel. 419 // If we just called the VM, it already did the mapping for us, 420 // but it's harmless to retry. 421 Label notNull; 422 423 // Stash null_sentinel address to get its value later 424 __ movptr(rarg, (uintptr_t)Universe::the_null_sentinel_addr()); 425 __ ldr(tmp, Address(rarg)); 426 __ resolve_oop_handle(tmp, r5, rscratch2); 427 __ cmpoop(result, tmp); 428 __ br(Assembler::NE, notNull); 429 __ mov(result, 0); // null object reference 430 __ bind(notNull); 431 } 432 433 if (VerifyOops) { 434 // Safe to call with 0 result 435 __ verify_oop(result); 436 } 437 } 438 439 void TemplateTable::ldc2_w() 440 { 441 transition(vtos, vtos); 442 Label notDouble, notLong, Done; 443 __ get_unsigned_2_byte_index_at_bcp(r0, 1); 444 445 __ get_cpool_and_tags(r1, r2); 446 const int base_offset = ConstantPool::header_size() * wordSize; 447 const int tags_offset = Array<u1>::base_offset_in_bytes(); 448 449 // get type 450 __ lea(r2, Address(r2, r0, Address::lsl(0))); 451 __ load_unsigned_byte(r2, Address(r2, tags_offset)); 452 __ cmpw(r2, (int)JVM_CONSTANT_Double); 453 __ br(Assembler::NE, notDouble); 454 455 // dtos 456 __ lea (r2, Address(r1, r0, Address::lsl(3))); 457 __ ldrd(v0, Address(r2, base_offset)); 458 __ push_d(); 459 __ b(Done); 460 461 __ bind(notDouble); 462 __ cmpw(r2, (int)JVM_CONSTANT_Long); 463 __ br(Assembler::NE, notLong); 464 465 // ltos 466 __ lea(r0, Address(r1, r0, Address::lsl(3))); 467 __ ldr(r0, Address(r0, base_offset)); 468 __ push_l(); 469 __ b(Done); 470 471 __ bind(notLong); 472 condy_helper(Done); 473 474 __ bind(Done); 475 } 476 477 void TemplateTable::condy_helper(Label& Done) 478 { 479 Register obj = r0; 480 Register rarg = r1; 481 Register flags = r2; 482 Register off = r3; 483 484 address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc); 485 486 __ mov(rarg, (int) bytecode()); 487 __ call_VM(obj, entry, rarg); 488 489 __ get_vm_result_2(flags, rthread); 490 491 // VMr = obj = base address to find primitive value to push 492 // VMr2 = flags = (tos, off) using format of CPCE::_flags 493 __ mov(off, flags); 494 __ andw(off, off, ConstantPoolCache::field_index_mask); 495 496 const Address field(obj, off); 497 498 // What sort of thing are we loading? 499 // x86 uses a shift and mask or wings it with a shift plus assert 500 // the mask is not needed. aarch64 just uses bitfield extract 501 __ ubfxw(flags, flags, ConstantPoolCache::tos_state_shift, 502 ConstantPoolCache::tos_state_bits); 503 504 switch (bytecode()) { 505 case Bytecodes::_ldc: 506 case Bytecodes::_ldc_w: 507 { 508 // tos in (itos, ftos, stos, btos, ctos, ztos) 509 Label notInt, notFloat, notShort, notByte, notChar, notBool; 510 __ cmpw(flags, itos); 511 __ br(Assembler::NE, notInt); 512 // itos 513 __ ldrw(r0, field); 514 __ push(itos); 515 __ b(Done); 516 517 __ bind(notInt); 518 __ cmpw(flags, ftos); 519 __ br(Assembler::NE, notFloat); 520 // ftos 521 __ load_float(field); 522 __ push(ftos); 523 __ b(Done); 524 525 __ bind(notFloat); 526 __ cmpw(flags, stos); 527 __ br(Assembler::NE, notShort); 528 // stos 529 __ load_signed_short(r0, field); 530 __ push(stos); 531 __ b(Done); 532 533 __ bind(notShort); 534 __ cmpw(flags, btos); 535 __ br(Assembler::NE, notByte); 536 // btos 537 __ load_signed_byte(r0, field); 538 __ push(btos); 539 __ b(Done); 540 541 __ bind(notByte); 542 __ cmpw(flags, ctos); 543 __ br(Assembler::NE, notChar); 544 // ctos 545 __ load_unsigned_short(r0, field); 546 __ push(ctos); 547 __ b(Done); 548 549 __ bind(notChar); 550 __ cmpw(flags, ztos); 551 __ br(Assembler::NE, notBool); 552 // ztos 553 __ load_signed_byte(r0, field); 554 __ push(ztos); 555 __ b(Done); 556 557 __ bind(notBool); 558 break; 559 } 560 561 case Bytecodes::_ldc2_w: 562 { 563 Label notLong, notDouble; 564 __ cmpw(flags, ltos); 565 __ br(Assembler::NE, notLong); 566 // ltos 567 __ ldr(r0, field); 568 __ push(ltos); 569 __ b(Done); 570 571 __ bind(notLong); 572 __ cmpw(flags, dtos); 573 __ br(Assembler::NE, notDouble); 574 // dtos 575 __ load_double(field); 576 __ push(dtos); 577 __ b(Done); 578 579 __ bind(notDouble); 580 break; 581 } 582 583 default: 584 ShouldNotReachHere(); 585 } 586 587 __ stop("bad ldc/condy"); 588 } 589 590 void TemplateTable::locals_index(Register reg, int offset) 591 { 592 __ ldrb(reg, at_bcp(offset)); 593 __ neg(reg, reg); 594 } 595 596 void TemplateTable::iload() { 597 iload_internal(); 598 } 599 600 void TemplateTable::nofast_iload() { 601 iload_internal(may_not_rewrite); 602 } 603 604 void TemplateTable::iload_internal(RewriteControl rc) { 605 transition(vtos, itos); 606 if (RewriteFrequentPairs && rc == may_rewrite) { 607 Label rewrite, done; 608 Register bc = r4; 609 610 // get next bytecode 611 __ load_unsigned_byte(r1, at_bcp(Bytecodes::length_for(Bytecodes::_iload))); 612 613 // if _iload, wait to rewrite to iload2. We only want to rewrite the 614 // last two iloads in a pair. Comparing against fast_iload means that 615 // the next bytecode is neither an iload or a caload, and therefore 616 // an iload pair. 617 __ cmpw(r1, Bytecodes::_iload); 618 __ br(Assembler::EQ, done); 619 620 // if _fast_iload rewrite to _fast_iload2 621 __ cmpw(r1, Bytecodes::_fast_iload); 622 __ movw(bc, Bytecodes::_fast_iload2); 623 __ br(Assembler::EQ, rewrite); 624 625 // if _caload rewrite to _fast_icaload 626 __ cmpw(r1, Bytecodes::_caload); 627 __ movw(bc, Bytecodes::_fast_icaload); 628 __ br(Assembler::EQ, rewrite); 629 630 // else rewrite to _fast_iload 631 __ movw(bc, Bytecodes::_fast_iload); 632 633 // rewrite 634 // bc: new bytecode 635 __ bind(rewrite); 636 patch_bytecode(Bytecodes::_iload, bc, r1, false); 637 __ bind(done); 638 639 } 640 641 // do iload, get the local value into tos 642 locals_index(r1); 643 __ ldr(r0, iaddress(r1)); 644 645 } 646 647 void TemplateTable::fast_iload2() 648 { 649 transition(vtos, itos); 650 locals_index(r1); 651 __ ldr(r0, iaddress(r1)); 652 __ push(itos); 653 locals_index(r1, 3); 654 __ ldr(r0, iaddress(r1)); 655 } 656 657 void TemplateTable::fast_iload() 658 { 659 transition(vtos, itos); 660 locals_index(r1); 661 __ ldr(r0, iaddress(r1)); 662 } 663 664 void TemplateTable::lload() 665 { 666 transition(vtos, ltos); 667 __ ldrb(r1, at_bcp(1)); 668 __ sub(r1, rlocals, r1, ext::uxtw, LogBytesPerWord); 669 __ ldr(r0, Address(r1, Interpreter::local_offset_in_bytes(1))); 670 } 671 672 void TemplateTable::fload() 673 { 674 transition(vtos, ftos); 675 locals_index(r1); 676 // n.b. we use ldrd here because this is a 64 bit slot 677 // this is comparable to the iload case 678 __ ldrd(v0, faddress(r1)); 679 } 680 681 void TemplateTable::dload() 682 { 683 transition(vtos, dtos); 684 __ ldrb(r1, at_bcp(1)); 685 __ sub(r1, rlocals, r1, ext::uxtw, LogBytesPerWord); 686 __ ldrd(v0, Address(r1, Interpreter::local_offset_in_bytes(1))); 687 } 688 689 void TemplateTable::aload() 690 { 691 transition(vtos, atos); 692 locals_index(r1); 693 __ ldr(r0, iaddress(r1)); 694 } 695 696 void TemplateTable::locals_index_wide(Register reg) { 697 __ ldrh(reg, at_bcp(2)); 698 __ rev16w(reg, reg); 699 __ neg(reg, reg); 700 } 701 702 void TemplateTable::wide_iload() { 703 transition(vtos, itos); 704 locals_index_wide(r1); 705 __ ldr(r0, iaddress(r1)); 706 } 707 708 void TemplateTable::wide_lload() 709 { 710 transition(vtos, ltos); 711 __ ldrh(r1, at_bcp(2)); 712 __ rev16w(r1, r1); 713 __ sub(r1, rlocals, r1, ext::uxtw, LogBytesPerWord); 714 __ ldr(r0, Address(r1, Interpreter::local_offset_in_bytes(1))); 715 } 716 717 void TemplateTable::wide_fload() 718 { 719 transition(vtos, ftos); 720 locals_index_wide(r1); 721 // n.b. we use ldrd here because this is a 64 bit slot 722 // this is comparable to the iload case 723 __ ldrd(v0, faddress(r1)); 724 } 725 726 void TemplateTable::wide_dload() 727 { 728 transition(vtos, dtos); 729 __ ldrh(r1, at_bcp(2)); 730 __ rev16w(r1, r1); 731 __ sub(r1, rlocals, r1, ext::uxtw, LogBytesPerWord); 732 __ ldrd(v0, Address(r1, Interpreter::local_offset_in_bytes(1))); 733 } 734 735 void TemplateTable::wide_aload() 736 { 737 transition(vtos, atos); 738 locals_index_wide(r1); 739 __ ldr(r0, aaddress(r1)); 740 } 741 742 void TemplateTable::index_check(Register array, Register index) 743 { 744 // destroys r1, rscratch1 745 // sign extend index for use by indexed load 746 // __ movl2ptr(index, index); 747 // check index 748 Register length = rscratch1; 749 __ ldrw(length, Address(array, arrayOopDesc::length_offset_in_bytes())); 750 __ cmpw(index, length); 751 if (index != r1) { 752 // ??? convention: move aberrant index into r1 for exception message 753 assert(r1 != array, "different registers"); 754 __ mov(r1, index); 755 } 756 Label ok; 757 __ br(Assembler::LO, ok); 758 // ??? convention: move array into r3 for exception message 759 __ mov(r3, array); 760 __ mov(rscratch1, Interpreter::_throw_ArrayIndexOutOfBoundsException_entry); 761 __ br(rscratch1); 762 __ bind(ok); 763 } 764 765 void TemplateTable::iaload() 766 { 767 transition(itos, itos); 768 __ mov(r1, r0); 769 __ pop_ptr(r0); 770 // r0: array 771 // r1: index 772 index_check(r0, r1); // leaves index in r1, kills rscratch1 773 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_INT) >> 2); 774 __ access_load_at(T_INT, IN_HEAP | IS_ARRAY, r0, Address(r0, r1, Address::uxtw(2)), noreg, noreg); 775 } 776 777 void TemplateTable::laload() 778 { 779 transition(itos, ltos); 780 __ mov(r1, r0); 781 __ pop_ptr(r0); 782 // r0: array 783 // r1: index 784 index_check(r0, r1); // leaves index in r1, kills rscratch1 785 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_LONG) >> 3); 786 __ access_load_at(T_LONG, IN_HEAP | IS_ARRAY, r0, Address(r0, r1, Address::uxtw(3)), noreg, noreg); 787 } 788 789 void TemplateTable::faload() 790 { 791 transition(itos, ftos); 792 __ mov(r1, r0); 793 __ pop_ptr(r0); 794 // r0: array 795 // r1: index 796 index_check(r0, r1); // leaves index in r1, kills rscratch1 797 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_FLOAT) >> 2); 798 __ access_load_at(T_FLOAT, IN_HEAP | IS_ARRAY, r0, Address(r0, r1, Address::uxtw(2)), noreg, noreg); 799 } 800 801 void TemplateTable::daload() 802 { 803 transition(itos, dtos); 804 __ mov(r1, r0); 805 __ pop_ptr(r0); 806 // r0: array 807 // r1: index 808 index_check(r0, r1); // leaves index in r1, kills rscratch1 809 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_DOUBLE) >> 3); 810 __ access_load_at(T_DOUBLE, IN_HEAP | IS_ARRAY, r0, Address(r0, r1, Address::uxtw(3)), noreg, noreg); 811 } 812 813 void TemplateTable::aaload() 814 { 815 transition(itos, atos); 816 __ mov(r1, r0); 817 __ pop_ptr(r0); 818 // r0: array 819 // r1: index 820 index_check(r0, r1); // leaves index in r1, kills rscratch1 821 __ profile_array_type<ArrayLoadData>(r2, r0, r4); 822 if (UseFlatArray) { 823 Label is_flat_array, done; 824 825 __ test_flat_array_oop(r0, r8 /*temp*/, is_flat_array); 826 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_OBJECT) >> LogBytesPerHeapOop); 827 do_oop_load(_masm, Address(r0, r1, Address::uxtw(LogBytesPerHeapOop)), r0, IS_ARRAY); 828 829 __ b(done); 830 __ bind(is_flat_array); 831 __ call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::value_array_load), r0, r1); 832 // Ensure the stores to copy the inline field contents are visible 833 // before any subsequent store that publishes this reference. 834 __ membar(Assembler::StoreStore); 835 __ bind(done); 836 } else { 837 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_OBJECT) >> LogBytesPerHeapOop); 838 do_oop_load(_masm, Address(r0, r1, Address::uxtw(LogBytesPerHeapOop)), r0, IS_ARRAY); 839 } 840 __ profile_element_type(r2, r0, r4); 841 } 842 843 void TemplateTable::baload() 844 { 845 transition(itos, itos); 846 __ mov(r1, r0); 847 __ pop_ptr(r0); 848 // r0: array 849 // r1: index 850 index_check(r0, r1); // leaves index in r1, kills rscratch1 851 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_BYTE) >> 0); 852 __ access_load_at(T_BYTE, IN_HEAP | IS_ARRAY, r0, Address(r0, r1, Address::uxtw(0)), noreg, noreg); 853 } 854 855 void TemplateTable::caload() 856 { 857 transition(itos, itos); 858 __ mov(r1, r0); 859 __ pop_ptr(r0); 860 // r0: array 861 // r1: index 862 index_check(r0, r1); // leaves index in r1, kills rscratch1 863 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_CHAR) >> 1); 864 __ access_load_at(T_CHAR, IN_HEAP | IS_ARRAY, r0, Address(r0, r1, Address::uxtw(1)), noreg, noreg); 865 } 866 867 // iload followed by caload frequent pair 868 void TemplateTable::fast_icaload() 869 { 870 transition(vtos, itos); 871 // load index out of locals 872 locals_index(r2); 873 __ ldr(r1, iaddress(r2)); 874 875 __ pop_ptr(r0); 876 877 // r0: array 878 // r1: index 879 index_check(r0, r1); // leaves index in r1, kills rscratch1 880 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_CHAR) >> 1); 881 __ access_load_at(T_CHAR, IN_HEAP | IS_ARRAY, r0, Address(r0, r1, Address::uxtw(1)), noreg, noreg); 882 } 883 884 void TemplateTable::saload() 885 { 886 transition(itos, itos); 887 __ mov(r1, r0); 888 __ pop_ptr(r0); 889 // r0: array 890 // r1: index 891 index_check(r0, r1); // leaves index in r1, kills rscratch1 892 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_SHORT) >> 1); 893 __ access_load_at(T_SHORT, IN_HEAP | IS_ARRAY, r0, Address(r0, r1, Address::uxtw(1)), noreg, noreg); 894 } 895 896 void TemplateTable::iload(int n) 897 { 898 transition(vtos, itos); 899 __ ldr(r0, iaddress(n)); 900 } 901 902 void TemplateTable::lload(int n) 903 { 904 transition(vtos, ltos); 905 __ ldr(r0, laddress(n)); 906 } 907 908 void TemplateTable::fload(int n) 909 { 910 transition(vtos, ftos); 911 __ ldrs(v0, faddress(n)); 912 } 913 914 void TemplateTable::dload(int n) 915 { 916 transition(vtos, dtos); 917 __ ldrd(v0, daddress(n)); 918 } 919 920 void TemplateTable::aload(int n) 921 { 922 transition(vtos, atos); 923 __ ldr(r0, iaddress(n)); 924 } 925 926 void TemplateTable::aload_0() { 927 aload_0_internal(); 928 } 929 930 void TemplateTable::nofast_aload_0() { 931 aload_0_internal(may_not_rewrite); 932 } 933 934 void TemplateTable::aload_0_internal(RewriteControl rc) { 935 // According to bytecode histograms, the pairs: 936 // 937 // _aload_0, _fast_igetfield 938 // _aload_0, _fast_agetfield 939 // _aload_0, _fast_fgetfield 940 // 941 // occur frequently. If RewriteFrequentPairs is set, the (slow) 942 // _aload_0 bytecode checks if the next bytecode is either 943 // _fast_igetfield, _fast_agetfield or _fast_fgetfield and then 944 // rewrites the current bytecode into a pair bytecode; otherwise it 945 // rewrites the current bytecode into _fast_aload_0 that doesn't do 946 // the pair check anymore. 947 // 948 // Note: If the next bytecode is _getfield, the rewrite must be 949 // delayed, otherwise we may miss an opportunity for a pair. 950 // 951 // Also rewrite frequent pairs 952 // aload_0, aload_1 953 // aload_0, iload_1 954 // These bytecodes with a small amount of code are most profitable 955 // to rewrite 956 if (RewriteFrequentPairs && rc == may_rewrite) { 957 Label rewrite, done; 958 const Register bc = r4; 959 960 // get next bytecode 961 __ load_unsigned_byte(r1, at_bcp(Bytecodes::length_for(Bytecodes::_aload_0))); 962 963 // if _getfield then wait with rewrite 964 __ cmpw(r1, Bytecodes::Bytecodes::_getfield); 965 __ br(Assembler::EQ, done); 966 967 // if _igetfield then rewrite to _fast_iaccess_0 968 assert(Bytecodes::java_code(Bytecodes::_fast_iaccess_0) == Bytecodes::_aload_0, "fix bytecode definition"); 969 __ cmpw(r1, Bytecodes::_fast_igetfield); 970 __ movw(bc, Bytecodes::_fast_iaccess_0); 971 __ br(Assembler::EQ, rewrite); 972 973 // if _agetfield then rewrite to _fast_aaccess_0 974 assert(Bytecodes::java_code(Bytecodes::_fast_aaccess_0) == Bytecodes::_aload_0, "fix bytecode definition"); 975 __ cmpw(r1, Bytecodes::_fast_agetfield); 976 __ movw(bc, Bytecodes::_fast_aaccess_0); 977 __ br(Assembler::EQ, rewrite); 978 979 // if _fgetfield then rewrite to _fast_faccess_0 980 assert(Bytecodes::java_code(Bytecodes::_fast_faccess_0) == Bytecodes::_aload_0, "fix bytecode definition"); 981 __ cmpw(r1, Bytecodes::_fast_fgetfield); 982 __ movw(bc, Bytecodes::_fast_faccess_0); 983 __ br(Assembler::EQ, rewrite); 984 985 // else rewrite to _fast_aload0 986 assert(Bytecodes::java_code(Bytecodes::_fast_aload_0) == Bytecodes::_aload_0, "fix bytecode definition"); 987 __ movw(bc, Bytecodes::Bytecodes::_fast_aload_0); 988 989 // rewrite 990 // bc: new bytecode 991 __ bind(rewrite); 992 patch_bytecode(Bytecodes::_aload_0, bc, r1, false); 993 994 __ bind(done); 995 } 996 997 // Do actual aload_0 (must do this after patch_bytecode which might call VM and GC might change oop). 998 aload(0); 999 } 1000 1001 void TemplateTable::istore() 1002 { 1003 transition(itos, vtos); 1004 locals_index(r1); 1005 // FIXME: We're being very pernickerty here storing a jint in a 1006 // local with strw, which costs an extra instruction over what we'd 1007 // be able to do with a simple str. We should just store the whole 1008 // word. 1009 __ lea(rscratch1, iaddress(r1)); 1010 __ strw(r0, Address(rscratch1)); 1011 } 1012 1013 void TemplateTable::lstore() 1014 { 1015 transition(ltos, vtos); 1016 locals_index(r1); 1017 __ str(r0, laddress(r1, rscratch1, _masm)); 1018 } 1019 1020 void TemplateTable::fstore() { 1021 transition(ftos, vtos); 1022 locals_index(r1); 1023 __ lea(rscratch1, iaddress(r1)); 1024 __ strs(v0, Address(rscratch1)); 1025 } 1026 1027 void TemplateTable::dstore() { 1028 transition(dtos, vtos); 1029 locals_index(r1); 1030 __ strd(v0, daddress(r1, rscratch1, _masm)); 1031 } 1032 1033 void TemplateTable::astore() 1034 { 1035 transition(vtos, vtos); 1036 __ pop_ptr(r0); 1037 locals_index(r1); 1038 __ str(r0, aaddress(r1)); 1039 } 1040 1041 void TemplateTable::wide_istore() { 1042 transition(vtos, vtos); 1043 __ pop_i(); 1044 locals_index_wide(r1); 1045 __ lea(rscratch1, iaddress(r1)); 1046 __ strw(r0, Address(rscratch1)); 1047 } 1048 1049 void TemplateTable::wide_lstore() { 1050 transition(vtos, vtos); 1051 __ pop_l(); 1052 locals_index_wide(r1); 1053 __ str(r0, laddress(r1, rscratch1, _masm)); 1054 } 1055 1056 void TemplateTable::wide_fstore() { 1057 transition(vtos, vtos); 1058 __ pop_f(); 1059 locals_index_wide(r1); 1060 __ lea(rscratch1, faddress(r1)); 1061 __ strs(v0, rscratch1); 1062 } 1063 1064 void TemplateTable::wide_dstore() { 1065 transition(vtos, vtos); 1066 __ pop_d(); 1067 locals_index_wide(r1); 1068 __ strd(v0, daddress(r1, rscratch1, _masm)); 1069 } 1070 1071 void TemplateTable::wide_astore() { 1072 transition(vtos, vtos); 1073 __ pop_ptr(r0); 1074 locals_index_wide(r1); 1075 __ str(r0, aaddress(r1)); 1076 } 1077 1078 void TemplateTable::iastore() { 1079 transition(itos, vtos); 1080 __ pop_i(r1); 1081 __ pop_ptr(r3); 1082 // r0: value 1083 // r1: index 1084 // r3: array 1085 index_check(r3, r1); // prefer index in r1 1086 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_INT) >> 2); 1087 __ access_store_at(T_INT, IN_HEAP | IS_ARRAY, Address(r3, r1, Address::uxtw(2)), r0, noreg, noreg, noreg); 1088 } 1089 1090 void TemplateTable::lastore() { 1091 transition(ltos, vtos); 1092 __ pop_i(r1); 1093 __ pop_ptr(r3); 1094 // r0: value 1095 // r1: index 1096 // r3: array 1097 index_check(r3, r1); // prefer index in r1 1098 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_LONG) >> 3); 1099 __ access_store_at(T_LONG, IN_HEAP | IS_ARRAY, Address(r3, r1, Address::uxtw(3)), r0, noreg, noreg, noreg); 1100 } 1101 1102 void TemplateTable::fastore() { 1103 transition(ftos, vtos); 1104 __ pop_i(r1); 1105 __ pop_ptr(r3); 1106 // v0: value 1107 // r1: index 1108 // r3: array 1109 index_check(r3, r1); // prefer index in r1 1110 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_FLOAT) >> 2); 1111 __ access_store_at(T_FLOAT, IN_HEAP | IS_ARRAY, Address(r3, r1, Address::uxtw(2)), noreg /* ftos */, noreg, noreg, noreg); 1112 } 1113 1114 void TemplateTable::dastore() { 1115 transition(dtos, vtos); 1116 __ pop_i(r1); 1117 __ pop_ptr(r3); 1118 // v0: value 1119 // r1: index 1120 // r3: array 1121 index_check(r3, r1); // prefer index in r1 1122 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_DOUBLE) >> 3); 1123 __ access_store_at(T_DOUBLE, IN_HEAP | IS_ARRAY, Address(r3, r1, Address::uxtw(3)), noreg /* dtos */, noreg, noreg, noreg); 1124 } 1125 1126 void TemplateTable::aastore() { 1127 Label is_null, is_flat_array, ok_is_subtype, done; 1128 transition(vtos, vtos); 1129 // stack: ..., array, index, value 1130 __ ldr(r0, at_tos()); // value 1131 __ ldr(r2, at_tos_p1()); // index 1132 __ ldr(r3, at_tos_p2()); // array 1133 1134 index_check(r3, r2); // kills r1 1135 1136 __ profile_array_type<ArrayStoreData>(r4, r3, r5); 1137 __ profile_multiple_element_types(r4, r0, r5, r6); 1138 1139 __ add(r4, r2, arrayOopDesc::base_offset_in_bytes(T_OBJECT) >> LogBytesPerHeapOop); 1140 Address element_address(r3, r4, Address::uxtw(LogBytesPerHeapOop)); 1141 // Be careful not to clobber r4 below 1142 1143 // do array store check - check for null value first 1144 __ cbz(r0, is_null); 1145 1146 // Move array class to r5 1147 __ load_klass(r5, r3); 1148 1149 if (UseFlatArray) { 1150 __ ldrw(r6, Address(r5, Klass::layout_helper_offset())); 1151 __ test_flat_array_layout(r6, is_flat_array); 1152 } 1153 1154 // Move subklass into r1 1155 __ load_klass(r1, r0); 1156 1157 // Move array element superklass into r0 1158 __ ldr(r0, Address(r5, ObjArrayKlass::element_klass_offset())); 1159 // Compress array + index*oopSize + 12 into a single register. Frees r2. 1160 1161 // Generate subtype check. Blows r2, r5 1162 // Superklass in r0. Subklass in r1. 1163 1164 // is "r1 <: r0" ? (value subclass <: array element superclass) 1165 __ gen_subtype_check(r1, ok_is_subtype, false); 1166 1167 // Come here on failure 1168 // object is at TOS 1169 __ b(Interpreter::_throw_ArrayStoreException_entry); 1170 1171 // Come here on success 1172 __ bind(ok_is_subtype); 1173 1174 // Get the value we will store 1175 __ ldr(r0, at_tos()); 1176 // Now store using the appropriate barrier 1177 do_oop_store(_masm, element_address, r0, IS_ARRAY); 1178 __ b(done); 1179 1180 // Have a null in r0, r3=array, r2=index. Store null at ary[idx] 1181 __ bind(is_null); 1182 if (EnableValhalla) { 1183 Label is_null_into_value_array_npe, store_null; 1184 1185 // No way to store null in flat null-free array 1186 __ test_null_free_array_oop(r3, r8, is_null_into_value_array_npe); 1187 __ b(store_null); 1188 1189 __ bind(is_null_into_value_array_npe); 1190 __ b(ExternalAddress(Interpreter::_throw_NullPointerException_entry)); 1191 1192 __ bind(store_null); 1193 } 1194 1195 // Store a null 1196 do_oop_store(_masm, element_address, noreg, IS_ARRAY); 1197 __ b(done); 1198 1199 if (UseFlatArray) { 1200 Label is_type_ok; 1201 __ bind(is_flat_array); // Store non-null value to flat 1202 1203 // Simplistic type check... 1204 // r0 - value, r2 - index, r3 - array. 1205 1206 // Profile the not-null value's klass. 1207 // Load value class 1208 __ load_klass(r1, r0); 1209 1210 // Move element klass into r7 1211 __ ldr(r7, Address(r5, ArrayKlass::element_klass_offset())); 1212 1213 // flat value array needs exact type match 1214 // is "r1 == r7" (value subclass == array element superclass) 1215 1216 __ cmp(r7, r1); 1217 __ br(Assembler::EQ, is_type_ok); 1218 1219 __ b(ExternalAddress(Interpreter::_throw_ArrayStoreException_entry)); 1220 1221 __ bind(is_type_ok); 1222 // r1: value's klass 1223 // r3: array 1224 // r5: array klass 1225 __ test_klass_is_empty_inline_type(r1, r7, done); 1226 1227 // calc dst for copy 1228 __ ldrw(r7, at_tos_p1()); // index 1229 __ data_for_value_array_index(r3, r5, r7, r7); 1230 1231 // ...and src for copy 1232 __ ldr(r6, at_tos()); // value 1233 __ data_for_oop(r6, r6, r1); 1234 1235 __ mov(r4, r1); // Shuffle arguments to avoid conflict with c_rarg1 1236 __ access_value_copy(IN_HEAP, r6, r7, r4); 1237 } 1238 1239 // Pop stack arguments 1240 __ bind(done); 1241 __ add(esp, esp, 3 * Interpreter::stackElementSize); 1242 } 1243 1244 void TemplateTable::bastore() 1245 { 1246 transition(itos, vtos); 1247 __ pop_i(r1); 1248 __ pop_ptr(r3); 1249 // r0: value 1250 // r1: index 1251 // r3: array 1252 index_check(r3, r1); // prefer index in r1 1253 1254 // Need to check whether array is boolean or byte 1255 // since both types share the bastore bytecode. 1256 __ load_klass(r2, r3); 1257 __ ldrw(r2, Address(r2, Klass::layout_helper_offset())); 1258 int diffbit_index = exact_log2(Klass::layout_helper_boolean_diffbit()); 1259 Label L_skip; 1260 __ tbz(r2, diffbit_index, L_skip); 1261 __ andw(r0, r0, 1); // if it is a T_BOOLEAN array, mask the stored value to 0/1 1262 __ bind(L_skip); 1263 1264 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_BYTE) >> 0); 1265 __ access_store_at(T_BYTE, IN_HEAP | IS_ARRAY, Address(r3, r1, Address::uxtw(0)), r0, noreg, noreg, noreg); 1266 } 1267 1268 void TemplateTable::castore() 1269 { 1270 transition(itos, vtos); 1271 __ pop_i(r1); 1272 __ pop_ptr(r3); 1273 // r0: value 1274 // r1: index 1275 // r3: array 1276 index_check(r3, r1); // prefer index in r1 1277 __ add(r1, r1, arrayOopDesc::base_offset_in_bytes(T_CHAR) >> 1); 1278 __ access_store_at(T_CHAR, IN_HEAP | IS_ARRAY, Address(r3, r1, Address::uxtw(1)), r0, noreg, noreg, noreg); 1279 } 1280 1281 void TemplateTable::sastore() 1282 { 1283 castore(); 1284 } 1285 1286 void TemplateTable::istore(int n) 1287 { 1288 transition(itos, vtos); 1289 __ str(r0, iaddress(n)); 1290 } 1291 1292 void TemplateTable::lstore(int n) 1293 { 1294 transition(ltos, vtos); 1295 __ str(r0, laddress(n)); 1296 } 1297 1298 void TemplateTable::fstore(int n) 1299 { 1300 transition(ftos, vtos); 1301 __ strs(v0, faddress(n)); 1302 } 1303 1304 void TemplateTable::dstore(int n) 1305 { 1306 transition(dtos, vtos); 1307 __ strd(v0, daddress(n)); 1308 } 1309 1310 void TemplateTable::astore(int n) 1311 { 1312 transition(vtos, vtos); 1313 __ pop_ptr(r0); 1314 __ str(r0, iaddress(n)); 1315 } 1316 1317 void TemplateTable::pop() 1318 { 1319 transition(vtos, vtos); 1320 __ add(esp, esp, Interpreter::stackElementSize); 1321 } 1322 1323 void TemplateTable::pop2() 1324 { 1325 transition(vtos, vtos); 1326 __ add(esp, esp, 2 * Interpreter::stackElementSize); 1327 } 1328 1329 void TemplateTable::dup() 1330 { 1331 transition(vtos, vtos); 1332 __ ldr(r0, Address(esp, 0)); 1333 __ push(r0); 1334 // stack: ..., a, a 1335 } 1336 1337 void TemplateTable::dup_x1() 1338 { 1339 transition(vtos, vtos); 1340 // stack: ..., a, b 1341 __ ldr(r0, at_tos()); // load b 1342 __ ldr(r2, at_tos_p1()); // load a 1343 __ str(r0, at_tos_p1()); // store b 1344 __ str(r2, at_tos()); // store a 1345 __ push(r0); // push b 1346 // stack: ..., b, a, b 1347 } 1348 1349 void TemplateTable::dup_x2() 1350 { 1351 transition(vtos, vtos); 1352 // stack: ..., a, b, c 1353 __ ldr(r0, at_tos()); // load c 1354 __ ldr(r2, at_tos_p2()); // load a 1355 __ str(r0, at_tos_p2()); // store c in a 1356 __ push(r0); // push c 1357 // stack: ..., c, b, c, c 1358 __ ldr(r0, at_tos_p2()); // load b 1359 __ str(r2, at_tos_p2()); // store a in b 1360 // stack: ..., c, a, c, c 1361 __ str(r0, at_tos_p1()); // store b in c 1362 // stack: ..., c, a, b, c 1363 } 1364 1365 void TemplateTable::dup2() 1366 { 1367 transition(vtos, vtos); 1368 // stack: ..., a, b 1369 __ ldr(r0, at_tos_p1()); // load a 1370 __ push(r0); // push a 1371 __ ldr(r0, at_tos_p1()); // load b 1372 __ push(r0); // push b 1373 // stack: ..., a, b, a, b 1374 } 1375 1376 void TemplateTable::dup2_x1() 1377 { 1378 transition(vtos, vtos); 1379 // stack: ..., a, b, c 1380 __ ldr(r2, at_tos()); // load c 1381 __ ldr(r0, at_tos_p1()); // load b 1382 __ push(r0); // push b 1383 __ push(r2); // push c 1384 // stack: ..., a, b, c, b, c 1385 __ str(r2, at_tos_p3()); // store c in b 1386 // stack: ..., a, c, c, b, c 1387 __ ldr(r2, at_tos_p4()); // load a 1388 __ str(r2, at_tos_p2()); // store a in 2nd c 1389 // stack: ..., a, c, a, b, c 1390 __ str(r0, at_tos_p4()); // store b in a 1391 // stack: ..., b, c, a, b, c 1392 } 1393 1394 void TemplateTable::dup2_x2() 1395 { 1396 transition(vtos, vtos); 1397 // stack: ..., a, b, c, d 1398 __ ldr(r2, at_tos()); // load d 1399 __ ldr(r0, at_tos_p1()); // load c 1400 __ push(r0) ; // push c 1401 __ push(r2); // push d 1402 // stack: ..., a, b, c, d, c, d 1403 __ ldr(r0, at_tos_p4()); // load b 1404 __ str(r0, at_tos_p2()); // store b in d 1405 __ str(r2, at_tos_p4()); // store d in b 1406 // stack: ..., a, d, c, b, c, d 1407 __ ldr(r2, at_tos_p5()); // load a 1408 __ ldr(r0, at_tos_p3()); // load c 1409 __ str(r2, at_tos_p3()); // store a in c 1410 __ str(r0, at_tos_p5()); // store c in a 1411 // stack: ..., c, d, a, b, c, d 1412 } 1413 1414 void TemplateTable::swap() 1415 { 1416 transition(vtos, vtos); 1417 // stack: ..., a, b 1418 __ ldr(r2, at_tos_p1()); // load a 1419 __ ldr(r0, at_tos()); // load b 1420 __ str(r2, at_tos()); // store a in b 1421 __ str(r0, at_tos_p1()); // store b in a 1422 // stack: ..., b, a 1423 } 1424 1425 void TemplateTable::iop2(Operation op) 1426 { 1427 transition(itos, itos); 1428 // r0 <== r1 op r0 1429 __ pop_i(r1); 1430 switch (op) { 1431 case add : __ addw(r0, r1, r0); break; 1432 case sub : __ subw(r0, r1, r0); break; 1433 case mul : __ mulw(r0, r1, r0); break; 1434 case _and : __ andw(r0, r1, r0); break; 1435 case _or : __ orrw(r0, r1, r0); break; 1436 case _xor : __ eorw(r0, r1, r0); break; 1437 case shl : __ lslvw(r0, r1, r0); break; 1438 case shr : __ asrvw(r0, r1, r0); break; 1439 case ushr : __ lsrvw(r0, r1, r0);break; 1440 default : ShouldNotReachHere(); 1441 } 1442 } 1443 1444 void TemplateTable::lop2(Operation op) 1445 { 1446 transition(ltos, ltos); 1447 // r0 <== r1 op r0 1448 __ pop_l(r1); 1449 switch (op) { 1450 case add : __ add(r0, r1, r0); break; 1451 case sub : __ sub(r0, r1, r0); break; 1452 case mul : __ mul(r0, r1, r0); break; 1453 case _and : __ andr(r0, r1, r0); break; 1454 case _or : __ orr(r0, r1, r0); break; 1455 case _xor : __ eor(r0, r1, r0); break; 1456 default : ShouldNotReachHere(); 1457 } 1458 } 1459 1460 void TemplateTable::idiv() 1461 { 1462 transition(itos, itos); 1463 // explicitly check for div0 1464 Label no_div0; 1465 __ cbnzw(r0, no_div0); 1466 __ mov(rscratch1, Interpreter::_throw_ArithmeticException_entry); 1467 __ br(rscratch1); 1468 __ bind(no_div0); 1469 __ pop_i(r1); 1470 // r0 <== r1 idiv r0 1471 __ corrected_idivl(r0, r1, r0, /* want_remainder */ false); 1472 } 1473 1474 void TemplateTable::irem() 1475 { 1476 transition(itos, itos); 1477 // explicitly check for div0 1478 Label no_div0; 1479 __ cbnzw(r0, no_div0); 1480 __ mov(rscratch1, Interpreter::_throw_ArithmeticException_entry); 1481 __ br(rscratch1); 1482 __ bind(no_div0); 1483 __ pop_i(r1); 1484 // r0 <== r1 irem r0 1485 __ corrected_idivl(r0, r1, r0, /* want_remainder */ true); 1486 } 1487 1488 void TemplateTable::lmul() 1489 { 1490 transition(ltos, ltos); 1491 __ pop_l(r1); 1492 __ mul(r0, r0, r1); 1493 } 1494 1495 void TemplateTable::ldiv() 1496 { 1497 transition(ltos, ltos); 1498 // explicitly check for div0 1499 Label no_div0; 1500 __ cbnz(r0, no_div0); 1501 __ mov(rscratch1, Interpreter::_throw_ArithmeticException_entry); 1502 __ br(rscratch1); 1503 __ bind(no_div0); 1504 __ pop_l(r1); 1505 // r0 <== r1 ldiv r0 1506 __ corrected_idivq(r0, r1, r0, /* want_remainder */ false); 1507 } 1508 1509 void TemplateTable::lrem() 1510 { 1511 transition(ltos, ltos); 1512 // explicitly check for div0 1513 Label no_div0; 1514 __ cbnz(r0, no_div0); 1515 __ mov(rscratch1, Interpreter::_throw_ArithmeticException_entry); 1516 __ br(rscratch1); 1517 __ bind(no_div0); 1518 __ pop_l(r1); 1519 // r0 <== r1 lrem r0 1520 __ corrected_idivq(r0, r1, r0, /* want_remainder */ true); 1521 } 1522 1523 void TemplateTable::lshl() 1524 { 1525 transition(itos, ltos); 1526 // shift count is in r0 1527 __ pop_l(r1); 1528 __ lslv(r0, r1, r0); 1529 } 1530 1531 void TemplateTable::lshr() 1532 { 1533 transition(itos, ltos); 1534 // shift count is in r0 1535 __ pop_l(r1); 1536 __ asrv(r0, r1, r0); 1537 } 1538 1539 void TemplateTable::lushr() 1540 { 1541 transition(itos, ltos); 1542 // shift count is in r0 1543 __ pop_l(r1); 1544 __ lsrv(r0, r1, r0); 1545 } 1546 1547 void TemplateTable::fop2(Operation op) 1548 { 1549 transition(ftos, ftos); 1550 switch (op) { 1551 case add: 1552 // n.b. use ldrd because this is a 64 bit slot 1553 __ pop_f(v1); 1554 __ fadds(v0, v1, v0); 1555 break; 1556 case sub: 1557 __ pop_f(v1); 1558 __ fsubs(v0, v1, v0); 1559 break; 1560 case mul: 1561 __ pop_f(v1); 1562 __ fmuls(v0, v1, v0); 1563 break; 1564 case div: 1565 __ pop_f(v1); 1566 __ fdivs(v0, v1, v0); 1567 break; 1568 case rem: 1569 __ fmovs(v1, v0); 1570 __ pop_f(v0); 1571 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::frem)); 1572 break; 1573 default: 1574 ShouldNotReachHere(); 1575 break; 1576 } 1577 } 1578 1579 void TemplateTable::dop2(Operation op) 1580 { 1581 transition(dtos, dtos); 1582 switch (op) { 1583 case add: 1584 // n.b. use ldrd because this is a 64 bit slot 1585 __ pop_d(v1); 1586 __ faddd(v0, v1, v0); 1587 break; 1588 case sub: 1589 __ pop_d(v1); 1590 __ fsubd(v0, v1, v0); 1591 break; 1592 case mul: 1593 __ pop_d(v1); 1594 __ fmuld(v0, v1, v0); 1595 break; 1596 case div: 1597 __ pop_d(v1); 1598 __ fdivd(v0, v1, v0); 1599 break; 1600 case rem: 1601 __ fmovd(v1, v0); 1602 __ pop_d(v0); 1603 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::drem)); 1604 break; 1605 default: 1606 ShouldNotReachHere(); 1607 break; 1608 } 1609 } 1610 1611 void TemplateTable::ineg() 1612 { 1613 transition(itos, itos); 1614 __ negw(r0, r0); 1615 1616 } 1617 1618 void TemplateTable::lneg() 1619 { 1620 transition(ltos, ltos); 1621 __ neg(r0, r0); 1622 } 1623 1624 void TemplateTable::fneg() 1625 { 1626 transition(ftos, ftos); 1627 __ fnegs(v0, v0); 1628 } 1629 1630 void TemplateTable::dneg() 1631 { 1632 transition(dtos, dtos); 1633 __ fnegd(v0, v0); 1634 } 1635 1636 void TemplateTable::iinc() 1637 { 1638 transition(vtos, vtos); 1639 __ load_signed_byte(r1, at_bcp(2)); // get constant 1640 locals_index(r2); 1641 __ ldr(r0, iaddress(r2)); 1642 __ addw(r0, r0, r1); 1643 __ str(r0, iaddress(r2)); 1644 } 1645 1646 void TemplateTable::wide_iinc() 1647 { 1648 transition(vtos, vtos); 1649 // __ mov(r1, zr); 1650 __ ldrw(r1, at_bcp(2)); // get constant and index 1651 __ rev16(r1, r1); 1652 __ ubfx(r2, r1, 0, 16); 1653 __ neg(r2, r2); 1654 __ sbfx(r1, r1, 16, 16); 1655 __ ldr(r0, iaddress(r2)); 1656 __ addw(r0, r0, r1); 1657 __ str(r0, iaddress(r2)); 1658 } 1659 1660 void TemplateTable::convert() 1661 { 1662 // Checking 1663 #ifdef ASSERT 1664 { 1665 TosState tos_in = ilgl; 1666 TosState tos_out = ilgl; 1667 switch (bytecode()) { 1668 case Bytecodes::_i2l: // fall through 1669 case Bytecodes::_i2f: // fall through 1670 case Bytecodes::_i2d: // fall through 1671 case Bytecodes::_i2b: // fall through 1672 case Bytecodes::_i2c: // fall through 1673 case Bytecodes::_i2s: tos_in = itos; break; 1674 case Bytecodes::_l2i: // fall through 1675 case Bytecodes::_l2f: // fall through 1676 case Bytecodes::_l2d: tos_in = ltos; break; 1677 case Bytecodes::_f2i: // fall through 1678 case Bytecodes::_f2l: // fall through 1679 case Bytecodes::_f2d: tos_in = ftos; break; 1680 case Bytecodes::_d2i: // fall through 1681 case Bytecodes::_d2l: // fall through 1682 case Bytecodes::_d2f: tos_in = dtos; break; 1683 default : ShouldNotReachHere(); 1684 } 1685 switch (bytecode()) { 1686 case Bytecodes::_l2i: // fall through 1687 case Bytecodes::_f2i: // fall through 1688 case Bytecodes::_d2i: // fall through 1689 case Bytecodes::_i2b: // fall through 1690 case Bytecodes::_i2c: // fall through 1691 case Bytecodes::_i2s: tos_out = itos; break; 1692 case Bytecodes::_i2l: // fall through 1693 case Bytecodes::_f2l: // fall through 1694 case Bytecodes::_d2l: tos_out = ltos; break; 1695 case Bytecodes::_i2f: // fall through 1696 case Bytecodes::_l2f: // fall through 1697 case Bytecodes::_d2f: tos_out = ftos; break; 1698 case Bytecodes::_i2d: // fall through 1699 case Bytecodes::_l2d: // fall through 1700 case Bytecodes::_f2d: tos_out = dtos; break; 1701 default : ShouldNotReachHere(); 1702 } 1703 transition(tos_in, tos_out); 1704 } 1705 #endif // ASSERT 1706 // static const int64_t is_nan = 0x8000000000000000L; 1707 1708 // Conversion 1709 switch (bytecode()) { 1710 case Bytecodes::_i2l: 1711 __ sxtw(r0, r0); 1712 break; 1713 case Bytecodes::_i2f: 1714 __ scvtfws(v0, r0); 1715 break; 1716 case Bytecodes::_i2d: 1717 __ scvtfwd(v0, r0); 1718 break; 1719 case Bytecodes::_i2b: 1720 __ sxtbw(r0, r0); 1721 break; 1722 case Bytecodes::_i2c: 1723 __ uxthw(r0, r0); 1724 break; 1725 case Bytecodes::_i2s: 1726 __ sxthw(r0, r0); 1727 break; 1728 case Bytecodes::_l2i: 1729 __ uxtw(r0, r0); 1730 break; 1731 case Bytecodes::_l2f: 1732 __ scvtfs(v0, r0); 1733 break; 1734 case Bytecodes::_l2d: 1735 __ scvtfd(v0, r0); 1736 break; 1737 case Bytecodes::_f2i: 1738 { 1739 Label L_Okay; 1740 __ clear_fpsr(); 1741 __ fcvtzsw(r0, v0); 1742 __ get_fpsr(r1); 1743 __ cbzw(r1, L_Okay); 1744 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::f2i)); 1745 __ bind(L_Okay); 1746 } 1747 break; 1748 case Bytecodes::_f2l: 1749 { 1750 Label L_Okay; 1751 __ clear_fpsr(); 1752 __ fcvtzs(r0, v0); 1753 __ get_fpsr(r1); 1754 __ cbzw(r1, L_Okay); 1755 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::f2l)); 1756 __ bind(L_Okay); 1757 } 1758 break; 1759 case Bytecodes::_f2d: 1760 __ fcvts(v0, v0); 1761 break; 1762 case Bytecodes::_d2i: 1763 { 1764 Label L_Okay; 1765 __ clear_fpsr(); 1766 __ fcvtzdw(r0, v0); 1767 __ get_fpsr(r1); 1768 __ cbzw(r1, L_Okay); 1769 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::d2i)); 1770 __ bind(L_Okay); 1771 } 1772 break; 1773 case Bytecodes::_d2l: 1774 { 1775 Label L_Okay; 1776 __ clear_fpsr(); 1777 __ fcvtzd(r0, v0); 1778 __ get_fpsr(r1); 1779 __ cbzw(r1, L_Okay); 1780 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::d2l)); 1781 __ bind(L_Okay); 1782 } 1783 break; 1784 case Bytecodes::_d2f: 1785 __ fcvtd(v0, v0); 1786 break; 1787 default: 1788 ShouldNotReachHere(); 1789 } 1790 } 1791 1792 void TemplateTable::lcmp() 1793 { 1794 transition(ltos, itos); 1795 Label done; 1796 __ pop_l(r1); 1797 __ cmp(r1, r0); 1798 __ mov(r0, (uint64_t)-1L); 1799 __ br(Assembler::LT, done); 1800 // __ mov(r0, 1UL); 1801 // __ csel(r0, r0, zr, Assembler::NE); 1802 // and here is a faster way 1803 __ csinc(r0, zr, zr, Assembler::EQ); 1804 __ bind(done); 1805 } 1806 1807 void TemplateTable::float_cmp(bool is_float, int unordered_result) 1808 { 1809 Label done; 1810 if (is_float) { 1811 // XXX get rid of pop here, use ... reg, mem32 1812 __ pop_f(v1); 1813 __ fcmps(v1, v0); 1814 } else { 1815 // XXX get rid of pop here, use ... reg, mem64 1816 __ pop_d(v1); 1817 __ fcmpd(v1, v0); 1818 } 1819 if (unordered_result < 0) { 1820 // we want -1 for unordered or less than, 0 for equal and 1 for 1821 // greater than. 1822 __ mov(r0, (uint64_t)-1L); 1823 // for FP LT tests less than or unordered 1824 __ br(Assembler::LT, done); 1825 // install 0 for EQ otherwise 1 1826 __ csinc(r0, zr, zr, Assembler::EQ); 1827 } else { 1828 // we want -1 for less than, 0 for equal and 1 for unordered or 1829 // greater than. 1830 __ mov(r0, 1L); 1831 // for FP HI tests greater than or unordered 1832 __ br(Assembler::HI, done); 1833 // install 0 for EQ otherwise ~0 1834 __ csinv(r0, zr, zr, Assembler::EQ); 1835 1836 } 1837 __ bind(done); 1838 } 1839 1840 void TemplateTable::branch(bool is_jsr, bool is_wide) 1841 { 1842 __ profile_taken_branch(r0, r1); 1843 const ByteSize be_offset = MethodCounters::backedge_counter_offset() + 1844 InvocationCounter::counter_offset(); 1845 const ByteSize inv_offset = MethodCounters::invocation_counter_offset() + 1846 InvocationCounter::counter_offset(); 1847 1848 // load branch displacement 1849 if (!is_wide) { 1850 __ ldrh(r2, at_bcp(1)); 1851 __ rev16(r2, r2); 1852 // sign extend the 16 bit value in r2 1853 __ sbfm(r2, r2, 0, 15); 1854 } else { 1855 __ ldrw(r2, at_bcp(1)); 1856 __ revw(r2, r2); 1857 // sign extend the 32 bit value in r2 1858 __ sbfm(r2, r2, 0, 31); 1859 } 1860 1861 // Handle all the JSR stuff here, then exit. 1862 // It's much shorter and cleaner than intermingling with the non-JSR 1863 // normal-branch stuff occurring below. 1864 1865 if (is_jsr) { 1866 // Pre-load the next target bytecode into rscratch1 1867 __ load_unsigned_byte(rscratch1, Address(rbcp, r2)); 1868 // compute return address as bci 1869 __ ldr(rscratch2, Address(rmethod, Method::const_offset())); 1870 __ add(rscratch2, rscratch2, 1871 in_bytes(ConstMethod::codes_offset()) - (is_wide ? 5 : 3)); 1872 __ sub(r1, rbcp, rscratch2); 1873 __ push_i(r1); 1874 // Adjust the bcp by the 16-bit displacement in r2 1875 __ add(rbcp, rbcp, r2); 1876 __ dispatch_only(vtos, /*generate_poll*/true); 1877 return; 1878 } 1879 1880 // Normal (non-jsr) branch handling 1881 1882 // Adjust the bcp by the displacement in r2 1883 __ add(rbcp, rbcp, r2); 1884 1885 assert(UseLoopCounter || !UseOnStackReplacement, 1886 "on-stack-replacement requires loop counters"); 1887 Label backedge_counter_overflow; 1888 Label dispatch; 1889 if (UseLoopCounter) { 1890 // increment backedge counter for backward branches 1891 // r0: MDO 1892 // w1: MDO bumped taken-count 1893 // r2: target offset 1894 __ cmp(r2, zr); 1895 __ br(Assembler::GT, dispatch); // count only if backward branch 1896 1897 // ECN: FIXME: This code smells 1898 // check if MethodCounters exists 1899 Label has_counters; 1900 __ ldr(rscratch1, Address(rmethod, Method::method_counters_offset())); 1901 __ cbnz(rscratch1, has_counters); 1902 __ push(r0); 1903 __ push(r1); 1904 __ push(r2); 1905 __ call_VM(noreg, CAST_FROM_FN_PTR(address, 1906 InterpreterRuntime::build_method_counters), rmethod); 1907 __ pop(r2); 1908 __ pop(r1); 1909 __ pop(r0); 1910 __ ldr(rscratch1, Address(rmethod, Method::method_counters_offset())); 1911 __ cbz(rscratch1, dispatch); // No MethodCounters allocated, OutOfMemory 1912 __ bind(has_counters); 1913 1914 Label no_mdo; 1915 int increment = InvocationCounter::count_increment; 1916 if (ProfileInterpreter) { 1917 // Are we profiling? 1918 __ ldr(r1, Address(rmethod, in_bytes(Method::method_data_offset()))); 1919 __ cbz(r1, no_mdo); 1920 // Increment the MDO backedge counter 1921 const Address mdo_backedge_counter(r1, in_bytes(MethodData::backedge_counter_offset()) + 1922 in_bytes(InvocationCounter::counter_offset())); 1923 const Address mask(r1, in_bytes(MethodData::backedge_mask_offset())); 1924 __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, 1925 r0, rscratch1, false, Assembler::EQ, 1926 UseOnStackReplacement ? &backedge_counter_overflow : &dispatch); 1927 __ b(dispatch); 1928 } 1929 __ bind(no_mdo); 1930 // Increment backedge counter in MethodCounters* 1931 __ ldr(rscratch1, Address(rmethod, Method::method_counters_offset())); 1932 const Address mask(rscratch1, in_bytes(MethodCounters::backedge_mask_offset())); 1933 __ increment_mask_and_jump(Address(rscratch1, be_offset), increment, mask, 1934 r0, rscratch2, false, Assembler::EQ, 1935 UseOnStackReplacement ? &backedge_counter_overflow : &dispatch); 1936 __ bind(dispatch); 1937 } 1938 1939 // Pre-load the next target bytecode into rscratch1 1940 __ load_unsigned_byte(rscratch1, Address(rbcp, 0)); 1941 1942 // continue with the bytecode @ target 1943 // rscratch1: target bytecode 1944 // rbcp: target bcp 1945 __ dispatch_only(vtos, /*generate_poll*/true); 1946 1947 if (UseLoopCounter && UseOnStackReplacement) { 1948 // invocation counter overflow 1949 __ bind(backedge_counter_overflow); 1950 __ neg(r2, r2); 1951 __ add(r2, r2, rbcp); // branch bcp 1952 // IcoResult frequency_counter_overflow([JavaThread*], address branch_bcp) 1953 __ call_VM(noreg, 1954 CAST_FROM_FN_PTR(address, 1955 InterpreterRuntime::frequency_counter_overflow), 1956 r2); 1957 __ load_unsigned_byte(r1, Address(rbcp, 0)); // restore target bytecode 1958 1959 // r0: osr nmethod (osr ok) or null (osr not possible) 1960 // w1: target bytecode 1961 // r2: scratch 1962 __ cbz(r0, dispatch); // test result -- no osr if null 1963 // nmethod may have been invalidated (VM may block upon call_VM return) 1964 __ ldrb(r2, Address(r0, nmethod::state_offset())); 1965 if (nmethod::in_use != 0) 1966 __ sub(r2, r2, nmethod::in_use); 1967 __ cbnz(r2, dispatch); 1968 1969 // We have the address of an on stack replacement routine in r0 1970 // We need to prepare to execute the OSR method. First we must 1971 // migrate the locals and monitors off of the stack. 1972 1973 __ mov(r19, r0); // save the nmethod 1974 1975 call_VM(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin)); 1976 1977 // r0 is OSR buffer, move it to expected parameter location 1978 __ mov(j_rarg0, r0); 1979 1980 // remove activation 1981 // get sender esp 1982 __ ldr(esp, 1983 Address(rfp, frame::interpreter_frame_sender_sp_offset * wordSize)); 1984 // remove frame anchor 1985 __ leave(); 1986 // Ensure compiled code always sees stack at proper alignment 1987 __ andr(sp, esp, -16); 1988 1989 // and begin the OSR nmethod 1990 __ ldr(rscratch1, Address(r19, nmethod::osr_entry_point_offset())); 1991 __ br(rscratch1); 1992 } 1993 } 1994 1995 1996 void TemplateTable::if_0cmp(Condition cc) 1997 { 1998 transition(itos, vtos); 1999 // assume branch is more often taken than not (loops use backward branches) 2000 Label not_taken; 2001 if (cc == equal) 2002 __ cbnzw(r0, not_taken); 2003 else if (cc == not_equal) 2004 __ cbzw(r0, not_taken); 2005 else { 2006 __ andsw(zr, r0, r0); 2007 __ br(j_not(cc), not_taken); 2008 } 2009 2010 branch(false, false); 2011 __ bind(not_taken); 2012 __ profile_not_taken_branch(r0); 2013 } 2014 2015 void TemplateTable::if_icmp(Condition cc) 2016 { 2017 transition(itos, vtos); 2018 // assume branch is more often taken than not (loops use backward branches) 2019 Label not_taken; 2020 __ pop_i(r1); 2021 __ cmpw(r1, r0, Assembler::LSL); 2022 __ br(j_not(cc), not_taken); 2023 branch(false, false); 2024 __ bind(not_taken); 2025 __ profile_not_taken_branch(r0); 2026 } 2027 2028 void TemplateTable::if_nullcmp(Condition cc) 2029 { 2030 transition(atos, vtos); 2031 // assume branch is more often taken than not (loops use backward branches) 2032 Label not_taken; 2033 if (cc == equal) 2034 __ cbnz(r0, not_taken); 2035 else 2036 __ cbz(r0, not_taken); 2037 branch(false, false); 2038 __ bind(not_taken); 2039 __ profile_not_taken_branch(r0); 2040 } 2041 2042 void TemplateTable::if_acmp(Condition cc) { 2043 transition(atos, vtos); 2044 // assume branch is more often taken than not (loops use backward branches) 2045 Label taken, not_taken; 2046 __ pop_ptr(r1); 2047 2048 __ profile_acmp(r2, r1, r0, r4); 2049 2050 Register is_inline_type_mask = rscratch1; 2051 __ mov(is_inline_type_mask, markWord::inline_type_pattern); 2052 2053 if (EnableValhalla) { 2054 __ cmp(r1, r0); 2055 __ br(Assembler::EQ, (cc == equal) ? taken : not_taken); 2056 2057 // might be substitutable, test if either r0 or r1 is null 2058 __ andr(r2, r0, r1); 2059 __ cbz(r2, (cc == equal) ? not_taken : taken); 2060 2061 // and both are values ? 2062 __ ldr(r2, Address(r1, oopDesc::mark_offset_in_bytes())); 2063 __ andr(r2, r2, is_inline_type_mask); 2064 __ ldr(r4, Address(r0, oopDesc::mark_offset_in_bytes())); 2065 __ andr(r4, r4, is_inline_type_mask); 2066 __ andr(r2, r2, r4); 2067 __ cmp(r2, is_inline_type_mask); 2068 __ br(Assembler::NE, (cc == equal) ? not_taken : taken); 2069 2070 // same value klass ? 2071 __ load_metadata(r2, r1); 2072 __ load_metadata(r4, r0); 2073 __ cmp(r2, r4); 2074 __ br(Assembler::NE, (cc == equal) ? not_taken : taken); 2075 2076 // Know both are the same type, let's test for substitutability... 2077 if (cc == equal) { 2078 invoke_is_substitutable(r0, r1, taken, not_taken); 2079 } else { 2080 invoke_is_substitutable(r0, r1, not_taken, taken); 2081 } 2082 __ stop("Not reachable"); 2083 } 2084 2085 __ cmpoop(r1, r0); 2086 __ br(j_not(cc), not_taken); 2087 __ bind(taken); 2088 branch(false, false); 2089 __ bind(not_taken); 2090 __ profile_not_taken_branch(r0, true); 2091 } 2092 2093 void TemplateTable::invoke_is_substitutable(Register aobj, Register bobj, 2094 Label& is_subst, Label& not_subst) { 2095 2096 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::is_substitutable), aobj, bobj); 2097 // Restored... r0 answer, jmp to outcome... 2098 __ cbz(r0, not_subst); 2099 __ b(is_subst); 2100 } 2101 2102 2103 void TemplateTable::ret() { 2104 transition(vtos, vtos); 2105 locals_index(r1); 2106 __ ldr(r1, aaddress(r1)); // get return bci, compute return bcp 2107 __ profile_ret(r1, r2); 2108 __ ldr(rbcp, Address(rmethod, Method::const_offset())); 2109 __ lea(rbcp, Address(rbcp, r1)); 2110 __ add(rbcp, rbcp, in_bytes(ConstMethod::codes_offset())); 2111 __ dispatch_next(vtos, 0, /*generate_poll*/true); 2112 } 2113 2114 void TemplateTable::wide_ret() { 2115 transition(vtos, vtos); 2116 locals_index_wide(r1); 2117 __ ldr(r1, aaddress(r1)); // get return bci, compute return bcp 2118 __ profile_ret(r1, r2); 2119 __ ldr(rbcp, Address(rmethod, Method::const_offset())); 2120 __ lea(rbcp, Address(rbcp, r1)); 2121 __ add(rbcp, rbcp, in_bytes(ConstMethod::codes_offset())); 2122 __ dispatch_next(vtos, 0, /*generate_poll*/true); 2123 } 2124 2125 2126 void TemplateTable::tableswitch() { 2127 Label default_case, continue_execution; 2128 transition(itos, vtos); 2129 // align rbcp 2130 __ lea(r1, at_bcp(BytesPerInt)); 2131 __ andr(r1, r1, -BytesPerInt); 2132 // load lo & hi 2133 __ ldrw(r2, Address(r1, BytesPerInt)); 2134 __ ldrw(r3, Address(r1, 2 * BytesPerInt)); 2135 __ rev32(r2, r2); 2136 __ rev32(r3, r3); 2137 // check against lo & hi 2138 __ cmpw(r0, r2); 2139 __ br(Assembler::LT, default_case); 2140 __ cmpw(r0, r3); 2141 __ br(Assembler::GT, default_case); 2142 // lookup dispatch offset 2143 __ subw(r0, r0, r2); 2144 __ lea(r3, Address(r1, r0, Address::uxtw(2))); 2145 __ ldrw(r3, Address(r3, 3 * BytesPerInt)); 2146 __ profile_switch_case(r0, r1, r2); 2147 // continue execution 2148 __ bind(continue_execution); 2149 __ rev32(r3, r3); 2150 __ load_unsigned_byte(rscratch1, Address(rbcp, r3, Address::sxtw(0))); 2151 __ add(rbcp, rbcp, r3, ext::sxtw); 2152 __ dispatch_only(vtos, /*generate_poll*/true); 2153 // handle default 2154 __ bind(default_case); 2155 __ profile_switch_default(r0); 2156 __ ldrw(r3, Address(r1, 0)); 2157 __ b(continue_execution); 2158 } 2159 2160 void TemplateTable::lookupswitch() { 2161 transition(itos, itos); 2162 __ stop("lookupswitch bytecode should have been rewritten"); 2163 } 2164 2165 void TemplateTable::fast_linearswitch() { 2166 transition(itos, vtos); 2167 Label loop_entry, loop, found, continue_execution; 2168 // bswap r0 so we can avoid bswapping the table entries 2169 __ rev32(r0, r0); 2170 // align rbcp 2171 __ lea(r19, at_bcp(BytesPerInt)); // btw: should be able to get rid of 2172 // this instruction (change offsets 2173 // below) 2174 __ andr(r19, r19, -BytesPerInt); 2175 // set counter 2176 __ ldrw(r1, Address(r19, BytesPerInt)); 2177 __ rev32(r1, r1); 2178 __ b(loop_entry); 2179 // table search 2180 __ bind(loop); 2181 __ lea(rscratch1, Address(r19, r1, Address::lsl(3))); 2182 __ ldrw(rscratch1, Address(rscratch1, 2 * BytesPerInt)); 2183 __ cmpw(r0, rscratch1); 2184 __ br(Assembler::EQ, found); 2185 __ bind(loop_entry); 2186 __ subs(r1, r1, 1); 2187 __ br(Assembler::PL, loop); 2188 // default case 2189 __ profile_switch_default(r0); 2190 __ ldrw(r3, Address(r19, 0)); 2191 __ b(continue_execution); 2192 // entry found -> get offset 2193 __ bind(found); 2194 __ lea(rscratch1, Address(r19, r1, Address::lsl(3))); 2195 __ ldrw(r3, Address(rscratch1, 3 * BytesPerInt)); 2196 __ profile_switch_case(r1, r0, r19); 2197 // continue execution 2198 __ bind(continue_execution); 2199 __ rev32(r3, r3); 2200 __ add(rbcp, rbcp, r3, ext::sxtw); 2201 __ ldrb(rscratch1, Address(rbcp, 0)); 2202 __ dispatch_only(vtos, /*generate_poll*/true); 2203 } 2204 2205 void TemplateTable::fast_binaryswitch() { 2206 transition(itos, vtos); 2207 // Implementation using the following core algorithm: 2208 // 2209 // int binary_search(int key, LookupswitchPair* array, int n) { 2210 // // Binary search according to "Methodik des Programmierens" by 2211 // // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985. 2212 // int i = 0; 2213 // int j = n; 2214 // while (i+1 < j) { 2215 // // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q) 2216 // // with Q: for all i: 0 <= i < n: key < a[i] 2217 // // where a stands for the array and assuming that the (inexisting) 2218 // // element a[n] is infinitely big. 2219 // int h = (i + j) >> 1; 2220 // // i < h < j 2221 // if (key < array[h].fast_match()) { 2222 // j = h; 2223 // } else { 2224 // i = h; 2225 // } 2226 // } 2227 // // R: a[i] <= key < a[i+1] or Q 2228 // // (i.e., if key is within array, i is the correct index) 2229 // return i; 2230 // } 2231 2232 // Register allocation 2233 const Register key = r0; // already set (tosca) 2234 const Register array = r1; 2235 const Register i = r2; 2236 const Register j = r3; 2237 const Register h = rscratch1; 2238 const Register temp = rscratch2; 2239 2240 // Find array start 2241 __ lea(array, at_bcp(3 * BytesPerInt)); // btw: should be able to 2242 // get rid of this 2243 // instruction (change 2244 // offsets below) 2245 __ andr(array, array, -BytesPerInt); 2246 2247 // Initialize i & j 2248 __ mov(i, 0); // i = 0; 2249 __ ldrw(j, Address(array, -BytesPerInt)); // j = length(array); 2250 2251 // Convert j into native byteordering 2252 __ rev32(j, j); 2253 2254 // And start 2255 Label entry; 2256 __ b(entry); 2257 2258 // binary search loop 2259 { 2260 Label loop; 2261 __ bind(loop); 2262 // int h = (i + j) >> 1; 2263 __ addw(h, i, j); // h = i + j; 2264 __ lsrw(h, h, 1); // h = (i + j) >> 1; 2265 // if (key < array[h].fast_match()) { 2266 // j = h; 2267 // } else { 2268 // i = h; 2269 // } 2270 // Convert array[h].match to native byte-ordering before compare 2271 __ ldr(temp, Address(array, h, Address::lsl(3))); 2272 __ rev32(temp, temp); 2273 __ cmpw(key, temp); 2274 // j = h if (key < array[h].fast_match()) 2275 __ csel(j, h, j, Assembler::LT); 2276 // i = h if (key >= array[h].fast_match()) 2277 __ csel(i, h, i, Assembler::GE); 2278 // while (i+1 < j) 2279 __ bind(entry); 2280 __ addw(h, i, 1); // i+1 2281 __ cmpw(h, j); // i+1 < j 2282 __ br(Assembler::LT, loop); 2283 } 2284 2285 // end of binary search, result index is i (must check again!) 2286 Label default_case; 2287 // Convert array[i].match to native byte-ordering before compare 2288 __ ldr(temp, Address(array, i, Address::lsl(3))); 2289 __ rev32(temp, temp); 2290 __ cmpw(key, temp); 2291 __ br(Assembler::NE, default_case); 2292 2293 // entry found -> j = offset 2294 __ add(j, array, i, ext::uxtx, 3); 2295 __ ldrw(j, Address(j, BytesPerInt)); 2296 __ profile_switch_case(i, key, array); 2297 __ rev32(j, j); 2298 __ load_unsigned_byte(rscratch1, Address(rbcp, j, Address::sxtw(0))); 2299 __ lea(rbcp, Address(rbcp, j, Address::sxtw(0))); 2300 __ dispatch_only(vtos, /*generate_poll*/true); 2301 2302 // default case -> j = default offset 2303 __ bind(default_case); 2304 __ profile_switch_default(i); 2305 __ ldrw(j, Address(array, -2 * BytesPerInt)); 2306 __ rev32(j, j); 2307 __ load_unsigned_byte(rscratch1, Address(rbcp, j, Address::sxtw(0))); 2308 __ lea(rbcp, Address(rbcp, j, Address::sxtw(0))); 2309 __ dispatch_only(vtos, /*generate_poll*/true); 2310 } 2311 2312 2313 void TemplateTable::_return(TosState state) 2314 { 2315 transition(state, state); 2316 assert(_desc->calls_vm(), 2317 "inconsistent calls_vm information"); // call in remove_activation 2318 2319 if (_desc->bytecode() == Bytecodes::_return_register_finalizer) { 2320 assert(state == vtos, "only valid state"); 2321 2322 __ ldr(c_rarg1, aaddress(0)); 2323 __ load_klass(r3, c_rarg1); 2324 __ ldrb(r3, Address(r3, Klass::misc_flags_offset())); 2325 Label skip_register_finalizer; 2326 __ tbz(r3, exact_log2(KlassFlags::_misc_has_finalizer), skip_register_finalizer); 2327 2328 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), c_rarg1); 2329 2330 __ bind(skip_register_finalizer); 2331 } 2332 2333 // Issue a StoreStore barrier after all stores but before return 2334 // from any constructor for any class with a final field. We don't 2335 // know if this is a finalizer, so we always do so. 2336 if (_desc->bytecode() == Bytecodes::_return) 2337 __ membar(MacroAssembler::StoreStore); 2338 2339 if (_desc->bytecode() != Bytecodes::_return_register_finalizer) { 2340 Label no_safepoint; 2341 __ ldr(rscratch1, Address(rthread, JavaThread::polling_word_offset())); 2342 __ tbz(rscratch1, log2i_exact(SafepointMechanism::poll_bit()), no_safepoint); 2343 __ push(state); 2344 __ push_cont_fastpath(rthread); 2345 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)); 2346 __ pop_cont_fastpath(rthread); 2347 __ pop(state); 2348 __ bind(no_safepoint); 2349 } 2350 2351 // Narrow result if state is itos but result type is smaller. 2352 // Need to narrow in the return bytecode rather than in generate_return_entry 2353 // since compiled code callers expect the result to already be narrowed. 2354 if (state == itos) { 2355 __ narrow(r0); 2356 } 2357 2358 __ remove_activation(state); 2359 __ ret(lr); 2360 } 2361 2362 // ---------------------------------------------------------------------------- 2363 // Volatile variables demand their effects be made known to all CPU's 2364 // in order. Store buffers on most chips allow reads & writes to 2365 // reorder; the JMM's ReadAfterWrite.java test fails in -Xint mode 2366 // without some kind of memory barrier (i.e., it's not sufficient that 2367 // the interpreter does not reorder volatile references, the hardware 2368 // also must not reorder them). 2369 // 2370 // According to the new Java Memory Model (JMM): 2371 // (1) All volatiles are serialized wrt to each other. ALSO reads & 2372 // writes act as acquire & release, so: 2373 // (2) A read cannot let unrelated NON-volatile memory refs that 2374 // happen after the read float up to before the read. It's OK for 2375 // non-volatile memory refs that happen before the volatile read to 2376 // float down below it. 2377 // (3) Similar a volatile write cannot let unrelated NON-volatile 2378 // memory refs that happen BEFORE the write float down to after the 2379 // write. It's OK for non-volatile memory refs that happen after the 2380 // volatile write to float up before it. 2381 // 2382 // We only put in barriers around volatile refs (they are expensive), 2383 // not _between_ memory refs (that would require us to track the 2384 // flavor of the previous memory refs). Requirements (2) and (3) 2385 // require some barriers before volatile stores and after volatile 2386 // loads. These nearly cover requirement (1) but miss the 2387 // volatile-store-volatile-load case. This final case is placed after 2388 // volatile-stores although it could just as well go before 2389 // volatile-loads. 2390 2391 void TemplateTable::resolve_cache_and_index_for_method(int byte_no, 2392 Register Rcache, 2393 Register index) { 2394 const Register temp = r19; 2395 assert_different_registers(Rcache, index, temp); 2396 assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); 2397 2398 Label resolved, clinit_barrier_slow; 2399 2400 Bytecodes::Code code = bytecode(); 2401 __ load_method_entry(Rcache, index); 2402 switch(byte_no) { 2403 case f1_byte: 2404 __ lea(temp, Address(Rcache, in_bytes(ResolvedMethodEntry::bytecode1_offset()))); 2405 break; 2406 case f2_byte: 2407 __ lea(temp, Address(Rcache, in_bytes(ResolvedMethodEntry::bytecode2_offset()))); 2408 break; 2409 } 2410 // Load-acquire the bytecode to match store-release in InterpreterRuntime 2411 __ ldarb(temp, temp); 2412 __ subs(zr, temp, (int) code); // have we resolved this bytecode? 2413 __ br(Assembler::EQ, resolved); 2414 2415 // resolve first time through 2416 // Class initialization barrier slow path lands here as well. 2417 __ bind(clinit_barrier_slow); 2418 address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_from_cache); 2419 __ mov(temp, (int) code); 2420 __ call_VM(noreg, entry, temp); 2421 2422 // Update registers with resolved info 2423 __ load_method_entry(Rcache, index); 2424 // n.b. unlike x86 Rcache is now rcpool plus the indexed offset 2425 // so all clients ofthis method must be modified accordingly 2426 __ bind(resolved); 2427 2428 // Class initialization barrier for static methods 2429 if (VM_Version::supports_fast_class_init_checks() && bytecode() == Bytecodes::_invokestatic) { 2430 __ ldr(temp, Address(Rcache, in_bytes(ResolvedMethodEntry::method_offset()))); 2431 __ load_method_holder(temp, temp); 2432 __ clinit_barrier(temp, rscratch1, nullptr, &clinit_barrier_slow); 2433 } 2434 } 2435 2436 void TemplateTable::resolve_cache_and_index_for_field(int byte_no, 2437 Register Rcache, 2438 Register index) { 2439 const Register temp = r19; 2440 assert_different_registers(Rcache, index, temp); 2441 2442 Label resolved; 2443 2444 Bytecodes::Code code = bytecode(); 2445 switch (code) { 2446 case Bytecodes::_nofast_getfield: code = Bytecodes::_getfield; break; 2447 case Bytecodes::_nofast_putfield: code = Bytecodes::_putfield; break; 2448 default: break; 2449 } 2450 2451 assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range"); 2452 __ load_field_entry(Rcache, index); 2453 if (byte_no == f1_byte) { 2454 __ lea(temp, Address(Rcache, in_bytes(ResolvedFieldEntry::get_code_offset()))); 2455 } else { 2456 __ lea(temp, Address(Rcache, in_bytes(ResolvedFieldEntry::put_code_offset()))); 2457 } 2458 // Load-acquire the bytecode to match store-release in ResolvedFieldEntry::fill_in() 2459 __ ldarb(temp, temp); 2460 __ subs(zr, temp, (int) code); // have we resolved this bytecode? 2461 __ br(Assembler::EQ, resolved); 2462 2463 // resolve first time through 2464 address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_from_cache); 2465 __ mov(temp, (int) code); 2466 __ call_VM(noreg, entry, temp); 2467 2468 // Update registers with resolved info 2469 __ load_field_entry(Rcache, index); 2470 __ bind(resolved); 2471 } 2472 2473 void TemplateTable::load_resolved_field_entry(Register obj, 2474 Register cache, 2475 Register tos_state, 2476 Register offset, 2477 Register flags, 2478 bool is_static = false) { 2479 assert_different_registers(cache, tos_state, flags, offset); 2480 2481 // Field offset 2482 __ load_sized_value(offset, Address(cache, in_bytes(ResolvedFieldEntry::field_offset_offset())), sizeof(int), true /*is_signed*/); 2483 2484 // Flags 2485 __ load_unsigned_byte(flags, Address(cache, in_bytes(ResolvedFieldEntry::flags_offset()))); 2486 2487 // TOS state 2488 if (tos_state != noreg) { 2489 __ load_unsigned_byte(tos_state, Address(cache, in_bytes(ResolvedFieldEntry::type_offset()))); 2490 } 2491 2492 // Klass overwrite register 2493 if (is_static) { 2494 __ ldr(obj, Address(cache, ResolvedFieldEntry::field_holder_offset())); 2495 const int mirror_offset = in_bytes(Klass::java_mirror_offset()); 2496 __ ldr(obj, Address(obj, mirror_offset)); 2497 __ resolve_oop_handle(obj, r5, rscratch2); 2498 } 2499 } 2500 2501 void TemplateTable::load_resolved_method_entry_special_or_static(Register cache, 2502 Register method, 2503 Register flags) { 2504 2505 // setup registers 2506 const Register index = flags; 2507 assert_different_registers(method, cache, flags); 2508 2509 // determine constant pool cache field offsets 2510 resolve_cache_and_index_for_method(f1_byte, cache, index); 2511 __ load_unsigned_byte(flags, Address(cache, in_bytes(ResolvedMethodEntry::flags_offset()))); 2512 __ ldr(method, Address(cache, in_bytes(ResolvedMethodEntry::method_offset()))); 2513 } 2514 2515 void TemplateTable::load_resolved_method_entry_handle(Register cache, 2516 Register method, 2517 Register ref_index, 2518 Register flags) { 2519 // setup registers 2520 const Register index = ref_index; 2521 assert_different_registers(method, flags); 2522 assert_different_registers(method, cache, index); 2523 2524 // determine constant pool cache field offsets 2525 resolve_cache_and_index_for_method(f1_byte, cache, index); 2526 __ load_unsigned_byte(flags, Address(cache, in_bytes(ResolvedMethodEntry::flags_offset()))); 2527 2528 // maybe push appendix to arguments (just before return address) 2529 Label L_no_push; 2530 __ tbz(flags, ResolvedMethodEntry::has_appendix_shift, L_no_push); 2531 // invokehandle uses an index into the resolved references array 2532 __ load_unsigned_short(ref_index, Address(cache, in_bytes(ResolvedMethodEntry::resolved_references_index_offset()))); 2533 // Push the appendix as a trailing parameter. 2534 // This must be done before we get the receiver, 2535 // since the parameter_size includes it. 2536 Register appendix = method; 2537 __ load_resolved_reference_at_index(appendix, ref_index); 2538 __ push(appendix); // push appendix (MethodType, CallSite, etc.) 2539 __ bind(L_no_push); 2540 2541 __ ldr(method, Address(cache, in_bytes(ResolvedMethodEntry::method_offset()))); 2542 } 2543 2544 void TemplateTable::load_resolved_method_entry_interface(Register cache, 2545 Register klass, 2546 Register method_or_table_index, 2547 Register flags) { 2548 // setup registers 2549 const Register index = method_or_table_index; 2550 assert_different_registers(method_or_table_index, cache, flags); 2551 2552 // determine constant pool cache field offsets 2553 resolve_cache_and_index_for_method(f1_byte, cache, index); 2554 __ load_unsigned_byte(flags, Address(cache, in_bytes(ResolvedMethodEntry::flags_offset()))); 2555 2556 // Invokeinterface can behave in different ways: 2557 // If calling a method from java.lang.Object, the forced virtual flag is true so the invocation will 2558 // behave like an invokevirtual call. The state of the virtual final flag will determine whether a method or 2559 // vtable index is placed in the register. 2560 // Otherwise, the registers will be populated with the klass and method. 2561 2562 Label NotVirtual; Label NotVFinal; Label Done; 2563 __ tbz(flags, ResolvedMethodEntry::is_forced_virtual_shift, NotVirtual); 2564 __ tbz(flags, ResolvedMethodEntry::is_vfinal_shift, NotVFinal); 2565 __ ldr(method_or_table_index, Address(cache, in_bytes(ResolvedMethodEntry::method_offset()))); 2566 __ b(Done); 2567 2568 __ bind(NotVFinal); 2569 __ load_unsigned_short(method_or_table_index, Address(cache, in_bytes(ResolvedMethodEntry::table_index_offset()))); 2570 __ b(Done); 2571 2572 __ bind(NotVirtual); 2573 __ ldr(method_or_table_index, Address(cache, in_bytes(ResolvedMethodEntry::method_offset()))); 2574 __ ldr(klass, Address(cache, in_bytes(ResolvedMethodEntry::klass_offset()))); 2575 __ bind(Done); 2576 } 2577 2578 void TemplateTable::load_resolved_method_entry_virtual(Register cache, 2579 Register method_or_table_index, 2580 Register flags) { 2581 // setup registers 2582 const Register index = flags; 2583 assert_different_registers(method_or_table_index, cache, flags); 2584 2585 // determine constant pool cache field offsets 2586 resolve_cache_and_index_for_method(f2_byte, cache, index); 2587 __ load_unsigned_byte(flags, Address(cache, in_bytes(ResolvedMethodEntry::flags_offset()))); 2588 2589 // method_or_table_index can either be an itable index or a method depending on the virtual final flag 2590 Label NotVFinal; Label Done; 2591 __ tbz(flags, ResolvedMethodEntry::is_vfinal_shift, NotVFinal); 2592 __ ldr(method_or_table_index, Address(cache, in_bytes(ResolvedMethodEntry::method_offset()))); 2593 __ b(Done); 2594 2595 __ bind(NotVFinal); 2596 __ load_unsigned_short(method_or_table_index, Address(cache, in_bytes(ResolvedMethodEntry::table_index_offset()))); 2597 __ bind(Done); 2598 } 2599 2600 // The rmethod register is input and overwritten to be the adapter method for the 2601 // indy call. Link Register (lr) is set to the return address for the adapter and 2602 // an appendix may be pushed to the stack. Registers r0-r3 are clobbered 2603 void TemplateTable::load_invokedynamic_entry(Register method) { 2604 // setup registers 2605 const Register appendix = r0; 2606 const Register cache = r2; 2607 const Register index = r3; 2608 assert_different_registers(method, appendix, cache, index, rcpool); 2609 2610 __ save_bcp(); 2611 2612 Label resolved; 2613 2614 __ load_resolved_indy_entry(cache, index); 2615 // Load-acquire the adapter method to match store-release in ResolvedIndyEntry::fill_in() 2616 __ lea(method, Address(cache, in_bytes(ResolvedIndyEntry::method_offset()))); 2617 __ ldar(method, method); 2618 2619 // Compare the method to zero 2620 __ cbnz(method, resolved); 2621 2622 Bytecodes::Code code = bytecode(); 2623 2624 // Call to the interpreter runtime to resolve invokedynamic 2625 address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_from_cache); 2626 __ mov(method, code); // this is essentially Bytecodes::_invokedynamic 2627 __ call_VM(noreg, entry, method); 2628 // Update registers with resolved info 2629 __ load_resolved_indy_entry(cache, index); 2630 // Load-acquire the adapter method to match store-release in ResolvedIndyEntry::fill_in() 2631 __ lea(method, Address(cache, in_bytes(ResolvedIndyEntry::method_offset()))); 2632 __ ldar(method, method); 2633 2634 #ifdef ASSERT 2635 __ cbnz(method, resolved); 2636 __ stop("Should be resolved by now"); 2637 #endif // ASSERT 2638 __ bind(resolved); 2639 2640 Label L_no_push; 2641 // Check if there is an appendix 2642 __ load_unsigned_byte(index, Address(cache, in_bytes(ResolvedIndyEntry::flags_offset()))); 2643 __ tbz(index, ResolvedIndyEntry::has_appendix_shift, L_no_push); 2644 2645 // Get appendix 2646 __ load_unsigned_short(index, Address(cache, in_bytes(ResolvedIndyEntry::resolved_references_index_offset()))); 2647 // Push the appendix as a trailing parameter 2648 // since the parameter_size includes it. 2649 __ push(method); 2650 __ mov(method, index); 2651 __ load_resolved_reference_at_index(appendix, method); 2652 __ verify_oop(appendix); 2653 __ pop(method); 2654 __ push(appendix); // push appendix (MethodType, CallSite, etc.) 2655 __ bind(L_no_push); 2656 2657 // compute return type 2658 __ load_unsigned_byte(index, Address(cache, in_bytes(ResolvedIndyEntry::result_type_offset()))); 2659 // load return address 2660 // Return address is loaded into link register(lr) and not pushed to the stack 2661 // like x86 2662 { 2663 const address table_addr = (address) Interpreter::invoke_return_entry_table_for(code); 2664 __ mov(rscratch1, table_addr); 2665 __ ldr(lr, Address(rscratch1, index, Address::lsl(3))); 2666 } 2667 } 2668 2669 // The registers cache and index expected to be set before call. 2670 // Correct values of the cache and index registers are preserved. 2671 void TemplateTable::jvmti_post_field_access(Register cache, Register index, 2672 bool is_static, bool has_tos) { 2673 // do the JVMTI work here to avoid disturbing the register state below 2674 // We use c_rarg registers here because we want to use the register used in 2675 // the call to the VM 2676 if (JvmtiExport::can_post_field_access()) { 2677 // Check to see if a field access watch has been set before we 2678 // take the time to call into the VM. 2679 Label L1; 2680 assert_different_registers(cache, index, r0); 2681 __ lea(rscratch1, ExternalAddress((address) JvmtiExport::get_field_access_count_addr())); 2682 __ ldrw(r0, Address(rscratch1)); 2683 __ cbzw(r0, L1); 2684 2685 __ load_field_entry(c_rarg2, index); 2686 2687 if (is_static) { 2688 __ mov(c_rarg1, zr); // null object reference 2689 } else { 2690 __ ldr(c_rarg1, at_tos()); // get object pointer without popping it 2691 __ verify_oop(c_rarg1); 2692 } 2693 // c_rarg1: object pointer or null 2694 // c_rarg2: cache entry pointer 2695 __ call_VM(noreg, CAST_FROM_FN_PTR(address, 2696 InterpreterRuntime::post_field_access), 2697 c_rarg1, c_rarg2); 2698 __ load_field_entry(cache, index); 2699 __ bind(L1); 2700 } 2701 } 2702 2703 void TemplateTable::pop_and_check_object(Register r) 2704 { 2705 __ pop_ptr(r); 2706 __ null_check(r); // for field access must check obj. 2707 __ verify_oop(r); 2708 } 2709 2710 void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteControl rc) 2711 { 2712 const Register cache = r2; 2713 const Register obj = r4; 2714 const Register klass = r5; 2715 const Register inline_klass = r7; 2716 const Register field_index = r23; 2717 const Register index = r3; 2718 const Register tos_state = r3; 2719 const Register off = r19; 2720 const Register flags = r6; 2721 const Register bc = r4; // uses same reg as obj, so don't mix them 2722 2723 resolve_cache_and_index_for_field(byte_no, cache, index); 2724 jvmti_post_field_access(cache, index, is_static, false); 2725 2726 // Valhalla extras 2727 __ load_unsigned_short(field_index, Address(cache, in_bytes(ResolvedFieldEntry::field_index_offset()))); 2728 __ ldr(klass, Address(cache, ResolvedFieldEntry::field_holder_offset())); 2729 2730 load_resolved_field_entry(obj, cache, tos_state, off, flags, is_static); 2731 2732 if (!is_static) { 2733 // obj is on the stack 2734 pop_and_check_object(obj); 2735 } 2736 2737 // 8179954: We need to make sure that the code generated for 2738 // volatile accesses forms a sequentially-consistent set of 2739 // operations when combined with STLR and LDAR. Without a leading 2740 // membar it's possible for a simple Dekker test to fail if loads 2741 // use LDR;DMB but stores use STLR. This can happen if C2 compiles 2742 // the stores in one method and we interpret the loads in another. 2743 if (!CompilerConfig::is_c1_or_interpreter_only_no_jvmci()){ 2744 Label notVolatile; 2745 __ tbz(flags, ResolvedFieldEntry::is_volatile_shift, notVolatile); 2746 __ membar(MacroAssembler::AnyAny); 2747 __ bind(notVolatile); 2748 } 2749 2750 const Address field(obj, off); 2751 2752 Label Done, notByte, notBool, notInt, notShort, notChar, 2753 notLong, notFloat, notObj, notDouble; 2754 2755 assert(btos == 0, "change code, btos != 0"); 2756 __ cbnz(tos_state, notByte); 2757 2758 // Don't rewrite getstatic, only getfield 2759 if (is_static) rc = may_not_rewrite; 2760 2761 // btos 2762 __ access_load_at(T_BYTE, IN_HEAP, r0, field, noreg, noreg); 2763 __ push(btos); 2764 // Rewrite bytecode to be faster 2765 if (rc == may_rewrite) { 2766 patch_bytecode(Bytecodes::_fast_bgetfield, bc, r1); 2767 } 2768 __ b(Done); 2769 2770 __ bind(notByte); 2771 __ cmp(tos_state, (u1)ztos); 2772 __ br(Assembler::NE, notBool); 2773 2774 // ztos (same code as btos) 2775 __ access_load_at(T_BOOLEAN, IN_HEAP, r0, field, noreg, noreg); 2776 __ push(ztos); 2777 // Rewrite bytecode to be faster 2778 if (rc == may_rewrite) { 2779 // use btos rewriting, no truncating to t/f bit is needed for getfield. 2780 patch_bytecode(Bytecodes::_fast_bgetfield, bc, r1); 2781 } 2782 __ b(Done); 2783 2784 __ bind(notBool); 2785 __ cmp(tos_state, (u1)atos); 2786 __ br(Assembler::NE, notObj); 2787 // atos 2788 if (!EnableValhalla) { 2789 do_oop_load(_masm, field, r0, IN_HEAP); 2790 __ push(atos); 2791 if (rc == may_rewrite) { 2792 patch_bytecode(Bytecodes::_fast_agetfield, bc, r1); 2793 } 2794 __ b(Done); 2795 } else { // Valhalla 2796 if (is_static) { 2797 __ load_heap_oop(r0, field, rscratch1, rscratch2); 2798 Label is_null_free_inline_type, uninitialized; 2799 // Issue below if the static field has not been initialized yet 2800 __ test_field_is_null_free_inline_type(flags, noreg /*temp*/, is_null_free_inline_type); 2801 // field is not a null free inline type 2802 __ push(atos); 2803 __ b(Done); 2804 // field is a null free inline type, must not return null even if uninitialized 2805 __ bind(is_null_free_inline_type); 2806 __ cbz(r0, uninitialized); 2807 __ push(atos); 2808 __ b(Done); 2809 __ bind(uninitialized); 2810 Label slow_case, finish; 2811 __ ldrb(rscratch1, Address(klass, InstanceKlass::init_state_offset())); 2812 __ cmp(rscratch1, (u1)InstanceKlass::fully_initialized); 2813 __ br(Assembler::NE, slow_case); 2814 __ get_default_value_oop(klass, off /* temp */, r0); 2815 __ b(finish); 2816 __ bind(slow_case); 2817 __ call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::uninitialized_static_inline_type_field), obj, cache); 2818 __ bind(finish); 2819 __ verify_oop(r0); 2820 __ push(atos); 2821 __ b(Done); 2822 } else { 2823 Label is_flat, nonnull, is_inline_type, has_null_marker, rewrite_inline; 2824 __ test_field_is_null_free_inline_type(flags, noreg /*temp*/, is_inline_type); 2825 __ test_field_has_null_marker(flags, noreg /*temp*/, has_null_marker); 2826 // Non-inline field case 2827 __ load_heap_oop(r0, field, rscratch1, rscratch2); 2828 __ push(atos); 2829 if (rc == may_rewrite) { 2830 patch_bytecode(Bytecodes::_fast_agetfield, bc, r1); 2831 } 2832 __ b(Done); 2833 __ bind(is_inline_type); 2834 __ test_field_is_flat(flags, noreg /* temp */, is_flat); 2835 // field is not flat 2836 __ load_heap_oop(r0, field, rscratch1, rscratch2); 2837 __ cbnz(r0, nonnull); 2838 __ get_inline_type_field_klass(klass, field_index, inline_klass); 2839 __ get_default_value_oop(inline_klass, klass /* temp */, r0); 2840 __ bind(nonnull); 2841 __ verify_oop(r0); 2842 __ push(atos); 2843 __ b(rewrite_inline); 2844 __ bind(is_flat); 2845 // field is flat 2846 __ mov(r0, obj); 2847 __ read_flat_field(cache, field_index, off, inline_klass /* temp */, r0); 2848 __ verify_oop(r0); 2849 __ push(atos); 2850 __ b(rewrite_inline); 2851 __ bind(has_null_marker); 2852 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::read_nullable_flat_field), obj, cache); 2853 __ verify_oop(r0); 2854 __ push(atos); 2855 __ bind(rewrite_inline); 2856 if (rc == may_rewrite) { 2857 patch_bytecode(Bytecodes::_fast_vgetfield, bc, r1); 2858 } 2859 __ b(Done); 2860 } 2861 } 2862 2863 __ bind(notObj); 2864 __ cmp(tos_state, (u1)itos); 2865 __ br(Assembler::NE, notInt); 2866 // itos 2867 __ access_load_at(T_INT, IN_HEAP, r0, field, noreg, noreg); 2868 __ push(itos); 2869 // Rewrite bytecode to be faster 2870 if (rc == may_rewrite) { 2871 patch_bytecode(Bytecodes::_fast_igetfield, bc, r1); 2872 } 2873 __ b(Done); 2874 2875 __ bind(notInt); 2876 __ cmp(tos_state, (u1)ctos); 2877 __ br(Assembler::NE, notChar); 2878 // ctos 2879 __ access_load_at(T_CHAR, IN_HEAP, r0, field, noreg, noreg); 2880 __ push(ctos); 2881 // Rewrite bytecode to be faster 2882 if (rc == may_rewrite) { 2883 patch_bytecode(Bytecodes::_fast_cgetfield, bc, r1); 2884 } 2885 __ b(Done); 2886 2887 __ bind(notChar); 2888 __ cmp(tos_state, (u1)stos); 2889 __ br(Assembler::NE, notShort); 2890 // stos 2891 __ access_load_at(T_SHORT, IN_HEAP, r0, field, noreg, noreg); 2892 __ push(stos); 2893 // Rewrite bytecode to be faster 2894 if (rc == may_rewrite) { 2895 patch_bytecode(Bytecodes::_fast_sgetfield, bc, r1); 2896 } 2897 __ b(Done); 2898 2899 __ bind(notShort); 2900 __ cmp(tos_state, (u1)ltos); 2901 __ br(Assembler::NE, notLong); 2902 // ltos 2903 __ access_load_at(T_LONG, IN_HEAP, r0, field, noreg, noreg); 2904 __ push(ltos); 2905 // Rewrite bytecode to be faster 2906 if (rc == may_rewrite) { 2907 patch_bytecode(Bytecodes::_fast_lgetfield, bc, r1); 2908 } 2909 __ b(Done); 2910 2911 __ bind(notLong); 2912 __ cmp(tos_state, (u1)ftos); 2913 __ br(Assembler::NE, notFloat); 2914 // ftos 2915 __ access_load_at(T_FLOAT, IN_HEAP, noreg /* ftos */, field, noreg, noreg); 2916 __ push(ftos); 2917 // Rewrite bytecode to be faster 2918 if (rc == may_rewrite) { 2919 patch_bytecode(Bytecodes::_fast_fgetfield, bc, r1); 2920 } 2921 __ b(Done); 2922 2923 __ bind(notFloat); 2924 #ifdef ASSERT 2925 __ cmp(tos_state, (u1)dtos); 2926 __ br(Assembler::NE, notDouble); 2927 #endif 2928 // dtos 2929 __ access_load_at(T_DOUBLE, IN_HEAP, noreg /* ftos */, field, noreg, noreg); 2930 __ push(dtos); 2931 // Rewrite bytecode to be faster 2932 if (rc == may_rewrite) { 2933 patch_bytecode(Bytecodes::_fast_dgetfield, bc, r1); 2934 } 2935 #ifdef ASSERT 2936 __ b(Done); 2937 2938 __ bind(notDouble); 2939 __ stop("Bad state"); 2940 #endif 2941 2942 __ bind(Done); 2943 2944 Label notVolatile; 2945 __ tbz(flags, ResolvedFieldEntry::is_volatile_shift, notVolatile); 2946 __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); 2947 __ bind(notVolatile); 2948 } 2949 2950 2951 void TemplateTable::getfield(int byte_no) 2952 { 2953 getfield_or_static(byte_no, false); 2954 } 2955 2956 void TemplateTable::nofast_getfield(int byte_no) { 2957 getfield_or_static(byte_no, false, may_not_rewrite); 2958 } 2959 2960 void TemplateTable::getstatic(int byte_no) 2961 { 2962 getfield_or_static(byte_no, true); 2963 } 2964 2965 // The registers cache and index expected to be set before call. 2966 // The function may destroy various registers, just not the cache and index registers. 2967 void TemplateTable::jvmti_post_field_mod(Register cache, Register index, bool is_static) { 2968 transition(vtos, vtos); 2969 2970 if (JvmtiExport::can_post_field_modification()) { 2971 // Check to see if a field modification watch has been set before 2972 // we take the time to call into the VM. 2973 Label L1; 2974 assert_different_registers(cache, index, r0); 2975 __ lea(rscratch1, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr())); 2976 __ ldrw(r0, Address(rscratch1)); 2977 __ cbz(r0, L1); 2978 2979 __ mov(c_rarg2, cache); 2980 2981 if (is_static) { 2982 // Life is simple. Null out the object pointer. 2983 __ mov(c_rarg1, zr); 2984 } else { 2985 // Life is harder. The stack holds the value on top, followed by 2986 // the object. We don't know the size of the value, though; it 2987 // could be one or two words depending on its type. As a result, 2988 // we must find the type to determine where the object is. 2989 __ load_unsigned_byte(c_rarg3, Address(c_rarg2, in_bytes(ResolvedFieldEntry::type_offset()))); 2990 Label nope2, done, ok; 2991 __ ldr(c_rarg1, at_tos_p1()); // initially assume a one word jvalue 2992 __ cmpw(c_rarg3, ltos); 2993 __ br(Assembler::EQ, ok); 2994 __ cmpw(c_rarg3, dtos); 2995 __ br(Assembler::NE, nope2); 2996 __ bind(ok); 2997 __ ldr(c_rarg1, at_tos_p2()); // ltos (two word jvalue) 2998 __ bind(nope2); 2999 } 3000 // object (tos) 3001 __ mov(c_rarg3, esp); 3002 // c_rarg1: object pointer set up above (null if static) 3003 // c_rarg2: cache entry pointer 3004 // c_rarg3: jvalue object on the stack 3005 __ call_VM(noreg, 3006 CAST_FROM_FN_PTR(address, 3007 InterpreterRuntime::post_field_modification), 3008 c_rarg1, c_rarg2, c_rarg3); 3009 __ load_field_entry(cache, index); 3010 __ bind(L1); 3011 } 3012 } 3013 3014 void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteControl rc) { 3015 transition(vtos, vtos); 3016 3017 const Register cache = r2; 3018 const Register index = r3; 3019 const Register tos_state = r3; 3020 const Register obj = r2; 3021 const Register off = r19; 3022 const Register flags = r6; 3023 const Register bc = r4; 3024 const Register inline_klass = r5; 3025 3026 resolve_cache_and_index_for_field(byte_no, cache, index); 3027 jvmti_post_field_mod(cache, index, is_static); 3028 load_resolved_field_entry(obj, cache, tos_state, off, flags, is_static); 3029 3030 Label Done; 3031 { 3032 Label notVolatile; 3033 __ tbz(flags, ResolvedFieldEntry::is_volatile_shift, notVolatile); 3034 __ membar(MacroAssembler::StoreStore | MacroAssembler::LoadStore); 3035 __ bind(notVolatile); 3036 } 3037 3038 // field address 3039 const Address field(obj, off); 3040 3041 Label notByte, notBool, notInt, notShort, notChar, 3042 notLong, notFloat, notObj, notDouble; 3043 3044 assert(btos == 0, "change code, btos != 0"); 3045 __ cbnz(tos_state, notByte); 3046 3047 // Don't rewrite putstatic, only putfield 3048 if (is_static) rc = may_not_rewrite; 3049 3050 // btos 3051 { 3052 __ pop(btos); 3053 if (!is_static) pop_and_check_object(obj); 3054 __ access_store_at(T_BYTE, IN_HEAP, field, r0, noreg, noreg, noreg); 3055 if (rc == may_rewrite) { 3056 patch_bytecode(Bytecodes::_fast_bputfield, bc, r1, true, byte_no); 3057 } 3058 __ b(Done); 3059 } 3060 3061 __ bind(notByte); 3062 __ cmp(tos_state, (u1)ztos); 3063 __ br(Assembler::NE, notBool); 3064 3065 // ztos 3066 { 3067 __ pop(ztos); 3068 if (!is_static) pop_and_check_object(obj); 3069 __ access_store_at(T_BOOLEAN, IN_HEAP, field, r0, noreg, noreg, noreg); 3070 if (rc == may_rewrite) { 3071 patch_bytecode(Bytecodes::_fast_zputfield, bc, r1, true, byte_no); 3072 } 3073 __ b(Done); 3074 } 3075 3076 __ bind(notBool); 3077 __ cmp(tos_state, (u1)atos); 3078 __ br(Assembler::NE, notObj); 3079 3080 // atos 3081 { 3082 if (!EnableValhalla) { 3083 __ pop(atos); 3084 if (!is_static) pop_and_check_object(obj); 3085 // Store into the field 3086 do_oop_store(_masm, field, r0, IN_HEAP); 3087 if (rc == may_rewrite) { 3088 patch_bytecode(Bytecodes::_fast_aputfield, bc, r1, true, byte_no); 3089 } 3090 __ b(Done); 3091 } else { // Valhalla 3092 __ pop(atos); 3093 if (is_static) { 3094 Label is_inline_type; 3095 __ test_field_is_not_null_free_inline_type(flags, noreg /* temp */, is_inline_type); 3096 __ null_check(r0); 3097 __ bind(is_inline_type); 3098 do_oop_store(_masm, field, r0, IN_HEAP); 3099 __ b(Done); 3100 } else { 3101 Label is_inline_type, is_flat, has_null_marker, rewrite_not_inline, rewrite_inline; 3102 __ test_field_is_null_free_inline_type(flags, noreg /*temp*/, is_inline_type); 3103 __ test_field_has_null_marker(flags, noreg /*temp*/, has_null_marker); 3104 // Not an inline type 3105 pop_and_check_object(obj); 3106 // Store into the field 3107 do_oop_store(_masm, field, r0, IN_HEAP); 3108 __ bind(rewrite_not_inline); 3109 if (rc == may_rewrite) { 3110 patch_bytecode(Bytecodes::_fast_aputfield, bc, r19, true, byte_no); 3111 } 3112 __ b(Done); 3113 // Implementation of the inline type semantic 3114 __ bind(is_inline_type); 3115 __ null_check(r0); 3116 __ test_field_is_flat(flags, noreg /*temp*/, is_flat); 3117 // field is not flat 3118 pop_and_check_object(obj); 3119 // Store into the field 3120 do_oop_store(_masm, field, r0, IN_HEAP); 3121 __ b(rewrite_inline); 3122 __ bind(is_flat); 3123 __ load_field_entry(cache, index); // reload field entry (cache) because it was erased by tos_state 3124 __ load_unsigned_short(index, Address(cache, in_bytes(ResolvedFieldEntry::field_index_offset()))); 3125 __ ldr(r2, Address(cache, in_bytes(ResolvedFieldEntry::field_holder_offset()))); 3126 __ inline_layout_info(r2, index, r6); 3127 pop_and_check_object(obj); 3128 __ load_klass(inline_klass, r0); 3129 __ data_for_oop(r0, r0, inline_klass); 3130 __ add(obj, obj, off); 3131 // because we use InlineLayoutInfo, we need special value access code specialized for fields (arrays will need a different API) 3132 __ flat_field_copy(IN_HEAP, r0, obj, r6); 3133 __ b(rewrite_inline); 3134 __ bind(has_null_marker); 3135 assert_different_registers(r0, cache, r19); 3136 pop_and_check_object(r19); 3137 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::write_nullable_flat_field), r19, r0, cache); 3138 __ bind(rewrite_inline); 3139 if (rc == may_rewrite) { 3140 patch_bytecode(Bytecodes::_fast_vputfield, bc, r19, true, byte_no); 3141 } 3142 __ b(Done); 3143 } 3144 } // Valhalla 3145 } 3146 3147 __ bind(notObj); 3148 __ cmp(tos_state, (u1)itos); 3149 __ br(Assembler::NE, notInt); 3150 3151 // itos 3152 { 3153 __ pop(itos); 3154 if (!is_static) pop_and_check_object(obj); 3155 __ access_store_at(T_INT, IN_HEAP, field, r0, noreg, noreg, noreg); 3156 if (rc == may_rewrite) { 3157 patch_bytecode(Bytecodes::_fast_iputfield, bc, r1, true, byte_no); 3158 } 3159 __ b(Done); 3160 } 3161 3162 __ bind(notInt); 3163 __ cmp(tos_state, (u1)ctos); 3164 __ br(Assembler::NE, notChar); 3165 3166 // ctos 3167 { 3168 __ pop(ctos); 3169 if (!is_static) pop_and_check_object(obj); 3170 __ access_store_at(T_CHAR, IN_HEAP, field, r0, noreg, noreg, noreg); 3171 if (rc == may_rewrite) { 3172 patch_bytecode(Bytecodes::_fast_cputfield, bc, r1, true, byte_no); 3173 } 3174 __ b(Done); 3175 } 3176 3177 __ bind(notChar); 3178 __ cmp(tos_state, (u1)stos); 3179 __ br(Assembler::NE, notShort); 3180 3181 // stos 3182 { 3183 __ pop(stos); 3184 if (!is_static) pop_and_check_object(obj); 3185 __ access_store_at(T_SHORT, IN_HEAP, field, r0, noreg, noreg, noreg); 3186 if (rc == may_rewrite) { 3187 patch_bytecode(Bytecodes::_fast_sputfield, bc, r1, true, byte_no); 3188 } 3189 __ b(Done); 3190 } 3191 3192 __ bind(notShort); 3193 __ cmp(tos_state, (u1)ltos); 3194 __ br(Assembler::NE, notLong); 3195 3196 // ltos 3197 { 3198 __ pop(ltos); 3199 if (!is_static) pop_and_check_object(obj); 3200 __ access_store_at(T_LONG, IN_HEAP, field, r0, noreg, noreg, noreg); 3201 if (rc == may_rewrite) { 3202 patch_bytecode(Bytecodes::_fast_lputfield, bc, r1, true, byte_no); 3203 } 3204 __ b(Done); 3205 } 3206 3207 __ bind(notLong); 3208 __ cmp(tos_state, (u1)ftos); 3209 __ br(Assembler::NE, notFloat); 3210 3211 // ftos 3212 { 3213 __ pop(ftos); 3214 if (!is_static) pop_and_check_object(obj); 3215 __ access_store_at(T_FLOAT, IN_HEAP, field, noreg /* ftos */, noreg, noreg, noreg); 3216 if (rc == may_rewrite) { 3217 patch_bytecode(Bytecodes::_fast_fputfield, bc, r1, true, byte_no); 3218 } 3219 __ b(Done); 3220 } 3221 3222 __ bind(notFloat); 3223 #ifdef ASSERT 3224 __ cmp(tos_state, (u1)dtos); 3225 __ br(Assembler::NE, notDouble); 3226 #endif 3227 3228 // dtos 3229 { 3230 __ pop(dtos); 3231 if (!is_static) pop_and_check_object(obj); 3232 __ access_store_at(T_DOUBLE, IN_HEAP, field, noreg /* dtos */, noreg, noreg, noreg); 3233 if (rc == may_rewrite) { 3234 patch_bytecode(Bytecodes::_fast_dputfield, bc, r1, true, byte_no); 3235 } 3236 } 3237 3238 #ifdef ASSERT 3239 __ b(Done); 3240 3241 __ bind(notDouble); 3242 __ stop("Bad state"); 3243 #endif 3244 3245 __ bind(Done); 3246 3247 { 3248 Label notVolatile; 3249 __ tbz(flags, ResolvedFieldEntry::is_volatile_shift, notVolatile); 3250 __ membar(MacroAssembler::StoreLoad | MacroAssembler::StoreStore); 3251 __ bind(notVolatile); 3252 } 3253 } 3254 3255 void TemplateTable::putfield(int byte_no) 3256 { 3257 putfield_or_static(byte_no, false); 3258 } 3259 3260 void TemplateTable::nofast_putfield(int byte_no) { 3261 putfield_or_static(byte_no, false, may_not_rewrite); 3262 } 3263 3264 void TemplateTable::putstatic(int byte_no) { 3265 putfield_or_static(byte_no, true); 3266 } 3267 3268 void TemplateTable::jvmti_post_fast_field_mod() { 3269 if (JvmtiExport::can_post_field_modification()) { 3270 // Check to see if a field modification watch has been set before 3271 // we take the time to call into the VM. 3272 Label L2; 3273 __ lea(rscratch1, ExternalAddress((address)JvmtiExport::get_field_modification_count_addr())); 3274 __ ldrw(c_rarg3, Address(rscratch1)); 3275 __ cbzw(c_rarg3, L2); 3276 __ pop_ptr(r19); // copy the object pointer from tos 3277 __ verify_oop(r19); 3278 __ push_ptr(r19); // put the object pointer back on tos 3279 // Save tos values before call_VM() clobbers them. Since we have 3280 // to do it for every data type, we use the saved values as the 3281 // jvalue object. 3282 switch (bytecode()) { // load values into the jvalue object 3283 case Bytecodes::_fast_vputfield: //fall through 3284 case Bytecodes::_fast_aputfield: __ push_ptr(r0); break; 3285 case Bytecodes::_fast_bputfield: // fall through 3286 case Bytecodes::_fast_zputfield: // fall through 3287 case Bytecodes::_fast_sputfield: // fall through 3288 case Bytecodes::_fast_cputfield: // fall through 3289 case Bytecodes::_fast_iputfield: __ push_i(r0); break; 3290 case Bytecodes::_fast_dputfield: __ push_d(); break; 3291 case Bytecodes::_fast_fputfield: __ push_f(); break; 3292 case Bytecodes::_fast_lputfield: __ push_l(r0); break; 3293 3294 default: 3295 ShouldNotReachHere(); 3296 } 3297 __ mov(c_rarg3, esp); // points to jvalue on the stack 3298 // access constant pool cache entry 3299 __ load_field_entry(c_rarg2, r0); 3300 __ verify_oop(r19); 3301 // r19: object pointer copied above 3302 // c_rarg2: cache entry pointer 3303 // c_rarg3: jvalue object on the stack 3304 __ call_VM(noreg, 3305 CAST_FROM_FN_PTR(address, 3306 InterpreterRuntime::post_field_modification), 3307 r19, c_rarg2, c_rarg3); 3308 3309 switch (bytecode()) { // restore tos values 3310 case Bytecodes::_fast_vputfield: //fall through 3311 case Bytecodes::_fast_aputfield: __ pop_ptr(r0); break; 3312 case Bytecodes::_fast_bputfield: // fall through 3313 case Bytecodes::_fast_zputfield: // fall through 3314 case Bytecodes::_fast_sputfield: // fall through 3315 case Bytecodes::_fast_cputfield: // fall through 3316 case Bytecodes::_fast_iputfield: __ pop_i(r0); break; 3317 case Bytecodes::_fast_dputfield: __ pop_d(); break; 3318 case Bytecodes::_fast_fputfield: __ pop_f(); break; 3319 case Bytecodes::_fast_lputfield: __ pop_l(r0); break; 3320 default: break; 3321 } 3322 __ bind(L2); 3323 } 3324 } 3325 3326 void TemplateTable::fast_storefield(TosState state) 3327 { 3328 transition(state, vtos); 3329 3330 ByteSize base = ConstantPoolCache::base_offset(); 3331 3332 jvmti_post_fast_field_mod(); 3333 3334 // access constant pool cache 3335 __ load_field_entry(r2, r1); 3336 3337 // R1: field offset, R2: field holder, R3: flags 3338 load_resolved_field_entry(r2, r2, noreg, r1, r3); 3339 3340 { 3341 Label notVolatile; 3342 __ tbz(r3, ResolvedFieldEntry::is_volatile_shift, notVolatile); 3343 __ membar(MacroAssembler::StoreStore | MacroAssembler::LoadStore); 3344 __ bind(notVolatile); 3345 } 3346 3347 Label notVolatile; 3348 3349 // Get object from stack 3350 pop_and_check_object(r2); 3351 3352 // field address 3353 const Address field(r2, r1); 3354 3355 // access field 3356 switch (bytecode()) { 3357 case Bytecodes::_fast_vputfield: 3358 { 3359 Label is_flat, has_null_marker, done; 3360 __ test_field_has_null_marker(r3, noreg /* temp */, has_null_marker); 3361 __ null_check(r0); 3362 __ test_field_is_flat(r3, noreg /* temp */, is_flat); 3363 // field is not flat 3364 do_oop_store(_masm, field, r0, IN_HEAP); 3365 __ b(done); 3366 __ bind(is_flat); 3367 // field is flat 3368 __ load_field_entry(r4, r3); 3369 __ load_unsigned_short(r3, Address(r4, in_bytes(ResolvedFieldEntry::field_index_offset()))); 3370 __ ldr(r4, Address(r4, in_bytes(ResolvedFieldEntry::field_holder_offset()))); 3371 __ inline_layout_info(r4, r3, r5); 3372 __ load_klass(r4, r0); 3373 __ data_for_oop(r0, r0, r4); 3374 __ lea(rscratch1, field); 3375 __ flat_field_copy(IN_HEAP, r0, rscratch1, r5); 3376 __ b(done); 3377 __ bind(has_null_marker); 3378 __ load_field_entry(r4, r1); 3379 __ mov(r1, r2); 3380 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::write_nullable_flat_field), r1, r0, r4); 3381 __ bind(done); 3382 } 3383 break; 3384 case Bytecodes::_fast_aputfield: 3385 do_oop_store(_masm, field, r0, IN_HEAP); 3386 break; 3387 case Bytecodes::_fast_lputfield: 3388 __ access_store_at(T_LONG, IN_HEAP, field, r0, noreg, noreg, noreg); 3389 break; 3390 case Bytecodes::_fast_iputfield: 3391 __ access_store_at(T_INT, IN_HEAP, field, r0, noreg, noreg, noreg); 3392 break; 3393 case Bytecodes::_fast_zputfield: 3394 __ access_store_at(T_BOOLEAN, IN_HEAP, field, r0, noreg, noreg, noreg); 3395 break; 3396 case Bytecodes::_fast_bputfield: 3397 __ access_store_at(T_BYTE, IN_HEAP, field, r0, noreg, noreg, noreg); 3398 break; 3399 case Bytecodes::_fast_sputfield: 3400 __ access_store_at(T_SHORT, IN_HEAP, field, r0, noreg, noreg, noreg); 3401 break; 3402 case Bytecodes::_fast_cputfield: 3403 __ access_store_at(T_CHAR, IN_HEAP, field, r0, noreg, noreg, noreg); 3404 break; 3405 case Bytecodes::_fast_fputfield: 3406 __ access_store_at(T_FLOAT, IN_HEAP, field, noreg /* ftos */, noreg, noreg, noreg); 3407 break; 3408 case Bytecodes::_fast_dputfield: 3409 __ access_store_at(T_DOUBLE, IN_HEAP, field, noreg /* dtos */, noreg, noreg, noreg); 3410 break; 3411 default: 3412 ShouldNotReachHere(); 3413 } 3414 3415 { 3416 Label notVolatile; 3417 __ tbz(r3, ResolvedFieldEntry::is_volatile_shift, notVolatile); 3418 __ membar(MacroAssembler::StoreLoad | MacroAssembler::StoreStore); 3419 __ bind(notVolatile); 3420 } 3421 } 3422 3423 3424 void TemplateTable::fast_accessfield(TosState state) 3425 { 3426 transition(atos, state); 3427 // Do the JVMTI work here to avoid disturbing the register state below 3428 if (JvmtiExport::can_post_field_access()) { 3429 // Check to see if a field access watch has been set before we 3430 // take the time to call into the VM. 3431 Label L1; 3432 __ lea(rscratch1, ExternalAddress((address) JvmtiExport::get_field_access_count_addr())); 3433 __ ldrw(r2, Address(rscratch1)); 3434 __ cbzw(r2, L1); 3435 // access constant pool cache entry 3436 __ load_field_entry(c_rarg2, rscratch2); 3437 __ verify_oop(r0); 3438 __ push_ptr(r0); // save object pointer before call_VM() clobbers it 3439 __ mov(c_rarg1, r0); 3440 // c_rarg1: object pointer copied above 3441 // c_rarg2: cache entry pointer 3442 __ call_VM(noreg, 3443 CAST_FROM_FN_PTR(address, 3444 InterpreterRuntime::post_field_access), 3445 c_rarg1, c_rarg2); 3446 __ pop_ptr(r0); // restore object pointer 3447 __ bind(L1); 3448 } 3449 3450 // access constant pool cache 3451 __ load_field_entry(r2, r1); 3452 3453 __ load_sized_value(r1, Address(r2, in_bytes(ResolvedFieldEntry::field_offset_offset())), sizeof(int), true /*is_signed*/); 3454 __ load_unsigned_byte(r3, Address(r2, in_bytes(ResolvedFieldEntry::flags_offset()))); 3455 3456 // r0: object 3457 __ verify_oop(r0); 3458 __ null_check(r0); 3459 const Address field(r0, r1); 3460 3461 // 8179954: We need to make sure that the code generated for 3462 // volatile accesses forms a sequentially-consistent set of 3463 // operations when combined with STLR and LDAR. Without a leading 3464 // membar it's possible for a simple Dekker test to fail if loads 3465 // use LDR;DMB but stores use STLR. This can happen if C2 compiles 3466 // the stores in one method and we interpret the loads in another. 3467 if (!CompilerConfig::is_c1_or_interpreter_only_no_jvmci()) { 3468 Label notVolatile; 3469 __ tbz(r3, ResolvedFieldEntry::is_volatile_shift, notVolatile); 3470 __ membar(MacroAssembler::AnyAny); 3471 __ bind(notVolatile); 3472 } 3473 3474 // access field 3475 switch (bytecode()) { 3476 case Bytecodes::_fast_vgetfield: 3477 { 3478 Register index = r4, klass = r5, inline_klass = r6, tmp = r7; 3479 Label is_flat, has_null_marker, nonnull, Done; 3480 __ test_field_has_null_marker(r3, noreg /*temp*/, has_null_marker); 3481 __ test_field_is_flat(r3, noreg /* temp */, is_flat); 3482 // field is not flat 3483 __ load_heap_oop(r0, field, rscratch1, rscratch2); 3484 __ cbnz(r0, nonnull); 3485 __ load_unsigned_short(index, Address(r2, in_bytes(ResolvedFieldEntry::field_index_offset()))); 3486 __ ldr(klass, Address(r2, in_bytes(ResolvedFieldEntry::field_holder_offset()))); 3487 __ get_inline_type_field_klass(klass, index, inline_klass); 3488 __ get_default_value_oop(inline_klass, tmp /* temp */, r0); 3489 __ bind(nonnull); 3490 __ verify_oop(r0); 3491 __ b(Done); 3492 __ bind(is_flat); 3493 // field is flat 3494 __ load_unsigned_short(index, Address(r2, in_bytes(ResolvedFieldEntry::field_index_offset()))); 3495 __ read_flat_field(r2, index, r1, tmp /* temp */, r0); 3496 __ verify_oop(r0); 3497 __ b(Done); 3498 __ bind(has_null_marker); 3499 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::read_nullable_flat_field), r0, r2); 3500 __ verify_oop(r0); 3501 __ bind(Done); 3502 } 3503 break; 3504 case Bytecodes::_fast_agetfield: 3505 do_oop_load(_masm, field, r0, IN_HEAP); 3506 __ verify_oop(r0); 3507 break; 3508 case Bytecodes::_fast_lgetfield: 3509 __ access_load_at(T_LONG, IN_HEAP, r0, field, noreg, noreg); 3510 break; 3511 case Bytecodes::_fast_igetfield: 3512 __ access_load_at(T_INT, IN_HEAP, r0, field, noreg, noreg); 3513 break; 3514 case Bytecodes::_fast_bgetfield: 3515 __ access_load_at(T_BYTE, IN_HEAP, r0, field, noreg, noreg); 3516 break; 3517 case Bytecodes::_fast_sgetfield: 3518 __ access_load_at(T_SHORT, IN_HEAP, r0, field, noreg, noreg); 3519 break; 3520 case Bytecodes::_fast_cgetfield: 3521 __ access_load_at(T_CHAR, IN_HEAP, r0, field, noreg, noreg); 3522 break; 3523 case Bytecodes::_fast_fgetfield: 3524 __ access_load_at(T_FLOAT, IN_HEAP, noreg /* ftos */, field, noreg, noreg); 3525 break; 3526 case Bytecodes::_fast_dgetfield: 3527 __ access_load_at(T_DOUBLE, IN_HEAP, noreg /* dtos */, field, noreg, noreg); 3528 break; 3529 default: 3530 ShouldNotReachHere(); 3531 } 3532 { 3533 Label notVolatile; 3534 __ tbz(r3, ResolvedFieldEntry::is_volatile_shift, notVolatile); 3535 __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); 3536 __ bind(notVolatile); 3537 } 3538 } 3539 3540 void TemplateTable::fast_xaccess(TosState state) 3541 { 3542 transition(vtos, state); 3543 3544 // get receiver 3545 __ ldr(r0, aaddress(0)); 3546 // access constant pool cache 3547 __ load_field_entry(r2, r3, 2); 3548 __ load_sized_value(r1, Address(r2, in_bytes(ResolvedFieldEntry::field_offset_offset())), sizeof(int), true /*is_signed*/); 3549 3550 // 8179954: We need to make sure that the code generated for 3551 // volatile accesses forms a sequentially-consistent set of 3552 // operations when combined with STLR and LDAR. Without a leading 3553 // membar it's possible for a simple Dekker test to fail if loads 3554 // use LDR;DMB but stores use STLR. This can happen if C2 compiles 3555 // the stores in one method and we interpret the loads in another. 3556 if (!CompilerConfig::is_c1_or_interpreter_only_no_jvmci()) { 3557 Label notVolatile; 3558 __ load_unsigned_byte(r3, Address(r2, in_bytes(ResolvedFieldEntry::flags_offset()))); 3559 __ tbz(r3, ResolvedFieldEntry::is_volatile_shift, notVolatile); 3560 __ membar(MacroAssembler::AnyAny); 3561 __ bind(notVolatile); 3562 } 3563 3564 // make sure exception is reported in correct bcp range (getfield is 3565 // next instruction) 3566 __ increment(rbcp); 3567 __ null_check(r0); 3568 switch (state) { 3569 case itos: 3570 __ access_load_at(T_INT, IN_HEAP, r0, Address(r0, r1, Address::lsl(0)), noreg, noreg); 3571 break; 3572 case atos: 3573 do_oop_load(_masm, Address(r0, r1, Address::lsl(0)), r0, IN_HEAP); 3574 __ verify_oop(r0); 3575 break; 3576 case ftos: 3577 __ access_load_at(T_FLOAT, IN_HEAP, noreg /* ftos */, Address(r0, r1, Address::lsl(0)), noreg, noreg); 3578 break; 3579 default: 3580 ShouldNotReachHere(); 3581 } 3582 3583 { 3584 Label notVolatile; 3585 __ load_unsigned_byte(r3, Address(r2, in_bytes(ResolvedFieldEntry::flags_offset()))); 3586 __ tbz(r3, ResolvedFieldEntry::is_volatile_shift, notVolatile); 3587 __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); 3588 __ bind(notVolatile); 3589 } 3590 3591 __ decrement(rbcp); 3592 } 3593 3594 3595 3596 //----------------------------------------------------------------------------- 3597 // Calls 3598 3599 void TemplateTable::prepare_invoke(Register cache, Register recv) { 3600 3601 Bytecodes::Code code = bytecode(); 3602 const bool load_receiver = (code != Bytecodes::_invokestatic) && (code != Bytecodes::_invokedynamic); 3603 3604 // save 'interpreter return address' 3605 __ save_bcp(); 3606 3607 // Load TOS state for later 3608 __ load_unsigned_byte(rscratch2, Address(cache, in_bytes(ResolvedMethodEntry::type_offset()))); 3609 3610 // load receiver if needed (note: no return address pushed yet) 3611 if (load_receiver) { 3612 __ load_unsigned_short(recv, Address(cache, in_bytes(ResolvedMethodEntry::num_parameters_offset()))); 3613 __ add(rscratch1, esp, recv, ext::uxtx, 3); 3614 __ ldr(recv, Address(rscratch1, -Interpreter::expr_offset_in_bytes(1))); 3615 __ verify_oop(recv); 3616 } 3617 3618 // load return address 3619 { 3620 const address table_addr = (address) Interpreter::invoke_return_entry_table_for(code); 3621 __ mov(rscratch1, table_addr); 3622 __ ldr(lr, Address(rscratch1, rscratch2, Address::lsl(3))); 3623 } 3624 } 3625 3626 3627 void TemplateTable::invokevirtual_helper(Register index, 3628 Register recv, 3629 Register flags) 3630 { 3631 // Uses temporary registers r0, r3 3632 assert_different_registers(index, recv, r0, r3); 3633 // Test for an invoke of a final method 3634 Label notFinal; 3635 __ tbz(flags, ResolvedMethodEntry::is_vfinal_shift, notFinal); 3636 3637 const Register method = index; // method must be rmethod 3638 assert(method == rmethod, 3639 "Method must be rmethod for interpreter calling convention"); 3640 3641 // do the call - the index is actually the method to call 3642 // that is, f2 is a vtable index if !is_vfinal, else f2 is a Method* 3643 3644 // It's final, need a null check here! 3645 __ null_check(recv); 3646 3647 // profile this call 3648 __ profile_final_call(r0); 3649 __ profile_arguments_type(r0, method, r4, true); 3650 3651 __ jump_from_interpreted(method, r0); 3652 3653 __ bind(notFinal); 3654 3655 // get receiver klass 3656 __ load_klass(r0, recv); 3657 3658 // profile this call 3659 __ profile_virtual_call(r0, rlocals, r3); 3660 3661 // get target Method & entry point 3662 __ lookup_virtual_method(r0, index, method); 3663 __ profile_arguments_type(r3, method, r4, true); 3664 // FIXME -- this looks completely redundant. is it? 3665 // __ ldr(r3, Address(method, Method::interpreter_entry_offset())); 3666 __ jump_from_interpreted(method, r3); 3667 } 3668 3669 void TemplateTable::invokevirtual(int byte_no) 3670 { 3671 transition(vtos, vtos); 3672 assert(byte_no == f2_byte, "use this argument"); 3673 3674 load_resolved_method_entry_virtual(r2, // ResolvedMethodEntry* 3675 rmethod, // Method* or itable index 3676 r3); // flags 3677 prepare_invoke(r2, r2); // recv 3678 3679 // rmethod: index (actually a Method*) 3680 // r2: receiver 3681 // r3: flags 3682 3683 invokevirtual_helper(rmethod, r2, r3); 3684 } 3685 3686 void TemplateTable::invokespecial(int byte_no) 3687 { 3688 transition(vtos, vtos); 3689 assert(byte_no == f1_byte, "use this argument"); 3690 3691 load_resolved_method_entry_special_or_static(r2, // ResolvedMethodEntry* 3692 rmethod, // Method* 3693 r3); // flags 3694 prepare_invoke(r2, r2); // get receiver also for null check 3695 __ verify_oop(r2); 3696 __ null_check(r2); 3697 // do the call 3698 __ profile_call(r0); 3699 __ profile_arguments_type(r0, rmethod, rbcp, false); 3700 __ jump_from_interpreted(rmethod, r0); 3701 } 3702 3703 void TemplateTable::invokestatic(int byte_no) 3704 { 3705 transition(vtos, vtos); 3706 assert(byte_no == f1_byte, "use this argument"); 3707 3708 load_resolved_method_entry_special_or_static(r2, // ResolvedMethodEntry* 3709 rmethod, // Method* 3710 r3); // flags 3711 prepare_invoke(r2, r2); // get receiver also for null check 3712 3713 // do the call 3714 __ profile_call(r0); 3715 __ profile_arguments_type(r0, rmethod, r4, false); 3716 __ jump_from_interpreted(rmethod, r0); 3717 } 3718 3719 void TemplateTable::fast_invokevfinal(int byte_no) 3720 { 3721 __ call_Unimplemented(); 3722 } 3723 3724 void TemplateTable::invokeinterface(int byte_no) { 3725 transition(vtos, vtos); 3726 assert(byte_no == f1_byte, "use this argument"); 3727 3728 load_resolved_method_entry_interface(r2, // ResolvedMethodEntry* 3729 r0, // Klass* 3730 rmethod, // Method* or itable/vtable index 3731 r3); // flags 3732 prepare_invoke(r2, r2); // receiver 3733 3734 // r0: interface klass (from f1) 3735 // rmethod: method (from f2) 3736 // r2: receiver 3737 // r3: flags 3738 3739 // First check for Object case, then private interface method, 3740 // then regular interface method. 3741 3742 // Special case of invokeinterface called for virtual method of 3743 // java.lang.Object. See cpCache.cpp for details. 3744 Label notObjectMethod; 3745 __ tbz(r3, ResolvedMethodEntry::is_forced_virtual_shift, notObjectMethod); 3746 3747 invokevirtual_helper(rmethod, r2, r3); 3748 __ bind(notObjectMethod); 3749 3750 Label no_such_interface; 3751 3752 // Check for private method invocation - indicated by vfinal 3753 Label notVFinal; 3754 __ tbz(r3, ResolvedMethodEntry::is_vfinal_shift, notVFinal); 3755 3756 // Get receiver klass into r3 3757 __ load_klass(r3, r2); 3758 3759 Label subtype; 3760 __ check_klass_subtype(r3, r0, r4, subtype); 3761 // If we get here the typecheck failed 3762 __ b(no_such_interface); 3763 __ bind(subtype); 3764 3765 __ profile_final_call(r0); 3766 __ profile_arguments_type(r0, rmethod, r4, true); 3767 __ jump_from_interpreted(rmethod, r0); 3768 3769 __ bind(notVFinal); 3770 3771 // Get receiver klass into r3 3772 __ restore_locals(); 3773 __ load_klass(r3, r2); 3774 3775 Label no_such_method; 3776 3777 // Preserve method for throw_AbstractMethodErrorVerbose. 3778 __ mov(r16, rmethod); 3779 // Receiver subtype check against REFC. 3780 // Superklass in r0. Subklass in r3. Blows rscratch2, r13 3781 __ lookup_interface_method(// inputs: rec. class, interface, itable index 3782 r3, r0, noreg, 3783 // outputs: scan temp. reg, scan temp. reg 3784 rscratch2, r13, 3785 no_such_interface, 3786 /*return_method=*/false); 3787 3788 // profile this call 3789 __ profile_virtual_call(r3, r13, r19); 3790 3791 // Get declaring interface class from method, and itable index 3792 3793 __ load_method_holder(r0, rmethod); 3794 __ ldrw(rmethod, Address(rmethod, Method::itable_index_offset())); 3795 __ subw(rmethod, rmethod, Method::itable_index_max); 3796 __ negw(rmethod, rmethod); 3797 3798 // Preserve recvKlass for throw_AbstractMethodErrorVerbose. 3799 __ mov(rlocals, r3); 3800 __ lookup_interface_method(// inputs: rec. class, interface, itable index 3801 rlocals, r0, rmethod, 3802 // outputs: method, scan temp. reg 3803 rmethod, r13, 3804 no_such_interface); 3805 3806 // rmethod,: Method to call 3807 // r2: receiver 3808 // Check for abstract method error 3809 // Note: This should be done more efficiently via a throw_abstract_method_error 3810 // interpreter entry point and a conditional jump to it in case of a null 3811 // method. 3812 __ cbz(rmethod, no_such_method); 3813 3814 __ profile_arguments_type(r3, rmethod, r13, true); 3815 3816 // do the call 3817 // r2: receiver 3818 // rmethod,: Method 3819 __ jump_from_interpreted(rmethod, r3); 3820 __ should_not_reach_here(); 3821 3822 // exception handling code follows... 3823 // note: must restore interpreter registers to canonical 3824 // state for exception handling to work correctly! 3825 3826 __ bind(no_such_method); 3827 // throw exception 3828 __ restore_bcp(); // bcp must be correct for exception handler (was destroyed) 3829 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) 3830 // Pass arguments for generating a verbose error message. 3831 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodErrorVerbose), r3, r16); 3832 // the call_VM checks for exception, so we should never return here. 3833 __ should_not_reach_here(); 3834 3835 __ bind(no_such_interface); 3836 // throw exception 3837 __ restore_bcp(); // bcp must be correct for exception handler (was destroyed) 3838 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) 3839 // Pass arguments for generating a verbose error message. 3840 __ call_VM(noreg, CAST_FROM_FN_PTR(address, 3841 InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose), r3, r0); 3842 // the call_VM checks for exception, so we should never return here. 3843 __ should_not_reach_here(); 3844 return; 3845 } 3846 3847 void TemplateTable::invokehandle(int byte_no) { 3848 transition(vtos, vtos); 3849 assert(byte_no == f1_byte, "use this argument"); 3850 3851 load_resolved_method_entry_handle(r2, // ResolvedMethodEntry* 3852 rmethod, // Method* 3853 r0, // Resolved reference 3854 r3); // flags 3855 prepare_invoke(r2, r2); 3856 3857 __ verify_method_ptr(r2); 3858 __ verify_oop(r2); 3859 __ null_check(r2); 3860 3861 // FIXME: profile the LambdaForm also 3862 3863 // r13 is safe to use here as a scratch reg because it is about to 3864 // be clobbered by jump_from_interpreted(). 3865 __ profile_final_call(r13); 3866 __ profile_arguments_type(r13, rmethod, r4, true); 3867 3868 __ jump_from_interpreted(rmethod, r0); 3869 } 3870 3871 void TemplateTable::invokedynamic(int byte_no) { 3872 transition(vtos, vtos); 3873 assert(byte_no == f1_byte, "use this argument"); 3874 3875 load_invokedynamic_entry(rmethod); 3876 3877 // r0: CallSite object (from cpool->resolved_references[]) 3878 // rmethod: MH.linkToCallSite method 3879 3880 // Note: r0_callsite is already pushed 3881 3882 // %%% should make a type profile for any invokedynamic that takes a ref argument 3883 // profile this call 3884 __ profile_call(rbcp); 3885 __ profile_arguments_type(r3, rmethod, r13, false); 3886 3887 __ verify_oop(r0); 3888 3889 __ jump_from_interpreted(rmethod, r0); 3890 } 3891 3892 3893 //----------------------------------------------------------------------------- 3894 // Allocation 3895 3896 void TemplateTable::_new() { 3897 transition(vtos, atos); 3898 3899 __ get_unsigned_2_byte_index_at_bcp(r3, 1); 3900 Label slow_case; 3901 Label done; 3902 Label initialize_header; 3903 3904 __ get_cpool_and_tags(r4, r0); 3905 // Make sure the class we're about to instantiate has been resolved. 3906 // This is done before loading InstanceKlass to be consistent with the order 3907 // how Constant Pool is updated (see ConstantPool::klass_at_put) 3908 const int tags_offset = Array<u1>::base_offset_in_bytes(); 3909 __ lea(rscratch1, Address(r0, r3, Address::lsl(0))); 3910 __ lea(rscratch1, Address(rscratch1, tags_offset)); 3911 __ ldarb(rscratch1, rscratch1); 3912 __ cmp(rscratch1, (u1)JVM_CONSTANT_Class); 3913 __ br(Assembler::NE, slow_case); 3914 3915 // get InstanceKlass 3916 __ load_resolved_klass_at_offset(r4, r3, r4, rscratch1); 3917 3918 // make sure klass is initialized 3919 assert(VM_Version::supports_fast_class_init_checks(), "Optimization requires support for fast class initialization checks"); 3920 __ clinit_barrier(r4, rscratch1, nullptr /*L_fast_path*/, &slow_case); 3921 3922 __ allocate_instance(r4, r0, r3, r1, true, slow_case); 3923 if (DTraceAllocProbes) { 3924 // Trigger dtrace event for fastpath 3925 __ push(atos); // save the return value 3926 __ call_VM_leaf( 3927 CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), r0); 3928 __ pop(atos); // restore the return value 3929 3930 } 3931 __ b(done); 3932 3933 // slow case 3934 __ bind(slow_case); 3935 __ get_constant_pool(c_rarg1); 3936 __ get_unsigned_2_byte_index_at_bcp(c_rarg2, 1); 3937 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), c_rarg1, c_rarg2); 3938 __ verify_oop(r0); 3939 3940 // continue 3941 __ bind(done); 3942 // Must prevent reordering of stores for object initialization with stores that publish the new object. 3943 __ membar(Assembler::StoreStore); 3944 } 3945 3946 void TemplateTable::newarray() { 3947 transition(itos, atos); 3948 __ load_unsigned_byte(c_rarg1, at_bcp(1)); 3949 __ mov(c_rarg2, r0); 3950 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::newarray), 3951 c_rarg1, c_rarg2); 3952 // Must prevent reordering of stores for object initialization with stores that publish the new object. 3953 __ membar(Assembler::StoreStore); 3954 } 3955 3956 void TemplateTable::anewarray() { 3957 transition(itos, atos); 3958 __ get_unsigned_2_byte_index_at_bcp(c_rarg2, 1); 3959 __ get_constant_pool(c_rarg1); 3960 __ mov(c_rarg3, r0); 3961 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::anewarray), 3962 c_rarg1, c_rarg2, c_rarg3); 3963 // Must prevent reordering of stores for object initialization with stores that publish the new object. 3964 __ membar(Assembler::StoreStore); 3965 } 3966 3967 void TemplateTable::arraylength() { 3968 transition(atos, itos); 3969 __ ldrw(r0, Address(r0, arrayOopDesc::length_offset_in_bytes())); 3970 } 3971 3972 void TemplateTable::checkcast() 3973 { 3974 transition(atos, atos); 3975 Label done, is_null, ok_is_subtype, quicked, resolved; 3976 __ cbz(r0, is_null); 3977 3978 // Get cpool & tags index 3979 __ get_cpool_and_tags(r2, r3); // r2=cpool, r3=tags array 3980 __ get_unsigned_2_byte_index_at_bcp(r19, 1); // r19=index 3981 // See if bytecode has already been quicked 3982 __ add(rscratch1, r3, Array<u1>::base_offset_in_bytes()); 3983 __ lea(r1, Address(rscratch1, r19)); 3984 __ ldarb(r1, r1); 3985 __ cmp(r1, (u1)JVM_CONSTANT_Class); 3986 __ br(Assembler::EQ, quicked); 3987 3988 __ push(atos); // save receiver for result, and for GC 3989 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc)); 3990 // vm_result_2 has metadata result 3991 __ get_vm_result_2(r0, rthread); 3992 __ pop(r3); // restore receiver 3993 __ b(resolved); 3994 3995 // Get superklass in r0 and subklass in r3 3996 __ bind(quicked); 3997 __ mov(r3, r0); // Save object in r3; r0 needed for subtype check 3998 __ load_resolved_klass_at_offset(r2, r19, r0, rscratch1); // r0 = klass 3999 4000 __ bind(resolved); 4001 __ load_klass(r19, r3); 4002 4003 // Generate subtype check. Blows r2, r5. Object in r3. 4004 // Superklass in r0. Subklass in r19. 4005 __ gen_subtype_check(r19, ok_is_subtype); 4006 4007 // Come here on failure 4008 __ push(r3); 4009 // object is at TOS 4010 __ b(Interpreter::_throw_ClassCastException_entry); 4011 4012 // Come here on success 4013 __ bind(ok_is_subtype); 4014 __ mov(r0, r3); // Restore object in r3 4015 4016 __ b(done); 4017 __ bind(is_null); 4018 4019 // Collect counts on whether this test sees nulls a lot or not. 4020 if (ProfileInterpreter) { 4021 __ profile_null_seen(r2); 4022 } 4023 4024 __ bind(done); 4025 } 4026 4027 void TemplateTable::instanceof() { 4028 transition(atos, itos); 4029 Label done, is_null, ok_is_subtype, quicked, resolved; 4030 __ cbz(r0, is_null); 4031 4032 // Get cpool & tags index 4033 __ get_cpool_and_tags(r2, r3); // r2=cpool, r3=tags array 4034 __ get_unsigned_2_byte_index_at_bcp(r19, 1); // r19=index 4035 // See if bytecode has already been quicked 4036 __ add(rscratch1, r3, Array<u1>::base_offset_in_bytes()); 4037 __ lea(r1, Address(rscratch1, r19)); 4038 __ ldarb(r1, r1); 4039 __ cmp(r1, (u1)JVM_CONSTANT_Class); 4040 __ br(Assembler::EQ, quicked); 4041 4042 __ push(atos); // save receiver for result, and for GC 4043 call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc)); 4044 // vm_result_2 has metadata result 4045 __ get_vm_result_2(r0, rthread); 4046 __ pop(r3); // restore receiver 4047 __ verify_oop(r3); 4048 __ load_klass(r3, r3); 4049 __ b(resolved); 4050 4051 // Get superklass in r0 and subklass in r3 4052 __ bind(quicked); 4053 __ load_klass(r3, r0); 4054 __ load_resolved_klass_at_offset(r2, r19, r0, rscratch1); 4055 4056 __ bind(resolved); 4057 4058 // Generate subtype check. Blows r2, r5 4059 // Superklass in r0. Subklass in r3. 4060 __ gen_subtype_check(r3, ok_is_subtype); 4061 4062 // Come here on failure 4063 __ mov(r0, 0); 4064 __ b(done); 4065 // Come here on success 4066 __ bind(ok_is_subtype); 4067 __ mov(r0, 1); 4068 4069 // Collect counts on whether this test sees nulls a lot or not. 4070 if (ProfileInterpreter) { 4071 __ b(done); 4072 __ bind(is_null); 4073 __ profile_null_seen(r2); 4074 } else { 4075 __ bind(is_null); // same as 'done' 4076 } 4077 __ bind(done); 4078 // r0 = 0: obj == nullptr or obj is not an instanceof the specified klass 4079 // r0 = 1: obj != nullptr and obj is an instanceof the specified klass 4080 } 4081 4082 //----------------------------------------------------------------------------- 4083 // Breakpoints 4084 void TemplateTable::_breakpoint() { 4085 // Note: We get here even if we are single stepping.. 4086 // jbug inists on setting breakpoints at every bytecode 4087 // even if we are in single step mode. 4088 4089 transition(vtos, vtos); 4090 4091 // get the unpatched byte code 4092 __ get_method(c_rarg1); 4093 __ call_VM(noreg, 4094 CAST_FROM_FN_PTR(address, 4095 InterpreterRuntime::get_original_bytecode_at), 4096 c_rarg1, rbcp); 4097 __ mov(r19, r0); 4098 4099 // post the breakpoint event 4100 __ call_VM(noreg, 4101 CAST_FROM_FN_PTR(address, InterpreterRuntime::_breakpoint), 4102 rmethod, rbcp); 4103 4104 // complete the execution of original bytecode 4105 __ mov(rscratch1, r19); 4106 __ dispatch_only_normal(vtos); 4107 } 4108 4109 //----------------------------------------------------------------------------- 4110 // Exceptions 4111 4112 void TemplateTable::athrow() { 4113 transition(atos, vtos); 4114 __ null_check(r0); 4115 __ b(Interpreter::throw_exception_entry()); 4116 } 4117 4118 //----------------------------------------------------------------------------- 4119 // Synchronization 4120 // 4121 // Note: monitorenter & exit are symmetric routines; which is reflected 4122 // in the assembly code structure as well 4123 // 4124 // Stack layout: 4125 // 4126 // [expressions ] <--- esp = expression stack top 4127 // .. 4128 // [expressions ] 4129 // [monitor entry] <--- monitor block top = expression stack bot 4130 // .. 4131 // [monitor entry] 4132 // [frame data ] <--- monitor block bot 4133 // ... 4134 // [saved rfp ] <--- rfp 4135 void TemplateTable::monitorenter() 4136 { 4137 transition(atos, vtos); 4138 4139 // check for null object 4140 __ null_check(r0); 4141 4142 Label is_inline_type; 4143 __ ldr(rscratch1, Address(r0, oopDesc::mark_offset_in_bytes())); 4144 __ test_markword_is_inline_type(rscratch1, is_inline_type); 4145 4146 const Address monitor_block_top( 4147 rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize); 4148 const Address monitor_block_bot( 4149 rfp, frame::interpreter_frame_initial_sp_offset * wordSize); 4150 const int entry_size = frame::interpreter_frame_monitor_size_in_bytes(); 4151 4152 Label allocated; 4153 4154 // initialize entry pointer 4155 __ mov(c_rarg1, zr); // points to free slot or null 4156 4157 // find a free slot in the monitor block (result in c_rarg1) 4158 { 4159 Label entry, loop, exit; 4160 __ ldr(c_rarg3, monitor_block_top); // derelativize pointer 4161 __ lea(c_rarg3, Address(rfp, c_rarg3, Address::lsl(Interpreter::logStackElementSize))); 4162 // c_rarg3 points to current entry, starting with top-most entry 4163 4164 __ lea(c_rarg2, monitor_block_bot); // points to word before bottom 4165 4166 __ b(entry); 4167 4168 __ bind(loop); 4169 // check if current entry is used 4170 // if not used then remember entry in c_rarg1 4171 __ ldr(rscratch1, Address(c_rarg3, BasicObjectLock::obj_offset())); 4172 __ cmp(zr, rscratch1); 4173 __ csel(c_rarg1, c_rarg3, c_rarg1, Assembler::EQ); 4174 // check if current entry is for same object 4175 __ cmp(r0, rscratch1); 4176 // if same object then stop searching 4177 __ br(Assembler::EQ, exit); 4178 // otherwise advance to next entry 4179 __ add(c_rarg3, c_rarg3, entry_size); 4180 __ bind(entry); 4181 // check if bottom reached 4182 __ cmp(c_rarg3, c_rarg2); 4183 // if not at bottom then check this entry 4184 __ br(Assembler::NE, loop); 4185 __ bind(exit); 4186 } 4187 4188 __ cbnz(c_rarg1, allocated); // check if a slot has been found and 4189 // if found, continue with that on 4190 4191 // allocate one if there's no free slot 4192 { 4193 Label entry, loop; 4194 // 1. compute new pointers // rsp: old expression stack top 4195 4196 __ check_extended_sp(); 4197 __ sub(sp, sp, entry_size); // make room for the monitor 4198 __ sub(rscratch1, sp, rfp); 4199 __ asr(rscratch1, rscratch1, Interpreter::logStackElementSize); 4200 __ str(rscratch1, Address(rfp, frame::interpreter_frame_extended_sp_offset * wordSize)); 4201 4202 __ ldr(c_rarg1, monitor_block_bot); // derelativize pointer 4203 __ lea(c_rarg1, Address(rfp, c_rarg1, Address::lsl(Interpreter::logStackElementSize))); 4204 // c_rarg1 points to the old expression stack bottom 4205 4206 __ sub(esp, esp, entry_size); // move expression stack top 4207 __ sub(c_rarg1, c_rarg1, entry_size); // move expression stack bottom 4208 __ mov(c_rarg3, esp); // set start value for copy loop 4209 __ sub(rscratch1, c_rarg1, rfp); // relativize pointer 4210 __ asr(rscratch1, rscratch1, Interpreter::logStackElementSize); 4211 __ str(rscratch1, monitor_block_bot); // set new monitor block bottom 4212 4213 __ b(entry); 4214 // 2. move expression stack contents 4215 __ bind(loop); 4216 __ ldr(c_rarg2, Address(c_rarg3, entry_size)); // load expression stack 4217 // word from old location 4218 __ str(c_rarg2, Address(c_rarg3, 0)); // and store it at new location 4219 __ add(c_rarg3, c_rarg3, wordSize); // advance to next word 4220 __ bind(entry); 4221 __ cmp(c_rarg3, c_rarg1); // check if bottom reached 4222 __ br(Assembler::NE, loop); // if not at bottom then 4223 // copy next word 4224 } 4225 4226 // call run-time routine 4227 // c_rarg1: points to monitor entry 4228 __ bind(allocated); 4229 4230 // Increment bcp to point to the next bytecode, so exception 4231 // handling for async. exceptions work correctly. 4232 // The object has already been popped from the stack, so the 4233 // expression stack looks correct. 4234 __ increment(rbcp); 4235 4236 // store object 4237 __ str(r0, Address(c_rarg1, BasicObjectLock::obj_offset())); 4238 __ lock_object(c_rarg1); 4239 4240 // check to make sure this monitor doesn't cause stack overflow after locking 4241 __ save_bcp(); // in case of exception 4242 __ generate_stack_overflow_check(0); 4243 4244 // The bcp has already been incremented. Just need to dispatch to 4245 // next instruction. 4246 __ dispatch_next(vtos); 4247 4248 __ bind(is_inline_type); 4249 __ call_VM(noreg, CAST_FROM_FN_PTR(address, 4250 InterpreterRuntime::throw_identity_exception), r0); 4251 __ should_not_reach_here(); 4252 } 4253 4254 4255 void TemplateTable::monitorexit() 4256 { 4257 transition(atos, vtos); 4258 4259 // check for null object 4260 __ null_check(r0); 4261 4262 const int is_inline_type_mask = markWord::inline_type_pattern; 4263 Label has_identity; 4264 __ ldr(rscratch1, Address(r0, oopDesc::mark_offset_in_bytes())); 4265 __ mov(rscratch2, is_inline_type_mask); 4266 __ andr(rscratch1, rscratch1, rscratch2); 4267 __ cmp(rscratch1, rscratch2); 4268 __ br(Assembler::NE, has_identity); 4269 __ call_VM(noreg, CAST_FROM_FN_PTR(address, 4270 InterpreterRuntime::throw_illegal_monitor_state_exception)); 4271 __ should_not_reach_here(); 4272 __ bind(has_identity); 4273 4274 const Address monitor_block_top( 4275 rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize); 4276 const Address monitor_block_bot( 4277 rfp, frame::interpreter_frame_initial_sp_offset * wordSize); 4278 const int entry_size = frame::interpreter_frame_monitor_size_in_bytes(); 4279 4280 Label found; 4281 4282 // find matching slot 4283 { 4284 Label entry, loop; 4285 __ ldr(c_rarg1, monitor_block_top); // derelativize pointer 4286 __ lea(c_rarg1, Address(rfp, c_rarg1, Address::lsl(Interpreter::logStackElementSize))); 4287 // c_rarg1 points to current entry, starting with top-most entry 4288 4289 __ lea(c_rarg2, monitor_block_bot); // points to word before bottom 4290 // of monitor block 4291 __ b(entry); 4292 4293 __ bind(loop); 4294 // check if current entry is for same object 4295 __ ldr(rscratch1, Address(c_rarg1, BasicObjectLock::obj_offset())); 4296 __ cmp(r0, rscratch1); 4297 // if same object then stop searching 4298 __ br(Assembler::EQ, found); 4299 // otherwise advance to next entry 4300 __ add(c_rarg1, c_rarg1, entry_size); 4301 __ bind(entry); 4302 // check if bottom reached 4303 __ cmp(c_rarg1, c_rarg2); 4304 // if not at bottom then check this entry 4305 __ br(Assembler::NE, loop); 4306 } 4307 4308 // error handling. Unlocking was not block-structured 4309 __ call_VM(noreg, CAST_FROM_FN_PTR(address, 4310 InterpreterRuntime::throw_illegal_monitor_state_exception)); 4311 __ should_not_reach_here(); 4312 4313 // call run-time routine 4314 __ bind(found); 4315 __ push_ptr(r0); // make sure object is on stack (contract with oopMaps) 4316 __ unlock_object(c_rarg1); 4317 __ pop_ptr(r0); // discard object 4318 } 4319 4320 4321 // Wide instructions 4322 void TemplateTable::wide() 4323 { 4324 __ load_unsigned_byte(r19, at_bcp(1)); 4325 __ mov(rscratch1, (address)Interpreter::_wentry_point); 4326 __ ldr(rscratch1, Address(rscratch1, r19, Address::uxtw(3))); 4327 __ br(rscratch1); 4328 } 4329 4330 4331 // Multi arrays 4332 void TemplateTable::multianewarray() { 4333 transition(vtos, atos); 4334 __ load_unsigned_byte(r0, at_bcp(3)); // get number of dimensions 4335 // last dim is on top of stack; we want address of first one: 4336 // first_addr = last_addr + (ndims - 1) * wordSize 4337 __ lea(c_rarg1, Address(esp, r0, Address::uxtw(3))); 4338 __ sub(c_rarg1, c_rarg1, wordSize); 4339 call_VM(r0, 4340 CAST_FROM_FN_PTR(address, InterpreterRuntime::multianewarray), 4341 c_rarg1); 4342 __ load_unsigned_byte(r1, at_bcp(3)); 4343 __ lea(esp, Address(esp, r1, Address::uxtw(3))); 4344 }