< prev index next >

src/hotspot/share/runtime/continuation.cpp

Print this page

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

370   ContinuationEntry* ce = current->last_continuation();
371   if (ce == nullptr) {
372     return true; // no continuation mounted
373   }
374   return ce->pin();
375 }
376 
377 bool Continuation::unpin(JavaThread* current) {
378   ContinuationEntry* ce = current->last_continuation();
379   if (ce == nullptr) {
380     return true; // no continuation mounted
381   }
382   return ce->unpin();
383 }
384 
385 frame Continuation::continuation_bottom_sender(JavaThread* thread, const frame& callee, intptr_t* sender_sp) {
386   assert (thread != nullptr, "");
387   ContinuationEntry* ce = get_continuation_entry_for_sp(thread, callee.sp());
388   assert(ce != nullptr, "callee.sp(): " INTPTR_FORMAT, p2i(callee.sp()));
389 
390   log_develop_debug(continuations)("continuation_bottom_sender: [" JLONG_FORMAT "] [%d] callee: " INTPTR_FORMAT
391     " sender_sp: " INTPTR_FORMAT,
392     java_tid(thread), thread->osthread()->thread_id(), p2i(callee.sp()), p2i(sender_sp));
393 
394   frame entry = ce->to_frame();
395   if (callee.is_interpreted_frame()) {
396     entry.set_sp(sender_sp); // sp != unextended_sp
397   }
398   return entry;
399 }
400 
401 address Continuation::get_top_return_pc_post_barrier(JavaThread* thread, address pc) {
402   ContinuationEntry* ce;
403   if (thread != nullptr && is_return_barrier_entry(pc) && (ce = thread->last_continuation()) != nullptr) {
404     return ce->entry_pc();
405   }
406   return pc;
407 }
408 
409 void Continuation::set_cont_fastpath_thread_state(JavaThread* thread) {
410   assert(thread != nullptr, "");
411   bool fast = !thread->is_interp_only_mode();
412   thread->set_cont_fastpath_thread_state(fast);

135   if (!is_vthread_safe_to_preempt(current, current->vthread())) {
136     return freeze_pinned_native;
137   }
138 
139   UnmountBeginMark ubm(current);
140   if (ubm.failed()) return freeze_pinned_native;
141   freeze_result res = CAST_TO_FN_PTR(FreezeContFnT, freeze_preempt_entry())(current, current->last_Java_sp());
142   log_trace(continuations, preempt)("try_preempt: %d", res);
143   ubm.set_result(res);
144 
145   if (current->has_pending_exception()) {
146     assert(res == freeze_exception, "expecting an exception result from freeze");
147     // We don't want to throw exceptions, especially when returning
148     // from monitorenter since the compiler does not expect one. We
149     // just ignore the exception and pin the vthread to the carrier.
150     current->clear_pending_exception();
151   }
152   return res;
153 }
154 






155 ContinuationEntry* Continuation::get_continuation_entry_for_continuation(JavaThread* thread, oop continuation) {
156   if (thread == nullptr || continuation == nullptr) {
157     return nullptr;
158   }
159 
160   for (ContinuationEntry* entry = thread->last_continuation(); entry != nullptr; entry = entry->parent()) {
161     if (continuation == entry->cont_oop(thread)) {
162       return entry;
163     }
164   }
165   return nullptr;
166 }
167 
168 static bool is_on_stack(JavaThread* thread, const ContinuationEntry* entry) {
169   if (entry == nullptr) {
170     return false;
171   }
172 
173   assert(thread->is_in_full_stack((address)entry), "");
174   return true;

364   ContinuationEntry* ce = current->last_continuation();
365   if (ce == nullptr) {
366     return true; // no continuation mounted
367   }
368   return ce->pin();
369 }
370 
371 bool Continuation::unpin(JavaThread* current) {
372   ContinuationEntry* ce = current->last_continuation();
373   if (ce == nullptr) {
374     return true; // no continuation mounted
375   }
376   return ce->unpin();
377 }
378 
379 frame Continuation::continuation_bottom_sender(JavaThread* thread, const frame& callee, intptr_t* sender_sp) {
380   assert (thread != nullptr, "");
381   ContinuationEntry* ce = get_continuation_entry_for_sp(thread, callee.sp());
382   assert(ce != nullptr, "callee.sp(): " INTPTR_FORMAT, p2i(callee.sp()));
383 
384   log_develop_debug(continuations)("continuation_bottom_sender: [%d] callee: " INTPTR_FORMAT " sender_sp: " INTPTR_FORMAT,
385       thread->osthread()->thread_id(), p2i(callee.sp()), p2i(sender_sp));

386 
387   frame entry = ce->to_frame();
388   if (callee.is_interpreted_frame()) {
389     entry.set_sp(sender_sp); // sp != unextended_sp
390   }
391   return entry;
392 }
393 
394 address Continuation::get_top_return_pc_post_barrier(JavaThread* thread, address pc) {
395   ContinuationEntry* ce;
396   if (thread != nullptr && is_return_barrier_entry(pc) && (ce = thread->last_continuation()) != nullptr) {
397     return ce->entry_pc();
398   }
399   return pc;
400 }
401 
402 void Continuation::set_cont_fastpath_thread_state(JavaThread* thread) {
403   assert(thread != nullptr, "");
404   bool fast = !thread->is_interp_only_mode();
405   thread->set_cont_fastpath_thread_state(fast);
< prev index next >