compiler opt defeating

This commit is contained in:
David Rose 2007-06-21 19:59:55 +00:00
parent 8504825116
commit c811ae5865
3 changed files with 23 additions and 9 deletions

View File

@ -132,8 +132,8 @@ do_lock() {
// Go to sleep on the condition variable until it's unlocked.
if (thread_cat.is_spam()) {
thread_cat.spam()
if (thread_cat.is_debug()) {
thread_cat.debug()
<< *this_thread << " blocking on " << *this << " (held by "
<< *_locking_thread << ")\n";
}
@ -141,8 +141,8 @@ do_lock() {
_cvar_impl.wait();
}
if (thread_cat.is_spam()) {
thread_cat.spam()
if (thread_cat.is_debug()) {
thread_cat.debug()
<< *this_thread << " awake on " << *this << "\n";
}

View File

@ -46,7 +46,13 @@ setup_context_2(ThreadSimpleImpl *self) {
// Here we are executing within the thread.
v_self->setup_context_3();
// We shouldn't get here.
abort();
// Even though this line should never be executed, setting it here
// seems to help the compiler figure out not to optimize away
// v_self.
*v_self = 0;
return v_self;
}

View File

@ -182,9 +182,8 @@ next_context() {
// Mark the current thread's resume point.
#ifdef HAVE_PYTHON
// Query the current Python thread state.
// Save the current Python thread state.
_current_thread->_python_state = PyThreadState_Swap(NULL);
PyThreadState_Swap(_current_thread->_python_state);
#endif // HAVE_PYTHON
#ifdef HAVE_UCONTEXT_H
@ -280,9 +279,18 @@ next_context() {
_current_thread->_start_time = now;
// All right, the thread is ready to roll. Begin.
if (thread_cat.is_spam()) {
thread_cat.spam()
<< "Switching to " << *_current_thread->_parent_obj << "\n";
if (thread_cat.is_debug()) {
size_t blocked_count = 0;
Blocked::const_iterator bi;
for (bi = _blocked.begin(); bi != _blocked.end(); ++bi) {
const FifoThreads &threads = (*bi).second;
blocked_count += threads.size();
}
thread_cat.debug()
<< "Switching to " << *_current_thread->_parent_obj
<< " (" << _ready.size() << " other threads ready, " << blocked_count
<< " blocked, " << _sleeping.size() << " sleeping)\n";
}
#ifdef HAVE_UCONTEXT_H