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
15 changes: 15 additions & 0 deletions src/mono/browser/runtime/jiterpreter-trace-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,21 @@ export function generateWasmBody (
break;
}

case MintOpcode.MINT_NEWARR: {
builder.block();
append_ldloca(builder, getArgU16(ip, 1), 4);
const vtable = get_imethod_data(frame, getArgU16(ip, 3));
builder.i32_const(vtable);
append_ldloc(builder, getArgU16(ip, 2), WasmOpcode.i32_load);
builder.callImport("newarr");
// If the newarr operation succeeded, continue, otherwise bailout
builder.appendU8(WasmOpcode.br_if);
builder.appendULeb(0);
append_bailout(builder, ip, BailoutReason.AllocFailed);
builder.endBlock();
break;
}

case MintOpcode.MINT_NEWOBJ_INLINED: {
builder.block();
// MonoObject *o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (vtable->klass));
Expand Down
10 changes: 10 additions & 0 deletions src/mono/browser/runtime/jiterpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ function getTraceImports () {
["ckovr_u4", "overflow_check_i4", getRawCwrap("mono_jiterp_overflow_check_u4")],
importDef("newobj_i", getRawCwrap("mono_jiterp_try_newobj_inlined")),
importDef("newstr", getRawCwrap("mono_jiterp_try_newstr")),
importDef("newarr", getRawCwrap("mono_jiterp_try_newarr")),
importDef("ld_del_ptr", getRawCwrap("mono_jiterp_ld_delegate_method_ptr")),
importDef("ldtsflda", getRawCwrap("mono_jiterp_ldtsflda")),
importDef("conv", getRawCwrap("mono_jiterp_conv")),
Expand Down Expand Up @@ -464,6 +465,15 @@ function initialize_builder (builder: WasmBuilder) {
},
WasmValtype.i32, true
);
builder.defineType(
"newarr",
{
"ppDestination": WasmValtype.i32,
"vtable": WasmValtype.i32,
"length": WasmValtype.i32,
},
WasmValtype.i32, true
);
builder.defineType(
"localloc",
{
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/interp/jiterpreter-opcode-values.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ OP(MINT_BOX, NORMAL)
OP(MINT_BOX_VT, NORMAL)
OP(MINT_UNBOX, NORMAL)
OP(MINT_NEWSTR, NORMAL)
OP(MINT_NEWARR, NORMAL)
OP(MINT_LD_DELEGATE_METHOD_PTR, NORMAL)
OP(MINT_LDTSFLDA, NORMAL)
OP(MINT_ADD_MUL_I4_IMM, NORMAL)
Expand Down
12 changes: 12 additions & 0 deletions src/mono/mono/mini/interp/jiterpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ mono_jiterp_try_newstr (MonoString **destination, int length) {
return *destination != 0;
}

EMSCRIPTEN_KEEPALIVE int
mono_jiterp_try_newarr (MonoArray **destination, MonoVTable *vtable, int length) {
if (length < 0)
return 0;
ERROR_DECL(error);
*destination = mono_array_new_specific_checked (vtable, length, error);
if (!is_ok (error))
*destination = 0;
mono_error_cleanup (error); // FIXME: do not swallow the error
return *destination != 0;
}

EMSCRIPTEN_KEEPALIVE int
mono_jiterp_gettype_ref (
MonoObject **destination, MonoObject **source
Expand Down