aboutsummaryrefslogtreecommitdiff
path: root/libphobos/libdruntime
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-09-27 10:43:32 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2022-09-27 10:50:18 +0200
commitc8dfa79c9948ce09a7b4071f8059294b1972aef6 (patch)
treecb93655417a5475c6baac88691fc92621b3fa7ce /libphobos/libdruntime
parentbe4a6551ed37c1e7dbdfb9400fc2e2b5d40c5be2 (diff)
d: Merge upstream dmd d579c467c1, phobos 88aa69b14.
D front-end changes: - Throwing from contracts of `nothrow' functions has been deprecated, as this breaks the guarantees of `nothrow'. - Added language support for initializing the interior pointer of associative arrays using `new' keyword. Phobos changes: - The std.digest.digest module has been removed. - The std.xml module has been removed. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd d579c467c1. * decl.cc (layout_struct_initializer): Update for new front-end interface. * expr.cc (ExprVisitor::visit (AssignExp *)): Remove lowering of array assignments. (ExprVisitor::visit (NewExp *)): Add new lowering of new'ing associative arrays to an _aaNew() library call. * runtime.def (ARRAYSETASSIGN): Remove. (AANEW): Define. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime d579c467c1. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Remove rt/arrayassign.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 88aa69b14. * src/Makefile.am (PHOBOS_DSOURCES): Remove std/digest/digest.d, std/xml.d. * src/Makefile.in: Regenerate.
Diffstat (limited to 'libphobos/libdruntime')
-rw-r--r--libphobos/libdruntime/MERGE2
-rw-r--r--libphobos/libdruntime/Makefile.am10
-rw-r--r--libphobos/libdruntime/Makefile.in21
-rw-r--r--libphobos/libdruntime/__builtins.di2
-rw-r--r--libphobos/libdruntime/core/demangle.d250
-rw-r--r--libphobos/libdruntime/core/internal/array/arrayassign.d148
-rw-r--r--libphobos/libdruntime/core/internal/dassert.d2
-rw-r--r--libphobos/libdruntime/core/internal/utf.d21
-rw-r--r--libphobos/libdruntime/core/simd.d2
-rw-r--r--libphobos/libdruntime/core/stdc/fenv.d2
-rw-r--r--libphobos/libdruntime/core/stdc/math.d11
-rw-r--r--libphobos/libdruntime/core/sys/darwin/mach/loader.d2
-rw-r--r--libphobos/libdruntime/core/sys/linux/fcntl.d2
-rw-r--r--libphobos/libdruntime/core/sys/posix/dlfcn.d4
-rw-r--r--libphobos/libdruntime/core/sys/posix/mqueue.d4
-rw-r--r--libphobos/libdruntime/core/sys/posix/setjmp.d16
-rw-r--r--libphobos/libdruntime/core/sys/posix/stdlib.d20
-rw-r--r--libphobos/libdruntime/core/sys/posix/sys/types.d12
-rw-r--r--libphobos/libdruntime/core/sys/windows/stacktrace.d3
-rw-r--r--libphobos/libdruntime/core/time.d2
-rw-r--r--libphobos/libdruntime/object.d3
-rw-r--r--libphobos/libdruntime/rt/arrayassign.d60
-rw-r--r--libphobos/libdruntime/rt/lifetime.d60
23 files changed, 417 insertions, 242 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 85fc49d3d0a..a4c46f3306e 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-817610b16d0f0f469b9fbb28c000956fb910c43f
+4219ba670ce9ff92f3e874f0f048f2c28134c008
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/Makefile.am b/libphobos/libdruntime/Makefile.am
index d828749837a..45749d7ef10 100644
--- a/libphobos/libdruntime/Makefile.am
+++ b/libphobos/libdruntime/Makefile.am
@@ -211,11 +211,11 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
gcc/sections/package.d gcc/sections/pecoff.d gcc/simd.d \
gcc/unwind/arm.d gcc/unwind/arm_common.d gcc/unwind/c6x.d \
gcc/unwind/generic.d gcc/unwind/package.d gcc/unwind/pe.d object.d \
- rt/aApply.d rt/aApplyR.d rt/aaA.d rt/adi.d rt/arrayassign.d \
- rt/arraycat.d rt/cast_.d rt/config.d rt/critical_.d rt/deh.d \
- rt/dmain2.d rt/ehalloc.d rt/invariant.d rt/lifetime.d rt/memory.d \
- rt/minfo.d rt/monitor_.d rt/profilegc.d rt/sections.d rt/tlsgc.d \
- rt/util/typeinfo.d rt/util/utility.d
+ rt/aApply.d rt/aApplyR.d rt/aaA.d rt/adi.d rt/arraycat.d rt/cast_.d \
+ rt/config.d rt/critical_.d rt/deh.d rt/dmain2.d rt/ehalloc.d \
+ rt/invariant.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \
+ rt/profilegc.d rt/sections.d rt/tlsgc.d rt/util/typeinfo.d \
+ rt/util/utility.d
DRUNTIME_DSOURCES_STDCXX = core/stdcpp/allocator.d core/stdcpp/array.d \
core/stdcpp/exception.d core/stdcpp/memory.d core/stdcpp/new_.d \
diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in
index 57660eeed1a..e86721fb3fe 100644
--- a/libphobos/libdruntime/Makefile.in
+++ b/libphobos/libdruntime/Makefile.in
@@ -242,11 +242,11 @@ am__objects_1 = core/atomic.lo core/attribute.lo core/bitop.lo \
gcc/unwind/arm_common.lo gcc/unwind/c6x.lo \
gcc/unwind/generic.lo gcc/unwind/package.lo gcc/unwind/pe.lo \
object.lo rt/aApply.lo rt/aApplyR.lo rt/aaA.lo rt/adi.lo \
- rt/arrayassign.lo rt/arraycat.lo rt/cast_.lo rt/config.lo \
- rt/critical_.lo rt/deh.lo rt/dmain2.lo rt/ehalloc.lo \
- rt/invariant.lo rt/lifetime.lo rt/memory.lo rt/minfo.lo \
- rt/monitor_.lo rt/profilegc.lo rt/sections.lo rt/tlsgc.lo \
- rt/util/typeinfo.lo rt/util/utility.lo
+ rt/arraycat.lo rt/cast_.lo rt/config.lo rt/critical_.lo \
+ rt/deh.lo rt/dmain2.lo rt/ehalloc.lo rt/invariant.lo \
+ rt/lifetime.lo rt/memory.lo rt/minfo.lo rt/monitor_.lo \
+ rt/profilegc.lo rt/sections.lo rt/tlsgc.lo rt/util/typeinfo.lo \
+ rt/util/utility.lo
am__objects_2 = core/stdc/libgdruntime_la-errno_.lo
am__objects_3 = core/sys/elf/package.lo
am__objects_4 = core/stdcpp/allocator.lo core/stdcpp/array.lo \
@@ -880,11 +880,11 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
gcc/sections/package.d gcc/sections/pecoff.d gcc/simd.d \
gcc/unwind/arm.d gcc/unwind/arm_common.d gcc/unwind/c6x.d \
gcc/unwind/generic.d gcc/unwind/package.d gcc/unwind/pe.d object.d \
- rt/aApply.d rt/aApplyR.d rt/aaA.d rt/adi.d rt/arrayassign.d \
- rt/arraycat.d rt/cast_.d rt/config.d rt/critical_.d rt/deh.d \
- rt/dmain2.d rt/ehalloc.d rt/invariant.d rt/lifetime.d rt/memory.d \
- rt/minfo.d rt/monitor_.d rt/profilegc.d rt/sections.d rt/tlsgc.d \
- rt/util/typeinfo.d rt/util/utility.d
+ rt/aApply.d rt/aApplyR.d rt/aaA.d rt/adi.d rt/arraycat.d rt/cast_.d \
+ rt/config.d rt/critical_.d rt/deh.d rt/dmain2.d rt/ehalloc.d \
+ rt/invariant.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \
+ rt/profilegc.d rt/sections.d rt/tlsgc.d rt/util/typeinfo.d \
+ rt/util/utility.d
DRUNTIME_DSOURCES_STDCXX = core/stdcpp/allocator.d core/stdcpp/array.d \
core/stdcpp/exception.d core/stdcpp/memory.d core/stdcpp/new_.d \
@@ -1364,7 +1364,6 @@ rt/aApply.lo: rt/$(am__dirstamp)
rt/aApplyR.lo: rt/$(am__dirstamp)
rt/aaA.lo: rt/$(am__dirstamp)
rt/adi.lo: rt/$(am__dirstamp)
-rt/arrayassign.lo: rt/$(am__dirstamp)
rt/arraycat.lo: rt/$(am__dirstamp)
rt/cast_.lo: rt/$(am__dirstamp)
rt/config.lo: rt/$(am__dirstamp)
diff --git a/libphobos/libdruntime/__builtins.di b/libphobos/libdruntime/__builtins.di
index cf05333429e..1c490358904 100644
--- a/libphobos/libdruntime/__builtins.di
+++ b/libphobos/libdruntime/__builtins.di
@@ -15,7 +15,7 @@ module __builtins;
/* gcc relies on internal __builtin_xxxx functions and templates to
* accomplish <stdarg.h>. D does the same thing with templates in core.stdc.stdarg.
* Here, we redirect the gcc builtin declarations to the equivalent
- * ones in core.stdc.stdarg, thereby avoiding having to hardware them
+ * ones in core.stdc.stdarg, thereby avoiding having to hardwire them
* into the D compiler.
*/
diff --git a/libphobos/libdruntime/core/demangle.d b/libphobos/libdruntime/core/demangle.d
index ca87f902909..c2d40322961 100644
--- a/libphobos/libdruntime/core/demangle.d
+++ b/libphobos/libdruntime/core/demangle.d
@@ -82,7 +82,7 @@ pure @safe:
static class ParseException : Exception
{
- @safe pure nothrow this( string msg )
+ this(string msg) @safe pure nothrow
{
super( msg );
}
@@ -91,14 +91,14 @@ pure @safe:
static class OverflowException : Exception
{
- @safe pure nothrow this( string msg )
+ this(string msg) @safe pure nothrow
{
super( msg );
}
}
- static void error( string msg = "Invalid symbol" ) @trusted /* exception only used in module */
+ static noreturn error( string msg = "Invalid symbol" ) @trusted /* exception only used in module */
{
pragma(inline, false); // tame dmd inliner
@@ -110,7 +110,7 @@ pure @safe:
}
- static void overflow( string msg = "Buffer overflow" ) @trusted /* exception only used in module */
+ static noreturn overflow( string msg = "Buffer overflow" ) @trusted /* exception only used in module */
{
pragma(inline, false); // tame dmd inliner
@@ -156,7 +156,6 @@ pure @safe:
if (val >= '0' && val <= '9')
return cast(ubyte)(val - '0');
error();
- return 0;
}
@@ -253,23 +252,22 @@ pure @safe:
put(", ");
}
- char[] put(char c) return scope
+ void put(char c) return scope
{
char[1] val = c;
- return put(val[]);
+ put(val[]);
}
- char[] put( scope const(char)[] val ) return scope
+ void put(scope const(char)[] val) return scope
{
pragma(inline, false); // tame dmd inliner
- if ( val.length )
- {
- if ( !contains( dst[0 .. len], val ) )
- return append( val );
- return shift( val );
- }
- return null;
+ if (!val.length) return;
+
+ if (!contains(dst[0 .. len], val))
+ append(val);
+ else
+ shift(val);
}
@@ -948,18 +946,19 @@ pure @safe:
return dst[beg .. len];
case 'D': // TypeDelegate (D TypeFunction)
popFront();
- auto modbeg = len;
- parseModifier();
- auto modend = len;
+ auto modifiers = parseModifier();
if ( front == 'Q' )
parseBackrefType( () => parseTypeFunction( name, IsDelegate.yes ) );
else
parseTypeFunction( name, IsDelegate.yes );
- if (modend > modbeg)
+ if (modifiers)
{
- // move modifiers behind the function arguments
- shift(dst[modend-1 .. modend]); // trailing space
- shift(dst[modbeg .. modend-1]);
+ // write modifiers behind the function arguments
+ while (auto str = typeCtors.toStringConsume(modifiers))
+ {
+ put(' ');
+ put(str);
+ }
}
return dst[beg .. len];
case 'n': // TypeNone (n)
@@ -1009,7 +1008,6 @@ pure @safe:
}
}
error();
- return null;
}
}
@@ -1110,43 +1108,44 @@ pure @safe:
}
}
- void parseModifier()
+ /// Returns: Flags of `TypeCtor`
+ ushort parseModifier()
{
+ TypeCtor res = TypeCtor.None;
switch ( front )
{
case 'y':
popFront();
- put( "immutable " );
- break;
+ return TypeCtor.Immutable;
case 'O':
popFront();
- put( "shared " );
- if ( front == 'x' )
+ res |= TypeCtor.Shared;
+ if (front == 'x')
goto case 'x';
- if ( front == 'N' )
+ if (front == 'N')
goto case 'N';
- break;
+ return TypeCtor.Shared;
case 'N':
- if ( peek( 1 ) != 'g' )
- break;
+ if (peek( 1 ) != 'g')
+ return res;
popFront();
popFront();
- put( "inout " );
+ res |= TypeCtor.InOut;
if ( front == 'x' )
goto case 'x';
- break;
+ return res;
case 'x':
popFront();
- put( "const " );
- break;
- default: break;
+ res |= TypeCtor.Const;
+ return res;
+ default: return TypeCtor.None;
}
}
- void parseFuncAttr()
+ ushort parseFuncAttr()
{
// FuncAttrs
- breakFuncAttrs:
+ ushort result;
while ('N' == front)
{
popFront();
@@ -1154,27 +1153,27 @@ pure @safe:
{
case 'a': // FuncAttrPure
popFront();
- put( "pure " );
+ result |= FuncAttributes.Pure;
continue;
case 'b': // FuncAttrNoThrow
popFront();
- put( "nothrow " );
+ result |= FuncAttributes.Nothrow;
continue;
case 'c': // FuncAttrRef
popFront();
- put( "ref " );
+ result |= FuncAttributes.Ref;
continue;
case 'd': // FuncAttrProperty
popFront();
- put( "@property " );
+ result |= FuncAttributes.Property;
continue;
case 'e': // FuncAttrTrusted
popFront();
- put( "@trusted " );
+ result |= FuncAttributes.Trusted;
continue;
case 'f': // FuncAttrSafe
popFront();
- put( "@safe " );
+ result |= FuncAttributes.Safe;
continue;
case 'g':
case 'h':
@@ -1188,27 +1187,42 @@ pure @safe:
// if we see these, then we know we're really in
// the parameter list. Rewind and break.
pos--;
- break breakFuncAttrs;
+ return result;
case 'i': // FuncAttrNogc
popFront();
- put( "@nogc " );
+ result |= FuncAttributes.NoGC;
continue;
case 'j': // FuncAttrReturn
popFront();
- put( "return " );
+ if (this.peek(0) == 'N' && this.peek(1) == 'l')
+ {
+ result |= FuncAttributes.ReturnScope;
+ popFront();
+ popFront();
+ } else {
+ result |= FuncAttributes.Return;
+ }
continue;
case 'l': // FuncAttrScope
popFront();
- put( "scope " );
+ if (this.peek(0) == 'N' && this.peek(1) == 'j')
+ {
+ result |= FuncAttributes.ScopeReturn;
+ popFront();
+ popFront();
+ } else {
+ result |= FuncAttributes.Scope;
+ }
continue;
case 'm': // FuncAttrLive
popFront();
- put( "@live " );
+ result |= FuncAttributes.Live;
continue;
default:
error();
}
}
+ return result;
}
void parseFuncArguments() scope
@@ -1346,19 +1360,20 @@ pure @safe:
auto beg = len;
parseCallConvention();
- auto attrbeg = len;
- parseFuncAttr();
+ auto attributes = parseFuncAttr();
auto argbeg = len;
put( '(' );
parseFuncArguments();
put( ')' );
- if (attrbeg < argbeg)
+ if (attributes)
{
- // move function attributes behind arguments
- shift( dst[argbeg - 1 .. argbeg] ); // trailing space
- shift( dst[attrbeg .. argbeg - 1] ); // attributes
- argbeg = attrbeg;
+ // write function attributes behind arguments
+ while (auto str = funcAttrs.toStringConsume(attributes))
+ {
+ put(' ');
+ put(str);
+ }
}
auto retbeg = len;
parseType();
@@ -1900,21 +1915,26 @@ pure @safe:
{
// do not emit "needs this"
popFront();
- parseModifier();
+ auto modifiers = parseModifier();
+ while (auto str = typeCtors.toStringConsume(modifiers))
+ {
+ put(str);
+ put(' ');
+ }
}
if ( isCallConvention( front ) )
{
// we don't want calling convention and attributes in the qualified name
parseCallConvention();
- parseFuncAttr();
- if ( keepAttr )
- {
+ auto attributes = parseFuncAttr();
+ if (keepAttr) {
+ while (auto str = funcAttrs.toStringConsume(attributes))
+ {
+ put(str);
+ put(' ');
+ }
attr = dst[prevlen .. len];
}
- else
- {
- len = prevlen;
- }
put( '(' );
parseFuncArguments();
@@ -2637,6 +2657,12 @@ else
["_D4test4rrs1FNkMJPiZv", "void test.rrs1(return scope out int*)"],
["_D4test4rrs1FNkMKPiZv", "void test.rrs1(return scope ref int*)"],
["_D4test4rrs1FNkMPiZv", "void test.rrs1(return scope int*)"],
+
+ // `scope` and `return` combinations
+ ["_D3foo3Foo3barMNgFNjNlNfZNgPv", "inout return scope @safe inout(void*) foo.Foo.bar()"],
+ ["_D3foo3FooQiMNgFNlNfZv", "inout scope @safe void foo.Foo.foo()"],
+ ["_D3foo3Foo4foorMNgFNjNfZv", "inout return @safe void foo.Foo.foor()"],
+ ["_D3foo3Foo3rabMNgFNlNjNfZv", "inout scope return @safe void foo.Foo.rab()"],
];
@@ -2720,7 +2746,12 @@ unittest
}
/*
+ * Expand an OMF, DMD-generated compressed identifier into its full form
*
+ * This function only has a visible effect for OMF binaries (Win32),
+ * as compression is otherwise not used.
+ *
+ * See_Also: `compiler/src/dmd/backend/compress.d`
*/
string decodeDmdString( const(char)[] ln, ref size_t p ) nothrow pure @safe
{
@@ -2781,3 +2812,92 @@ extern (C) private
errno = err;
}
}
+
+private struct ManglingFlagInfo
+{
+ /// The flag value to use
+ ushort flag;
+
+ /// Human-readable representation
+ string value;
+}
+
+private enum TypeCtor : ushort {
+ None = 0,
+ //// 'x'
+ Const = (1 << 1),
+ /// 'y'
+ Immutable = (1 << 2),
+ /// 'O'
+ Shared = (1 << 3),
+ ///
+ InOut = (1 << 4),
+}
+
+private immutable ManglingFlagInfo[] typeCtors = [
+ ManglingFlagInfo(TypeCtor.Immutable, "immutable"),
+ ManglingFlagInfo(TypeCtor.Shared, "shared"),
+ ManglingFlagInfo(TypeCtor.InOut, "inout"),
+ ManglingFlagInfo(TypeCtor.Const, "const"),
+];
+
+private enum FuncAttributes : ushort {
+ None = 0,
+ //// 'a'
+ Pure = (1 << 1),
+ //// 'b'
+ Nothrow = (1 << 2),
+ //// 'c'
+ Ref = (1 << 3),
+ //// 'd'
+ Property = (1 << 4),
+ //// 'e'
+ Trusted = (1 << 5),
+ //// 'f'
+ Safe = (1 << 6),
+ //// 'i'
+ NoGC = (1 << 7),
+ //// 'j'
+ Return = (1 << 8),
+ //// 'l'
+ Scope = (1 << 9),
+ //// 'm'
+ Live = (1 << 10),
+
+ /// Their order matter
+ ReturnScope = (1 << 11),
+ ScopeReturn = (1 << 12),
+}
+
+// The order in which we process is the same as in compiler/dmd/src/dmangle.d
+private immutable ManglingFlagInfo[] funcAttrs = [
+ ManglingFlagInfo(FuncAttributes.Pure, "pure"),
+ ManglingFlagInfo(FuncAttributes.Nothrow, "nothrow"),
+ ManglingFlagInfo(FuncAttributes.Ref, "ref"),
+ ManglingFlagInfo(FuncAttributes.Property, "@property"),
+ ManglingFlagInfo(FuncAttributes.NoGC, "@nogc"),
+
+ ManglingFlagInfo(FuncAttributes.ReturnScope, "return scope"),
+ ManglingFlagInfo(FuncAttributes.ScopeReturn, "scope return"),
+
+ ManglingFlagInfo(FuncAttributes.Return, "return"),
+ ManglingFlagInfo(FuncAttributes.Scope, "scope"),
+
+ ManglingFlagInfo(FuncAttributes.Live, "@live"),
+ ManglingFlagInfo(FuncAttributes.Trusted, "@trusted"),
+ ManglingFlagInfo(FuncAttributes.Safe, "@safe"),
+];
+
+private string toStringConsume (immutable ManglingFlagInfo[] infos, ref ushort base)
+ @safe pure nothrow @nogc
+{
+ foreach (const ref info; infos)
+ {
+ if ((base & info.flag) == info.flag)
+ {
+ base &= ~info.flag;
+ return info.value;
+ }
+ }
+ return null;
+}
diff --git a/libphobos/libdruntime/core/internal/array/arrayassign.d b/libphobos/libdruntime/core/internal/array/arrayassign.d
index 6132e68db1a..6e3c1fdc3ef 100644
--- a/libphobos/libdruntime/core/internal/array/arrayassign.d
+++ b/libphobos/libdruntime/core/internal/array/arrayassign.d
@@ -302,3 +302,151 @@ Tarr _d_arrayassign_r(Tarr : T[], T)(return scope Tarr to, scope Tarr from) @tru
assert(!didThrow);
assert(counter == 0);
}
+
+/**
+ * Sets all elements of an array to a single value. Takes into account postblits,
+ * copy constructors and destructors. For Plain Old Data elements,`rt/memset.d`
+ * is used.
+ *
+ * ---
+ * struct S
+ * {
+ * ~this() {} // destructor, so not Plain Old Data
+ * }
+ *
+ * void main()
+ * {
+ * S[3] arr;
+ * S value;
+ *
+ * arr = value;
+ * // Generates:
+ * // _d_arraysetassign(arr[], value), arr;
+ * }
+ * ---
+ *
+ * Params:
+ * to = destination array
+ * value = the element to set
+ * Returns:
+ * `to`
+ */
+Tarr _d_arraysetassign(Tarr : T[], T)(return scope Tarr to, scope ref T value) @trusted
+{
+ import core.internal.traits : Unqual;
+ import core.lifetime : copyEmplace;
+ import core.stdc.string : memcpy;
+
+ enum elemSize = T.sizeof;
+ void[elemSize] tmp = void;
+
+ foreach (ref dst; to)
+ {
+ memcpy(&tmp, cast(void*) &dst, elemSize);
+ // Use `memcpy` if `T` has a `@disable`d postblit.
+ static if (__traits(isCopyable, T))
+ copyEmplace(value, dst);
+ else
+ memcpy(cast(void*) &value, cast(void*) &dst, elemSize);
+ auto elem = cast(Unqual!T*) &tmp;
+ destroy(*elem);
+ }
+
+ return to;
+}
+
+// postblit and destructor
+@safe unittest
+{
+ string ops;
+ struct S
+ {
+ int val;
+ this(this) { ops ~= "="; }
+ ~this() { ops ~= "~"; }
+ }
+
+ S[4] arr;
+ S s = S(1234);
+ _d_arraysetassign(arr[], s);
+ assert(ops == "=~=~=~=~");
+ assert(arr == [S(1234), S(1234), S(1234), S(1234)]);
+}
+
+// copy constructor
+@safe unittest
+{
+ string ops;
+ struct S
+ {
+ int val;
+ this(const scope ref S rhs)
+ {
+ val = rhs.val;
+ ops ~= "=";
+ }
+ ~this() { ops ~= "~"; }
+ }
+
+ S[4] arr;
+ S s = S(1234);
+ _d_arraysetassign(arr[], s);
+ assert(ops == "=~=~=~=~");
+ assert(arr == [S(1234), S(1234), S(1234), S(1234)]);
+}
+
+// throwing and `nothrow`
+@safe nothrow unittest
+{
+ // Test that throwing works
+ bool didThrow;
+ int counter;
+ struct Throw
+ {
+ int val;
+ this(this)
+ {
+ counter++;
+ if (counter == 2)
+ throw new Exception("Oh no.");
+ }
+ }
+
+ try
+ {
+ Throw[4] a;
+ Throw b = Throw(1);
+ _d_arraysetassign(a[], b);
+ }
+ catch (Exception)
+ {
+ didThrow = true;
+ }
+ assert(didThrow);
+ assert(counter == 2);
+
+ // Test that `nothrow` works
+ didThrow = false;
+ counter = 0;
+ struct NoThrow
+ {
+ int val;
+ this(this) { counter++; }
+ }
+
+ try
+ {
+ NoThrow[4] a;
+ NoThrow b = NoThrow(1);
+ _d_arraysetassign(a[], b);
+ foreach (ref e; a)
+ assert(e == NoThrow(1));
+ }
+ catch (Exception)
+ {
+ didThrow = true;
+ }
+ assert(!didThrow);
+ // The array `a` is destroyed when the `try` block ends.
+ assert(counter == 4);
+}
diff --git a/libphobos/libdruntime/core/internal/dassert.d b/libphobos/libdruntime/core/internal/dassert.d
index 07486c216f0..dbad0e6064f 100644
--- a/libphobos/libdruntime/core/internal/dassert.d
+++ b/libphobos/libdruntime/core/internal/dassert.d
@@ -518,7 +518,7 @@ private auto assumeFakeAttributes(T)(T t) @trusted
}
/// Wrapper for `miniFormat` which assumes that the implementation is `@safe`, `@nogc`, ...
-/// s.t. it does not violate the constraints of the the function containing the `assert`.
+/// s.t. it does not violate the constraints of the function containing the `assert`.
private string miniFormatFakeAttributes(T)(const scope ref T t)
{
alias miniT = miniFormat!T;
diff --git a/libphobos/libdruntime/core/internal/utf.d b/libphobos/libdruntime/core/internal/utf.d
index 27bf7f2b905..9808b9947f5 100644
--- a/libphobos/libdruntime/core/internal/utf.d
+++ b/libphobos/libdruntime/core/internal/utf.d
@@ -567,17 +567,22 @@ ubyte codeLength(C)(dchar c)
/***********************************
Checks to see if string is well formed or not. $(D S) can be an array
- of $(D char), $(D wchar), or $(D dchar). Throws a $(D UtfException)
- if it is not. Use to check all untrusted input for correctness.
+ of $(D char), $(D wchar), or $(D dchar). Returns $(D false) if it is not.
+ Use to check all untrusted input for correctness.
*/
-@safe pure
-void validate(S)(const scope S s)
+@safe pure nothrow
+bool isValidString(S)(const scope S s)
{
auto len = s.length;
for (size_t i = 0; i < len; )
{
- decode(s, i);
+ try
+ decode(s, i);
+ catch (Exception e)
+ return false;
}
+
+ return true;
}
/* =================== Conversion to UTF8 ======================= */
@@ -626,7 +631,7 @@ char[] toUTF8(return scope char[] buf, dchar c)
string toUTF8(return scope string s)
in
{
- validate(s);
+ assert(isValidString(s));
}
do
{
@@ -787,7 +792,7 @@ wptr toUTF16z(const scope char[] s)
wstring toUTF16(return scope wstring s)
in
{
- validate(s);
+ assert(isValidString(s));
}
do
{
@@ -867,7 +872,7 @@ dstring toUTF32(const scope wchar[] s)
dstring toUTF32(return scope dstring s)
in
{
- validate(s);
+ assert(isValidString(s));
}
do
{
diff --git a/libphobos/libdruntime/core/simd.d b/libphobos/libdruntime/core/simd.d
index f1bf59b0ac4..c2b343a0847 100644
--- a/libphobos/libdruntime/core/simd.d
+++ b/libphobos/libdruntime/core/simd.d
@@ -704,7 +704,7 @@ version (D_SIMD)
// store `v` to location pointed to by `d`
storeUnaligned(cast(T*)d, v);
- // check that the the data was stored correctly
+ // check that the data was stored correctly
foreach (j; 0..T.sizeof)
{
assert(ptrToV[j] == d[j]);
diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d
index 88123fb16a6..5242ba9d4e2 100644
--- a/libphobos/libdruntime/core/stdc/fenv.d
+++ b/libphobos/libdruntime/core/stdc/fenv.d
@@ -483,7 +483,7 @@ else version (CRuntime_UClibc)
alias fexcept_t = ushort;
}
- else version (MIPS32)
+ else version (MIPS_Any)
{
struct fenv_t
{
diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d
index 0393ea52c07..2666c952992 100644
--- a/libphobos/libdruntime/core/stdc/math.d
+++ b/libphobos/libdruntime/core/stdc/math.d
@@ -106,21 +106,14 @@ else version (CRuntime_Bionic)
}
else version (CRuntime_UClibc)
{
- version (X86)
- {
- ///
- enum int FP_ILOGB0 = int.min;
- ///
- enum int FP_ILOGBNAN = int.min;
- }
- else version (X86_64)
+ version (X86_Any)
{
///
enum int FP_ILOGB0 = int.min;
///
enum int FP_ILOGBNAN = int.min;
}
- else version (MIPS32)
+ else version (MIPS_Any)
{
///
enum int FP_ILOGB0 = -int.max;
diff --git a/libphobos/libdruntime/core/sys/darwin/mach/loader.d b/libphobos/libdruntime/core/sys/darwin/mach/loader.d
index f46698c3b53..7713eea9785 100644
--- a/libphobos/libdruntime/core/sys/darwin/mach/loader.d
+++ b/libphobos/libdruntime/core/sys/darwin/mach/loader.d
@@ -1803,7 +1803,7 @@ version (CoreDdoc)
* image. The isub_image field is an index into the sub-images
* (sub-frameworks and sub-umbrellas list) that made up the two-level image
* that the undefined symbol was found in when it was built by the static
- * link editor. If isub-image is 0 the the symbol is expected to be defined
+ * link editor. If isub-image is 0 the symbol is expected to be defined
* in library and not in the sub-images. If isub-image is non-zero it is an
* index into the array of sub-images for the umbrella with the first index
* in the sub-images being 1. The array of sub-images is the ordered list of
diff --git a/libphobos/libdruntime/core/sys/linux/fcntl.d b/libphobos/libdruntime/core/sys/linux/fcntl.d
index 11c374530bf..89dc019cc8f 100644
--- a/libphobos/libdruntime/core/sys/linux/fcntl.d
+++ b/libphobos/libdruntime/core/sys/linux/fcntl.d
@@ -42,7 +42,7 @@ These cmd values will set locks that conflict with process-associated
record locks, but are "owned" by the open file description, not the
process. This means that they are inherited across fork() like BSD (flock)
locks, and they are only released automatically when the last reference to
-the the open file against which they were acquired is put.
+the open file against which they were acquired is put.
*/
enum
diff --git a/libphobos/libdruntime/core/sys/posix/dlfcn.d b/libphobos/libdruntime/core/sys/posix/dlfcn.d
index a9519ca234a..04a8e8bb866 100644
--- a/libphobos/libdruntime/core/sys/posix/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/posix/dlfcn.d
@@ -377,7 +377,7 @@ else version (CRuntime_Musl)
}
else version (CRuntime_UClibc)
{
- version (X86_64)
+ version (X86_Any)
{
enum RTLD_LAZY = 0x0001;
enum RTLD_NOW = 0x0002;
@@ -387,7 +387,7 @@ else version (CRuntime_UClibc)
enum RTLD_LOCAL = 0;
enum RTLD_NODELETE = 0x01000;
}
- else version (MIPS32)
+ else version (MIPS_Any)
{
enum RTLD_LAZY = 0x0001;
enum RTLD_NOW = 0x0002;
diff --git a/libphobos/libdruntime/core/sys/posix/mqueue.d b/libphobos/libdruntime/core/sys/posix/mqueue.d
index 2f1a8c69ad6..7085fc4dfa5 100644
--- a/libphobos/libdruntime/core/sys/posix/mqueue.d
+++ b/libphobos/libdruntime/core/sys/posix/mqueue.d
@@ -147,7 +147,7 @@ int mq_notify (mqd_t mqdes, const(sigevent)* notification);
/**
- * Receive the oldest message with the highest priority the the message queue
+ * Receive the oldest message with the highest priority the message queue
*
* Params:
* mqdes = Message queue descriptor.
@@ -164,7 +164,7 @@ ssize_t mq_receive (mqd_t mqdes, char* msg_ptr, size_t msg_len, uint* msg_prio);
/**
- * Receive the oldest message with the highest priority the the message queue,
+ * Receive the oldest message with the highest priority the message queue,
* wait up to a certain timeout.
*
* Params:
diff --git a/libphobos/libdruntime/core/sys/posix/setjmp.d b/libphobos/libdruntime/core/sys/posix/setjmp.d
index 91e3a19d081..5a15d82d2ee 100644
--- a/libphobos/libdruntime/core/sys/posix/setjmp.d
+++ b/libphobos/libdruntime/core/sys/posix/setjmp.d
@@ -370,6 +370,22 @@ else version (CRuntime_UClibc)
double[6] __fpregs;
}
}
+ else version (MIPS64)
+ {
+ struct __jmp_buf
+ {
+ long __pc;
+ long __sp;
+ long[8] __regs;
+ long __fp;
+ long __gp;
+ int __fpc_csr;
+ version (MIPS_N64)
+ double[8] __fpregs;
+ else
+ double[6] __fpregs;
+ }
+ }
else
static assert(0, "unimplemented");
diff --git a/libphobos/libdruntime/core/sys/posix/stdlib.d b/libphobos/libdruntime/core/sys/posix/stdlib.d
index 4c10d4e0ed5..df96a3d3371 100644
--- a/libphobos/libdruntime/core/sys/posix/stdlib.d
+++ b/libphobos/libdruntime/core/sys/posix/stdlib.d
@@ -95,44 +95,44 @@ int posix_memalign(void**, size_t, size_t);
version (CRuntime_Glibc)
{
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
else version (FreeBSD)
{
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
else version (NetBSD)
{
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
else version (OpenBSD)
{
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
else version (DragonFlyBSD)
{
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
else version (Solaris)
{
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
else version (Darwin)
{
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
else version (CRuntime_Bionic)
{
// Added since Lollipop
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
else version (CRuntime_Musl)
{
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
else version (CRuntime_UClibc)
{
- int posix_memalign(void**, size_t, size_t);
+ int posix_memalign(scope void**, size_t, size_t) pure;
}
//
diff --git a/libphobos/libdruntime/core/sys/posix/sys/types.d b/libphobos/libdruntime/core/sys/posix/sys/types.d
index ec229dd3b2b..3e515c4c68e 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/types.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/types.d
@@ -1140,6 +1140,18 @@ else version (CRuntime_UClibc)
enum __SIZEOF_PTHREAD_BARRIER_T = 20;
enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
}
+ else version (MIPS64)
+ {
+ enum __SIZEOF_PTHREAD_ATTR_T = 56;
+ enum __SIZEOF_PTHREAD_MUTEX_T = 40;
+ enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+ enum __SIZEOF_PTHREAD_COND_T = 48;
+ enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+ enum __SIZEOF_PTHREAD_RWLOCK_T = 56;
+ enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+ enum __SIZEOF_PTHREAD_BARRIER_T = 32;
+ enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+ }
else version (ARM)
{
enum __SIZEOF_PTHREAD_ATTR_T = 36;
diff --git a/libphobos/libdruntime/core/sys/windows/stacktrace.d b/libphobos/libdruntime/core/sys/windows/stacktrace.d
index 2922e54ebae..798208597b1 100644
--- a/libphobos/libdruntime/core/sys/windows/stacktrace.d
+++ b/libphobos/libdruntime/core/sys/windows/stacktrace.d
@@ -288,7 +288,8 @@ private:
auto res = formatStackFrame(pc);
res ~= " in ";
const(char)[] tempSymName = symName[0 .. strlen(symName)];
- //Deal with dmd mangling of long names
+ // Deal with dmd mangling of long names for OMF 32 bits builds
+ // Note that `target.d` only defines `CRuntime_DigitalMars` for OMF builds
version (CRuntime_DigitalMars)
{
size_t decodeIndex = 0;
diff --git a/libphobos/libdruntime/core/time.d b/libphobos/libdruntime/core/time.d
index 9b8391e7207..ea163a0958a 100644
--- a/libphobos/libdruntime/core/time.d
+++ b/libphobos/libdruntime/core/time.d
@@ -3362,7 +3362,7 @@ struct TickDuration
$(D gettimeofday) (the decision is made when $(D TickDuration) is
compiled), which unfortunately, is not monotonic, but if
$(D mach_absolute_time) and $(D clock_gettime) aren't available, then
- $(D gettimeofday) is the the best that there is.
+ $(D gettimeofday) is the best that there is.
$(RED Warning):
On some systems, the monotonic clock may stop counting when
diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d
index d842499b8db..83351f26038 100644
--- a/libphobos/libdruntime/object.d
+++ b/libphobos/libdruntime/object.d
@@ -2700,7 +2700,7 @@ class Exception : Throwable
* Creates a new instance of Exception. The nextInChain parameter is used
* internally and should always be $(D null) when passed by user code.
* This constructor does not automatically throw the newly-created
- * Exception; the $(D throw) statement should be used for that purpose.
+ * Exception; the $(D throw) expression should be used for that purpose.
*/
@nogc @safe pure nothrow this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable nextInChain = null)
{
@@ -4617,6 +4617,7 @@ public import core.internal.array.construction : _d_arrayctor;
public import core.internal.array.construction : _d_arraysetctor;
public import core.internal.array.arrayassign : _d_arrayassign_l;
public import core.internal.array.arrayassign : _d_arrayassign_r;
+public import core.internal.array.arrayassign : _d_arraysetassign;
public import core.internal.array.capacity: _d_arraysetlengthTImpl;
public import core.internal.dassert: _d_assert_fail;
diff --git a/libphobos/libdruntime/rt/arrayassign.d b/libphobos/libdruntime/rt/arrayassign.d
deleted file mode 100644
index c9e2b15025f..00000000000
--- a/libphobos/libdruntime/rt/arrayassign.d
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Implementation of array assignment support routines.
- *
- *
- * Copyright: Copyright Digital Mars 2010 - 2016.
- * License: Distributed under the
- * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
- * Authors: Walter Bright, Kenji Hara
- * Source: $(DRUNTIMESRC rt/_arrayassign.d)
- */
-
-module rt.arrayassign;
-
-private
-{
- import core.internal.util.array;
- import core.stdc.string;
- import core.stdc.stdlib;
- debug(PRINTF) import core.stdc.stdio;
-}
-
-/**
-Set all elements of an array to a single value.
-
----
-p[0 .. count] = value;
----
-
-Takes into account postblits and destructors, for Plain Old Data elements,
-`rt/memset.d` is used.
-
-Params:
- p = pointer to start of array
- value = bytes of the element to set. Size is derived from `ti`.
- count = amount of array elements to set
- ti = type info of the array element type / `value`
-Returns: `p`
-*/
-extern (C) void* _d_arraysetassign(void* p, void* value, int count, TypeInfo ti)
-{
- void* pstart = p;
-
- auto element_size = ti.tsize;
-
- // Need a temporary buffer tmp[] big enough to hold one element
- immutable maxAllocaSize = 512;
- void *ptmp = (element_size > maxAllocaSize) ? malloc(element_size) : alloca(element_size);
-
- foreach (i; 0 .. count)
- {
- memcpy(ptmp, p, element_size);
- memcpy(p, value, element_size);
- ti.postblit(p);
- ti.destroy(ptmp);
- p += element_size;
- }
- if (element_size > maxAllocaSize)
- free(ptmp);
- return pstart;
-}
diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d
index 026001f5ad7..f2515c3c677 100644
--- a/libphobos/libdruntime/rt/lifetime.d
+++ b/libphobos/libdruntime/rt/lifetime.d
@@ -1232,61 +1232,6 @@ debug(PRINTF)
/**
*
*/
-extern (C) void _d_delarray_t(void[]* p, const TypeInfo_Struct ti) @weak
-{
- if (p)
- {
- auto bic = __getBlkInfo(p.ptr);
- auto info = bic ? *bic : GC.query(p.ptr);
-
- if (info.base && (info.attr & BlkAttr.APPENDABLE))
- {
- if (ti) // ti non-null only if ti is a struct with dtor
- {
- void* start = __arrayStart(info);
- size_t length = __arrayAllocLength(info, ti);
- finalize_array(start, length, ti);
- }
-
- // if p is in the cache, clear it there as well
- if (bic)
- bic.base = null;
-
- GC.free(info.base);
- *p = null;
- }
- }
-}
-
-deprecated unittest
-{
- __gshared size_t countDtor = 0;
- struct S
- {
- int x;
- ~this() { countDtor++; }
- }
- // destroy large array with x.ptr not base address of allocation
- auto x = new S[10000];
- void* p = x.ptr;
- assert(GC.addrOf(p) != null);
- _d_delarray_t(cast(void[]*)&x, typeid(typeof(x[0]))); // delete x;
- assert(GC.addrOf(p) == null);
- assert(countDtor == 10000);
-
- // destroy full array even if only slice passed
- auto y = new S[400];
- auto z = y[200 .. 300];
- p = z.ptr;
- assert(GC.addrOf(p) != null);
- _d_delarray_t(cast(void[]*)&z, typeid(typeof(z[0]))); // delete z;
- assert(GC.addrOf(p) == null);
- assert(countDtor == 10000 + 400);
-}
-
-/**
- *
- */
extern (C) void _d_delmemory(void* *p) @weak
{
if (*p)
@@ -2755,11 +2700,6 @@ deprecated unittest
}
dtorCount = 0;
- S1[] arr1 = new S1[7];
- _d_delarray_t(cast(void[]*)&arr1, typeid(typeof(arr1[0]))); // delete arr1;
- assert(dtorCount == 7);
-
- dtorCount = 0;
S1* s2 = new S1;
GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
assert(dtorCount == 1);