mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 13:49:16 +02:00
WIP
This commit is contained in:
parent
e7e8cbd744
commit
eaac66ab37
3 changed files with 16 additions and 9 deletions
13
gc.c
13
gc.c
|
@ -1156,7 +1156,8 @@ void gc_wait_handshake()
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_status = ATOMIC_GET(&(m->thread_state));
|
thread_status = ATOMIC_GET(&(m->thread_state));
|
||||||
if (thread_status == CYC_THREAD_STATE_BLOCKED) {
|
if (thread_status == CYC_THREAD_STATE_BLOCKED ||
|
||||||
|
thread_status == CYC_THREAD_STATE_BLOCKED_COOPERATING) {
|
||||||
if (statusm == STATUS_ASYNC) { // Prev state
|
if (statusm == STATUS_ASYNC) { // Prev state
|
||||||
ATOMIC_SET_IF_EQ(&(m->gc_status), statusm, statusc);
|
ATOMIC_SET_IF_EQ(&(m->gc_status), statusm, statusc);
|
||||||
// Async is done, so clean up old mark data from the last collection
|
// Async is done, so clean up old mark data from the last collection
|
||||||
|
@ -1173,12 +1174,10 @@ printf("DEBUG - is mutator still blocked?\n");
|
||||||
if (ATOMIC_SET_IF_EQ(&(m->thread_state),
|
if (ATOMIC_SET_IF_EQ(&(m->thread_state),
|
||||||
CYC_THREAD_STATE_BLOCKED,
|
CYC_THREAD_STATE_BLOCKED,
|
||||||
CYC_THREAD_STATE_BLOCKED_COOPERATING)
|
CYC_THREAD_STATE_BLOCKED_COOPERATING)
|
||||||
// TODO: seems to work OK for first collection, but then gc is blocked
|
||
|
||||||
// again. tried this but there must be another issue...
|
ATOMIC_SET_IF_EQ(&(m->thread_state),
|
||||||
// ||
|
CYC_THREAD_STATE_BLOCKED_COOPERATING,
|
||||||
// ATOMIC_SET_IF_EQ(&(m->thread_state),
|
CYC_THREAD_STATE_BLOCKED_COOPERATING)
|
||||||
// CYC_THREAD_STATE_BLOCKED_COOPERATING,
|
|
||||||
// CYC_THREAD_STATE_BLOCKED_COOPERATING)
|
|
||||||
) {
|
) {
|
||||||
printf("DEBUG - update mutator GC status\n");
|
printf("DEBUG - update mutator GC status\n");
|
||||||
ATOMIC_SET_IF_EQ(&(m->gc_status), statusm, statusc);
|
ATOMIC_SET_IF_EQ(&(m->gc_status), statusm, statusc);
|
||||||
|
|
11
runtime.c
11
runtime.c
|
@ -2157,10 +2157,17 @@ void gc_mark_globals()
|
||||||
|
|
||||||
char *gc_fixup_moved_obj(gc_thread_data *thd, int *alloci, char *obj, object hp)
|
char *gc_fixup_moved_obj(gc_thread_data *thd, int *alloci, char *obj, object hp)
|
||||||
{
|
{
|
||||||
|
int acquired_lock = 0;
|
||||||
if (grayed(obj)) {
|
if (grayed(obj)) {
|
||||||
pthread_mutex_lock(&(thd->lock));
|
// Try to acquire the lock, because we are already locked if
|
||||||
|
// the collector is cooperating on behalf of the mutator
|
||||||
|
if (pthread_mutex_trylock(&(thd->lock)) == 0) {
|
||||||
|
acquired_lock = 1;
|
||||||
|
}
|
||||||
gc_mark_gray2(thd, hp);
|
gc_mark_gray2(thd, hp);
|
||||||
pthread_mutex_unlock(&(thd->lock));
|
if (acquired_lock){
|
||||||
|
pthread_mutex_unlock(&(thd->lock));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hp ==> new heap object, point to it from old stack object
|
// hp ==> new heap object, point to it from old stack object
|
||||||
|
|
1
test.scm
1
test.scm
|
@ -32,6 +32,7 @@
|
||||||
(loop))
|
(loop))
|
||||||
)))
|
)))
|
||||||
(read)
|
(read)
|
||||||
|
(write "main thread is done")
|
||||||
|
|
||||||
;;;; A temporary file to attempt to repro crashing / data corruption
|
;;;; A temporary file to attempt to repro crashing / data corruption
|
||||||
;;(import (scheme base) (scheme write))
|
;;(import (scheme base) (scheme write))
|
||||||
|
|
Loading…
Add table
Reference in a new issue