Skip to content

Commit d265ed9

Browse files
committedDec 31, 2015
Defer to Immix marker at checkpoints.
1 parent 899dca7 commit d265ed9

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed
 

‎vm/gc/immix_marker.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ namespace rubinius {
8282
timer::StopWatch<timer::milliseconds> timer(
8383
state->vm()->metrics().gc.immix_concurrent_ms);
8484

85-
// TODO: Set status of this thread so STW won't consider it a
86-
// possible deadlock when the thread doesn't yield soon enough.
85+
state->shared().thread_nexus()->blocking(state->vm());
86+
8787
while(immix_->process_mark_stack(immix_->memory()->collect_mature_now)) {
8888
if(state->shared().thread_nexus()->stop_p()) {
8989
state->shared().thread_nexus()->yielding(state->vm());
9090
}
91+
state->shared().thread_nexus()->blocking(state->vm());
9192
}
9293
}
9394

95+
state->vm()->become_managed();
96+
9497
if(thread_exit_) break;
9598

9699
{

‎vm/thread_nexus.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <time.h>
1414

1515
namespace rubinius {
16+
bool ThreadNexus::blocking_p(VM* vm) {
17+
return (vm->thread_phase() & cBlocking) == cBlocking;
18+
}
19+
1620
bool ThreadNexus::yielding_p(VM* vm) {
1721
return (vm->thread_phase() & cYielding) == cYielding;
1822
}
@@ -97,6 +101,8 @@ namespace rubinius {
97101
return "cWaiting";
98102
case ThreadNexus::cYielding:
99103
return "cYielding";
104+
case ThreadNexus::cBlocking:
105+
return "cBlocking";
100106
}
101107
}
102108

@@ -117,6 +123,10 @@ namespace rubinius {
117123
rubinius::abort();
118124
}
119125

126+
void ThreadNexus::blocking(VM* vm) {
127+
vm->set_thread_phase(cBlocking);
128+
}
129+
120130
#define RBX_MAX_STOP_ITERATIONS 10000
121131

122132
bool ThreadNexus::locking(VM* vm) {
@@ -137,6 +147,8 @@ namespace rubinius {
137147
if(yielding_p(other_vm)) {
138148
yielding = true;
139149
break;
150+
} else if(blocking_p(other_vm)) {
151+
return false;
140152
}
141153

142154
static int delay[] = { 1, 21, 270, 482, 268, 169, 224, 481,

‎vm/thread_nexus.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace rubinius {
3232
enum Phase {
3333
cStop = 0x01,
3434
cManaged = 0x02,
35+
cBlocking = 0x04,
3536
cUnmanaged = 0x81,
3637
cWaiting = 0x82,
3738
cYielding = 0x80
@@ -70,6 +71,8 @@ namespace rubinius {
7071
lock_.unlock();
7172
}
7273

74+
bool blocking_p(VM* vm);
75+
void blocking(VM* vm);
7376
bool yielding_p(VM* vm);
7477
void yielding(VM* vm);
7578
bool locking(VM* vm);

‎vm/util/immix.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ namespace immix {
10971097
desc.walk_pointers(addr, mark);
10981098
}
10991099

1100-
return true;
1100+
return !exit;
11011101
}
11021102

11031103
/**

0 commit comments

Comments
 (0)
Please sign in to comment.