Skip to content

Commit 32e5de5

Browse files
authored
Merge pull request #1040 from Unity-Technologies/unity-master-sync-il2cpp
Sync changes from IL2CPP
2 parents 94cb80b + ada06d4 commit 32e5de5

File tree

9 files changed

+45
-8
lines changed

9 files changed

+45
-8
lines changed

mono/arch/arm64/arm64-codegen.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ arm_is_bl_disp (void *code, void *target)
170170
static G_GNUC_UNUSED inline unsigned int
171171
arm_get_disp (void *p, void *target)
172172
{
173-
unsigned int disp = ((char*)target - (char*)p) / 4;
173+
unsigned int disp = (unsigned int)(((char*)target - (char*)p) / 4);
174174

175175
if (target)
176176
g_assert (arm_is_bl_disp (p, target));
@@ -196,7 +196,7 @@ arm_is_disp19 (void *code, void *target)
196196
static G_GNUC_UNUSED inline unsigned int
197197
arm_get_disp19 (void *p, void *target)
198198
{
199-
unsigned int disp = ((char*)target - (char*)p) / 4;
199+
unsigned int disp = (unsigned int)(((char*)target - (char*)p) / 4);
200200

201201
if (target)
202202
g_assert (arm_is_disp19 (p, target));
@@ -224,7 +224,7 @@ arm_get_disp19 (void *p, void *target)
224224
static G_GNUC_UNUSED inline unsigned int
225225
arm_get_disp15 (void *p, void *target)
226226
{
227-
unsigned int disp = ((char*)target - (char*)p) / 4;
227+
unsigned int disp = (unsigned int)(((char*)target - (char*)p) / 4);
228228
return (disp & 0x7fff);
229229
}
230230

mono/mini/debugger-agent.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4178,7 +4178,11 @@ thread_startup (MonoProfiler *prof, uintptr_t tid)
41784178
tls = g_new0 (DebuggerTlsData, 1);
41794179
#endif
41804180
MONO_GC_REGISTER_ROOT_SINGLE (tls->thread, MONO_ROOT_SOURCE_DEBUGGER, NULL, "Debugger Thread Reference");
4181+
#ifdef RUNTIME_IL2CPP
4182+
il2cpp_gc_wbarrier_set_field(tls, (void**)&tls->thread, thread);
4183+
#else
41814184
tls->thread = thread;
4185+
#endif
41824186
mono_native_tls_set_value (debugger_tls_id, tls);
41834187

41844188
DEBUG_PRINTF (1, "[%p] Thread started, obj=%p, tls=%p.\n", (gpointer)tid, thread, tls);
@@ -4214,10 +4218,12 @@ thread_end (MonoProfiler *prof, uintptr_t tid)
42144218
/* Can't remove from tid_to_thread, as that would defeat the check in thread_start () */
42154219
#ifndef RUNTIME_IL2CPP
42164220
MONO_GC_UNREGISTER_ROOT (tls->thread);
4217-
#else
4218-
callbacks.il2cpp_debugger_free_thread_context(&tls->il2cpp_context);
42194221
#endif
4222+
#ifdef RUNTIME_IL2CPP
4223+
il2cpp_gc_wbarrier_set_field(tls, (void**)&tls->thread, NULL);
4224+
#else
42204225
tls->thread = NULL;
4226+
#endif
42214227
}
42224228
}
42234229
mono_loader_unlock ();

mono/mini/il2cpp-compat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
#ifdef RUNTIME_IL2CPP
1414

15+
#ifndef THREAD_STATIC_FIELD_OFFSET
1516
#define THREAD_STATIC_FIELD_OFFSET -1
17+
#endif
1618

1719
#define VM_DOMAIN_GET_AGENT_INFO(domain) il2cpp_domain_get_agent_info(domain)
1820
#define VM_DOMAIN_SET_AGENT_INFO(domain, value) il2cpp_domain_set_agent_info(domain, value)

mono/sgen/sgen-gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2573,7 +2573,7 @@ typedef struct {
25732573

25742574
static SgenGcRequest gc_request;
25752575

2576-
#include <emscripten.h>
2576+
#include <emscripten/emscripten.h>
25772577

25782578
static void
25792579
gc_pump_callback (void)

mono/utils/mono-context.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,21 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *ctx)
458458

459459
#include <mono/utils/mono-context.h>
460460

461+
#ifdef HOST_WIN32
462+
#include <windows.h>
463+
#endif
464+
461465
void
462466
mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
463467
{
464468
#ifdef MONO_CROSS_COMPILE
465469
g_assert_not_reached ();
470+
#elif defined(HOST_WIN32)
471+
CONTEXT *context = (CONTEXT*)sigctx;
472+
473+
mctx->pc = context->Pc;
474+
memcpy(&mctx->regs, &context->X0, sizeof(mgreg_t) * 31);
475+
memcpy(&mctx->fregs, &context->V, sizeof(MonoContextSimdReg) * 32);
466476
#else
467477
memcpy (mctx->regs, UCONTEXT_GREGS (sigctx), sizeof (mgreg_t) * 31);
468478
mctx->pc = UCONTEXT_REG_PC (sigctx);
@@ -484,6 +494,12 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
484494
{
485495
#ifdef MONO_CROSS_COMPILE
486496
g_assert_not_reached ();
497+
#elif defined(HOST_WIN32)
498+
CONTEXT *context = (CONTEXT*)sigctx;
499+
500+
context->Pc = mctx->pc;
501+
memcpy(&context->X0, &mctx->regs, sizeof(mgreg_t) * 31);
502+
memcpy(&context->V, &mctx->fregs, sizeof(MonoContextSimdReg) * 32);
487503
#else
488504
memcpy (UCONTEXT_GREGS (sigctx), mctx->regs, sizeof (mgreg_t) * 31);
489505
UCONTEXT_REG_PC (sigctx) = mctx->pc;

mono/utils/mono-context.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ typedef struct _libc_xmmreg MonoContextSimdReg;
4141
typedef __m128d MonoContextSimdReg;
4242
#endif
4343
#elif defined(TARGET_ARM64)
44+
#if defined(HOST_WIN32)
45+
#include <arm64_neon.h>
46+
typedef __n128 MonoContextSimdReg;
47+
#else
4448
typedef __uint128_t MonoContextSimdReg;
4549
#endif
50+
#endif
4651

4752
/*
4853
* General notes about mono-context.

mono/utils/mono-hwcap-web.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "mono/utils/mono-hwcap.h"
2+
3+
void
4+
mono_hwcap_arch_init (void)
5+
{
6+
}

mono/utils/mono-sigcontext.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,9 @@ typedef struct ucontext {
461461
#define UCONTEXT_REG_R0(ctx) (((ucontext64_t*)(ctx))->uc_mcontext64->__ss.__x [ARMREG_R0])
462462
#define UCONTEXT_GREGS(ctx) (&(((ucontext64_t*)(ctx))->uc_mcontext64->__ss.__x))
463463
#else
464-
#include <ucontext.h>
464+
# if HAVE_UCONTEXT_H
465+
# include <ucontext.h>
466+
# endif
465467
#define UCONTEXT_REG_PC(ctx) (((ucontext_t*)(ctx))->uc_mcontext.pc)
466468
#define UCONTEXT_REG_SP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.sp)
467469
#define UCONTEXT_REG_R0(ctx) (((ucontext_t*)(ctx))->uc_mcontext.regs [ARMREG_R0])

mono/utils/mono-threads-posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
extern int tkill (pid_t tid, int signal);
3333
#endif
3434

35-
#if defined(_POSIX_VERSION) && !defined (TARGET_WASM)
35+
#if (defined(_POSIX_VERSION) && !defined (TARGET_WASM)) || (defined(TARGET_WASM) && defined(__EMSCRIPTEN_PTHREADS__))
3636

3737
#include <pthread.h>
3838

0 commit comments

Comments
 (0)