-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract LibGC usages. Enable none garbage collector. #5314
Abstract LibGC usages. Enable none garbage collector. #5314
Conversation
(now nobody will guess whatever I've been getting my hands dirty with these past few weeks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps just a small spec that checks that hello world compiles and runs using -Dnull_gc
?
src/gc.cr
Outdated
end | ||
end | ||
|
||
{% if flag?(:GC_NULL)%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically flags so far have been lowercase so far (without_openssl
, etc), why not null_gc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe -Dno_gc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case, maybe we should rename gc/null
to gc/none
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn’t use “no gc”. Seems more like a toggle to switch to a c++ like memory management to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Habit? Too much C reading? Constant-like looking? Anyway, can change to whatever.
src/gc.cr
Outdated
|
||
# :nodoc: | ||
fun __crystal_malloc_atomic(size : UInt32) : Void* | ||
GC.malloc(LibC::SizeT.new(size)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point if __crystal_malloc_atomic
& __crystal_malloc
have the same implementation?
It doesn't look right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, these should use GC.malloc_atomic
.
end | ||
{% end %} | ||
|
||
GC.malloc(LibC::SizeT.new(size)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto regarding atomic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcardiff I think this was addressed in latest change, can you check again? Thank you.
src/gc.cr
Outdated
end | ||
end | ||
|
||
{% if flag?(:GC_NULL)%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn’t use “no gc”. Seems more like a toggle to switch to a c++ like memory management to me.
8c399c4
to
0bfd178
Compare
Fixed thread issue in specs. Fixed atomic malloc calls. Renamed |
@ysbaddaden please make |
src/gc.cr
Outdated
end | ||
end | ||
|
||
{% if flag?(:gc_none)%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space before %}
0bfd178
to
355d4d1
Compare
All direct calls do LibGC are now abstracted under the GC module; the null GC was updated to follow the API. The `__crystal_malloc` collection of internal functions were also abstracted to call into the `GC.malloc` implementations. Also introduces a `GC_NULL` compilation flag to select the null GC instead of Boehm GC, which enables experiments to implement or use alternative garbage collectors.
355d4d1
to
c08c7ad
Compare
All direct calls do
LibGC
are now abstracted under theGC
module. The null and boehm garbage collectors were updated to follow the new API (the null GC compiles again). The__crystal_malloc
internal functions were also abstracted to call intoGC.malloc
where implementation / bindings are expected to be.Also introduces a
GC_NULL
compilation flag to select the null garbage collection instead of Boehm GC.This patch allows experimenting with alternative or custom garbage collectors.