< prev index next >

src/cpu/aarch64/vm/interp_masm_aarch64.cpp

Print this page
rev 10997 : 8154957: AArch64: Better byte behavior
Summary:  The fix for 8132051 is needed for AArch64.
Reviewed-by: roland


  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "interp_masm_aarch64.hpp"
  28 #include "interpreter/interpreter.hpp"
  29 #include "interpreter/interpreterRuntime.hpp"
  30 #include "oops/arrayOop.hpp"
  31 #include "oops/markOop.hpp"
  32 #include "oops/methodData.hpp"
  33 #include "oops/method.hpp"
  34 #include "prims/jvmtiExport.hpp"
  35 #include "prims/jvmtiRedefineClassesTrace.hpp"
  36 #include "prims/jvmtiThreadState.hpp"
  37 #include "runtime/basicLock.hpp"
  38 #include "runtime/biasedLocking.hpp"
  39 #include "runtime/sharedRuntime.hpp"
  40 #include "runtime/thread.inline.hpp"
  41 
  42 
  43 // Implementation of InterpreterMacroAssembler




































  44 
  45 void InterpreterMacroAssembler::jump_to_entry(address entry) {
  46   assert(entry, "Entry must have been generated by now");
  47   b(entry);
  48 }
  49 
  50 void InterpreterMacroAssembler::check_and_handle_popframe(Register java_thread) {
  51   if (JvmtiExport::can_pop_frame()) {
  52     Label L;
  53     // Initiate popframe handling only if it is not already being
  54     // processed.  If the flag has the popframe_processing bit set, it
  55     // means that this code is called *during* popframe handling - we
  56     // don't want to reenter.
  57     // This method is only called just after the call into the vm in
  58     // call_VM_base, so the arg registers are available.
  59     ldrw(rscratch1, Address(rthread, JavaThread::popframe_condition_offset()));
  60     tstw(rscratch1, JavaThread::popframe_pending_bit);
  61     br(Assembler::EQ, L);
  62     tstw(rscratch1, JavaThread::popframe_processing_bit);
  63     br(Assembler::NE, L);
  64     // Call Interpreter::remove_activation_preserving_args_entry() to get the
  65     // address of the same-named entrypoint in the generated interpreter code.
  66     call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));
  67     br(r0);
  68     bind(L);
  69   }
  70 }
  71 
  72 
  73 void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
  74   ldr(r2, Address(rthread, JavaThread::jvmti_thread_state_offset()));
  75   const Address tos_addr(r2, JvmtiThreadState::earlyret_tos_offset());
  76   const Address oop_addr(r2, JvmtiThreadState::earlyret_oop_offset());
  77   const Address val_addr(r2, JvmtiThreadState::earlyret_value_offset());
  78   switch (state) {
  79     case atos: ldr(r0, oop_addr);
  80                str(zr, oop_addr);
  81                verify_oop(r0, state);               break;
  82     case ltos: ldr(r0, val_addr);                   break;
  83     case btos:                                   // fall through

  84     case ctos:                                   // fall through
  85     case stos:                                   // fall through
  86     case itos: ldrw(r0, val_addr);                  break;
  87     case ftos: ldrs(v0, val_addr);                  break;
  88     case dtos: ldrd(v0, val_addr);                  break;
  89     case vtos: /* nothing to do */                  break;
  90     default  : ShouldNotReachHere();
  91   }
  92   // Clean up tos value in the thread object
  93   movw(rscratch1, (int) ilgl);
  94   strw(rscratch1, tos_addr);
  95   strw(zr, val_addr);
  96 }
  97 
  98 
  99 void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread) {
 100   if (JvmtiExport::can_force_early_return()) {
 101     Label L;
 102     ldr(rscratch1, Address(rthread, JavaThread::jvmti_thread_state_offset()));
 103     cbz(rscratch1, L); // if (thread->jvmti_thread_state() == NULL) exit;


 297 void InterpreterMacroAssembler::pop_f(FloatRegister r) {
 298   ldrs(r, post(esp, wordSize));
 299 }
 300 
 301 void InterpreterMacroAssembler::pop_d(FloatRegister r) {
 302   ldrd(r, post(esp, 2 * Interpreter::stackElementSize));
 303 }
 304 
 305 void InterpreterMacroAssembler::push_f(FloatRegister r) {
 306   strs(r, pre(esp, -wordSize));
 307 }
 308 
 309 void InterpreterMacroAssembler::push_d(FloatRegister r) {
 310   strd(r, pre(esp, 2* -wordSize));
 311 }
 312 
 313 void InterpreterMacroAssembler::pop(TosState state) {
 314   switch (state) {
 315   case atos: pop_ptr();                 break;
 316   case btos:

 317   case ctos:
 318   case stos:
 319   case itos: pop_i();                   break;
 320   case ltos: pop_l();                   break;
 321   case ftos: pop_f();                   break;
 322   case dtos: pop_d();                   break;
 323   case vtos: /* nothing to do */        break;
 324   default:   ShouldNotReachHere();
 325   }
 326   verify_oop(r0, state);
 327 }
 328 
 329 void InterpreterMacroAssembler::push(TosState state) {
 330   verify_oop(r0, state);
 331   switch (state) {
 332   case atos: push_ptr();                break;
 333   case btos:

 334   case ctos:
 335   case stos:
 336   case itos: push_i();                  break;
 337   case ltos: push_l();                  break;
 338   case ftos: push_f();                  break;
 339   case dtos: push_d();                  break;
 340   case vtos: /* nothing to do */        break;
 341   default  : ShouldNotReachHere();
 342   }
 343 }
 344 
 345 // Helpers for swap and dup
 346 void InterpreterMacroAssembler::load_ptr(int n, Register val) {
 347   ldr(val, Address(esp, Interpreter::expr_offset_in_bytes(n)));
 348 }
 349 
 350 void InterpreterMacroAssembler::store_ptr(int n, Register val) {
 351   str(val, Address(esp, Interpreter::expr_offset_in_bytes(n)));
 352 }
 353 




  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "interp_masm_aarch64.hpp"
  28 #include "interpreter/interpreter.hpp"
  29 #include "interpreter/interpreterRuntime.hpp"
  30 #include "oops/arrayOop.hpp"
  31 #include "oops/markOop.hpp"
  32 #include "oops/methodData.hpp"
  33 #include "oops/method.hpp"
  34 #include "prims/jvmtiExport.hpp"
  35 #include "prims/jvmtiRedefineClassesTrace.hpp"
  36 #include "prims/jvmtiThreadState.hpp"
  37 #include "runtime/basicLock.hpp"
  38 #include "runtime/biasedLocking.hpp"
  39 #include "runtime/sharedRuntime.hpp"
  40 #include "runtime/thread.inline.hpp"
  41 
  42 
  43 void InterpreterMacroAssembler::narrow(Register result) {
  44 
  45   // Get method->_constMethod->_result_type
  46   ldr(rscratch1, Address(rfp, frame::interpreter_frame_method_offset * wordSize));
  47   ldr(rscratch1, Address(rscratch1, Method::const_offset()));
  48   ldrb(rscratch1, Address(rscratch1, ConstMethod::result_type_offset()));
  49 
  50   Label done, notBool, notByte, notChar;
  51 
  52   // common case first
  53   cmpw(rscratch1, T_INT);
  54   br(Assembler::EQ, done);
  55 
  56   // mask integer result to narrower return type.
  57   cmpw(rscratch1, T_BOOLEAN);
  58   br(Assembler::NE, notBool);
  59   andw(result, result, 0x1);
  60   b(done);
  61 
  62   bind(notBool);
  63   cmpw(rscratch1, T_BYTE);
  64   br(Assembler::NE, notByte);
  65   sbfx(result, result, 0, 8);
  66   b(done);
  67 
  68   bind(notByte);
  69   cmpw(rscratch1, T_CHAR);
  70   br(Assembler::NE, notChar);
  71   ubfx(result, result, 0, 16);  // truncate upper 16 bits
  72   b(done);
  73 
  74   bind(notChar);
  75   sbfx(result, result, 0, 16);     // sign-extend short
  76 
  77   // Nothing to do for T_INT
  78   bind(done);
  79 }
  80 
  81 void InterpreterMacroAssembler::jump_to_entry(address entry) {
  82   assert(entry, "Entry must have been generated by now");
  83   b(entry);
  84 }
  85 
  86 void InterpreterMacroAssembler::check_and_handle_popframe(Register java_thread) {
  87   if (JvmtiExport::can_pop_frame()) {
  88     Label L;
  89     // Initiate popframe handling only if it is not already being
  90     // processed.  If the flag has the popframe_processing bit set, it
  91     // means that this code is called *during* popframe handling - we
  92     // don't want to reenter.
  93     // This method is only called just after the call into the vm in
  94     // call_VM_base, so the arg registers are available.
  95     ldrw(rscratch1, Address(rthread, JavaThread::popframe_condition_offset()));
  96     tstw(rscratch1, JavaThread::popframe_pending_bit);
  97     br(Assembler::EQ, L);
  98     tstw(rscratch1, JavaThread::popframe_processing_bit);
  99     br(Assembler::NE, L);
 100     // Call Interpreter::remove_activation_preserving_args_entry() to get the
 101     // address of the same-named entrypoint in the generated interpreter code.
 102     call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));
 103     br(r0);
 104     bind(L);
 105   }
 106 }
 107 
 108 
 109 void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
 110   ldr(r2, Address(rthread, JavaThread::jvmti_thread_state_offset()));
 111   const Address tos_addr(r2, JvmtiThreadState::earlyret_tos_offset());
 112   const Address oop_addr(r2, JvmtiThreadState::earlyret_oop_offset());
 113   const Address val_addr(r2, JvmtiThreadState::earlyret_value_offset());
 114   switch (state) {
 115     case atos: ldr(r0, oop_addr);
 116                str(zr, oop_addr);
 117                verify_oop(r0, state);               break;
 118     case ltos: ldr(r0, val_addr);                   break;
 119     case btos:                                   // fall through
 120     case ztos:                                   // fall through
 121     case ctos:                                   // fall through
 122     case stos:                                   // fall through
 123     case itos: ldrw(r0, val_addr);                  break;
 124     case ftos: ldrs(v0, val_addr);                  break;
 125     case dtos: ldrd(v0, val_addr);                  break;
 126     case vtos: /* nothing to do */                  break;
 127     default  : ShouldNotReachHere();
 128   }
 129   // Clean up tos value in the thread object
 130   movw(rscratch1, (int) ilgl);
 131   strw(rscratch1, tos_addr);
 132   strw(zr, val_addr);
 133 }
 134 
 135 
 136 void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread) {
 137   if (JvmtiExport::can_force_early_return()) {
 138     Label L;
 139     ldr(rscratch1, Address(rthread, JavaThread::jvmti_thread_state_offset()));
 140     cbz(rscratch1, L); // if (thread->jvmti_thread_state() == NULL) exit;


 334 void InterpreterMacroAssembler::pop_f(FloatRegister r) {
 335   ldrs(r, post(esp, wordSize));
 336 }
 337 
 338 void InterpreterMacroAssembler::pop_d(FloatRegister r) {
 339   ldrd(r, post(esp, 2 * Interpreter::stackElementSize));
 340 }
 341 
 342 void InterpreterMacroAssembler::push_f(FloatRegister r) {
 343   strs(r, pre(esp, -wordSize));
 344 }
 345 
 346 void InterpreterMacroAssembler::push_d(FloatRegister r) {
 347   strd(r, pre(esp, 2* -wordSize));
 348 }
 349 
 350 void InterpreterMacroAssembler::pop(TosState state) {
 351   switch (state) {
 352   case atos: pop_ptr();                 break;
 353   case btos:
 354   case ztos:
 355   case ctos:
 356   case stos:
 357   case itos: pop_i();                   break;
 358   case ltos: pop_l();                   break;
 359   case ftos: pop_f();                   break;
 360   case dtos: pop_d();                   break;
 361   case vtos: /* nothing to do */        break;
 362   default:   ShouldNotReachHere();
 363   }
 364   verify_oop(r0, state);
 365 }
 366 
 367 void InterpreterMacroAssembler::push(TosState state) {
 368   verify_oop(r0, state);
 369   switch (state) {
 370   case atos: push_ptr();                break;
 371   case btos:
 372   case ztos:
 373   case ctos:
 374   case stos:
 375   case itos: push_i();                  break;
 376   case ltos: push_l();                  break;
 377   case ftos: push_f();                  break;
 378   case dtos: push_d();                  break;
 379   case vtos: /* nothing to do */        break;
 380   default  : ShouldNotReachHere();
 381   }
 382 }
 383 
 384 // Helpers for swap and dup
 385 void InterpreterMacroAssembler::load_ptr(int n, Register val) {
 386   ldr(val, Address(esp, Interpreter::expr_offset_in_bytes(n)));
 387 }
 388 
 389 void InterpreterMacroAssembler::store_ptr(int n, Register val) {
 390   str(val, Address(esp, Interpreter::expr_offset_in_bytes(n)));
 391 }
 392 


< prev index next >