< prev index next >

src/hotspot/cpu/x86/interp_masm_x86.cpp

Print this page
rev 58099 : 8239492: [x86] Turn MacroAssembler::verify_oop into macro recording file and line


  34 #include "prims/jvmtiExport.hpp"
  35 #include "prims/jvmtiThreadState.hpp"
  36 #include "runtime/basicLock.hpp"
  37 #include "runtime/biasedLocking.hpp"
  38 #include "runtime/frame.inline.hpp"
  39 #include "runtime/safepointMechanism.hpp"
  40 #include "runtime/sharedRuntime.hpp"
  41 #include "runtime/thread.inline.hpp"
  42 #include "utilities/powerOfTwo.hpp"
  43 
  44 // Implementation of InterpreterMacroAssembler
  45 
  46 void InterpreterMacroAssembler::jump_to_entry(address entry) {
  47   assert(entry, "Entry must have been generated by now");
  48   jump(RuntimeAddress(entry));
  49 }
  50 
  51 void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) {
  52   Label update, next, none;
  53 
  54   verify_oop(obj);
  55 
  56   testptr(obj, obj);
  57   jccb(Assembler::notZero, update);
  58   orptr(mdo_addr, TypeEntries::null_seen);
  59   jmpb(next);
  60 
  61   bind(update);
  62   load_klass(obj, obj);
  63 
  64   xorptr(obj, mdo_addr);
  65   testptr(obj, TypeEntries::type_klass_mask);
  66   jccb(Assembler::zero, next); // klass seen before, nothing to
  67                                // do. The unknown bit may have been
  68                                // set already but no need to check.
  69 
  70   testptr(obj, TypeEntries::type_unknown);
  71   jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
  72 
  73   cmpptr(mdo_addr, 0);
  74   jccb(Assembler::equal, none);


 332     // Call Interpreter::remove_activation_preserving_args_entry() to get the
 333     // address of the same-named entrypoint in the generated interpreter code.
 334     call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));
 335     jmp(rax);
 336     bind(L);
 337     NOT_LP64(get_thread(java_thread);)
 338   }
 339 }
 340 
 341 void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
 342   Register thread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
 343   NOT_LP64(get_thread(thread);)
 344   movptr(rcx, Address(thread, JavaThread::jvmti_thread_state_offset()));
 345   const Address tos_addr(rcx, JvmtiThreadState::earlyret_tos_offset());
 346   const Address oop_addr(rcx, JvmtiThreadState::earlyret_oop_offset());
 347   const Address val_addr(rcx, JvmtiThreadState::earlyret_value_offset());
 348 #ifdef _LP64
 349   switch (state) {
 350     case atos: movptr(rax, oop_addr);
 351                movptr(oop_addr, (int32_t)NULL_WORD);
 352                verify_oop(rax, state);              break;
 353     case ltos: movptr(rax, val_addr);                 break;
 354     case btos:                                   // fall through
 355     case ztos:                                   // fall through
 356     case ctos:                                   // fall through
 357     case stos:                                   // fall through
 358     case itos: movl(rax, val_addr);                 break;
 359     case ftos: load_float(val_addr);                break;
 360     case dtos: load_double(val_addr);               break;
 361     case vtos: /* nothing to do */                  break;
 362     default  : ShouldNotReachHere();
 363   }
 364   // Clean up tos value in the thread object
 365   movl(tos_addr,  (int) ilgl);
 366   movl(val_addr,  (int32_t) NULL_WORD);
 367 #else
 368   const Address val_addr1(rcx, JvmtiThreadState::earlyret_value_offset()
 369                              + in_ByteSize(wordSize));
 370   switch (state) {
 371     case atos: movptr(rax, oop_addr);
 372                movptr(oop_addr, NULL_WORD);
 373                verify_oop(rax, state);                break;
 374     case ltos:
 375                movl(rdx, val_addr1);               // fall through
 376     case btos:                                     // fall through
 377     case ztos:                                     // fall through
 378     case ctos:                                     // fall through
 379     case stos:                                     // fall through
 380     case itos: movl(rax, val_addr);                   break;
 381     case ftos: load_float(val_addr);                  break;
 382     case dtos: load_double(val_addr);                 break;
 383     case vtos: /* nothing to do */                    break;
 384     default  : ShouldNotReachHere();
 385   }
 386 #endif // _LP64
 387   // Clean up tos value in the thread object
 388   movl(tos_addr,  (int32_t) ilgl);
 389   movptr(val_addr,  NULL_WORD);
 390   NOT_LP64(movptr(val_addr1, NULL_WORD);)
 391 }
 392 
 393 


 639 void InterpreterMacroAssembler::push_l(Register r) {
 640   subptr(rsp, 2 * wordSize);
 641   movptr(Address(rsp, Interpreter::expr_offset_in_bytes(0)), r         );
 642   movptr(Address(rsp, Interpreter::expr_offset_in_bytes(1)), NULL_WORD );
 643 }
 644 
 645 void InterpreterMacroAssembler::pop(TosState state) {
 646   switch (state) {
 647   case atos: pop_ptr();                 break;
 648   case btos:
 649   case ztos:
 650   case ctos:
 651   case stos:
 652   case itos: pop_i();                   break;
 653   case ltos: pop_l();                   break;
 654   case ftos: pop_f(xmm0);               break;
 655   case dtos: pop_d(xmm0);               break;
 656   case vtos: /* nothing to do */        break;
 657   default:   ShouldNotReachHere();
 658   }
 659   verify_oop(rax, state);
 660 }
 661 
 662 void InterpreterMacroAssembler::push(TosState state) {
 663   verify_oop(rax, state);
 664   switch (state) {
 665   case atos: push_ptr();                break;
 666   case btos:
 667   case ztos:
 668   case ctos:
 669   case stos:
 670   case itos: push_i();                  break;
 671   case ltos: push_l();                  break;
 672   case ftos: push_f(xmm0);              break;
 673   case dtos: push_d(xmm0);              break;
 674   case vtos: /* nothing to do */        break;
 675   default  : ShouldNotReachHere();
 676   }
 677 }
 678 #else
 679 void InterpreterMacroAssembler::pop_i(Register r) {
 680   pop(r);
 681 }
 682 
 683 void InterpreterMacroAssembler::pop_l(Register lo, Register hi) {


 705     case stos:                                               // fall through
 706     case itos: pop_i(rax);                                   break;
 707     case ltos: pop_l(rax, rdx);                              break;
 708     case ftos:
 709       if (UseSSE >= 1) {
 710         pop_f(xmm0);
 711       } else {
 712         pop_f();
 713       }
 714       break;
 715     case dtos:
 716       if (UseSSE >= 2) {
 717         pop_d(xmm0);
 718       } else {
 719         pop_d();
 720       }
 721       break;
 722     case vtos: /* nothing to do */                           break;
 723     default  : ShouldNotReachHere();
 724   }
 725   verify_oop(rax, state);
 726 }
 727 
 728 
 729 void InterpreterMacroAssembler::push_l(Register lo, Register hi) {
 730   push(hi);
 731   push(lo);
 732 }
 733 
 734 void InterpreterMacroAssembler::push_f() {
 735   // Do not schedule for no AGI! Never write beyond rsp!
 736   subptr(rsp, 1 * wordSize);
 737   fstp_s(Address(rsp, 0));
 738 }
 739 
 740 void InterpreterMacroAssembler::push_d() {
 741   // Do not schedule for no AGI! Never write beyond rsp!
 742   subptr(rsp, 2 * wordSize);
 743   fstp_d(Address(rsp, 0));
 744 }
 745 
 746 
 747 void InterpreterMacroAssembler::push(TosState state) {
 748   verify_oop(rax, state);
 749   switch (state) {
 750     case atos: push_ptr(rax); break;
 751     case btos:                                               // fall through
 752     case ztos:                                               // fall through
 753     case ctos:                                               // fall through
 754     case stos:                                               // fall through
 755     case itos: push_i(rax);                                    break;
 756     case ltos: push_l(rax, rdx);                               break;
 757     case ftos:
 758       if (UseSSE >= 1) {
 759         push_f(xmm0);
 760       } else {
 761         push_f();
 762       }
 763       break;
 764     case dtos:
 765       if (UseSSE >= 2) {
 766         push_d(xmm0);
 767       } else {
 768         push_d();


 827 }
 828 
 829 void InterpreterMacroAssembler::dispatch_base(TosState state,
 830                                               address* table,
 831                                               bool verifyoop,
 832                                               bool generate_poll) {
 833   verify_FPU(1, state);
 834   if (VerifyActivationFrameSize) {
 835     Label L;
 836     mov(rcx, rbp);
 837     subptr(rcx, rsp);
 838     int32_t min_frame_size =
 839       (frame::link_offset - frame::interpreter_frame_initial_sp_offset) *
 840       wordSize;
 841     cmpptr(rcx, (int32_t)min_frame_size);
 842     jcc(Assembler::greaterEqual, L);
 843     stop("broken stack frame");
 844     bind(L);
 845   }
 846   if (verifyoop) {
 847     verify_oop(rax, state);
 848   }
 849 
 850   address* const safepoint_table = Interpreter::safept_table(state);
 851 #ifdef _LP64
 852   Label no_safepoint, dispatch;
 853   if (SafepointMechanism::uses_thread_local_poll() && table != safepoint_table && generate_poll) {
 854     NOT_PRODUCT(block_comment("Thread-local Safepoint poll"));
 855     testb(Address(r15_thread, Thread::polling_page_offset()), SafepointMechanism::poll_bit());
 856 
 857     jccb(Assembler::zero, no_safepoint);
 858     lea(rscratch1, ExternalAddress((address)safepoint_table));
 859     jmpb(dispatch);
 860   }
 861 
 862   bind(no_safepoint);
 863   lea(rscratch1, ExternalAddress((address)table));
 864   bind(dispatch);
 865   jmp(Address(rscratch1, rbx, Address::times_8));
 866 
 867 #else


1942     imulptr(index, reg2); // XXX l ?
1943     addptr(index, in_bytes(MultiBranchData::case_array_offset())); // XXX l ?
1944 
1945     // Update the case count
1946     increment_mdp_data_at(mdp,
1947                           index,
1948                           in_bytes(MultiBranchData::relative_count_offset()));
1949 
1950     // The method data pointer needs to be updated.
1951     update_mdp_by_offset(mdp,
1952                          index,
1953                          in_bytes(MultiBranchData::
1954                                   relative_displacement_offset()));
1955 
1956     bind(profile_continue);
1957   }
1958 }
1959 
1960 
1961 
1962 void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) {
1963   if (state == atos) {
1964     MacroAssembler::verify_oop(reg);
1965   }
1966 }
1967 
1968 void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
1969 #ifndef _LP64
1970   if ((state == ftos && UseSSE < 1) ||
1971       (state == dtos && UseSSE < 2)) {
1972     MacroAssembler::verify_FPU(stack_depth);
1973   }
1974 #endif
1975 }
1976 
1977 // Jump if ((*counter_addr += increment) & mask) satisfies the condition.
1978 void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr,
1979                                                         int increment, Address mask,
1980                                                         Register scratch, bool preloaded,
1981                                                         Condition cond, Label* where) {
1982   if (!preloaded) {
1983     movl(scratch, counter_addr);
1984   }




  34 #include "prims/jvmtiExport.hpp"
  35 #include "prims/jvmtiThreadState.hpp"
  36 #include "runtime/basicLock.hpp"
  37 #include "runtime/biasedLocking.hpp"
  38 #include "runtime/frame.inline.hpp"
  39 #include "runtime/safepointMechanism.hpp"
  40 #include "runtime/sharedRuntime.hpp"
  41 #include "runtime/thread.inline.hpp"
  42 #include "utilities/powerOfTwo.hpp"
  43 
  44 // Implementation of InterpreterMacroAssembler
  45 
  46 void InterpreterMacroAssembler::jump_to_entry(address entry) {
  47   assert(entry, "Entry must have been generated by now");
  48   jump(RuntimeAddress(entry));
  49 }
  50 
  51 void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) {
  52   Label update, next, none;
  53 
  54   interp_verify_oop(obj, atos, __FILE__, __LINE__);
  55 
  56   testptr(obj, obj);
  57   jccb(Assembler::notZero, update);
  58   orptr(mdo_addr, TypeEntries::null_seen);
  59   jmpb(next);
  60 
  61   bind(update);
  62   load_klass(obj, obj);
  63 
  64   xorptr(obj, mdo_addr);
  65   testptr(obj, TypeEntries::type_klass_mask);
  66   jccb(Assembler::zero, next); // klass seen before, nothing to
  67                                // do. The unknown bit may have been
  68                                // set already but no need to check.
  69 
  70   testptr(obj, TypeEntries::type_unknown);
  71   jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
  72 
  73   cmpptr(mdo_addr, 0);
  74   jccb(Assembler::equal, none);


 332     // Call Interpreter::remove_activation_preserving_args_entry() to get the
 333     // address of the same-named entrypoint in the generated interpreter code.
 334     call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry));
 335     jmp(rax);
 336     bind(L);
 337     NOT_LP64(get_thread(java_thread);)
 338   }
 339 }
 340 
 341 void InterpreterMacroAssembler::load_earlyret_value(TosState state) {
 342   Register thread = LP64_ONLY(r15_thread) NOT_LP64(rcx);
 343   NOT_LP64(get_thread(thread);)
 344   movptr(rcx, Address(thread, JavaThread::jvmti_thread_state_offset()));
 345   const Address tos_addr(rcx, JvmtiThreadState::earlyret_tos_offset());
 346   const Address oop_addr(rcx, JvmtiThreadState::earlyret_oop_offset());
 347   const Address val_addr(rcx, JvmtiThreadState::earlyret_value_offset());
 348 #ifdef _LP64
 349   switch (state) {
 350     case atos: movptr(rax, oop_addr);
 351                movptr(oop_addr, (int32_t)NULL_WORD);
 352                interp_verify_oop(rax, state, __FILE__, __LINE__); break;
 353     case ltos: movptr(rax, val_addr);                 break;
 354     case btos:                                   // fall through
 355     case ztos:                                   // fall through
 356     case ctos:                                   // fall through
 357     case stos:                                   // fall through
 358     case itos: movl(rax, val_addr);                 break;
 359     case ftos: load_float(val_addr);                break;
 360     case dtos: load_double(val_addr);               break;
 361     case vtos: /* nothing to do */                  break;
 362     default  : ShouldNotReachHere();
 363   }
 364   // Clean up tos value in the thread object
 365   movl(tos_addr,  (int) ilgl);
 366   movl(val_addr,  (int32_t) NULL_WORD);
 367 #else
 368   const Address val_addr1(rcx, JvmtiThreadState::earlyret_value_offset()
 369                              + in_ByteSize(wordSize));
 370   switch (state) {
 371     case atos: movptr(rax, oop_addr);
 372                movptr(oop_addr, NULL_WORD);
 373                interp_verify_oop(rax, state, __FILE__, __LINE__); break;
 374     case ltos:
 375                movl(rdx, val_addr1);               // fall through
 376     case btos:                                     // fall through
 377     case ztos:                                     // fall through
 378     case ctos:                                     // fall through
 379     case stos:                                     // fall through
 380     case itos: movl(rax, val_addr);                   break;
 381     case ftos: load_float(val_addr);                  break;
 382     case dtos: load_double(val_addr);                 break;
 383     case vtos: /* nothing to do */                    break;
 384     default  : ShouldNotReachHere();
 385   }
 386 #endif // _LP64
 387   // Clean up tos value in the thread object
 388   movl(tos_addr,  (int32_t) ilgl);
 389   movptr(val_addr,  NULL_WORD);
 390   NOT_LP64(movptr(val_addr1, NULL_WORD);)
 391 }
 392 
 393 


 639 void InterpreterMacroAssembler::push_l(Register r) {
 640   subptr(rsp, 2 * wordSize);
 641   movptr(Address(rsp, Interpreter::expr_offset_in_bytes(0)), r         );
 642   movptr(Address(rsp, Interpreter::expr_offset_in_bytes(1)), NULL_WORD );
 643 }
 644 
 645 void InterpreterMacroAssembler::pop(TosState state) {
 646   switch (state) {
 647   case atos: pop_ptr();                 break;
 648   case btos:
 649   case ztos:
 650   case ctos:
 651   case stos:
 652   case itos: pop_i();                   break;
 653   case ltos: pop_l();                   break;
 654   case ftos: pop_f(xmm0);               break;
 655   case dtos: pop_d(xmm0);               break;
 656   case vtos: /* nothing to do */        break;
 657   default:   ShouldNotReachHere();
 658   }
 659   interp_verify_oop(rax, state, __FILE__, __LINE__);
 660 }
 661 
 662 void InterpreterMacroAssembler::push(TosState state) {
 663   interp_verify_oop(rax, state, __FILE__, __LINE__);
 664   switch (state) {
 665   case atos: push_ptr();                break;
 666   case btos:
 667   case ztos:
 668   case ctos:
 669   case stos:
 670   case itos: push_i();                  break;
 671   case ltos: push_l();                  break;
 672   case ftos: push_f(xmm0);              break;
 673   case dtos: push_d(xmm0);              break;
 674   case vtos: /* nothing to do */        break;
 675   default  : ShouldNotReachHere();
 676   }
 677 }
 678 #else
 679 void InterpreterMacroAssembler::pop_i(Register r) {
 680   pop(r);
 681 }
 682 
 683 void InterpreterMacroAssembler::pop_l(Register lo, Register hi) {


 705     case stos:                                               // fall through
 706     case itos: pop_i(rax);                                   break;
 707     case ltos: pop_l(rax, rdx);                              break;
 708     case ftos:
 709       if (UseSSE >= 1) {
 710         pop_f(xmm0);
 711       } else {
 712         pop_f();
 713       }
 714       break;
 715     case dtos:
 716       if (UseSSE >= 2) {
 717         pop_d(xmm0);
 718       } else {
 719         pop_d();
 720       }
 721       break;
 722     case vtos: /* nothing to do */                           break;
 723     default  : ShouldNotReachHere();
 724   }
 725   interp_verify_oop(rax, state, __FILE__, __LINE__);
 726 }
 727 
 728 
 729 void InterpreterMacroAssembler::push_l(Register lo, Register hi) {
 730   push(hi);
 731   push(lo);
 732 }
 733 
 734 void InterpreterMacroAssembler::push_f() {
 735   // Do not schedule for no AGI! Never write beyond rsp!
 736   subptr(rsp, 1 * wordSize);
 737   fstp_s(Address(rsp, 0));
 738 }
 739 
 740 void InterpreterMacroAssembler::push_d() {
 741   // Do not schedule for no AGI! Never write beyond rsp!
 742   subptr(rsp, 2 * wordSize);
 743   fstp_d(Address(rsp, 0));
 744 }
 745 
 746 
 747 void InterpreterMacroAssembler::push(TosState state) {
 748   interp_verify_oop(rax, state, __FILE__, __LINE__);
 749   switch (state) {
 750     case atos: push_ptr(rax); break;
 751     case btos:                                               // fall through
 752     case ztos:                                               // fall through
 753     case ctos:                                               // fall through
 754     case stos:                                               // fall through
 755     case itos: push_i(rax);                                    break;
 756     case ltos: push_l(rax, rdx);                               break;
 757     case ftos:
 758       if (UseSSE >= 1) {
 759         push_f(xmm0);
 760       } else {
 761         push_f();
 762       }
 763       break;
 764     case dtos:
 765       if (UseSSE >= 2) {
 766         push_d(xmm0);
 767       } else {
 768         push_d();


 827 }
 828 
 829 void InterpreterMacroAssembler::dispatch_base(TosState state,
 830                                               address* table,
 831                                               bool verifyoop,
 832                                               bool generate_poll) {
 833   verify_FPU(1, state);
 834   if (VerifyActivationFrameSize) {
 835     Label L;
 836     mov(rcx, rbp);
 837     subptr(rcx, rsp);
 838     int32_t min_frame_size =
 839       (frame::link_offset - frame::interpreter_frame_initial_sp_offset) *
 840       wordSize;
 841     cmpptr(rcx, (int32_t)min_frame_size);
 842     jcc(Assembler::greaterEqual, L);
 843     stop("broken stack frame");
 844     bind(L);
 845   }
 846   if (verifyoop) {
 847     interp_verify_oop(rax, state, __FILE__, __LINE__);
 848   }
 849 
 850   address* const safepoint_table = Interpreter::safept_table(state);
 851 #ifdef _LP64
 852   Label no_safepoint, dispatch;
 853   if (SafepointMechanism::uses_thread_local_poll() && table != safepoint_table && generate_poll) {
 854     NOT_PRODUCT(block_comment("Thread-local Safepoint poll"));
 855     testb(Address(r15_thread, Thread::polling_page_offset()), SafepointMechanism::poll_bit());
 856 
 857     jccb(Assembler::zero, no_safepoint);
 858     lea(rscratch1, ExternalAddress((address)safepoint_table));
 859     jmpb(dispatch);
 860   }
 861 
 862   bind(no_safepoint);
 863   lea(rscratch1, ExternalAddress((address)table));
 864   bind(dispatch);
 865   jmp(Address(rscratch1, rbx, Address::times_8));
 866 
 867 #else


1942     imulptr(index, reg2); // XXX l ?
1943     addptr(index, in_bytes(MultiBranchData::case_array_offset())); // XXX l ?
1944 
1945     // Update the case count
1946     increment_mdp_data_at(mdp,
1947                           index,
1948                           in_bytes(MultiBranchData::relative_count_offset()));
1949 
1950     // The method data pointer needs to be updated.
1951     update_mdp_by_offset(mdp,
1952                          index,
1953                          in_bytes(MultiBranchData::
1954                                   relative_displacement_offset()));
1955 
1956     bind(profile_continue);
1957   }
1958 }
1959 
1960 
1961 
1962 void InterpreterMacroAssembler::interp_verify_oop(Register reg, TosState state, const char* file, int line) {
1963   if (state == atos) {
1964     MacroAssembler::_verify_oop(reg, "broken oop", file, line);
1965   }
1966 }
1967 
1968 void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) {
1969 #ifndef _LP64
1970   if ((state == ftos && UseSSE < 1) ||
1971       (state == dtos && UseSSE < 2)) {
1972     MacroAssembler::verify_FPU(stack_depth);
1973   }
1974 #endif
1975 }
1976 
1977 // Jump if ((*counter_addr += increment) & mask) satisfies the condition.
1978 void InterpreterMacroAssembler::increment_mask_and_jump(Address counter_addr,
1979                                                         int increment, Address mask,
1980                                                         Register scratch, bool preloaded,
1981                                                         Condition cond, Label* where) {
1982   if (!preloaded) {
1983     movl(scratch, counter_addr);
1984   }


< prev index next >