From 3d4aa90369e1a69587871c6818c76cc04894910c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 14 Aug 2024 16:34:26 +0200 Subject: [PATCH] [mono] Remove unused CompareExchange icall The icall returning a `success` parameter isn't used anymore, it's a leftover from mono/mono. --- src/mono/mono/metadata/icall-def.h | 1 - src/mono/mono/metadata/threads-types.h | 3 --- src/mono/mono/metadata/threads.c | 10 -------- src/mono/mono/mini/intrinsics.c | 33 -------------------------- 4 files changed, 47 deletions(-) diff --git a/src/mono/mono/metadata/icall-def.h b/src/mono/mono/metadata/icall-def.h index ad7044a08439f..c6e2b73218a83 100644 --- a/src/mono/mono/metadata/icall-def.h +++ b/src/mono/mono/metadata/icall-def.h @@ -555,7 +555,6 @@ ICALL_TYPE(ILOCK, "System.Threading.Interlocked", ILOCK_1) NOHANDLES(ICALL(ILOCK_1, "Add(int&,int)", ves_icall_System_Threading_Interlocked_Add_Int)) NOHANDLES(ICALL(ILOCK_2, "Add(long&,long)", ves_icall_System_Threading_Interlocked_Add_Long)) NOHANDLES(ICALL(ILOCK_5, "CompareExchange(int&,int,int)", ves_icall_System_Threading_Interlocked_CompareExchange_Int)) -NOHANDLES(ICALL(ILOCK_6, "CompareExchange(int&,int,int,bool&)", ves_icall_System_Threading_Interlocked_CompareExchange_Int_Success)) NOHANDLES(ICALL(ILOCK_8, "CompareExchange(long&,long,long)", ves_icall_System_Threading_Interlocked_CompareExchange_Long)) NOHANDLES(ICALL(ILOCK_9, "CompareExchange(object&,object&,object&,object&)", ves_icall_System_Threading_Interlocked_CompareExchange_Object)) NOHANDLES(ICALL(ILOCK_11, "Decrement(int&)", ves_icall_System_Threading_Interlocked_Decrement_Int)) diff --git a/src/mono/mono/metadata/threads-types.h b/src/mono/mono/metadata/threads-types.h index c92e61497dba6..da86f3a15d880 100644 --- a/src/mono/mono/metadata/threads-types.h +++ b/src/mono/mono/metadata/threads-types.h @@ -148,9 +148,6 @@ void ves_icall_System_Threading_Interlocked_Exchange_Object (MonoObject *volatil ICALL_EXPORT gint32 ves_icall_System_Threading_Interlocked_CompareExchange_Int(gint32 *location, gint32 value, gint32 comparand); -ICALL_EXPORT -gint32 ves_icall_System_Threading_Interlocked_CompareExchange_Int_Success(gint32 *location, gint32 value, gint32 comparand, MonoBoolean *success); - ICALL_EXPORT gint64 ves_icall_System_Threading_Interlocked_CompareExchange_Long(gint64 *location, gint64 value, gint64 comparand); diff --git a/src/mono/mono/metadata/threads.c b/src/mono/mono/metadata/threads.c index 22a7760450e84..11fb393d77067 100644 --- a/src/mono/mono/metadata/threads.c +++ b/src/mono/mono/metadata/threads.c @@ -2199,16 +2199,6 @@ gint32 ves_icall_System_Threading_Interlocked_CompareExchange_Int(gint32 *locati return mono_atomic_cas_i32(location, value, comparand); } -gint32 ves_icall_System_Threading_Interlocked_CompareExchange_Int_Success(gint32 *location, gint32 value, gint32 comparand, MonoBoolean *success) -{ - if (G_UNLIKELY (!location)) - return (gint32)set_pending_null_reference_exception (); - - gint32 r = mono_atomic_cas_i32(location, value, comparand); - *success = r == comparand; - return r; -} - void ves_icall_System_Threading_Interlocked_CompareExchange_Object (MonoObject *volatile*location, MonoObject *volatile*value, MonoObject *volatile*comparand, MonoObject *volatile* res) { diff --git a/src/mono/mono/mini/intrinsics.c b/src/mono/mono/mini/intrinsics.c index b994a01c48745..402d58b3c7651 100644 --- a/src/mono/mono/mini/intrinsics.c +++ b/src/mono/mono/mini/intrinsics.c @@ -1722,39 +1722,6 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign if (cfg->gen_write_barriers && is_ref) mini_emit_write_barrier (cfg, args [0], args [1]); } - else if ((strcmp (cmethod->name, "CompareExchange") == 0) && fsig->param_count == 4 && - fsig->params [1]->type == MONO_TYPE_I4) { - MonoInst *cmp, *ceq; - - if (!mono_arch_opcode_supported (OP_ATOMIC_CAS_I4)) - return NULL; - - /* int32 r = CAS (location, value, comparand); */ - MONO_INST_NEW (cfg, ins, OP_ATOMIC_CAS_I4); - ins->dreg = alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->sreg2 = args [1]->dreg; - ins->sreg3 = args [2]->dreg; - ins->type = STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - - /* bool result = r == comparand; */ - MONO_INST_NEW (cfg, cmp, OP_ICOMPARE); - cmp->sreg1 = ins->dreg; - cmp->sreg2 = args [2]->dreg; - cmp->type = STACK_I4; - MONO_ADD_INS (cfg->cbb, cmp); - - MONO_INST_NEW (cfg, ceq, OP_ICEQ); - ceq->dreg = alloc_ireg (cfg); - ceq->type = STACK_I4; - MONO_ADD_INS (cfg->cbb, ceq); - - /* *success = result; */ - MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI1_MEMBASE_REG, args [3]->dreg, 0, ceq->dreg); - - cfg->has_atomic_cas_i4 = TRUE; - } else if (strcmp (cmethod->name, "MemoryBarrier") == 0 && fsig->param_count == 0) ins = mini_emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_SEQ);