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
56 changes: 56 additions & 0 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5374,6 +5374,19 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
ip += 4;
goto call;
}
MINT_IN_CASE(MINT_NEWOBJ_STRING_UNOPT) {
// Same as MINT_NEWOBJ_STRING but copy params into right place on stack
cmethod = (InterpMethod*)frame->imethod->data_items [ip [2]];
return_offset = ip [1];
call_args_offset = ip [1];

int param_size = ip [3];
if (param_size)
memmove (locals + call_args_offset + MINT_STACK_SLOT_SIZE, locals + call_args_offset, param_size);
LOCAL_VAR (call_args_offset, gpointer) = NULL;
ip += 4;
goto call;
}
MINT_IN_CASE(MINT_NEWOBJ) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [4]];
INIT_VTABLE (vtable);
Expand Down Expand Up @@ -5474,6 +5487,49 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
ip += 4;
goto call;
}
MINT_IN_CASE(MINT_NEWOBJ_SLOW_UNOPT) {
call_args_offset = ip [1];
guint16 param_size = ip [3];
guint16 ret_size = ip [4];
gpointer this_ptr;

// Should only be called in unoptimized code. This opcode moves the params around
// to compensate for the lack of use of a proper offset allocator in unoptimized code.
gboolean is_vt = ret_size != 0;
if (!is_vt)
ret_size = MINT_STACK_SLOT_SIZE;

cmethod = (InterpMethod*)frame->imethod->data_items [ip [2]];

MonoClass *newobj_class = cmethod->method->klass;

// We allocate space on the stack for return value and for this pointer, that is passed to ctor
if (param_size)
memmove (locals + call_args_offset + ret_size + MINT_STACK_SLOT_SIZE, locals + call_args_offset, param_size);

if (is_vt) {
this_ptr = locals + call_args_offset;
memset (this_ptr, 0, ret_size);
call_args_offset += ret_size;
} else {
// FIXME push/pop LMF
MonoVTable *vtable = mono_class_vtable_checked (newobj_class, error);
if (!is_ok (error) || !mono_runtime_class_init_full (vtable, error)) {
MonoException *exc = interp_error_convert_to_exception (frame, error, ip);
g_assert (exc);
THROW_EX (exc, ip);
}
error_init_reuse (error);
this_ptr = mono_object_new_checked (newobj_class, error);
mono_interp_error_cleanup (error); // FIXME: do not swallow the error
LOCAL_VAR (call_args_offset, gpointer) = this_ptr; // return value
call_args_offset += MINT_STACK_SLOT_SIZE;
}
LOCAL_VAR (call_args_offset, gpointer) = this_ptr;
return_offset = call_args_offset; // unused, prevent warning
ip += 5;
goto call;
}
MINT_IN_CASE(MINT_INTRINS_SPAN_CTOR) {
gpointer ptr = LOCAL_VAR (ip [2], gpointer);
int len = LOCAL_VAR (ip [3], gint32);
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/interp/mintops.def
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ OPDEF(MINT_JMP, "jmp", 2, 0, 0, MintOpMethodToken)

OPDEF(MINT_ENDFILTER, "endfilter", 2, 0, 1, MintOpNoArgs)

OPDEF(MINT_NEWOBJ_SLOW_UNOPT, "newobj_slow_unopt", 5, 1, 0, MintOpMethodToken)
OPDEF(MINT_NEWOBJ_STRING_UNOPT, "newobj_string_unopt", 4, 1, 0, MintOpMethodToken)
OPDEF(MINT_NEWOBJ_SLOW, "newobj_slow", 4, 1, 1, MintOpMethodToken)
OPDEF(MINT_NEWOBJ_ARRAY, "newobj_array", 5, 1, 1, MintOpMethodToken)
OPDEF(MINT_NEWOBJ_STRING, "newobj_string", 4, 1, 1, MintOpMethodToken)
Expand Down
Loading