d: Merge upstream dmd 934df6f8c, druntime 7bdd83d7

Corrects a previous change made to the SPARC stdc bindings, and
backports PPC-related fixes.  The library and language testsuite now
passes fully on powerpc64le-linux-gnu.

Fixes: PR d/90719
Fixes: PR d/94825

Reviewed-on: https://github.com/dlang/dmd/pull/11079
	     https://github.com/dlang/druntime/pull/3078
	     https://github.com/dlang/druntime/pull/3083

libphobos/ChangeLog:

	PR d/94825
	* libdruntime/Makefile.am (DRUNTIME_SOURCES_CONFIGURED): Remove
	config/powerpc/switchcontext.S
	* libdruntime/Makefile.in: Regenerate.
	* libdruntime/config/powerpc/callwithstack.S: Remove.
	* libdruntime/config/powerpc/switchcontext.S: Fix symbol name of
	fiber_switchContext.
	* libdruntime/core/thread.d: Disable fiber migration tests on PPC.
	* testsuite/libphobos.thread/fiber_guard_page.d: Set guardPageSize
	same as stackSize.
This commit is contained in:
Iain Buclaw 2020-04-30 11:03:33 +02:00
parent e33a1eae25
commit 05b6520ed2
14 changed files with 109 additions and 278 deletions

View File

@ -1,4 +1,4 @@
06160ccaed7af7955d169024f417c43beb7a8f9f
934df6f8cf848071dd0312098975f0c13873e01c
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.

View File

@ -1,3 +1,4 @@
// RUNNABLE_PHOBOS_TEST
import std.math;
extern(C) int printf(const char*, ...);

View File

@ -1,3 +1,4 @@
// RUNNABLE_PHOBOS_TEST
// PERMUTE_ARGS:
int magicVariable()

View File

@ -1,3 +1,4 @@
// RUNNABLE_PHOBOS_TEST
// original post to the D newsgroup:
// http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=D&artnum=10554&header
// Test to manipulate 3D vectors, in D!

View File

@ -1,3 +1,4 @@
// RUNNABLE_PHOBOS_TEST
// PERMUTE_ARGS:
extern(C) int printf(const char*, ...);

View File

@ -1,4 +1,4 @@
476882795473a884f837bea6da850ac5181868d1
7bdd83d7b4bd9fd4cb9ffca0d50babc90b31bfd6
The first line of this file holds the git revision number of the last
merge done from the dlang/druntime repository.

View File

@ -81,8 +81,7 @@ if DRUNTIME_CPU_MIPS
DRUNTIME_SOURCES_CONFIGURED += config/mips/switchcontext.S
endif
if DRUNTIME_CPU_POWERPC
DRUNTIME_SOURCES_CONFIGURED += config/powerpc/callwithstack.S \
config/powerpc/switchcontext.S
DRUNTIME_SOURCES_CONFIGURED += config/powerpc/switchcontext.S
endif
if DRUNTIME_CPU_X86
if DRUNTIME_OS_MINGW

View File

@ -123,9 +123,7 @@ target_triplet = @target@
@DRUNTIME_CPU_AARCH64_TRUE@am__append_11 = config/aarch64/switchcontext.S
@DRUNTIME_CPU_ARM_TRUE@am__append_12 = config/arm/switchcontext.S
@DRUNTIME_CPU_MIPS_TRUE@am__append_13 = config/mips/switchcontext.S
@DRUNTIME_CPU_POWERPC_TRUE@am__append_14 = config/powerpc/callwithstack.S \
@DRUNTIME_CPU_POWERPC_TRUE@ config/powerpc/switchcontext.S
@DRUNTIME_CPU_POWERPC_TRUE@am__append_14 = config/powerpc/switchcontext.S
@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__append_15 = config/mingw/switchcontext.S
@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__append_16 = config/x86/switchcontext.S
@DRUNTIME_CPU_SYSTEMZ_TRUE@am__append_17 = config/systemz/get_tls_offset.S
@ -441,8 +439,7 @@ am__objects_21 = core/sys/solaris/dlfcn.lo core/sys/solaris/elf.lo \
@DRUNTIME_CPU_AARCH64_TRUE@am__objects_23 = config/aarch64/libgdruntime_la-switchcontext.lo
@DRUNTIME_CPU_ARM_TRUE@am__objects_24 = config/arm/libgdruntime_la-switchcontext.lo
@DRUNTIME_CPU_MIPS_TRUE@am__objects_25 = config/mips/libgdruntime_la-switchcontext.lo
@DRUNTIME_CPU_POWERPC_TRUE@am__objects_26 = config/powerpc/libgdruntime_la-callwithstack.lo \
@DRUNTIME_CPU_POWERPC_TRUE@ config/powerpc/libgdruntime_la-switchcontext.lo
@DRUNTIME_CPU_POWERPC_TRUE@am__objects_26 = config/powerpc/libgdruntime_la-switchcontext.lo
@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_27 = config/mingw/libgdruntime_la-switchcontext.lo
@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_28 = config/x86/libgdruntime_la-switchcontext.lo
@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_29 = config/systemz/libgdruntime_la-get_tls_offset.lo
@ -463,8 +460,7 @@ am__objects_34 = core/stdc/libgdruntime_convenience_la-errno_.lo
@DRUNTIME_CPU_AARCH64_TRUE@am__objects_35 = config/aarch64/libgdruntime_convenience_la-switchcontext.lo
@DRUNTIME_CPU_ARM_TRUE@am__objects_36 = config/arm/libgdruntime_convenience_la-switchcontext.lo
@DRUNTIME_CPU_MIPS_TRUE@am__objects_37 = config/mips/libgdruntime_convenience_la-switchcontext.lo
@DRUNTIME_CPU_POWERPC_TRUE@am__objects_38 = config/powerpc/libgdruntime_convenience_la-callwithstack.lo \
@DRUNTIME_CPU_POWERPC_TRUE@ config/powerpc/libgdruntime_convenience_la-switchcontext.lo
@DRUNTIME_CPU_POWERPC_TRUE@am__objects_38 = config/powerpc/libgdruntime_convenience_la-switchcontext.lo
@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_39 = config/mingw/libgdruntime_convenience_la-switchcontext.lo
@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_40 = config/x86/libgdruntime_convenience_la-switchcontext.lo
@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_41 = config/systemz/libgdruntime_convenience_la-get_tls_offset.lo
@ -1748,8 +1744,6 @@ config/mips/libgdruntime_la-switchcontext.lo: \
config/powerpc/$(am__dirstamp):
@$(MKDIR_P) config/powerpc
@: > config/powerpc/$(am__dirstamp)
config/powerpc/libgdruntime_la-callwithstack.lo: \
config/powerpc/$(am__dirstamp)
config/powerpc/libgdruntime_la-switchcontext.lo: \
config/powerpc/$(am__dirstamp)
config/mingw/$(am__dirstamp):
@ -1785,8 +1779,6 @@ config/arm/libgdruntime_convenience_la-switchcontext.lo: \
config/arm/$(am__dirstamp)
config/mips/libgdruntime_convenience_la-switchcontext.lo: \
config/mips/$(am__dirstamp)
config/powerpc/libgdruntime_convenience_la-callwithstack.lo: \
config/powerpc/$(am__dirstamp)
config/powerpc/libgdruntime_convenience_la-switchcontext.lo: \
config/powerpc/$(am__dirstamp)
config/mingw/libgdruntime_convenience_la-switchcontext.lo: \
@ -1921,9 +1913,6 @@ config/arm/libgdruntime_la-switchcontext.lo: config/arm/switchcontext.S
config/mips/libgdruntime_la-switchcontext.lo: config/mips/switchcontext.S
$(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(libgdruntime_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o config/mips/libgdruntime_la-switchcontext.lo `test -f 'config/mips/switchcontext.S' || echo '$(srcdir)/'`config/mips/switchcontext.S
config/powerpc/libgdruntime_la-callwithstack.lo: config/powerpc/callwithstack.S
$(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(libgdruntime_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o config/powerpc/libgdruntime_la-callwithstack.lo `test -f 'config/powerpc/callwithstack.S' || echo '$(srcdir)/'`config/powerpc/callwithstack.S
config/powerpc/libgdruntime_la-switchcontext.lo: config/powerpc/switchcontext.S
$(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(libgdruntime_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o config/powerpc/libgdruntime_la-switchcontext.lo `test -f 'config/powerpc/switchcontext.S' || echo '$(srcdir)/'`config/powerpc/switchcontext.S
@ -1948,9 +1937,6 @@ config/arm/libgdruntime_convenience_la-switchcontext.lo: config/arm/switchcontex
config/mips/libgdruntime_convenience_la-switchcontext.lo: config/mips/switchcontext.S
$(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(libgdruntime_convenience_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o config/mips/libgdruntime_convenience_la-switchcontext.lo `test -f 'config/mips/switchcontext.S' || echo '$(srcdir)/'`config/mips/switchcontext.S
config/powerpc/libgdruntime_convenience_la-callwithstack.lo: config/powerpc/callwithstack.S
$(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(libgdruntime_convenience_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o config/powerpc/libgdruntime_convenience_la-callwithstack.lo `test -f 'config/powerpc/callwithstack.S' || echo '$(srcdir)/'`config/powerpc/callwithstack.S
config/powerpc/libgdruntime_convenience_la-switchcontext.lo: config/powerpc/switchcontext.S
$(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) $(libgdruntime_convenience_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o config/powerpc/libgdruntime_convenience_la-switchcontext.lo `test -f 'config/powerpc/switchcontext.S' || echo '$(srcdir)/'`config/powerpc/switchcontext.S

View File

@ -1,172 +0,0 @@
/* PowerPC64 support code for fibers and multithreading.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#include "../common/threadasm.S"
#if defined(__PPC64__)
#if defined(_CALL_ELF) && _CALL_ELF == 2
#define USE_ABI_2
#define LINKAGE_SZ 32
#define LR_OFS 16
#define TOC_OFS 24
#define GPR_OFS 32
#define STACK_SZ (LINKAGE_SZ + 26*8)
#define OFS_R3_R10 GPR_OFS
#define OFS_R14_R31 (GPR_OFS+8*8)
#else
#define LINKAGE_SZ 48
#define LR_OFS 16
#define TOC_OFS 40
#define GPR_OFS 112
#define STACK_SZ (LINKAGE_SZ + 8*8 + 18*8)
#define OFS_R3_R10 (STACK_SZ+LINKAGE_SZ)
#define OFS_R14_R31 GPR_OFS
#endif
.text
#if defined( USE_ABI_2 )
.abiversion 2
#endif
.globl _D4core6thread18callWithStackShellFNbMDFNbPvZvZv
.align 2
.type _D4core6thread18callWithStackShellFNbMDFNbPvZvZv,@function
#if defined( USE_ABI_2 )
.section .text._D4core6thread18callWithStackShellFNbMDFNbPvZvZv,"a",@progbits
#else
.section .opd,"aw",@progbits
#endif
_D4core6thread18callWithStackShellFNbMDFNbPvZvZv:
#if !defined( USE_ABI_2 )
.align 3
.quad .L._D4core6thread18callWithStackShellFNbMDFNbPvZvZv
.quad .TOC.@tocbase
.quad 0
#endif
.text
/*
* Called with:
* r3: pointer context
* r4: pointer to function
*/
.L._D4core6thread18callWithStackShellFNbMDFNbPvZvZv:
.cfi_startproc
stdu 1, -STACK_SZ(1)
mflr 0
std 0, LR_OFS(1)
.cfi_def_cfa_offset 256
.cfi_offset lr, 16
/* Save r14-r31 in general register save area */
std 14, (OFS_R14_R31 + 0 * 8)(1)
std 15, (OFS_R14_R31 + 1 * 8)(1)
std 16, (OFS_R14_R31 + 2 * 8)(1)
std 17, (OFS_R14_R31 + 3 * 8)(1)
std 18, (OFS_R14_R31 + 4 * 8)(1)
std 19, (OFS_R14_R31 + 5 * 8)(1)
std 20, (OFS_R14_R31 + 6 * 8)(1)
std 21, (OFS_R14_R31 + 7 * 8)(1)
std 22, (OFS_R14_R31 + 8 * 8)(1)
std 23, (OFS_R14_R31 + 9 * 8)(1)
std 24, (OFS_R14_R31 + 10 * 8)(1)
std 25, (OFS_R14_R31 + 11 * 8)(1)
std 26, (OFS_R14_R31 + 12 * 8)(1)
std 27, (OFS_R14_R31 + 13 * 8)(1)
std 28, (OFS_R14_R31 + 14 * 8)(1)
std 29, (OFS_R14_R31 + 15 * 8)(1)
std 30, (OFS_R14_R31 + 16 * 8)(1)
std 31, (OFS_R14_R31 + 17 * 8)(1)
/* Save r3-r10 in parameter save area of caller */
std 3, (OFS_R3_R10 + 0 * 8)(1)
std 4, (OFS_R3_R10 + 1 * 8)(1)
std 5, (OFS_R3_R10 + 2 * 8)(1)
std 6, (OFS_R3_R10 + 3 * 8)(1)
std 7, (OFS_R3_R10 + 4 * 8)(1)
std 8, (OFS_R3_R10 + 5 * 8)(1)
std 9, (OFS_R3_R10 + 6 * 8)(1)
std 10, (OFS_R3_R10 + 7 * 8)(1)
/* Save r2 in TOC save area */
std 2, TOC_OFS(1)
/* Do not save r11, r12 and r13. */
/* Call delegate:
* r3: pointer to context
* r4: pointer to stack
*/
mr 5, 4
mr 4, 1
ld 6, 0(5)
ld 11, 16(5)
ld 2, 8(5)
mtctr 6
bctrl
nop
/* Restore r2 from TOC save area */
ld 2, TOC_OFS(1)
/* Restore r3-r10 from local variable space */
ld 3, (OFS_R3_R10 + 0 * 8)(1)
ld 4, (OFS_R3_R10 + 1 * 8)(1)
ld 5, (OFS_R3_R10 + 2 * 8)(1)
ld 6, (OFS_R3_R10 + 3 * 8)(1)
ld 7, (OFS_R3_R10 + 4 * 8)(1)
ld 8, (OFS_R3_R10 + 5 * 8)(1)
ld 9, (OFS_R3_R10 + 6 * 8)(1)
ld 10, (OFS_R3_R10 + 7 * 8)(1)
/* Restore r14-r31 from general register save area */
ld 14, (OFS_R14_R31 + 0 * 8)(1)
ld 15, (OFS_R14_R31 + 1 * 8)(1)
ld 16, (OFS_R14_R31 + 2 * 8)(1)
ld 17, (OFS_R14_R31 + 3 * 8)(1)
ld 18, (OFS_R14_R31 + 4 * 8)(1)
ld 19, (OFS_R14_R31 + 5 * 8)(1)
ld 20, (OFS_R14_R31 + 6 * 8)(1)
ld 21, (OFS_R14_R31 + 7 * 8)(1)
ld 22, (OFS_R14_R31 + 8 * 8)(1)
ld 23, (OFS_R14_R31 + 9 * 8)(1)
ld 24, (OFS_R14_R31 + 10 * 8)(1)
ld 25, (OFS_R14_R31 + 11 * 8)(1)
ld 26, (OFS_R14_R31 + 12 * 8)(1)
ld 27, (OFS_R14_R31 + 13 * 8)(1)
ld 28, (OFS_R14_R31 + 14 * 8)(1)
ld 29, (OFS_R14_R31 + 15 * 8)(1)
ld 30, (OFS_R14_R31 + 16 * 8)(1)
ld 31, (OFS_R14_R31 + 17 * 8)(1)
ld 0, LR_OFS(1)
mtlr 0
addi 1, 1, STACK_SZ
blr
.long 0
.quad 0
.Lend:
.size _D4core6thread18callWithStackShellFNbMDFNbPvZvZv, .Lend-.L._D4core6thread18callWithStackShellFNbMDFNbPvZvZv
.cfi_endproc
#endif /* defined(__PPC64__) */

View File

@ -34,10 +34,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
*
*/
.text
.globl CSYM(_fiber_switchContext)
.type CSYM(_fiber_switchContext), @function
.globl CSYM(fiber_switchContext)
.type CSYM(fiber_switchContext), @function
.align 2
CSYM(_fiber_switchContext):
CSYM(fiber_switchContext):
.cfi_startproc
/* Save linkage area */
mflr 0
@ -149,6 +149,6 @@ CSYM(_fiber_switchContext):
/* Return and switch context */
blr
.cfi_endproc
.size CSYM(_fiber_switchContext),.-CSYM(_fiber_switchContext)
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
#endif /* !defined(__PPC64__) */

View File

@ -84,7 +84,10 @@ const(ubyte)[] toUbyte(T)(const ref T val) if (is(Unqual!T == float) || is(Unqua
ubyte[] buff = ctfe_alloc(T.sizeof);
enum msbSize = double.sizeof;
double hi = toPrec!double(val);
static if (is(Unqual!T == ireal))
double hi = toPrec!double(val.im);
else
double hi = toPrec!double(val);
buff[0 .. msbSize] = toUbyte(hi)[];
if (val is cast(T)0.0 || val is cast(T)-0.0 ||
@ -98,7 +101,10 @@ const(ubyte)[] toUbyte(T)(const ref T val) if (is(Unqual!T == float) || is(Unqua
}
else
{
double low = toPrec!double(val - hi);
static if (is(Unqual!T == ireal))
double low = toPrec!double(val.im - hi);
else
double low = toPrec!double(val - hi);
buff[msbSize .. $] = toUbyte(low)[];
}

View File

@ -1391,6 +1391,7 @@ else version (Solaris)
dev_t st_rdev;
c_long[2] st_pad2;
off_t st_size;
c_long st_pad3;
union
{
timestruc_t st_atim;
@ -1424,7 +1425,6 @@ else version (Solaris)
dev_t st_rdev;
c_long[2] st_pad2;
off64_t st_size;
c_long st_pad3;
union
{
timestruc_t st_atim;

View File

@ -2407,93 +2407,84 @@ shared static ~this()
// Used for needLock below.
private __gshared bool multiThreadedFlag = false;
version (PPC64) version = ExternStackShell;
version (ExternStackShell)
// Calls the given delegate, passing the current thread's stack pointer to it.
private void callWithStackShell(scope void delegate(void* sp) nothrow fn) nothrow
in
{
extern(D) public void callWithStackShell(scope void delegate(void* sp) nothrow fn) nothrow;
assert(fn);
}
else
body
{
// Calls the given delegate, passing the current thread's stack pointer to it.
private void callWithStackShell(scope void delegate(void* sp) nothrow fn) nothrow
in
// The purpose of the 'shell' is to ensure all the registers get
// put on the stack so they'll be scanned. We only need to push
// the callee-save registers.
void *sp = void;
version (GNU)
{
assert(fn);
__builtin_unwind_init();
sp = &sp;
}
body
else version (AsmX86_Posix)
{
// The purpose of the 'shell' is to ensure all the registers get
// put on the stack so they'll be scanned. We only need to push
// the callee-save registers.
void *sp = void;
version (GNU)
size_t[3] regs = void;
asm pure nothrow @nogc
{
__builtin_unwind_init();
sp = &sp;
}
else version (AsmX86_Posix)
{
size_t[3] regs = void;
asm pure nothrow @nogc
{
mov [regs + 0 * 4], EBX;
mov [regs + 1 * 4], ESI;
mov [regs + 2 * 4], EDI;
mov [regs + 0 * 4], EBX;
mov [regs + 1 * 4], ESI;
mov [regs + 2 * 4], EDI;
mov sp[EBP], ESP;
}
mov sp[EBP], ESP;
}
else version (AsmX86_Windows)
{
size_t[3] regs = void;
asm pure nothrow @nogc
{
mov [regs + 0 * 4], EBX;
mov [regs + 1 * 4], ESI;
mov [regs + 2 * 4], EDI;
mov sp[EBP], ESP;
}
}
else version (AsmX86_64_Posix)
{
size_t[5] regs = void;
asm pure nothrow @nogc
{
mov [regs + 0 * 8], RBX;
mov [regs + 1 * 8], R12;
mov [regs + 2 * 8], R13;
mov [regs + 3 * 8], R14;
mov [regs + 4 * 8], R15;
mov sp[RBP], RSP;
}
}
else version (AsmX86_64_Windows)
{
size_t[7] regs = void;
asm pure nothrow @nogc
{
mov [regs + 0 * 8], RBX;
mov [regs + 1 * 8], RSI;
mov [regs + 2 * 8], RDI;
mov [regs + 3 * 8], R12;
mov [regs + 4 * 8], R13;
mov [regs + 5 * 8], R14;
mov [regs + 6 * 8], R15;
mov sp[RBP], RSP;
}
}
else
{
static assert(false, "Architecture not supported.");
}
fn(sp);
}
else version (AsmX86_Windows)
{
size_t[3] regs = void;
asm pure nothrow @nogc
{
mov [regs + 0 * 4], EBX;
mov [regs + 1 * 4], ESI;
mov [regs + 2 * 4], EDI;
mov sp[EBP], ESP;
}
}
else version (AsmX86_64_Posix)
{
size_t[5] regs = void;
asm pure nothrow @nogc
{
mov [regs + 0 * 8], RBX;
mov [regs + 1 * 8], R12;
mov [regs + 2 * 8], R13;
mov [regs + 3 * 8], R14;
mov [regs + 4 * 8], R15;
mov sp[RBP], RSP;
}
}
else version (AsmX86_64_Windows)
{
size_t[7] regs = void;
asm pure nothrow @nogc
{
mov [regs + 0 * 8], RBX;
mov [regs + 1 * 8], RSI;
mov [regs + 2 * 8], RDI;
mov [regs + 3 * 8], R12;
mov [regs + 4 * 8], R13;
mov [regs + 5 * 8], R14;
mov [regs + 6 * 8], R15;
mov sp[RBP], RSP;
}
}
else
{
static assert(false, "Architecture not supported.");
}
fn(sp);
}
// Used for suspendAll/resumeAll below.
@ -5287,6 +5278,23 @@ unittest
// Multiple threads running shared fibers
version (PPC) version = UnsafeFiberMigration;
version (PPC64) version = UnsafeFiberMigration;
version (UnsafeFiberMigration)
{
// XBUG: core.thread fibers are supposed to be safe to migrate across
// threads, however, there is a problem: GCC always assumes that the
// address of thread-local variables don't change while on a given stack.
// In consequence, migrating fibers between threads currently is an unsafe
// thing to do, and will break on some targets (possibly PR26461).
}
else
{
version = FiberMigrationUnittest;
}
version (FiberMigrationUnittest)
unittest
{
shared bool[10] locks;

View File

@ -18,7 +18,7 @@ void stackMethod()
void main()
{
auto test_fiber = new Fiber(&stackMethod, stackSize);
auto test_fiber = new Fiber(&stackMethod, stackSize, stackSize);
// allocate a page below (above) the fiber's stack to make stack overflows possible (w/o segfaulting)
version (StackGrowsDown)