Skip to content

Commit b3b9a25

Browse files
More fixes
1 parent c512f0b commit b3b9a25

File tree

13 files changed

+191
-12
lines changed

13 files changed

+191
-12
lines changed

.github/workflows/bflat-cicd.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
- os: windows
4242
arch: arm64
4343
vm: windows-latest
44+
- os: windows
45+
arch: x86
46+
vm: windows-latest
4447
runs-on: ${{ matrix.vm }}
4548
name: Build and test ${{ matrix.os }} ${{ matrix.arch }}
4649
container: ${{ matrix.container }}
@@ -202,6 +205,16 @@ jobs:
202205
asset_name: bflat-refs.zip
203206
asset_content_type: application/zip
204207

208+
- name: Upload native compiler (windows-x86)
209+
uses: actions/upload-release-asset@v1
210+
env:
211+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
212+
with:
213+
upload_url: ${{ steps.create_release.outputs.upload_url }}
214+
asset_path: native-compiler-windows-x86/bflat-compiler-native-windows-x86.zip
215+
asset_name: bflat-compiler-native-windows-x86.zip
216+
asset_content_type: application/zip
217+
205218
- name: Upload native compiler (windows-x64)
206219
uses: actions/upload-release-asset@v1
207220
env:
@@ -222,6 +235,16 @@ jobs:
222235
asset_name: bflat-compiler-native-linux-glibc-x64.zip
223236
asset_content_type: application/zip
224237

238+
- name: Upload libs (windows-x86)
239+
uses: actions/upload-release-asset@v1
240+
env:
241+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
242+
with:
243+
upload_url: ${{ steps.create_release.outputs.upload_url }}
244+
asset_path: libs-windows-x86/bflat-libs-windows-x86.zip
245+
asset_name: bflat-libs-windows-x86.zip
246+
asset_content_type: application/zip
247+
225248
- name: Upload libs (windows-x64)
226249
uses: actions/upload-release-asset@v1
227250
env:

src/coreclr/nativeaot/Shcrt/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ set(SOURCES
66
nocrt.cpp
77
)
88

9-
add_library(shcrt STATIC ${SOURCES})
9+
set(ASM_SOURCES
10+
${ARCH_SOURCES_DIR}/chkstk.asm
11+
)
12+
13+
convert_to_absolute_path(ASM_SOURCES ${ASM_SOURCES})
14+
preprocess_files(ASM_SOURCES ${ASM_SOURCES})
15+
16+
add_library(shcrt STATIC ${SOURCES} ${ASM_SOURCES})
1017

1118
install_static_library(shcrt aotsdk nativeaot)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.code
2+
3+
__chkstk proc
4+
5+
sub rsp,10h
6+
mov qword ptr [rsp],r10
7+
mov qword ptr [rsp+8],r11
8+
xor r11,r11
9+
lea r10,[rsp+18h]
10+
sub r10,rax
11+
cmovb r10,r11
12+
mov r11,qword ptr gs:[0000000000000010h]
13+
cmp r10,r11
14+
jae cs20
15+
and r10w,0F000h
16+
cs10:
17+
lea r11,[r11-1000h]
18+
mov byte ptr [r11],0
19+
cmp r10,r11
20+
jne cs10
21+
cs20:
22+
mov r10,qword ptr [rsp]
23+
mov r11,qword ptr [rsp+8]
24+
add rsp,10h
25+
ret
26+
27+
__chkstk endp
28+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <ksarm64.h>
2+
3+
TEXTAREA
4+
5+
LEAF_ENTRY chkstk, _TEXT
6+
7+
ldr xip1,[xpr,#0x10]
8+
subs xip0,sp,x15,lsl #4
9+
csello xip0,xzr,xip0
10+
cmp xip0,xip1
11+
blo LOC0
12+
ret
13+
LOC0
14+
and xip0,xip0,#-0x1000
15+
LOC1
16+
sub xip1,xip1,#1,lsl #0xC
17+
ldr xzr,[xip1]
18+
cmp xip1,xip0
19+
bne LOC1
20+
ret
21+
22+
LEAF_END chkstk
23+
24+
END
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.386
2+
.model flat
3+
.code
4+
5+
__chkstk proc
6+
7+
push ecx
8+
lea ecx,[esp+4]
9+
sub ecx,eax
10+
sbb eax,eax
11+
not eax
12+
and ecx,eax
13+
mov eax,esp
14+
and eax,0FFFFF000h
15+
cs10:
16+
cmp ecx,eax
17+
jb cs20
18+
mov eax,ecx
19+
pop ecx
20+
xchg eax,esp
21+
mov eax,dword ptr [eax]
22+
mov dword ptr [esp],eax
23+
ret
24+
cs20:
25+
sub eax,1000h
26+
test dword ptr [eax],eax
27+
jmp cs10
28+
29+
__chkstk endp
30+
end

src/coreclr/nativeaot/Shcrt/nocrt.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ namespace std {
1111
const std::nothrow_t nothrow = std::nothrow_t(); // define nothrow
1212
}
1313

14-
void* operator new[](size_t const size, std::nothrow_t const& x) noexcept
14+
void* __CRTDECL operator new[](size_t const size, std::nothrow_t const& x) noexcept
1515
{
1616
return malloc(size);
1717
}
1818

19-
void* operator new(size_t const size, std::nothrow_t const& x) noexcept
19+
void* __CRTDECL operator new(size_t const size, std::nothrow_t const& x) noexcept
2020
{
2121
return malloc(size);
2222
}
2323

24-
void operator delete[](void* const block) noexcept
24+
void __CRTDECL operator delete[](void* const block) noexcept
2525
{
2626
free(block);
2727
}
2828

2929

30-
void operator delete(void* const block, size_t const) noexcept
30+
void __CRTDECL operator delete(void* const block, size_t const) noexcept
3131
{
3232
free(block);
3333
}
@@ -401,7 +401,7 @@ __cdecl atexit(_PVFV Func)
401401
}
402402

403403
#pragma function(memset)
404-
extern "C" void *memset(void *Dest, int Value, size_t Size)
404+
extern "C" void* __cdecl memset(void *Dest, int Value, size_t Size)
405405
{
406406
unsigned char Val = *(unsigned char*)&Value;
407407
unsigned char *At = (unsigned char*)Dest;
@@ -414,7 +414,7 @@ extern "C" void *memset(void *Dest, int Value, size_t Size)
414414
}
415415

416416
#pragma function(memcpy)
417-
extern "C" void *memcpy(void *Dest, const void *Source, size_t Size)
417+
extern "C" void* __cdecl memcpy(void *Dest, const void *Source, size_t Size)
418418
{
419419
char *D = (char*)Dest;
420420
const char *S = (char*)Source;
@@ -427,7 +427,7 @@ extern "C" void *memcpy(void *Dest, const void *Source, size_t Size)
427427
}
428428

429429
#pragma function(memcmp)
430-
extern "C" int memcmp(const void *A, const void *B, size_t Count)
430+
extern "C" int __cdecl memcmp(const void *A, const void *B, size_t Count)
431431
{
432432
register const unsigned char *s1 = (const unsigned char*)A;
433433
register const unsigned char *s2 = (const unsigned char*)B;
@@ -444,7 +444,7 @@ extern "C" int memcmp(const void *A, const void *B, size_t Count)
444444
}
445445

446446
#pragma function(memmove)
447-
extern "C" void* memmove(void *dest, void const *src, size_t len)
447+
extern "C" void* __cdecl memmove(void *dest, void const *src, size_t len)
448448
{
449449
size_t i;
450450
char *char_src = (char*)src;

src/coreclr/nativeaot/zerolib.native/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function(install_bootstrapper_object targetName destination)
1515
endif()
1616
endfunction()
1717

18-
if (CLR_CMAKE_HOST_ARCH_ARM64 OR CLR_CMAKE_HOST_ARCH_X86)
18+
if (CLR_CMAKE_HOST_ARCH_ARM64 OR CLR_CMAKE_HOST_ARCH_I386)
1919
set(SOURCES ${ARCH_SOURCES_DIR}/stubs.${ASM_SUFFIX})
2020

2121
convert_to_absolute_path(SOURCES ${SOURCES})
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.586
2+
.xmm
3+
.model flat
4+
5+
ALTERNATE_ENTRY macro Name
6+
7+
Name label proc
8+
PUBLIC Name
9+
endm
10+
11+
.code
12+
13+
PUBLIC RhpByRefAssignRef
14+
RhpByRefAssignRef PROC
15+
movs dword ptr es:[edi],dword ptr [esi]
16+
ret
17+
RhpByRefAssignRef ENDP
18+
19+
PUBLIC RhpCheckedAssignRefEAX
20+
ALTERNATE_ENTRY RhpAssignRefEAX
21+
RhpCheckedAssignRefEAX PROC
22+
mov DWORD PTR [edx], eax
23+
ret
24+
RhpCheckedAssignRefEAX ENDP
25+
26+
PUBLIC RhpCheckedAssignRefEBX
27+
ALTERNATE_ENTRY RhpAssignRefEBX
28+
RhpCheckedAssignRefEBX PROC
29+
mov DWORD PTR [edx], ebx
30+
ret
31+
RhpCheckedAssignRefEBX ENDP
32+
33+
PUBLIC RhpCheckedAssignRefECX
34+
ALTERNATE_ENTRY RhpAssignRefECX
35+
RhpCheckedAssignRefECX PROC
36+
mov DWORD PTR [edx], ecx
37+
ret
38+
RhpCheckedAssignRefECX ENDP
39+
40+
PUBLIC RhpCheckedAssignRefESI
41+
ALTERNATE_ENTRY RhpAssignRefESI
42+
RhpCheckedAssignRefESI PROC
43+
mov DWORD PTR [edx], esi
44+
ret
45+
RhpCheckedAssignRefESI ENDP
46+
47+
PUBLIC RhpCheckedAssignRefEDI
48+
ALTERNATE_ENTRY RhpAssignRefEDI
49+
RhpCheckedAssignRefEDI PROC
50+
mov DWORD PTR [edx], edi
51+
ret
52+
RhpCheckedAssignRefEDI ENDP
53+
54+
PUBLIC RhpCheckedAssignRefEBP
55+
ALTERNATE_ENTRY RhpAssignRefEBP
56+
RhpCheckedAssignRefEBP PROC
57+
mov DWORD PTR [edx], ebp
58+
ret
59+
RhpCheckedAssignRefEBP ENDP
60+
61+
end

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static class SettingsTunnel
2424
public static bool EmitGSCookies = true;
2525
public static bool EmitGCInfo = true;
2626
public static bool EmitEHInfo = true;
27+
public static bool ZerolibLike;
2728
}
2829

2930
public abstract class Compilation : ICompilation

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ private void CompileSingleMethod(ScannedMethodNode methodCodeNodeNeedingCode)
138138

139139
ILScanResults IILScanner.Scan()
140140
{
141+
if (!SettingsTunnel.ZerolibLike)
142+
{
141143
_dependencyGraph.AddRoot(GetHelperEntrypoint(ReadyToRunHelper.BulkWriteBarrier), "Not tracked by scanner");
142144
_dependencyGraph.AddRoot(GetHelperEntrypoint(ReadyToRunHelper.MemCpy), "Not tracked by scanner");
143145
_dependencyGraph.AddRoot(GetHelperEntrypoint(ReadyToRunHelper.MemSet), "Not tracked by scanner");
@@ -151,6 +153,7 @@ ILScanResults IILScanner.Scan()
151153
_dependencyGraph.AddRoot(GetHelperEntrypoint(ReadyToRunHelper.CheckInstanceClass), "Not tracked by scanner");
152154
_dependencyGraph.AddRoot(GetHelperEntrypoint(ReadyToRunHelper.IsInstanceOfException), "Not tracked by scanner");
153155
_dependencyGraph.AddRoot(_nodeFactory.MethodEntrypoint(_nodeFactory.TypeSystemContext.GetHelperEntryPoint("ThrowHelpers", "ThrowFeatureBodyRemoved")), "Substitution for methods removed based on scanning");
156+
}
154157

155158
_dependencyGraph.ComputeMarkedNodes();
156159

@@ -292,7 +295,7 @@ public BodyAndFieldSubstitutions GetBodyAndFieldSubstitutions()
292295
}
293296
}
294297

295-
if (!hasIDynamicInterfaceCastableType)
298+
if (!hasIDynamicInterfaceCastableType && !SettingsTunnel.ZerolibLike)
296299
{
297300
// We can't easily trim out some of the IDynamicInterfaceCastable infrastructure because
298301
// the callers do type checks based on flags on the MethodTable instead of an actual type cast.

0 commit comments

Comments
 (0)