-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code that is specific to stock GC
- Loading branch information
Showing
8 changed files
with
207 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
/* | ||
write barriers which should be inlined by the compiler | ||
*/ | ||
|
||
#ifndef JL_GC_WB_H | ||
#define JL_GC_WB_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// GC write barriers | ||
|
||
// TODO: implement these functions for MMTk | ||
STATIC_INLINE void jl_gc_wb(const void *parent, const void *ptr) JL_NOTSAFEPOINT | ||
{ | ||
} | ||
|
||
STATIC_INLINE void jl_gc_wb_back(const void *ptr) JL_NOTSAFEPOINT // ptr isa jl_value_t* | ||
{ | ||
} | ||
|
||
STATIC_INLINE void jl_gc_multi_wb(const void *parent, const jl_value_t *ptr) JL_NOTSAFEPOINT | ||
{ | ||
} | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
/* | ||
write barriers which should be inlined by the compiler | ||
*/ | ||
|
||
#ifndef JL_GC_WB_H | ||
#define JL_GC_WB_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// GC write barriers | ||
|
||
STATIC_INLINE void jl_gc_wb(const void *parent, const void *ptr) JL_NOTSAFEPOINT | ||
{ | ||
// parent and ptr isa jl_value_t* | ||
if (__unlikely(jl_astaggedvalue(parent)->bits.gc == 3 /* GC_OLD_MARKED */ && // parent is old and not in remset | ||
(jl_astaggedvalue(ptr)->bits.gc & 1 /* GC_MARKED */) == 0)) // ptr is young | ||
jl_gc_queue_root((jl_value_t*)parent); | ||
} | ||
|
||
STATIC_INLINE void jl_gc_wb_back(const void *ptr) JL_NOTSAFEPOINT // ptr isa jl_value_t* | ||
{ | ||
// if ptr is old | ||
if (__unlikely(jl_astaggedvalue(ptr)->bits.gc == 3 /* GC_OLD_MARKED */)) { | ||
jl_gc_queue_root((jl_value_t*)ptr); | ||
} | ||
} | ||
|
||
STATIC_INLINE void jl_gc_multi_wb(const void *parent, const jl_value_t *ptr) JL_NOTSAFEPOINT | ||
{ | ||
// 3 == GC_OLD_MARKED | ||
// ptr is an immutable object | ||
if (__likely(jl_astaggedvalue(parent)->bits.gc != 3)) | ||
return; // parent is young or in remset | ||
if (__likely(jl_astaggedvalue(ptr)->bits.gc == 3)) | ||
return; // ptr is old and not in remset (thus it does not point to young) | ||
jl_datatype_t *dt = (jl_datatype_t*)jl_typeof(ptr); | ||
const jl_datatype_layout_t *ly = dt->layout; | ||
if (ly->npointers) | ||
jl_gc_queue_multiroot((jl_value_t*)parent, ptr, dt); | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters