aboutsummaryrefslogtreecommitdiff
path: root/libphobos
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2024-02-12 16:46:33 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2024-02-12 16:55:33 +0100
commit2dde675ff48600188d3e892d191a2345bad2e6ae (patch)
treebbef7d663cf48cc8d2238aa0098732a14321a0e9 /libphobos
parent3c57b1c12a8e34d50bdf6aaf44146760db6d1b33 (diff)
downloadgcc-2dde675ff48600188d3e892d191a2345bad2e6ae.zip
gcc-2dde675ff48600188d3e892d191a2345bad2e6ae.tar.gz
gcc-2dde675ff48600188d3e892d191a2345bad2e6ae.tar.bz2
d: Merge dmd, druntime 11240a9663
D front-end changes: - Import latest fixes from dmd v2.107.0. D runtime changes: - Import latest fixes from druntime v2.107.0. Included in the merge are the fix for PR113772, and new testsuite directives to enable fixing PR104739. PR d/113772 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 11240a9663. * d-builtins.cc (build_frontend_type): Update for new front-end interface. * types.cc (same_type_p): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 11240a9663.
Diffstat (limited to 'libphobos')
-rw-r--r--libphobos/libdruntime/MERGE2
-rw-r--r--libphobos/libdruntime/core/demangle.d160
-rw-r--r--libphobos/libdruntime/core/internal/atomic.d2
-rw-r--r--libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d39
-rw-r--r--libphobos/libdruntime/core/internal/qsort.d5
-rw-r--r--libphobos/libdruntime/core/memory.d1
-rw-r--r--libphobos/libdruntime/core/thread/osthread.d2
-rw-r--r--libphobos/libdruntime/core/time.d4
-rw-r--r--libphobos/libdruntime/rt/aaA.d1
-rw-r--r--libphobos/libdruntime/rt/lifetime.d1
10 files changed, 115 insertions, 102 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 57ac2dc..74c1945 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-a6f10836997d0b5526c8c363d781b4029c77f09f
+11240a96635074b2f79d908b9348e9c0fbc3c7dc
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
diff --git a/libphobos/libdruntime/core/demangle.d b/libphobos/libdruntime/core/demangle.d
index 5a6ad6f..272ee1e 100644
--- a/libphobos/libdruntime/core/demangle.d
+++ b/libphobos/libdruntime/core/demangle.d
@@ -79,17 +79,6 @@ pure @safe:
AddType addType = AddType.yes;
bool mute = false;
Hooks hooks;
- bool hasErrors = false;
-
- /// Called when encountering an error / unrecognized mangle.
- ///
- /// Currently, errors simply make `demangle` return
- /// the input string, but the `msg` string can be used for debugging.
- /// As a future enhancement, error handlers can be supplied through `Hooks`
- void error(string msg = "error")
- {
- hasErrors = true;
- }
//////////////////////////////////////////////////////////////////////////
// Type Testing and Conversion
@@ -733,7 +722,7 @@ pure @safe:
TypeTuple:
B Number Arguments
*/
- BufSlice parseType() return scope nothrow
+ BufSlice parseType(out bool errStatus) return scope nothrow
{
static immutable string[23] primitives = [
"char", // a
@@ -763,8 +752,8 @@ pure @safe:
static if (__traits(hasMember, Hooks, "parseType"))
{
- auto n = hooks.parseType(this, null);
- if (this.hasErrors)
+ auto n = hooks.parseType(errStatus, this, null);
+ if (errStatus)
return dst.bslice_empty;
else
if (n !is null)
@@ -776,11 +765,11 @@ pure @safe:
auto beg = dst.length;
auto t = front;
- BufSlice parseBackrefType(scope BufSlice delegate() pure @safe nothrow parseDg) pure @safe nothrow
+ BufSlice parseBackrefType(out string errStatus, scope BufSlice delegate(bool err_flag) pure @safe nothrow parseDg) pure @safe nothrow
{
if (pos == brp)
{
- this.error("recursive back reference");
+ errStatus = "recursive back reference";
return dst.bslice_empty;
}
@@ -789,7 +778,7 @@ pure @safe:
auto n = decodeBackref();
if (n == 0 || n > pos)
{
- this.error("invalid back reference");
+ errStatus = "invalid back reference";
return dst.bslice_empty;
}
@@ -801,31 +790,44 @@ pure @safe:
pos = refPos - n;
brp = refPos;
- auto ret = parseDg();
+ bool err_flag;
+ auto ret = parseDg(err_flag);
+ if (err_flag)
+ {
+ errStatus = "parseDg error";
+ return dst.bslice_empty;
+ }
+
return ret;
}
+ // call parseType() and return error if occured
+ enum parseTypeOrF = "parseType(errStatus); if (errStatus) return dst.bslice_empty;";
+
switch ( t )
{
case 'Q': // Type back reference
- auto r = parseBackrefType(() => parseType());
+ string errMsg;
+ auto r = parseBackrefType(errMsg, (e_flag) => parseType(e_flag));
+ if (errMsg !is null)
+ return dst.bslice_empty;
return r;
case 'O': // Shared (O Type)
popFront();
put( "shared(" );
- parseType();
+ mixin(parseTypeOrF);
put( ')' );
return dst[beg .. $];
case 'x': // Const (x Type)
popFront();
put( "const(" );
- parseType();
+ mixin(parseTypeOrF);
put( ')' );
return dst[beg .. $];
case 'y': // Immutable (y Type)
popFront();
put( "immutable(" );
- parseType();
+ mixin(parseTypeOrF);
put( ')' );
return dst[beg .. $];
case 'N':
@@ -840,28 +842,28 @@ pure @safe:
popFront();
// TODO: Anything needed here?
put( "inout(" );
- parseType();
+ mixin(parseTypeOrF);
put( ')' );
return dst[beg .. $];
case 'h': // TypeVector (Nh Type)
popFront();
put( "__vector(" );
- parseType();
+ mixin(parseTypeOrF);
put( ')' );
return dst[beg .. $];
default:
- error();
+ errStatus = true;
return dst.bslice_empty;
}
case 'A': // TypeArray (A Type)
popFront();
- parseType();
+ mixin(parseTypeOrF);
put( "[]" );
return dst[beg .. $];
case 'G': // TypeStaticArray (G Number Type)
popFront();
auto num = sliceNumber();
- parseType();
+ mixin(parseTypeOrF);
put( '[' );
put( num );
put( ']' );
@@ -869,34 +871,29 @@ pure @safe:
case 'H': // TypeAssocArray (H Type Type)
popFront();
// skip t1
- auto tx = parseType();
- if (this.hasErrors)
+ auto tx = parseType(errStatus);
+ if (errStatus)
return dst.bslice_empty;
- parseType();
+ mixin(parseTypeOrF);
put( '[' );
shift(tx);
put( ']' );
return dst[beg .. $];
case 'P': // TypePointer (P Type)
popFront();
- parseType();
+ mixin(parseTypeOrF);
put( '*' );
return dst[beg .. $];
case 'F': case 'U': case 'W': case 'V': case 'R': // TypeFunction
- bool errStatus;
auto r = parseTypeFunction(errStatus);
if (errStatus)
- {
- error();
return dst.bslice_empty;
- }
return r;
case 'C': // TypeClass (C LName)
case 'S': // TypeStruct (S LName)
case 'E': // TypeEnum (E LName)
case 'T': // TypeTypedef (T LName)
popFront();
- bool errStatus;
parseQualifiedName(errStatus);
if (errStatus)
return dst.bslice_empty;
@@ -906,20 +903,16 @@ pure @safe:
auto modifiers = parseModifier();
if ( front == 'Q' )
{
- bool errStatus;
- auto r = parseBackrefType(() => parseTypeFunction(errStatus, IsDelegate.yes));
- if (errStatus)
- {
- error();
+ string errMsg;
+ auto r = parseBackrefType(errMsg, (e_flag) => parseTypeFunction(e_flag, IsDelegate.yes));
+ if (errMsg !is null)
return dst.bslice_empty;
- }
return r;
}
else
{
- bool errStatus;
parseTypeFunction(errStatus, IsDelegate.yes);
- if (this.hasErrors || errStatus)
+ if (errStatus)
return dst.bslice_empty;
}
@@ -972,11 +965,11 @@ pure @safe:
put( "ucent" );
return dst[beg .. $];
default:
- error("unknown type");
+ errStatus = true;
return dst.bslice_empty;
}
}
- error("unknown type");
+ errStatus = true;
return dst.bslice_empty;
}
}
@@ -1289,6 +1282,9 @@ pure @safe:
pos--;
}
+ // call parseType() and return error if occured
+ enum parseTypeOrF = "parseType(errStatus); if (errStatus) return;";
+
switch ( front )
{
case 'I': // in (I Type)
@@ -1296,25 +1292,25 @@ pure @safe:
put("in ");
if (front == 'K')
goto case;
- parseType();
+ mixin(parseTypeOrF);
continue;
case 'K': // ref (K Type)
popFront();
put( "ref " );
- parseType();
+ mixin(parseTypeOrF);
continue;
case 'J': // out (J Type)
popFront();
put( "out " );
- parseType();
+ mixin(parseTypeOrF);
continue;
case 'L': // lazy (L Type)
popFront();
put( "lazy " );
- parseType();
+ mixin(parseTypeOrF);
continue;
default:
- parseType();
+ mixin(parseTypeOrF);
}
}
}
@@ -1361,8 +1357,8 @@ pure @safe:
// e.g. `delegate(int) @safedouble ' => 'double delegate(int) @safe'
{
auto retbeg = dst.length;
- parseType();
- if (this.hasErrors)
+ parseType(errStatus);
+ if (errStatus)
return dst.bslice_empty;
put(' ');
shift(dst[argbeg .. retbeg]);
@@ -1576,9 +1572,7 @@ pure @safe:
// f MangledName
// A function literal symbol
popFront();
- parseMangledName(false, 1);
- if (this.hasErrors)
- errStatus = true;
+ parseMangledName(errStatus, false, 1);
return;
default:
errStatus = true;
@@ -1716,12 +1710,9 @@ pure @safe:
case 'T':
popFront();
putComma(n);
- parseType();
- if (this.hasErrors)
- {
- errStatus = true;
+ parseType(errStatus);
+ if (errStatus)
return;
- }
continue;
case 'V':
popFront();
@@ -1742,7 +1733,7 @@ pure @safe:
}
}
BufSlice name = dst.bslice_empty;
- silent( errStatus, delegate void(out bool e_flg) nothrow { name = parseType(); } );
+ silent( errStatus, delegate void(out bool e_flg) nothrow { name = parseType(e_flg); } );
if (errStatus)
return;
parseValue( errStatus, name, t );
@@ -1857,20 +1848,20 @@ pure @safe:
debug(trace) printf( "parseMangledNameArg+\n" );
debug(trace) scope(success) printf( "parseMangledNameArg-\n" );
+ bool errStatus;
+
size_t n = 0;
if ( isDigit( front ) )
{
- bool errStatus;
n = decodeNumber(errStatus);
+
if (errStatus)
- {
- error();
return false;
- }
}
- parseMangledName(false, n);
- return !this.hasErrors;
+ parseMangledName(errStatus, false, n );
+
+ return !errStatus;
}
/*
@@ -2091,7 +2082,7 @@ pure @safe:
_D QualifiedName Type
_D QualifiedName M Type
*/
- void parseMangledName(bool displayType, size_t n = 0 ) scope nothrow
+ void parseMangledName( out bool errStatus, bool displayType, size_t n = 0 ) scope nothrow
{
debug(trace) printf( "parseMangledName+\n" );
debug(trace) scope(success) printf( "parseMangledName-\n" );
@@ -2100,8 +2091,9 @@ pure @safe:
auto end = pos + n;
eat( '_' );
- if (!match('D'))
- return error();
+ errStatus = !match( 'D' );
+ if (errStatus)
+ return;
do
{
@@ -2117,17 +2109,16 @@ pure @safe:
if (beg != dst.length)
put( '.' );
- bool errStatus;
parseSymbolName(errStatus);
if (errStatus)
- return error();
+ return;
nameEnd = dst.length;
attr = parseFunctionTypeNoReturn( displayType );
is_sym_name_front = isSymbolNameFront(errStatus);
if (errStatus)
- return error();
+ return;
} while (is_sym_name_front);
if ( displayType )
@@ -2142,8 +2133,8 @@ pure @safe:
popFront(); // has 'this' pointer
auto lastlen = dst.length;
- auto type = parseType();
- if (this.hasErrors)
+ auto type = parseType(errStatus);
+ if (errStatus)
return;
if ( displayType )
@@ -2176,9 +2167,9 @@ pure @safe:
} while ( true );
}
- void parseMangledName() nothrow
+ void parseMangledName(out bool errStatus) nothrow
{
- parseMangledName(AddType.yes == addType);
+ parseMangledName(errStatus, AddType.yes == addType);
}
char[] doDemangle(alias FUNC)() return scope nothrow
@@ -2187,8 +2178,9 @@ pure @safe:
{
debug(info) printf( "demangle(%.*s)\n", cast(int) buf.length, buf.ptr );
- FUNC();
- if (!this.hasErrors)
+ bool errStatus;
+ FUNC(errStatus);
+ if (!errStatus)
{
return dst[0 .. $].getSlice;
}
@@ -2387,9 +2379,8 @@ char[] reencodeMangled(return scope const(char)[] mangled) nothrow pure @safe
return true;
}
- char[] parseType(ref Remangle d, char[] name) return scope nothrow
+ char[] parseType( out bool errStatus, ref Remangle d, char[] name ) return scope nothrow
{
- bool errStatus;
if (d.front != 'Q')
return null;
@@ -2400,7 +2391,8 @@ char[] reencodeMangled(return scope const(char)[] mangled) nothrow pure @safe
auto n = d.decodeBackref();
if (n == 0 || n > refPos)
{
- d.error("invalid back reference");
+ // invalid back reference
+ errStatus = true;
return null;
}
@@ -2436,7 +2428,7 @@ char[] reencodeMangled(return scope const(char)[] mangled) nothrow pure @safe
bool errStatus;
d.parseMangledName(errStatus);
- if (d.hasErrors)
+ if (errStatus)
{
// error cannot occur
return mangled.dup;
diff --git a/libphobos/libdruntime/core/internal/atomic.d b/libphobos/libdruntime/core/internal/atomic.d
index 03d1c01..6242d76 100644
--- a/libphobos/libdruntime/core/internal/atomic.d
+++ b/libphobos/libdruntime/core/internal/atomic.d
@@ -609,7 +609,7 @@ else version (GNU)
import gcc.builtins;
import gcc.config;
- enum IsAtomicLockFree(T) = __atomic_is_lock_free(T.sizeof, null);
+ enum IsAtomicLockFree(T) = __traits(compiles, { enum E = __atomic_is_lock_free(T.sizeof, null); });
inout(T) atomicLoad(MemoryOrder order = MemoryOrder.seq, T)(inout(T)* src) pure nothrow @nogc @trusted
if (CanCAS!T)
diff --git a/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d b/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d
index 73fe087..56433b4 100644
--- a/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d
+++ b/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d
@@ -4941,6 +4941,7 @@ unittest
// improve predictability of coverage of code that is eventually not hit by other tests
debug (SENTINEL) {} else // cannot extend with SENTINEL
debug (MARK_PRINTF) {} else // takes forever
+version (OnlyLowMemUnittests) {} else
unittest
{
import core.memory;
@@ -4988,24 +4989,34 @@ version (D_LP64) unittest
{
// only run if the system has enough physical memory
size_t sz = 2L^^32;
- //import core.stdc.stdio;
- //printf("availphys = %lld", os_physical_mem(true));
- if (os_physical_mem(true) > sz)
+ size_t phys_mem = os_physical_mem(true);
+ if (phys_mem > sz)
{
import core.memory;
+ import core.exception;
GC.collect();
GC.minimize();
- auto stats = GC.stats();
- auto ptr = GC.malloc(sz, BlkAttr.NO_SCAN);
- auto info = GC.query(ptr);
- //printf("info.size = %lld", info.size);
- assert(info.size >= sz);
- GC.free(ptr);
- GC.minimize();
- auto nstats = GC.stats();
- assert(nstats.usedSize == stats.usedSize);
- assert(nstats.freeSize == stats.freeSize);
- assert(nstats.allocatedInCurrentThread - sz == stats.allocatedInCurrentThread);
+ try
+ {
+ auto stats = GC.stats();
+ auto ptr = GC.malloc(sz, BlkAttr.NO_SCAN);
+ auto info = GC.query(ptr);
+ //printf("info.size = %lld", info.size);
+ assert(info.size >= sz);
+ GC.free(ptr);
+ GC.minimize();
+ auto nstats = GC.stats();
+ assert(nstats.usedSize == stats.usedSize);
+ assert(nstats.freeSize == stats.freeSize);
+ assert(nstats.allocatedInCurrentThread - sz == stats.allocatedInCurrentThread);
+ }
+ catch (OutOfMemoryError)
+ {
+ // ignore if the system still doesn't have enough virtual memory
+ import core.stdc.stdio;
+ printf("%s(%d): out-of-memory execption ignored, phys_mem = %zd",
+ __FILE__.ptr, __LINE__, phys_mem);
+ }
}
}
}
diff --git a/libphobos/libdruntime/core/internal/qsort.d b/libphobos/libdruntime/core/internal/qsort.d
index ad8307a..ada914c 100644
--- a/libphobos/libdruntime/core/internal/qsort.d
+++ b/libphobos/libdruntime/core/internal/qsort.d
@@ -132,6 +132,7 @@ else
unittest
{
+ debug(qsort) import core.stdc.stdio;
debug(qsort) printf("array.sort.unittest()\n");
int[] a = new int[10];
@@ -151,8 +152,8 @@ unittest
for (int i = 0; i < a.length - 1; i++)
{
- //printf("i = %d", i);
- //printf(" %d %d\n", a[i], a[i + 1]);
+ debug(qsort) printf("i = %d", i);
+ debug(qsort) printf(" %d %d\n", a[i], a[i + 1]);
assert(a[i] <= a[i + 1]);
}
}
diff --git a/libphobos/libdruntime/core/memory.d b/libphobos/libdruntime/core/memory.d
index f2a48f9..239d23f 100644
--- a/libphobos/libdruntime/core/memory.d
+++ b/libphobos/libdruntime/core/memory.d
@@ -575,6 +575,7 @@ extern(C):
// https://issues.dlang.org/show_bug.cgi?id=13111
///
+ version (OnlyLowMemUnittests) {} else // Test needs a lot of RAM
unittest
{
enum size1 = 1 << 11 + 1; // page in large object pool
diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index 9390243..295ca52 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -2103,6 +2103,8 @@ private extern (D) void resume(ThreadBase _t) nothrow @nogc
t.m_curr.tstack = t.m_curr.bstack;
}
}
+ else
+ static assert(false, "Platform not supported.");
}
diff --git a/libphobos/libdruntime/core/time.d b/libphobos/libdruntime/core/time.d
index be941e2a..c3192fc 100644
--- a/libphobos/libdruntime/core/time.d
+++ b/libphobos/libdruntime/core/time.d
@@ -2584,6 +2584,8 @@ extern(C) void _d_initMonoTime() @nogc nothrow
}
}
}
+ else
+ static assert(0, "Unsupported platform");
}
@@ -2883,6 +2885,8 @@ deprecated:
else
ticksPerSec = 1_000_000;
}
+ else
+ static assert(0, "Unsupported platform");
if (ticksPerSec != 0)
appOrigin = TickDuration.currSystemTick;
diff --git a/libphobos/libdruntime/rt/aaA.d b/libphobos/libdruntime/rt/aaA.d
index 36f2555..5903d9c 100644
--- a/libphobos/libdruntime/rt/aaA.d
+++ b/libphobos/libdruntime/rt/aaA.d
@@ -437,6 +437,7 @@ unittest
string[412] names;
ubyte[1024] moredata;
}
+ version (OnlyLowMemUnittests) {} else
test!(Large, Large);
}
diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d
index 8ce2d56..4a071f3 100644
--- a/libphobos/libdruntime/rt/lifetime.d
+++ b/libphobos/libdruntime/rt/lifetime.d
@@ -2247,6 +2247,7 @@ unittest
assert(GC.getAttr(p) == BlkAttr.NO_SCAN);
}
test(16);
+ version (OnlyLowMemUnittests) {} else
test(1024 * 1024);
}