< prev index next >

src/hotspot/cpu/x86/interp_masm_x86.cpp

Print this page
rev 47591 : Add Thread Local handshakes and thread local polling
rev 47596 : imported patch Interpreter-Poll-7

@@ -33,10 +33,11 @@
 #include "oops/method.hpp"
 #include "prims/jvmtiExport.hpp"
 #include "prims/jvmtiThreadState.hpp"
 #include "runtime/basicLock.hpp"
 #include "runtime/biasedLocking.hpp"
+#include "runtime/safepointMechanism.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.inline.hpp"
 
 // Implementation of InterpreterMacroAssembler
 

@@ -807,11 +808,12 @@
   dispatch_next(state, step);
 }
 
 void InterpreterMacroAssembler::dispatch_base(TosState state,
                                               address* table,
-                                              bool verifyoop) {
+                                              bool verifyoop,
+                                              bool generate_poll) {
   verify_FPU(1, state);
   if (VerifyActivationFrameSize) {
     Label L;
     mov(rcx, rbp);
     subptr(rcx, rsp);

@@ -825,22 +827,38 @@
   }
   if (verifyoop) {
     verify_oop(rax, state);
   }
 #ifdef _LP64
+
+  Label no_safepoint, dispatch;
+  address* const safepoint_table = Interpreter::safept_table(state);
+  if (SafepointMechanism::uses_thread_local_poll() && table != safepoint_table && generate_poll) {
+    NOT_PRODUCT(block_comment("Thread-local Safepoint poll"));
+
+    testb(Address(r15_thread, Thread::polling_page_offset()), SafepointMechanism::poll_bit());
+
+    jccb(Assembler::zero, no_safepoint);
+    lea(rscratch1, ExternalAddress((address)safepoint_table));
+    jmpb(dispatch);
+  }
+
+  bind(no_safepoint);
   lea(rscratch1, ExternalAddress((address)table));
+  bind(dispatch);
   jmp(Address(rscratch1, rbx, Address::times_8));
+
 #else
   Address index(noreg, rbx, Address::times_ptr);
   ExternalAddress tbl((address)table);
   ArrayAddress dispatch(tbl, index);
   jump(dispatch);
 #endif // _LP64
 }
 
-void InterpreterMacroAssembler::dispatch_only(TosState state) {
-  dispatch_base(state, Interpreter::dispatch_table(state));
+void InterpreterMacroAssembler::dispatch_only(TosState state, bool generate_poll) {
+  dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll);
 }
 
 void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {
   dispatch_base(state, Interpreter::normal_table(state));
 }

@@ -848,16 +866,16 @@
 void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) {
   dispatch_base(state, Interpreter::normal_table(state), false);
 }
 
 
-void InterpreterMacroAssembler::dispatch_next(TosState state, int step) {
+void InterpreterMacroAssembler::dispatch_next(TosState state, int step, bool generate_poll) {
   // load next bytecode (load before advancing _bcp_register to prevent AGI)
   load_unsigned_byte(rbx, Address(_bcp_register, step));
   // advance _bcp_register
   increment(_bcp_register, step);
-  dispatch_base(state, Interpreter::dispatch_table(state));
+  dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll);
 }
 
 void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
   // load current bytecode
   load_unsigned_byte(rbx, Address(_bcp_register, 0));
< prev index next >