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
28 changes: 28 additions & 0 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,34 @@ jit_call_cb (gpointer arg)
func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], ftndesc);
break;
}
case 9: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;

func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], ftndesc);
break;
}
case 10: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;

func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9], ftndesc);
break;
}
case 11: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;

func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9], args [10], ftndesc);
break;
}
case 12: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;

func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], args [8], args [9], args [10], args [11], ftndesc);
break;
}
default:
g_assert_not_reached ();
break;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ mono_interp_jit_call_supported (MonoMethod *method, MonoMethodSignature *sig)
{
GSList *l;

if (sig->param_count > 6)
if (sig->param_count > 10)
return FALSE;
if (sig->pinvoke)
return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ llvm_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
}

if (in_corlib && !strcmp (m_class_get_name (cmethod->klass), "Buffer")) {
if (!strcmp (cmethod->name, "Memmove") && fsig->param_count == 3 && fsig->params [0]->type == MONO_TYPE_PTR && fsig->params [1]->type == MONO_TYPE_PTR) {
if (!strcmp (cmethod->name, "Memmove") && fsig->param_count == 3 && m_type_is_byref (fsig->params [0]) && m_type_is_byref (fsig->params [1]) && !cmethod->is_inflated) {
MonoBasicBlock *end_bb;
NEW_BBLOCK (cfg, end_bb);

Expand Down
36 changes: 20 additions & 16 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -5670,6 +5670,19 @@ handle_ctor_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fs
return;
}

if ((cfg->opt & MONO_OPT_INLINE) && mono_method_check_inlining (cfg, cmethod) &&
!mono_class_is_subclass_of_internal (cmethod->klass, mono_defaults.exception_class, FALSE)) {
int costs;

costs = inline_method (cfg, cmethod, fsig, sp, ip, cfg->real_offset, FALSE, NULL);
if (costs) {
cfg->real_offset += 5;

*inline_costs += costs - 5;
return;
}
}

if (mono_class_generic_sharing_enabled (cmethod->klass) && mono_method_is_generic_sharable (cmethod, TRUE)) {
MonoRgctxAccess access = mini_get_rgctx_access_for_method (cmethod);

Expand All @@ -5682,22 +5695,12 @@ handle_ctor_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fs
}

/* Avoid virtual calls to ctors if possible */
if ((cfg->opt & MONO_OPT_INLINE) && cmethod && !context_used && !rgctx_arg &&
mono_method_check_inlining (cfg, cmethod) &&
!mono_class_is_subclass_of_internal (cmethod->klass, mono_defaults.exception_class, FALSE)) {
int costs;

if ((costs = inline_method (cfg, cmethod, fsig, sp, ip, cfg->real_offset, FALSE, NULL))) {
cfg->real_offset += 5;

*inline_costs += costs - 5;
} else {
INLINE_FAILURE ("inline failure");
// FIXME-VT: Clean this up
if (cfg->gsharedvt && mini_is_gsharedvt_signature (fsig))
GSHAREDVT_FAILURE(*ip);
mini_emit_method_call_full (cfg, cmethod, fsig, FALSE, sp, callvirt_this_arg, NULL, NULL);
}
if (!context_used && !rgctx_arg) {
INLINE_FAILURE ("inline failure");
// FIXME-VT: Clean this up
if (cfg->gsharedvt && mini_is_gsharedvt_signature (fsig))
GSHAREDVT_FAILURE(*ip);
mini_emit_method_call_full (cfg, cmethod, fsig, FALSE, sp, callvirt_this_arg, NULL, NULL);
} else if (cfg->gsharedvt && mini_is_gsharedvt_signature (fsig)) {
MonoInst *addr;

Expand Down Expand Up @@ -6593,6 +6596,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
else
EMIT_NEW_PCONST (cfg, args [1], info);

cfg->init_method_rgctx_ins_arg = args [1];
cfg->init_method_rgctx_ins = mono_emit_jit_icall (cfg, mini_init_method_rgctx, args);
}

Expand Down
5 changes: 2 additions & 3 deletions src/mono/mono/mini/mini-generic-sharing.c
Original file line number Diff line number Diff line change
Expand Up @@ -3161,12 +3161,11 @@ mono_class_fill_runtime_generic_context (MonoVTable *class_vtable, guint32 slot,
{
MonoRuntimeGenericContext *rgctx, *new_rgctx;
gpointer info;
MonoJitMemoryManager *jit_mm = jit_mm_for_class (class_vtable->klass);

error_init (error);

rgctx = class_vtable->runtime_generic_context;
if (G_UNLIKELY (!rgctx)) {
MonoJitMemoryManager *jit_mm = jit_mm_for_class (class_vtable->klass);

new_rgctx = alloc_rgctx_array (jit_mm->mem_manager, 0, FALSE);
/* Make sure that this array is zeroed if other threads access it */
mono_memory_write_barrier ();
Expand Down
20 changes: 15 additions & 5 deletions src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3816,6 +3816,11 @@ emit_unbox_tramp (EmitContext *ctx, const char *method_name, LLVMTypeRef method_
static void
emit_gc_pin (EmitContext *ctx, LLVMBuilderRef builder, int vreg)
{
if (ctx->values [vreg] == LLVMConstNull (IntPtrType ()))
return;
MonoInst *var = get_vreg_to_inst (ctx->cfg, vreg);
if (var && var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT|MONO_INST_IS_DEAD))
return;
LLVMValueRef index0 = const_int32 (0);
LLVMValueRef index1 = const_int32 (ctx->gc_var_indexes [vreg] - 1);
LLVMValueRef indexes [] = { index0, index1 };
Expand Down Expand Up @@ -3856,8 +3861,11 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder)
int ngc_vars = 0;
for (int i = 0; i < cfg->next_vreg; ++i) {
if (vreg_is_ref (cfg, i)) {
ctx->gc_var_indexes [i] = ngc_vars + 1;
ngc_vars ++;
MonoInst *var = get_vreg_to_inst (ctx->cfg, i);
if (!(var && var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT|MONO_INST_IS_DEAD))) {
ctx->gc_var_indexes [i] = ngc_vars + 1;
ngc_vars ++;
}
}
}

Expand Down Expand Up @@ -4106,15 +4114,17 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder)

#ifdef TARGET_WASM
/*
* Store ref arguments to the pin area.
* FIXME: This might not be needed, since the caller already does it ?
* Storing ref arguments to the pin area is not needed
* since it's done by the caller.
*/
/*
for (int i = 0; i < cfg->num_varinfo; ++i) {
MonoInst *var = cfg->varinfo [i];

if (var->opcode == OP_ARG && vreg_is_ref (cfg, var->dreg) && ctx->values [var->dreg])
emit_gc_pin (ctx, builder, var->dreg);
}
*/
#endif

if (cfg->deopt) {
Expand Down Expand Up @@ -11284,7 +11294,7 @@ MONO_RESTORE_WARNING
if (!skip_volatile_store)
emit_volatile_store (ctx, ins->dreg);
#ifdef TARGET_WASM
if (vreg_is_ref (cfg, ins->dreg) && ctx->values [ins->dreg])
if (vreg_is_ref (cfg, ins->dreg) && ctx->values [ins->dreg] && ins->opcode != OP_MOVE)
emit_gc_pin (ctx, builder, ins->dreg);
#endif
}
Expand Down
31 changes: 31 additions & 0 deletions src/mono/mono/mini/mini-wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,37 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
gboolean
mono_arch_opcode_supported (int opcode)
{
switch (opcode) {
case OP_ATOMIC_ADD_I4:
case OP_ATOMIC_ADD_I8:
case OP_ATOMIC_EXCHANGE_I4:
case OP_ATOMIC_EXCHANGE_I8:
case OP_ATOMIC_CAS_I4:
case OP_ATOMIC_CAS_I8:
case OP_ATOMIC_LOAD_I1:
case OP_ATOMIC_LOAD_I2:
case OP_ATOMIC_LOAD_I4:
case OP_ATOMIC_LOAD_I8:
case OP_ATOMIC_LOAD_U1:
case OP_ATOMIC_LOAD_U2:
case OP_ATOMIC_LOAD_U4:
case OP_ATOMIC_LOAD_U8:
case OP_ATOMIC_LOAD_R4:
case OP_ATOMIC_LOAD_R8:
case OP_ATOMIC_STORE_I1:
case OP_ATOMIC_STORE_I2:
case OP_ATOMIC_STORE_I4:
case OP_ATOMIC_STORE_I8:
case OP_ATOMIC_STORE_U1:
case OP_ATOMIC_STORE_U2:
case OP_ATOMIC_STORE_U4:
case OP_ATOMIC_STORE_U8:
case OP_ATOMIC_STORE_R4:
case OP_ATOMIC_STORE_R8:
return TRUE;
default:
return FALSE;
}
return FALSE;
}

Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/mini.c
Original file line number Diff line number Diff line change
Expand Up @@ -3756,6 +3756,8 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts
NULLIFY_INS (cfg->init_method_rgctx_ins);
/* Needed by the assert in get_gshared_info_slot () */
cfg->init_method_rgctx_ins = NULL;
cfg->init_method_rgctx_ins_arg->opcode = OP_PCONST;
cfg->init_method_rgctx_ins_arg->inst_p0 = NULL;
}

if (cfg->got_var) {
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/mini.h
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ typedef struct {

/* Points to the call to mini_init_method_rgctx () */
MonoInst *init_method_rgctx_ins;
MonoInst *init_method_rgctx_ins_arg;

MonoInst *lmf_var;
MonoInst *lmf_addr_var;
Expand Down