Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ if (CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET
set(CLR_CMAKE_USE_SYSTEM_ZLIB 1)
endif()

if (NOT CLR_CMAKE_TARGET_ANDROID)
if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER)
# opt into building tools like ildasm/ilasm
set(CLR_CMAKE_BUILD_TOOLS 1)
endif()
2 changes: 1 addition & 1 deletion eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ extends:
- browser_wasm
jobParameters:
nameSuffix: AllSubsets_CoreCLR
buildArgs: -s mono.emsdk+clr.paltests -rc Release -c Release -lc $(_BuildConfig)
buildArgs: -s mono.emsdk+clr.runtime -rc Release -c Release -lc $(_BuildConfig)
timeoutInMinutes: 120
condition: >-
or(
Expand Down
29 changes: 22 additions & 7 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ endif()

OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)

if (DEFINED CLR_CMAKE_ICU_DIR)
include_directories(${CLR_CMAKE_ICU_DIR}/include)
endif(DEFINED CLR_CMAKE_ICU_DIR)

#----------------------------------------------------
# Cross target Component build specific configuration
#----------------------------------------------------
Expand All @@ -59,7 +63,7 @@ include(components.cmake)
#---------------------------
# Build the single file host
#---------------------------
if(NOT CLR_CROSS_COMPONENTS_BUILD AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
if(NOT CLR_CROSS_COMPONENTS_BUILD AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
set(CLR_SINGLE_FILE_HOST_ONLY 1)
add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static)
add_dependencies(runtime singlefilehost)
Expand Down Expand Up @@ -267,7 +271,7 @@ if(CLR_CMAKE_HOST_UNIX)
add_subdirectory(nativeresources)
endif(CLR_CMAKE_HOST_UNIX)

if(NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_BROWSER)
if(NOT CLR_CMAKE_HOST_TVOS)
add_subdirectory(utilcode)
add_subdirectory(inc)

Expand All @@ -276,16 +280,27 @@ if(NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_BROWSER)
add_subdirectory(ildasm)
endif(CLR_CMAKE_BUILD_TOOLS)
add_subdirectory(gcinfo)
add_subdirectory(jit)

if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
add_subdirectory(jit)
endif()

add_subdirectory(vm)
add_subdirectory(md)
add_subdirectory(debug)

if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
add_subdirectory(debug)
endif()

add_subdirectory(binder)
add_subdirectory(classlibnative)
add_subdirectory(dlls)
add_subdirectory(unwinder)
add_subdirectory(interop)
endif(NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_BROWSER)

if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
add_subdirectory(unwinder)
add_subdirectory(interop)
endif()
endif(NOT CLR_CMAKE_HOST_TVOS)

if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
add_subdirectory(tools)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if(CLR_CMAKE_HOST_WIN32)
add_compile_definitions(NOMINMAX)
endif(CLR_CMAKE_HOST_WIN32)

if (NOT (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX))
if (NOT ((CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX) OR CLR_CMAKE_TARGET_ARCH_WASM))
add_compile_definitions(FEATURE_METADATA_UPDATER)
endif()
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_WIN32))
Expand Down Expand Up @@ -119,9 +119,9 @@ if(CLR_CMAKE_TARGET_LINUX)
add_definitions(-DFEATURE_EVENTSOURCE_XPLAT)
endif(CLR_CMAKE_TARGET_LINUX)
# NetBSD doesn't implement this feature
if(NOT CLR_CMAKE_TARGET_NETBSD)
if(NOT CLR_CMAKE_TARGET_NETBSD AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
add_definitions(-DFEATURE_HIJACK)
endif(NOT CLR_CMAKE_TARGET_NETBSD)
endif(NOT CLR_CMAKE_TARGET_NETBSD AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM64))
add_definitions(-DFEATURE_INTEROP_DEBUGGING)
endif (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM64))
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/clrfeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if (CLR_CMAKE_TARGET_WIN32)
endif(CLR_CMAKE_TARGET_WIN32)


if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_ARCH_WASM)
set(FEATURE_CORECLR_CACHED_INTERFACE_DISPATCH 1)
set(FEATURE_CORECLR_VIRTUAL_STUB_DISPATCH 0)
else()
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/debug/inc/dbgipcevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,9 @@ C_ASSERT(DBG_TARGET_REGNUM_AMBIENT_SP == ICorDebugInfo::REGNUM_AMBIENT_SP);
C_ASSERT(DBG_TARGET_REGNUM_SP == ICorDebugInfo::REGNUM_SP);
C_ASSERT(DBG_TARGET_REGNUM_AMBIENT_SP == ICorDebugInfo::REGNUM_AMBIENT_SP);
#endif
#elif defined(TARGET_WASM)
#define DBG_TARGET_REGNUM_SP 0
#define DBG_TARGET_REGNUM_AMBIENT_SP 0
#else
#error Target registers are not defined for this platform
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/debug/inc/dbgtargetcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
#define DTCONTEXT_IS_LOONGARCH64
#elif defined (TARGET_RISCV64)
#define DTCONTEXT_IS_RISCV64
#elif defined (TARGET_WASM)
#define DTCONTEXT_IS_WASM
#endif

#define CONTEXT_AREA_MASK 0xffff
Expand Down Expand Up @@ -614,6 +616,10 @@ typedef struct DECLSPEC_ALIGN(16) {

static_assert(sizeof(DT_CONTEXT) == sizeof(T_CONTEXT), "DT_CONTEXT size must equal the T_CONTEXT size");

#elif defined(DTCONTEXT_IS_WASM)
// no context for wasm
typedef struct {
} DT_CONTEXT;
#else
#error Unsupported platform
#endif
Expand Down
39 changes: 39 additions & 0 deletions src/coreclr/debug/inc/wasm/primitives.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//*****************************************************************************
// File: primitives.h
//

//
// Platform-specific debugger primitives
//
//*****************************************************************************

#ifndef PRIMITIVES_H_
#define PRIMITIVES_H_

inline CORDB_ADDRESS GetPatchEndAddr(CORDB_ADDRESS patchAddr)
{
_ASSERTE("The function is not implemented on wasm");
return patchAddr;
}

typedef const BYTE CORDB_ADDRESS_TYPE;
typedef DPTR(CORDB_ADDRESS_TYPE) PTR_CORDB_ADDRESS_TYPE;

//This is an abstraction to keep x86/ia64 patch data separate
#define PRD_TYPE USHORT

#define MAX_INSTRUCTION_LENGTH 2 // update once we have codegen

#define CORDbg_BREAK_INSTRUCTION_SIZE 1
#define CORDbg_BREAK_INSTRUCTION 0 // unreachable intruction

inline bool PRDIsEmpty(PRD_TYPE p1)
{
LIMITED_METHOD_CONTRACT;

return p1 == 0;
}

#endif
10 changes: 7 additions & 3 deletions src/coreclr/dlls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ if(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE)
add_subdirectory(clretwrc)
endif(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE)
if (NOT (CLR_CMAKE_TARGET_WIN32 AND FEATURE_CROSSBITNESS))
add_subdirectory(mscordbi)
add_subdirectory(mscordac)
if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
add_subdirectory(mscordbi)
add_subdirectory(mscordac)
endif()
add_subdirectory(mscoree)
endif()
add_subdirectory(mscorpe)
if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
add_subdirectory(mscorpe)
endif()
add_subdirectory(mscorrc)
5 changes: 4 additions & 1 deletion src/coreclr/gc/env/gcenv.base.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(void* lpThreadParameter);
#pragma intrinsic(__dmb)
#define MemoryBarrier() { __dmb(_ARM64_BARRIER_SY); }

#elif defined(HOST_AMD64)
#elif defined(HOST_BROWSER)
#define YieldProcessor()
#define MemoryBarrier __sync_synchronize
#elif defined(HOST_AMD64)

extern "C" void
_mm_pause (
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#define membarrier(...) syscall(__NR_membarrier, __VA_ARGS__)
#elif HAVE_SYS_MEMBARRIER_H
#include <sys/membarrier.h>
#ifdef TARGET_BROWSER
#define membarrier(cmd, flags, cpu_id) 0 // browser/wasm is currently single threaded
#endif
#endif

#include <sys/resource.h>
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/inc/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,9 @@ CHECK CheckOverflow(UINT64 value1, UINT64 value2);
#ifdef __APPLE__
CHECK CheckOverflow(SIZE_T value1, SIZE_T value2);
#endif
#ifndef __wasm__
CHECK CheckOverflow(PTR_CVOID address, UINT offset);
#endif
#if defined(_MSC_VER)
CHECK CheckOverflow(const void *address, ULONG offset);
#endif
Expand Down
9 changes: 5 additions & 4 deletions src/coreclr/inc/check.inl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ inline CHECK CheckAligned(UINT64 value, UINT alignment)
CHECK_OK;
}

#ifdef __APPLE__
#if defined(__APPLE__) || defined(__wasm__)
inline CHECK CheckAligned(SIZE_T value, UINT alignment)
{
STATIC_CONTRACT_WRAPPER;
Expand Down Expand Up @@ -237,7 +237,7 @@ inline CHECK CheckOverflow(const void *address, UINT64 offset)
CHECK_OK;
}

#ifdef __APPLE__
#if defined(__APPLE__) || defined(__wasm__)
inline CHECK CheckOverflow(const void *address, SIZE_T offset)
{
CHECK((UINT64) address + offset >= (UINT64) address);
Expand Down Expand Up @@ -316,10 +316,11 @@ inline CHECK CheckUnderflow(const void *address, UINT64 offset)
CHECK_OK;
}

#ifdef __APPLE__
#if defined(__APPLE__) || defined(__wasm__)
inline CHECK CheckUnderflow(const void *address, SIZE_T offset)
{
#if POINTER_BITS == 32
// SIZE_T is 32bit on wasm32
#if !defined(__wasm__) && POINTER_BITS == 32
Comment thread
radekdoulik marked this conversation as resolved.
CHECK(offset >> 32 == 0);
CHECK((UINT) (SIZE_T) address - (UINT) offset <= (UINT) (SIZE_T) address);
#else
Expand Down
44 changes: 44 additions & 0 deletions src/coreclr/inc/clrnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,48 @@ RtlVirtualUnwind(

#endif // TARGET_RISCV64

#ifdef TARGET_WASM
//
// Define unwind information flags.
//

#define UNW_FLAG_NHANDLER 0x0 /* any handler */
#define UNW_FLAG_EHANDLER 0x1 /* filter handler */
#define UNW_FLAG_UHANDLER 0x2 /* unwind handler */

PEXCEPTION_ROUTINE
RtlVirtualUnwind (
Comment thread
radekdoulik marked this conversation as resolved.
_In_ DWORD HandlerType,
_In_ DWORD ImageBase,
_In_ DWORD ControlPc,
_In_ PRUNTIME_FUNCTION FunctionEntry,
__inout PT_CONTEXT ContextRecord,
_Out_ PVOID *HandlerData,
_Out_ PDWORD EstablisherFrame,
__inout_opt PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers
);

FORCEINLINE
ULONG
RtlpGetFunctionEndAddress (
_In_ PT_RUNTIME_FUNCTION FunctionEntry,
_In_ TADDR ImageBase
)
{
_ASSERTE("The function RtlpGetFunctionEndAddress is not implemented on wasm");
return 0;
}

#define RUNTIME_FUNCTION__BeginAddress(FunctionEntry) ((FunctionEntry)->BeginAddress)
#define RUNTIME_FUNCTION__SetBeginAddress(FunctionEntry,address) ((FunctionEntry)->BeginAddress = (address))

#define RUNTIME_FUNCTION__EndAddress(FunctionEntry, ImageBase) (RtlpGetFunctionEndAddress(FunctionEntry, (ULONG64)(ImageBase)))

#define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf,address) do { (prf)->UnwindData = (address); } while (0)

typedef struct _UNWIND_INFO {
// dummy
} UNWIND_INFO, *PUNWIND_INFO;
#endif

#endif // CLRNT_H_
8 changes: 4 additions & 4 deletions src/coreclr/inc/clrtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ inline UINT64 AlignUp(UINT64 value, UINT alignment)
return (value+alignment-1)&~(UINT64)(alignment-1);
}

#ifdef __APPLE__
#if defined(__APPLE__) || defined(__wasm__)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me why we need this for wasm when it was used on apple only before.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 32bit SIZE_T again, without this change the calls to AlighnUp with SIZE_T argument are ambiguous between UINT and UINT64 versions.

inline SIZE_T AlignUp(SIZE_T value, UINT alignment)
{
STATIC_CONTRACT_LEAF;
Expand Down Expand Up @@ -399,13 +399,13 @@ inline UINT AlignmentPad(UINT64 value, UINT alignment)
return (UINT) (AlignUp(value, alignment) - value);
}

#ifdef __APPLE__
#if defined(__APPLE__) || defined(__wasm__)
inline UINT AlignmentPad(SIZE_T value, UINT alignment)
{
STATIC_CONTRACT_WRAPPER;
return (UINT) (AlignUp(value, alignment) - value);
}
#endif // __APPLE__
#endif // __APPLE__ || __wasm__

inline UINT AlignmentTrim(UINT value, UINT alignment)
{
Expand All @@ -432,7 +432,7 @@ inline UINT AlignmentTrim(UINT64 value, UINT alignment)
return ((UINT)value)&(alignment-1);
}

#ifdef __APPLE__
#if defined(__APPLE__) || defined(__wasm__)
inline UINT AlignmentTrim(SIZE_T value, UINT alignment)
{
STATIC_CONTRACT_LEAF;
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/inc/corcompile.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ inline ReadyToRunCrossModuleInlineFlags operator &( const ReadyToRunCrossModuleI
return static_cast<ReadyToRunCrossModuleInlineFlags>(static_cast<uint32_t>(left) & static_cast<uint32_t>(right));
}

#ifdef TARGET_WASM
// why was it defined only for x86 before?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because all other platforms have it defined in either the pal.h or in the Windows SDK.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see it in pal.h, so is it in the windows sdk then?

typedef DPTR(RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION;
#endif

#ifdef TARGET_X86

typedef DPTR(RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION;
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/inc/cordebuginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ class ICorDebugInfo
REGNUM_T5,
REGNUM_T6,
REGNUM_PC,
#elif TARGET_WASM
REGNUM_PC, // wasm doesn't have registers
#else
PORTABILITY_WARNING("Register numbers not defined on this platform")
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/inc/crosscomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,8 @@ typedef struct _T_KNONVOLATILE_CONTEXT_POINTERS {
#define DAC_CS_NATIVE_DATA_SIZE 48
#elif defined(TARGET_HAIKU) && defined(TARGET_AMD64)
#define DAC_CS_NATIVE_DATA_SIZE 56
#elif defined(TARGET_WASM)
#define DAC_CS_NATIVE_DATA_SIZE 76
#else
#warning
#error DAC_CS_NATIVE_DATA_SIZE is not defined for this architecture. This should be same value as PAL_CS_NATIVE_DATA_SIZE (aka sizeof(PAL_CS_NATIVE_DATA)).
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/inc/pedecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ inline CHECK CheckOverflow(RVA value1, COUNT_T value2)
#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_UNKNOWN
#elif defined(TARGET_RISCV64)
#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_RISCV64
#elif defined(TARGET_WASM)
#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_UNKNOWN
#else
#error "port me"
#endif
Expand Down
Loading