-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[wasm coreclr] Prepare for running tests #119807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
245f7f1
4de3190
f566b4a
3a0f482
4ac4b0d
a3ca1d0
737f8a5
b51566f
4185cad
9acd730
e5c7472
df7cda4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,11 @@ | ||||||
// Licensed to the .NET Foundation under one or more agreements. | ||||||
// The .NET Foundation licenses this file to you under the MIT license. | ||||||
|
||||||
#include <malloc.h> | ||||||
#include <string.h> | ||||||
#include <fcntl.h> | ||||||
#include <sys/stat.h> | ||||||
#include <unistd.h> | ||||||
|
||||||
#define _In_z_ | ||||||
#define _In_ | ||||||
|
@@ -27,3 +31,84 @@ void wasm_add_pinvoke_override() | |||||
{ | ||||||
PInvokeOverride::SetPInvokeOverride(pinvoke_override, PInvokeOverride::Source::RuntimeConfiguration); | ||||||
} | ||||||
|
||||||
extern "C" int32_t mono_wasm_load_icu_data(const void* pData); | ||||||
|
||||||
static char* _wasm_get_icu_dat_file_path(const char* assemblyPath) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{ | ||||||
if (!assemblyPath || !*assemblyPath) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When will this be |
||||||
return nullptr; | ||||||
|
||||||
const char* lastSlash = strrchr(assemblyPath, '/'); | ||||||
const char* lastBackslash = strrchr(assemblyPath, '\\'); | ||||||
|
||||||
const char* lastSeparator = nullptr; | ||||||
if (lastSlash && lastBackslash) | ||||||
lastSeparator = (lastSlash > lastBackslash) ? lastSlash : lastBackslash; | ||||||
else if (lastSlash) | ||||||
lastSeparator = lastSlash; | ||||||
else if (lastBackslash) | ||||||
lastSeparator = lastBackslash; | ||||||
|
||||||
const char icuFileName[] = "icudt.dat"; | ||||||
|
||||||
if (!lastSeparator) | ||||||
return strdup(icuFileName); | ||||||
|
||||||
size_t dirLen = (size_t)(lastSeparator - assemblyPath) + 1; // include separator | ||||||
size_t fileNameLen = sizeof(icuFileName) - 1; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the |
||||||
|
||||||
char* icuPath = (char*)malloc(dirLen + fileNameLen + 1); | ||||||
if (!icuPath) | ||||||
return nullptr; | ||||||
|
||||||
memcpy(icuPath, assemblyPath, dirLen); | ||||||
memcpy(icuPath + dirLen, icuFileName, fileNameLen); | ||||||
icuPath[dirLen + fileNameLen] = '\0'; | ||||||
|
||||||
return icuPath; | ||||||
} | ||||||
|
||||||
int32_t wasm_load_icu_data(const char* assemblyPath) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize this is probably copied from somewhere, but it is using very low leve APIs. For example, |
||||||
{ | ||||||
char* icuFile = _wasm_get_icu_dat_file_path(assemblyPath); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (!icuFile) { | ||||||
return 0; | ||||||
} | ||||||
|
||||||
int fd = open(icuFile, O_RDONLY); | ||||||
if (fd < 0) { | ||||||
free(icuFile); | ||||||
return 0; | ||||||
} | ||||||
|
||||||
struct stat st; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (stat(icuFile, &st) != 0 || !S_ISREG(st.st_mode) || st.st_size <= 0) { | ||||||
close(fd); | ||||||
free(icuFile); | ||||||
return 0; | ||||||
} | ||||||
|
||||||
free(icuFile); | ||||||
|
||||||
size_t size = static_cast<size_t>(st.st_size); | ||||||
void* buffer = malloc(size); | ||||||
if (!buffer) { | ||||||
close(fd); | ||||||
return 0; | ||||||
} | ||||||
|
||||||
size_t total = 0; | ||||||
while (total < size) { | ||||||
ssize_t n = read(fd, static_cast<char*>(buffer) + total, size - total); | ||||||
if (n <= 0) { | ||||||
free(buffer); | ||||||
close(fd); | ||||||
return 0; | ||||||
} | ||||||
total += static_cast<size_t>(n); | ||||||
} | ||||||
close(fd); | ||||||
|
||||||
return mono_wasm_load_icu_data(buffer); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this returns failure, we should clean things up. |
||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ | |
#define __CORERUN_WASM_HPP__ | ||
|
||
void wasm_add_pinvoke_override(); | ||
int32_t wasm_load_icu_data(const char* assemblyPath); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update this to be |
||
|
||
#endif // __CORERUN_WASM_HPP__ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,8 @@ struct HijackArgs | |
|
||
inline LPVOID STDCALL GetCurrentSP() | ||
{ | ||
_ASSERTE("The function is not implemented on wasm, it lacks registers"); | ||
// WASM-TODO: check where we reach that, return nullptr for now to not break runtime initialization | ||
//PORTABILITY_ASSERT("The function is not implemented on wasm, it lacks registers"); | ||
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How are we getting here? Can you share a callstack? I would prefer us to nicely ifdef out the caller in an intelligent way. |
||
return nullptr; | ||
} | ||
|
||
|
@@ -75,10 +76,10 @@ class StubLinkerCPU : public StubLinker | |
public: | ||
static void Init() { /* no-op on wasm */ } | ||
inline void EmitShuffleThunk(struct ShuffleEntry *pShuffleEntryArray) { | ||
_ASSERTE("The EmitShuffleThunk is not implemented on wasm"); | ||
PORTABILITY_ASSERT("The EmitShuffleThunk is not implemented on wasm"); | ||
} | ||
inline VOID EmitComputedInstantiatingMethodStub(MethodDesc* pSharedMD, struct ShuffleEntry *pShuffleEntryArray, void* extraArg) { | ||
_ASSERTE("The EmitComputedInstantiatingMethodStub is not implemented on wasm"); | ||
PORTABILITY_ASSERT("The EmitComputedInstantiatingMethodStub is not implemented on wasm"); | ||
} | ||
}; | ||
|
||
|
@@ -144,13 +145,13 @@ inline BOOL ClrFlushInstructionCache(LPCVOID pCodeAddr, size_t sizeOfCode, bool | |
//------------------------------------------------------------------------ | ||
inline void emitBackToBackJump(LPBYTE pBufferRX, LPBYTE pBufferRW, LPVOID target) | ||
{ | ||
_ASSERTE("emitBackToBackJump is not implemented on wasm"); | ||
PORTABILITY_ASSERT("emitBackToBackJump is not implemented on wasm"); | ||
} | ||
|
||
//------------------------------------------------------------------------ | ||
inline PCODE decodeBackToBackJump(PCODE pBuffer) | ||
{ | ||
_ASSERTE("decodeBackToBackJump is not implemented on wasm"); | ||
PORTABILITY_ASSERT("decodeBackToBackJump is not implemented on wasm"); | ||
return 0; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.