Skip to content

Commit ef9732f

Browse files
committed
Runtime swapContext type detection removed
1 parent b458335 commit ef9732f

3 files changed

Lines changed: 14 additions & 52 deletions

File tree

druntime/src/core/thread/osthread.d

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,6 @@ version (GNU)
6565
import gcc.builtins;
6666
}
6767

68-
/**
69-
* Hook for whatever EH implementation is used to save/restore some data
70-
* per stack.
71-
*
72-
* Params:
73-
* newContext = The return value of the prior call to this function
74-
* where the stack was last swapped out, or null when a fiber stack
75-
* is switched in for the first time.
76-
*/
77-
package extern(C) void* _d_eh_swapContext(void* newContext) nothrow @nogc;
78-
7968
extern(D) void* swapContext(void* newContext) nothrow @nogc => swapContextImpl(newContext);
8069

8170
/**

druntime/src/core/thread/posix_impl.d

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -112,48 +112,10 @@ version (GNU)
112112
import gcc.builtins;
113113
}
114114

115-
version (DigitalMars)
115+
private extern(C) void* _d_eh_swapContextDwarf(void* newContext) nothrow @nogc;
116+
package void* swapContextImpl(void* newContext) nothrow @nogc
116117
{
117-
extern(C) void* _d_eh_swapContextDwarf(void* newContext) nothrow @nogc;
118-
119-
package void* swapContextImpl(void* newContext) nothrow @nogc
120-
{
121-
/* Detect at runtime which scheme is being used.
122-
* Eventually, determine it statically.
123-
*/
124-
static int which = 0;
125-
final switch (which)
126-
{
127-
case 0:
128-
{
129-
assert(newContext == null);
130-
auto p = _d_eh_swapContext(newContext);
131-
auto pdwarf = _d_eh_swapContextDwarf(newContext);
132-
if (p)
133-
{
134-
which = 1;
135-
return p;
136-
}
137-
else if (pdwarf)
138-
{
139-
which = 2;
140-
return pdwarf;
141-
}
142-
return null;
143-
}
144-
case 1:
145-
return _d_eh_swapContext(newContext);
146-
case 2:
147-
return _d_eh_swapContextDwarf(newContext);
148-
}
149-
}
150-
}
151-
else
152-
{
153-
package void* swapContextImpl(void* newContext) nothrow @nogc
154-
{
155-
return _d_eh_swapContext(newContext);
156-
}
118+
return _d_eh_swapContextDwarf(newContext);
157119
}
158120

159121
version (WASI)

druntime/src/core/thread/windows_impl.d

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ version (GNU)
4747
import gcc.builtins;
4848
}
4949

50+
/**
51+
* Hook for whatever EH implementation is used to save/restore some data
52+
* per stack.
53+
*
54+
* Params:
55+
* newContext = The return value of the prior call to this function
56+
* where the stack was last swapped out, or null when a fiber stack
57+
* is switched in for the first time.
58+
*/
59+
private extern(C) void* _d_eh_swapContext(void* newContext) nothrow @nogc;
60+
5061
package void* swapContextImpl()(void* newContext) nothrow @nogc
5162
{
5263
return _d_eh_swapContext(newContext);

0 commit comments

Comments
 (0)