Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
16ac6d9
Toggle forking gc on/off
May 11, 2019
b5e5109
Annotate used functions with @nogc
May 11, 2019
1016224
C functions and imports
May 11, 2019
89af969
Core logic of the fork() based gc.
May 11, 2019
dbab396
whitespace
May 11, 2019
412e6ec
whitespace before parenthesis
May 11, 2019
5ebfe3d
mmap as parameter not attribute
May 16, 2019
89b9c48
rebase
May 16, 2019
24b4b4e
dashes and comments on same line
May 16, 2019
b71bc05
style changes as per review
May 16, 2019
a805390
import _Exit from core.posix
May 16, 2019
53c6786
markbits are mmapped
May 16, 2019
708cd4b
redundant code
May 16, 2019
afacea0
style changes
May 16, 2019
d3fe6ad
moved functions as per review
May 16, 2019
c634dfe
throws an error, still recursive locking
May 16, 2019
e7117b2
redundant code
Jun 17, 2019
8f396e0
indentation and lowercasing
Jun 17, 2019
54aeb92
renamed bool mmap to share
Jun 17, 2019
0d92515
throws in case of failed fork
Jun 17, 2019
91e8a26
added configuration error: can't mix parallel and fork
Jun 17, 2019
a442737
added a version switch for the fork() behaviour
Jun 17, 2019
b6620ea
use mem_map and mem_unmap only when requested
Jun 18, 2019
92d1223
redundant version(COLLECT_FORK)
Jun 18, 2019
61541c9
redundant code
Jun 18, 2019
fe28004
bits dtor called implicitly and on config.fork
Jun 18, 2019
28b76b8
better imports
Jun 18, 2019
b95c493
better naming of doMinimize
Jun 18, 2019
4605f19
call freebits.setAll for smallPools only
Jun 18, 2019
65a029d
update timings outside markFork
Jun 18, 2019
00b236b
formatting
Jun 18, 2019
c734c8e
allow threaded marking in the child process
Jun 18, 2019
b0f3542
moved comments back
Jun 18, 2019
0ea99da
remove freebits.setAll call
Jun 18, 2019
8856570
fork enabled temporarely for CI
Jun 18, 2019
6a4e909
style
Jun 18, 2019
d2f4506
solve compilation error on OSes that do not support fork()
Jun 25, 2019
c0e3539
forgot else statement
Jun 25, 2019
d7ed6bd
change RT-config description
Jul 4, 2019
c5eedb3
no need for private bool
Jul 4, 2019
eab16e9
pool.mark.set only if collectInprogress
Jul 4, 2019
f172e98
refactoring
Jul 4, 2019
ce10aa3
temporary fix for fullCollect on RT termination
Jul 4, 2019
d84375f
import fflush only in debug
Jul 12, 2019
df46a6a
moved asserts
Jul 12, 2019
5ad7ce2
Merge branch 'master' of https://github.com/dlang/druntime into saoc
Jul 15, 2019
6af3c10
ignore echild
Jul 15, 2019
4e8d5cc
Merge remote-tracking branch 'upstream/master' into saoc
Jul 17, 2019
0bc32ba
pass fork to gc/config
Jul 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/core/exception.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ void __switch_errorT()(string file = __FILE__, size_t line = __LINE__) @trusted
assert(0, "No appropriate switch clause found");
}


/**
* Thrown on a configuration error.
*/
class ForkError : Error
{
this( string file = __FILE__, size_t line = __LINE__, Throwable next = null ) @nogc nothrow pure @safe
{
super( "fork() failed", file, line, next );
}
}


version (D_BetterC)
{
// When compiling with -betterC we use template functions so if they are
Expand Down Expand Up @@ -539,6 +552,22 @@ extern (C) void onInvalidMemoryOperationError(void* pretend_sideffect = null) @t
throw staticError!InvalidMemoryOperationError();
}


/**
* A callback for errors in the case of a failed fork in D. A $(LREF ForkError) will be thrown.
*
* Params:
* file = The name of the file that signaled this error.
* line = The line number on which this error occurred.
*
* Throws:
* $(LREF ConfigurationError).
*/
extern (C) void onForkError( string file = __FILE__, size_t line = __LINE__ ) @trusted pure nothrow @nogc
{
throw staticError!ForkError( file, line, null );
}

/**
* A callback for unicode errors in D. A $(LREF UnicodeException) will be thrown.
*
Expand Down
4 changes: 3 additions & 1 deletion src/core/gc/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ __gshared Config config;
struct Config
{
bool disable; // start disabled
bool fork = true; // optional concurrent behaviour
ubyte profile; // enable profiling with summary when terminating program
string gc = "conservative"; // select gc implementation conservative|precise|manual

Expand All @@ -39,8 +40,9 @@ struct Config

printf("GC options are specified as white space separated assignments:
disable:0|1 - start disabled (%d)
fork:0|1 - set fork behaviour (%d)
profile:0|1|2 - enable profiling with summary when terminating program (%d)
gc:".ptr, disable, profile);
gc:".ptr, disable, profile, fork);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the wrong order, now. It's in the middle in the format string.

foreach (i, entry; registeredGCFactories)
{
if (i) printf("|");
Expand Down
36 changes: 26 additions & 10 deletions src/gc/bits.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
module gc.bits;

import gc.os : os_mem_map, os_mem_unmap, HaveFork;

import core.bitop;
import core.stdc.string;
Expand All @@ -38,24 +39,34 @@ struct GCBits
wordtype* data;
size_t nbits;

void Dtor() nothrow
void Dtor(bool share = false) nothrow @nogc
{
if (data)
{
free(data);
static if (!HaveFork)
free(data);
else if (share)
os_mem_unmap(data, nwords * data[0].sizeof);
else
free(data);
data = null;
}
}

void alloc(size_t nbits) nothrow
void alloc(size_t nbits, bool share = false) nothrow
{
this.nbits = nbits;
data = cast(typeof(data[0])*)calloc(nwords, data[0].sizeof);
static if (!HaveFork)
data = cast(typeof(data[0])*)calloc(nwords, data[0].sizeof);
else if (share)
data = cast(typeof(data[0])*)os_mem_map(nwords * data[0].sizeof, true); // Allocate as MAP_SHARED
else
data = cast(typeof(data[0])*)calloc(nwords, data[0].sizeof);
if (!data)
onOutOfMemoryError();
}

wordtype test(size_t i) const nothrow
wordtype test(size_t i) const nothrow @nogc
in
{
assert(i < nbits);
Expand All @@ -65,7 +76,7 @@ struct GCBits
return core.bitop.bt(data, i);
}

int set(size_t i) nothrow
int set(size_t i) nothrow @nogc
in
{
assert(i < nbits);
Expand All @@ -75,7 +86,7 @@ struct GCBits
return core.bitop.bts(data, i);
}

int clear(size_t i) nothrow
int clear(size_t i) nothrow @nogc
in
{
assert(i <= nbits);
Expand Down Expand Up @@ -432,12 +443,17 @@ struct GCBits
testCopyRange(2, 3, 166); // failed with assert
}

void zero() nothrow
void zero() nothrow @nogc
{
memset(data, 0, nwords * wordtype.sizeof);
}

void copy(GCBits *f) nothrow
void setAll() nothrow @nogc
{
memset(data, 0xFF, nwords * wordtype.sizeof);
}

void copy(GCBits *f) nothrow @nogc
in
{
assert(nwords == f.nwords);
Expand All @@ -447,7 +463,7 @@ struct GCBits
memcpy(data, f.data, nwords * wordtype.sizeof);
}

@property size_t nwords() const pure nothrow
@property size_t nwords() const pure nothrow @nogc
{
return (nbits + (BITS_PER_WORD - 1)) >> BITS_SHIFT;
}
Expand Down
Loading