aboutsummaryrefslogtreecommitdiff
path: root/libphobos
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-05-27 19:36:06 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2022-05-27 20:19:02 +0200
commit610d789832b57e9ab0158b330865e24b9b699040 (patch)
tree0b42094ea5f69e9fd0257dd578589a60ef6b736a /libphobos
parentd822f4bbd714c6595f70cc68888dcebecfb6662d (diff)
downloadgcc-610d789832b57e9ab0158b330865e24b9b699040.zip
gcc-610d789832b57e9ab0158b330865e24b9b699040.tar.gz
gcc-610d789832b57e9ab0158b330865e24b9b699040.tar.bz2
d: Merge upstream dmd 4d07f22f2, druntime f89da313, phobos d46814c86.
D front-end changes: - `scope' semantics are now enforced in `@safe' code on pointers to stack memory, but only as deprecation warnings. - Overriding virtual functions are now marked with the `override' and `final' in the generated headers of `-fdump-c++-spec='. - `-fpreview=fiximmmutableconv` has been added that disallows implicitly converting a return value with indirections to immutable if it determines the result must be unique. D runtime changes: - Posix (excluding Darwin): Switch default GC signals from SIGUSR1/2 to SIGRTMIN/SIGRTMIN+1 Phobos changes: - Import latest bug fixes to mainline. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 4d07f22f2 * d-lang.cc (d_handle_option): Handle OPT_fpreview_fiximmutableconv. * lang.opt (fpreview=fiximmutableconv): New option. * runtime.def (ARRAYAPPENDT): Remove. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime f89da313. * src/MERGE: Merge upstream phobos d46814c86. Signed-off-by: Iain Buclaw <ibuclaw@gdcproject.org>
Diffstat (limited to 'libphobos')
-rw-r--r--libphobos/libdruntime/MERGE2
-rw-r--r--libphobos/libdruntime/core/internal/array/appending.d21
-rw-r--r--libphobos/libdruntime/core/memory.d2
-rw-r--r--libphobos/libdruntime/core/thread/fiber.d7
-rw-r--r--libphobos/libdruntime/core/thread/osthread.d21
-rw-r--r--libphobos/libdruntime/core/thread/threadbase.d4
-rw-r--r--libphobos/libdruntime/object.d25
-rw-r--r--libphobos/libdruntime/rt/arrayassign.d72
-rw-r--r--libphobos/libdruntime/rt/lifetime.d39
-rw-r--r--libphobos/src/MERGE2
-rw-r--r--libphobos/src/std/package.d2
-rw-r--r--libphobos/src/std/process.d4
-rw-r--r--libphobos/src/std/utf.d4
13 files changed, 65 insertions, 140 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 1a9faf9..d503bae 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-94bd5bcb448405d90bc50113d1cfd45a0880a50d
+f89da31331ef5df50d3bc7a26efd1b7acdefde8c
The first line of this file holds the git revision number of the last
merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/core/internal/array/appending.d b/libphobos/libdruntime/core/internal/array/appending.d
index 5d4f3b4..d416efe 100644
--- a/libphobos/libdruntime/core/internal/array/appending.d
+++ b/libphobos/libdruntime/core/internal/array/appending.d
@@ -85,20 +85,35 @@ ref Tarr _d_arrayappendT(Tarr : T[], T)(return ref scope Tarr x, scope Tarr y) @
import core.internal.traits : hasElaborateCopyConstructor, Unqual;
import core.lifetime : copyEmplace;
+ enum hasPostblit = __traits(hasPostblit, T);
auto length = x.length;
_d_arrayappendcTXImpl!Tarr._d_arrayappendcTX(x, y.length);
- static if (hasElaborateCopyConstructor!T)
+ // Only call `copyEmplace` if `T` has a copy ctor and no postblit.
+ static if (hasElaborateCopyConstructor!T && !hasPostblit)
{
foreach (i, ref elem; y)
copyEmplace(elem, x[length + i]);
}
else
{
- // blit all elements at once
if (y.length)
- memcpy(cast(Unqual!T *)&x[length], cast(Unqual!T *)&y[0], y.length * T.sizeof);
+ {
+ // blit all elements at once
+ auto xptr = cast(Unqual!T *)&x[length];
+ immutable size = T.sizeof;
+
+ memcpy(xptr, cast(Unqual!T *)&y[0], y.length * size);
+
+ // call postblits if they exist
+ static if (hasPostblit)
+ {
+ auto eptr = xptr + y.length;
+ for (auto ptr = xptr; ptr < eptr; ptr++)
+ ptr.__xpostblit();
+ }
+ }
}
return x;
diff --git a/libphobos/libdruntime/core/memory.d b/libphobos/libdruntime/core/memory.d
index b63b111..7d1356af 100644
--- a/libphobos/libdruntime/core/memory.d
+++ b/libphobos/libdruntime/core/memory.d
@@ -38,7 +38,7 @@
*
* Notes_to_implementors:
* $(UL
- * $(LI On POSIX systems, the signals SIGUSR1 and SIGUSR2 are reserved
+ * $(LI On POSIX systems, the signals `SIGRTMIN` and `SIGRTMIN + 1` are reserved
* by this module for use in the garbage collector implementation.
* Typically, they will be used to stop and resume other threads
* when performing a collection, but an implementation may choose
diff --git a/libphobos/libdruntime/core/thread/fiber.d b/libphobos/libdruntime/core/thread/fiber.d
index bd53eed..efbad7d 100644
--- a/libphobos/libdruntime/core/thread/fiber.d
+++ b/libphobos/libdruntime/core/thread/fiber.d
@@ -653,14 +653,9 @@ class Fiber
*/
this( void delegate() dg, size_t sz = PAGESIZE * defaultStackPages,
size_t guardPageSize = PAGESIZE ) nothrow
- in
- {
- assert( dg );
- }
- do
{
allocStack( sz, guardPageSize );
- reset( dg );
+ reset( cast(void delegate() const) dg );
}
diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index 1bbce3f..ef073a9 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -1251,7 +1251,7 @@ version (CoreDdoc)
{
/**
* Instruct the thread module, when initialized, to use a different set of
- * signals besides SIGUSR1 and SIGUSR2 for suspension and resumption of threads.
+ * signals besides SIGRTMIN and SIGRTMIN + 1 for suspension and resumption of threads.
* This function should be called at most once, prior to thread_init().
* This function is Posix-only.
*/
@@ -1281,8 +1281,8 @@ else version (Posix)
version (Posix)
{
- private __gshared int suspendSignalNumber = SIGUSR1;
- private __gshared int resumeSignalNumber = SIGUSR2;
+ private __gshared int suspendSignalNumber;
+ private __gshared int resumeSignalNumber;
}
private extern (D) ThreadBase attachThread(ThreadBase _thisThread) @nogc nothrow
@@ -2115,11 +2115,6 @@ extern (C) void thread_init() @nogc
initLowlevelThreads();
Thread.initLocks();
- // The Android VM runtime intercepts SIGUSR1 and apparently doesn't allow
- // its signal handler to run, so swap the two signals on Android, since
- // thread_resumeHandler does nothing.
- version (Android) thread_setGCSignals(SIGUSR2, SIGUSR1);
-
version (Darwin)
{
// thread id different in forked child process
@@ -2135,6 +2130,16 @@ extern (C) void thread_init() @nogc
}
else version (Posix)
{
+ if ( suspendSignalNumber == 0 )
+ {
+ suspendSignalNumber = SIGRTMIN;
+ }
+
+ if ( resumeSignalNumber == 0 )
+ {
+ resumeSignalNumber = SIGRTMIN + 1;
+ assert(resumeSignalNumber <= SIGRTMAX);
+ }
int status;
sigaction_t suspend = void;
sigaction_t resume = void;
diff --git a/libphobos/libdruntime/core/thread/threadbase.d b/libphobos/libdruntime/core/thread/threadbase.d
index 9042a36..505be00 100644
--- a/libphobos/libdruntime/core/thread/threadbase.d
+++ b/libphobos/libdruntime/core/thread/threadbase.d
@@ -108,8 +108,8 @@ class ThreadBase
m_call = fn;
}
- this(void delegate() dg, size_t sz = 0) @safe pure nothrow @nogc
- in(dg)
+ this(void delegate() dg, size_t sz = 0) @trusted pure nothrow @nogc
+ in( cast(void delegate() const) dg)
{
this(sz);
m_call = dg;
diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d
index 3a88552..fe65c09 100644
--- a/libphobos/libdruntime/object.d
+++ b/libphobos/libdruntime/object.d
@@ -1481,7 +1481,7 @@ class TypeInfo_Delegate : TypeInfo
override size_t getHash(scope const void* p) @trusted const
{
- return hashOf(*cast(void delegate()*)p);
+ return hashOf(*cast(const void delegate() *)p);
}
override bool equals(in void* p1, in void* p2) const
@@ -4428,7 +4428,7 @@ nothrow @safe @nogc unittest
}
}
-private extern (C) void rt_finalize(void *data, bool det=true) nothrow;
+private extern (C) void rt_finalize2(void* p, bool det = true, bool resetMemory = true) nothrow;
/// ditto
void destroy(bool initialize = true, T)(T obj) if (is(T == class))
@@ -4448,7 +4448,7 @@ void destroy(bool initialize = true, T)(T obj) if (is(T == class))
{
// Bypass overloaded opCast
auto ptr = (() @trusted => *cast(void**) &obj)();
- rt_finalize(ptr);
+ rt_finalize2(ptr, true, initialize);
}
}
@@ -4723,6 +4723,25 @@ nothrow unittest
destroy(B.init);
}
+// make sure destroy!false skips re-initialization
+unittest
+{
+ static struct S { int x; }
+ static class C { int x; }
+ static extern(C++) class Cpp { int x; }
+
+ static void test(T)(T inst)
+ {
+ inst.x = 123;
+ destroy!false(inst);
+ assert(inst.x == 123, T.stringof);
+ }
+
+ test(S());
+ test(new C());
+ test(new Cpp());
+}
+
/// ditto
void destroy(bool initialize = true, T)(ref T obj)
if (__traits(isStaticArray, T))
diff --git a/libphobos/libdruntime/rt/arrayassign.d b/libphobos/libdruntime/rt/arrayassign.d
index 21d50b0..9a34ec7 100644
--- a/libphobos/libdruntime/rt/arrayassign.d
+++ b/libphobos/libdruntime/rt/arrayassign.d
@@ -163,45 +163,6 @@ extern (C) void[] _d_arrayassign_r(TypeInfo ti, void[] src, void[] dst, void* pt
}
/**
- * Does array initialization (not assignment) from another
- * array of the same element type.
- * ti is the element type.
- */
-extern (C) void[] _d_arrayctor(TypeInfo ti, void[] from, void[] to)
-{
- debug(PRINTF) printf("_d_arrayctor(from = %p,%d, to = %p,%d) size = %d\n", from.ptr, from.length, to.ptr, to.length, ti.tsize);
-
-
- auto element_size = ti.tsize;
-
- enforceRawArraysConformable("initialization", element_size, from, to);
-
- size_t i;
- try
- {
- for (i = 0; i < to.length; i++)
- {
- // Copy construction is defined as bit copy followed by postblit.
- memcpy(to.ptr + i * element_size, from.ptr + i * element_size, element_size);
- ti.postblit(to.ptr + i * element_size);
- }
- }
- catch (Throwable o)
- {
- /* Destroy, in reverse order, what we've constructed so far
- */
- while (i--)
- {
- ti.destroy(to.ptr + i * element_size);
- }
-
- throw o;
- }
- return to;
-}
-
-
-/**
* Do assignment to an array.
* p[0 .. count] = value;
*/
@@ -227,36 +188,3 @@ extern (C) void* _d_arraysetassign(void* p, void* value, int count, TypeInfo ti)
free(ptmp);
return pstart;
}
-
-/**
- * Do construction of an array.
- * ti[count] p = value;
- */
-extern (C) void* _d_arraysetctor(void* p, void* value, int count, TypeInfo ti)
-{
- void* pstart = p;
- auto element_size = ti.tsize;
-
- try
- {
- foreach (i; 0 .. count)
- {
- // Copy construction is defined as bit copy followed by postblit.
- memcpy(p, value, element_size);
- ti.postblit(p);
- p += element_size;
- }
- }
- catch (Throwable o)
- {
- // Destroy, in reverse order, what we've constructed so far
- while (p > pstart)
- {
- p -= element_size;
- ti.destroy(p);
- }
-
- throw o;
- }
- return pstart;
-}
diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d
index 96d9a80..5a18968 100644
--- a/libphobos/libdruntime/rt/lifetime.d
+++ b/libphobos/libdruntime/rt/lifetime.d
@@ -163,23 +163,6 @@ extern (C) void _d_delclass(Object* p) @weak
}
}
-/**
- * This is called for a delete statement where the value
- * being deleted is a pointer to a struct with a destructor
- * but doesn't have an overloaded delete operator.
- */
-extern (C) void _d_delstruct(void** p, TypeInfo_Struct inf) @weak
-{
- if (*p)
- {
- debug(PRINTF) printf("_d_delstruct(%p, %p)\n", *p, cast(void*)inf);
-
- inf.destroy(*p);
- GC.free(*p);
- *p = null;
- }
-}
-
// strip const/immutable/shared/inout from type info
inout(TypeInfo) unqualify(return scope inout(TypeInfo) cti) pure nothrow @nogc
{
@@ -1872,23 +1855,6 @@ do
return *p;
}
-/**
- * Append y[] to array x[]
- */
-extern (C) void[] _d_arrayappendT(const TypeInfo ti, ref byte[] x, byte[] y) @weak
-{
- import core.stdc.string;
- auto length = x.length;
- auto tinext = unqualify(ti.next);
- auto sizeelem = tinext.tsize; // array element size
- _d_arrayappendcTX(ti, x, y.length);
- memcpy(x.ptr + length * sizeelem, y.ptr, y.length * sizeelem);
-
- // do postblit
- __doPostblit(x.ptr + length * sizeelem, y.length * sizeelem, tinext);
- return x;
-}
-
/**
*
@@ -2607,11 +2573,6 @@ deprecated unittest
}
dtorCount = 0;
- S1* s1 = new S1;
- _d_delstruct(cast(void**)&s1, typeid(typeof(*s1))); // delete s1;
- assert(dtorCount == 1);
-
- dtorCount = 0;
S1[] arr1 = new S1[7];
_d_delarray_t(cast(void[]*)&arr1, typeid(typeof(arr1[0]))); // delete arr1;
assert(dtorCount == 7);
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index 3de142f..ddf730e 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@
-3a1cd9a01479155958c7799e573e55a93dd189a0
+d46814c86392007ebb4fb73cb684ef9e8caa605a
The first line of this file holds the git revision number of the last
merge done from the dlang/phobos repository.
diff --git a/libphobos/src/std/package.d b/libphobos/src/std/package.d
index a1d0444..bfb135b 100644
--- a/libphobos/src/std/package.d
+++ b/libphobos/src/std/package.d
@@ -35,6 +35,7 @@ public import
std.base64,
std.bigint,
std.bitmanip,
+ std.checkedint,
std.compiler,
std.complex,
std.concurrency,
@@ -50,6 +51,7 @@ public import
std.format,
std.functional,
std.getopt,
+ std.int128,
std.json,
std.math,
std.mathspecial,
diff --git a/libphobos/src/std/process.d b/libphobos/src/std/process.d
index 28bfb04..d4fe8a1 100644
--- a/libphobos/src/std/process.d
+++ b/libphobos/src/std/process.d
@@ -613,7 +613,7 @@ private:
* writefln("Current process ID: %d", thisProcessID);
* ---
*/
-@property int thisProcessID() @trusted nothrow //TODO: @safe
+@property int thisProcessID() @trusted nothrow @nogc //TODO: @safe
{
version (Windows) return GetCurrentProcessId();
else version (Posix) return core.sys.posix.unistd.getpid();
@@ -632,7 +632,7 @@ private:
* writefln("Current thread ID: %s", thisThreadID);
* ---
*/
-@property ThreadID thisThreadID() @trusted nothrow //TODO: @safe
+@property ThreadID thisThreadID() @trusted nothrow @nogc //TODO: @safe
{
version (Windows)
return GetCurrentThreadId();
diff --git a/libphobos/src/std/utf.d b/libphobos/src/std/utf.d
index f0200ce..d22dac8 100644
--- a/libphobos/src/std/utf.d
+++ b/libphobos/src/std/utf.d
@@ -4275,10 +4275,10 @@ private int impureVariable;
* UseReplacementDchar.no means throw `UTFException` for invalid UTF
*
* Throws:
- * `UTFException` if invalid UTF sequence and `useReplacementDchar` is set to `UseReplacementDchar.yes`
+ * `UTFException` if invalid UTF sequence and `useReplacementDchar` is set to `UseReplacementDchar.no`
*
* GC:
- * Does not use GC if `useReplacementDchar` is set to `UseReplacementDchar.no`
+ * Does not use GC if `useReplacementDchar` is set to `UseReplacementDchar.yes`
*
* Returns:
* A bidirectional range if `R` is a bidirectional range and not auto-decodable,