< prev index next >

src/hotspot/share/runtime/continuation.cpp

Print this page

149   if (!is_vthread_safe_to_preempt(current, current->vthread())) {
150     return freeze_pinned_native;
151   }
152 
153   JVMTI_ONLY(JvmtiUnmountBeginMark jubm(current);)
154   JVMTI_ONLY(if (jubm.failed()) return freeze_pinned_native;)
155   freeze_result res = CAST_TO_FN_PTR(FreezeContFnT, freeze_preempt_entry())(current, current->last_Java_sp());
156   log_trace(continuations, preempt)("try_preempt: %d", res);
157   JVMTI_ONLY(jubm.set_result(res);)
158 
159   if (current->has_pending_exception()) {
160     assert(res == freeze_exception, "expecting an exception result from freeze");
161     // We don't want to throw exceptions, especially when returning
162     // from monitorenter since the compiler does not expect one. We
163     // just ignore the exception and pin the vthread to the carrier.
164     current->clear_pending_exception();
165   }
166   return res;
167 }
168 
169 #ifndef PRODUCT
170 static jlong java_tid(JavaThread* thread) {
171   return java_lang_Thread::thread_id(thread->threadObj());
172 }
173 #endif
174 
175 ContinuationEntry* Continuation::get_continuation_entry_for_continuation(JavaThread* thread, oop continuation) {
176   if (thread == nullptr || continuation == nullptr) {
177     return nullptr;
178   }
179 
180   for (ContinuationEntry* entry = thread->last_continuation(); entry != nullptr; entry = entry->parent()) {
181     if (continuation == entry->cont_oop(thread)) {
182       return entry;
183     }
184   }
185   return nullptr;
186 }
187 
188 static bool is_on_stack(JavaThread* thread, const ContinuationEntry* entry) {
189   if (entry == nullptr) {
190     return false;
191   }
192 
193   assert(thread->is_in_full_stack((address)entry), "");
194   return true;

384   ContinuationEntry* ce = current->last_continuation();
385   if (ce == nullptr) {
386     return true; // no continuation mounted
387   }
388   return ce->pin();
389 }
390 
391 bool Continuation::unpin(JavaThread* current) {
392   ContinuationEntry* ce = current->last_continuation();
393   if (ce == nullptr) {
394     return true; // no continuation mounted
395   }
396   return ce->unpin();
397 }
398 
399 frame Continuation::continuation_bottom_sender(JavaThread* thread, const frame& callee, intptr_t* sender_sp) {
400   assert (thread != nullptr, "");
401   ContinuationEntry* ce = get_continuation_entry_for_sp(thread, callee.sp());
402   assert(ce != nullptr, "callee.sp(): " INTPTR_FORMAT, p2i(callee.sp()));
403 
404   log_develop_debug(continuations)("continuation_bottom_sender: [" JLONG_FORMAT "] [%d] callee: " INTPTR_FORMAT
405     " sender_sp: " INTPTR_FORMAT,
406     java_tid(thread), thread->osthread()->thread_id(), p2i(callee.sp()), p2i(sender_sp));
407 
408   frame entry = ce->to_frame();
409   if (callee.is_interpreted_frame()) {
410     entry.set_sp(sender_sp); // sp != unextended_sp
411   }
412   return entry;
413 }
414 
415 address Continuation::get_top_return_pc_post_barrier(JavaThread* thread, address pc) {
416   ContinuationEntry* ce;
417   if (thread != nullptr && is_return_barrier_entry(pc) && (ce = thread->last_continuation()) != nullptr) {
418     return ce->entry_pc();
419   }
420   return pc;
421 }
422 
423 void Continuation::set_cont_fastpath_thread_state(JavaThread* thread) {
424   assert(thread != nullptr, "");
425   bool fast = !thread->is_interp_only_mode();
426   thread->set_cont_fastpath_thread_state(fast);

149   if (!is_vthread_safe_to_preempt(current, current->vthread())) {
150     return freeze_pinned_native;
151   }
152 
153   JVMTI_ONLY(JvmtiUnmountBeginMark jubm(current);)
154   JVMTI_ONLY(if (jubm.failed()) return freeze_pinned_native;)
155   freeze_result res = CAST_TO_FN_PTR(FreezeContFnT, freeze_preempt_entry())(current, current->last_Java_sp());
156   log_trace(continuations, preempt)("try_preempt: %d", res);
157   JVMTI_ONLY(jubm.set_result(res);)
158 
159   if (current->has_pending_exception()) {
160     assert(res == freeze_exception, "expecting an exception result from freeze");
161     // We don't want to throw exceptions, especially when returning
162     // from monitorenter since the compiler does not expect one. We
163     // just ignore the exception and pin the vthread to the carrier.
164     current->clear_pending_exception();
165   }
166   return res;
167 }
168 






169 ContinuationEntry* Continuation::get_continuation_entry_for_continuation(JavaThread* thread, oop continuation) {
170   if (thread == nullptr || continuation == nullptr) {
171     return nullptr;
172   }
173 
174   for (ContinuationEntry* entry = thread->last_continuation(); entry != nullptr; entry = entry->parent()) {
175     if (continuation == entry->cont_oop(thread)) {
176       return entry;
177     }
178   }
179   return nullptr;
180 }
181 
182 static bool is_on_stack(JavaThread* thread, const ContinuationEntry* entry) {
183   if (entry == nullptr) {
184     return false;
185   }
186 
187   assert(thread->is_in_full_stack((address)entry), "");
188   return true;

378   ContinuationEntry* ce = current->last_continuation();
379   if (ce == nullptr) {
380     return true; // no continuation mounted
381   }
382   return ce->pin();
383 }
384 
385 bool Continuation::unpin(JavaThread* current) {
386   ContinuationEntry* ce = current->last_continuation();
387   if (ce == nullptr) {
388     return true; // no continuation mounted
389   }
390   return ce->unpin();
391 }
392 
393 frame Continuation::continuation_bottom_sender(JavaThread* thread, const frame& callee, intptr_t* sender_sp) {
394   assert (thread != nullptr, "");
395   ContinuationEntry* ce = get_continuation_entry_for_sp(thread, callee.sp());
396   assert(ce != nullptr, "callee.sp(): " INTPTR_FORMAT, p2i(callee.sp()));
397 
398   log_develop_debug(continuations)("continuation_bottom_sender: [%d] callee: " INTPTR_FORMAT " sender_sp: " INTPTR_FORMAT,
399       thread->osthread()->thread_id(), p2i(callee.sp()), p2i(sender_sp));

400 
401   frame entry = ce->to_frame();
402   if (callee.is_interpreted_frame()) {
403     entry.set_sp(sender_sp); // sp != unextended_sp
404   }
405   return entry;
406 }
407 
408 address Continuation::get_top_return_pc_post_barrier(JavaThread* thread, address pc) {
409   ContinuationEntry* ce;
410   if (thread != nullptr && is_return_barrier_entry(pc) && (ce = thread->last_continuation()) != nullptr) {
411     return ce->entry_pc();
412   }
413   return pc;
414 }
415 
416 void Continuation::set_cont_fastpath_thread_state(JavaThread* thread) {
417   assert(thread != nullptr, "");
418   bool fast = !thread->is_interp_only_mode();
419   thread->set_cont_fastpath_thread_state(fast);
< prev index next >