aboutsummaryrefslogtreecommitdiff
path: root/libphobos/libdruntime/rt
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2023-03-29 09:01:23 -0700
committerIan Lance Taylor <iant@golang.org>2023-03-29 09:01:23 -0700
commit6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced (patch)
tree1deecdcfbf185c7044bc861d0ace51285c96cb62 /libphobos/libdruntime/rt
parent795cffe109e28b248a54b8ee583cbae48368c2a7 (diff)
parentaa8f4242efc99f24de73c59d53996f28db28c13f (diff)
downloadgcc-6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced.zip
gcc-6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced.tar.gz
gcc-6612f4f8cb9b0d5af18ec69ad04e56debc3e6ced.tar.bz2
Merge from trunk revision aa8f4242efc99f24de73c59d53996f28db28c13f.
Diffstat (limited to 'libphobos/libdruntime/rt')
-rw-r--r--libphobos/libdruntime/rt/arrayassign.d60
-rw-r--r--libphobos/libdruntime/rt/deh.d2
-rw-r--r--libphobos/libdruntime/rt/dmain2.d12
-rw-r--r--libphobos/libdruntime/rt/lifetime.d60
4 files changed, 12 insertions, 122 deletions
diff --git a/libphobos/libdruntime/rt/arrayassign.d b/libphobos/libdruntime/rt/arrayassign.d
deleted file mode 100644
index c9e2b15..0000000
--- 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/deh.d b/libphobos/libdruntime/rt/deh.d
index 695f2ce..0a44be3 100644
--- a/libphobos/libdruntime/rt/deh.d
+++ b/libphobos/libdruntime/rt/deh.d
@@ -42,12 +42,14 @@ module rt.deh;
extern (C)
{
Throwable.TraceInfo _d_traceContext(void* ptr = null);
+ Throwable.TraceDeallocator rt_getTraceDeallocator();
void _d_createTrace(Throwable t, void* context)
{
if (t !is null && t.info is null &&
cast(byte*) t !is typeid(t).initializer.ptr)
{
t.info = _d_traceContext(context);
+ t.infoDeallocator = rt_getTraceDeallocator();
}
}
}
diff --git a/libphobos/libdruntime/rt/dmain2.d b/libphobos/libdruntime/rt/dmain2.d
index 0739b74..8a10aac 100644
--- a/libphobos/libdruntime/rt/dmain2.d
+++ b/libphobos/libdruntime/rt/dmain2.d
@@ -182,6 +182,7 @@ extern (C) int rt_term()
*/
alias Throwable.TraceInfo function(void* ptr) TraceHandler;
private __gshared TraceHandler traceHandler = null;
+private __gshared Throwable.TraceDeallocator traceDeallocator = null;
/**
@@ -189,10 +190,12 @@ private __gshared TraceHandler traceHandler = null;
*
* Params:
* h = The new trace handler. Set to null to use the default handler.
+ * d = The new dealloactor to use.
*/
-extern (C) void rt_setTraceHandler(TraceHandler h)
+extern (C) void rt_setTraceHandler(TraceHandler h, Throwable.TraceDeallocator d = null)
{
traceHandler = h;
+ traceDeallocator = d;
}
/**
@@ -203,6 +206,11 @@ extern (C) TraceHandler rt_getTraceHandler()
return traceHandler;
}
+extern (C) Throwable.TraceDeallocator rt_getTraceDeallocator()
+{
+ return traceDeallocator;
+}
+
/**
* This function will be called when an exception is constructed. The
* user-supplied trace handler will be called if one has been supplied,
@@ -577,7 +585,7 @@ extern (C) void _d_print_throwable(Throwable t)
{
WCHAR* ptr; size_t len;
- void sink(const scope char[] s) scope nothrow
+ void sink(in char[] s) scope nothrow
{
if (!s.length) return;
int swlen = MultiByteToWideChar(
diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d
index 026001f..f2515c3 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);