gcc/libphobos/testsuite/libphobos.allocations/tls_gc_integration.d

51 lines
972 B
D
Raw Permalink Normal View History

d: Merge upstream dmd 46133f761, druntime 0fd4364c D front-end changes: - Backported built-in function handling from upstream. - Added new intrinsic `byteswap(ushort)`. Druntime changes: - Update intrinsic modules core.bitop, core.checkedint, core.simd, core.vararg, and core.volatile. - Backport platform-specific fixes for runtime modules core.cpuid, core.internal.traits, and rt.lifetime. - Backport openbsd fixes for core.stdc.stdio. - Backport solaris fixes for core.sys.posix.locale, and core.thread.osthread (PR98910). gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 46133f761. * d-builtins.cc (d_build_builtins_module): Set builtins as BUILTINgcc. (maybe_set_builtin_1): Likewise. * d-frontend.cc (eval_builtin): Adjust condition for early return. * intrinsics.cc (maybe_set_intrinsic): Set intrinsics as BUILTINgcc. (maybe_expand_intrinsic): Add case for INTRINSIC_BSWAP16. * intrinsics.def (INTRINSIC_BT): Update signature. (INTRINSIC_BT64): Likewise. (INTRINSIC_BSWAP16): New intrinsic. (INTRINSIC_VLOAD8): Update module. (INTRINSIC_VLOAD16): Likewise. (INTRINSIC_VLOAD32): Likewise. (INTRINSIC_VLOAD64): Likewise. (INTRINSIC_VSTORE8): Likewise. (INTRINSIC_VSTORE16): Likewise. (INTRINSIC_VSTORE32): Likewise. (INTRINSIC_VSTORE64): Likewise. (INTRINSIC_ADDS): Update signature. (INTRINSIC_ADDSL): Likewise. (INTRINSIC_ADDU): Likewise. (INTRINSIC_ADDUL): Likewise. (INTRINSIC_SUBS): Likewise. (INTRINSIC_SUBSL): Likewise. (INTRINSIC_SUBU): Likewise. (INTRINSIC_SUBUL): Likewise. (INTRINSIC_MULS): Likewise. (INTRINSIC_MULSL): Likewise. (INTRINSIC_MULU): Likewise. (INTRINSIC_MULUI): Likewise. (INTRINSIC_MULUL): Likewise. (INTRINSIC_NEGS): Likewise. (INTRINSIC_NEGSL): Likewise. libphobos/ChangeLog: PR d/98910 * libdruntime/MERGE: Merge upstream druntime 0fd4364c. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/volatile.d. * libdruntime/Makefile.in: Regenerate. * testsuite/libphobos.allocations/tls_gc_integration.d: Update test. gcc/testsuite/ChangeLog: * gdc.dg/intrinsics.d: Update test.
2021-02-04 22:34:22 +01:00
import core.memory, core.thread, core.volatile;
/*
* This test repeatedly performs operations on GC-allocated objects which
* are only reachable from TLS storage. Tests are performed in multiple threads
* and GC collections are triggered repeatedly, so if the GC does not properly
* scan TLS memory, this provokes a crash.
*/
class TestTLS
{
uint a;
void addNumber()
{
auto val = volatileLoad(&a);
val++;
volatileStore(&a, val);
}
}
TestTLS tlsPtr;
static this()
{
tlsPtr = new TestTLS();
}
void main()
{
void runThread()
{
for (size_t i = 0; i < 100; i++)
{
Thread.sleep(10.msecs);
tlsPtr.addNumber();
GC.collect();
}
}
Thread[] threads;
for (size_t i = 0; i < 20; i++)
{
auto t = new Thread(&runThread);
threads ~= t;
t.start();
}
runThread();
foreach (thread; threads)
thread.join();
}