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
42 changes: 0 additions & 42 deletions src/mono/wasm/runtime/corebindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,45 +123,3 @@ mono_wasm_typed_array_new_ref (char *arr, int length, int size, int type, PPVOLA
store_volatile((PPVOLATILE(MonoObject))result, (MonoObject *)buffer);
MONO_EXIT_GC_UNSAFE;
}

// TODO: Remove - no longer used? If not, convert to ref
EMSCRIPTEN_KEEPALIVE int
mono_wasm_unbox_enum (PVOLATILE(MonoObject) obj)
{
if (!obj)
return 0;

int result = 0;
MONO_ENTER_GC_UNSAFE;
PVOLATILE(MonoType) type = mono_class_get_type (mono_object_get_class(obj));

PVOLATILE(void) ptr = mono_object_unbox (obj);
switch (mono_type_get_type(mono_type_get_underlying_type (type))) {
case MONO_TYPE_I1:
case MONO_TYPE_U1:
result = *(unsigned char*)ptr;
break;
case MONO_TYPE_I2:
result = *(short*)ptr;
break;
case MONO_TYPE_U2:
result = *(unsigned short*)ptr;
break;
case MONO_TYPE_I4:
result = *(int*)ptr;
break;
case MONO_TYPE_U4:
result = *(unsigned int*)ptr;
break;
// WASM doesn't support returning longs to JS
// case MONO_TYPE_I8:
// case MONO_TYPE_U8:
default:
printf ("Invalid type %d to mono_unbox_enum\n", mono_type_get_type(mono_type_get_underlying_type (type)));
break;
}
MONO_EXIT_GC_UNSAFE;
return result;
}


37 changes: 0 additions & 37 deletions src/mono/wasm/runtime/cwraps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const fn_signatures: SigLine[] = [
// MONO
[true, "mono_wasm_register_root", "number", ["number", "number", "string"]],
[true, "mono_wasm_deregister_root", null, ["number"]],
[true, "mono_wasm_string_get_data", null, ["number", "number", "number", "number"]],
[true, "mono_wasm_string_get_data_ref", null, ["number", "number", "number", "number"]],
[true, "mono_wasm_set_is_debugger_attached", "void", ["bool"]],
[true, "mono_wasm_send_dbg_command", "bool", ["number", "number", "number", "number", "number"]],
Expand All @@ -41,13 +40,9 @@ const fn_signatures: SigLine[] = [
[true, "mono_wasm_find_corlib_type", "number", ["string", "string"]],
[true, "mono_wasm_assembly_find_type", "number", ["number", "string", "string"]],
[true, "mono_wasm_assembly_find_method", "number", ["number", "string", "number"]],
[true, "mono_wasm_invoke_method", "number", ["number", "number", "number", "number"]],
[false, "mono_wasm_invoke_method_ref", "void", ["number", "number", "number", "number", "number"]],
[true, "mono_wasm_string_get_utf8", "number", ["number"]],
[true, "mono_wasm_string_from_utf16_ref", "void", ["number", "number", "number"]],
[true, "mono_wasm_get_obj_type", "number", ["number"]],
[true, "mono_wasm_array_length_ref", "number", ["number"]],
[true, "mono_wasm_array_get", "number", ["number", "number"]],
[true, "mono_wasm_array_get_ref", "void", ["number", "number", "number"]],
[false, "mono_wasm_obj_array_new", "number", ["number"]],
[false, "mono_wasm_obj_array_new_ref", "void", ["number", "number"]],
Expand All @@ -62,7 +57,6 @@ const fn_signatures: SigLine[] = [
[true, "mono_wasm_string_array_new_ref", "void", ["number", "number"]],
[true, "mono_wasm_typed_array_new_ref", "void", ["number", "number", "number", "number", "number"]],
[true, "mono_wasm_class_get_type", "number", ["number"]],
[true, "mono_wasm_type_get_class", "number", ["number"]],
[true, "mono_wasm_get_type_name", "string", ["number"]],
[true, "mono_wasm_get_type_aqn", "string", ["number"]],

Expand All @@ -75,9 +69,6 @@ const fn_signatures: SigLine[] = [
[true, "mono_wasm_diagnostic_server_post_resume_runtime", "void", []],
[true, "mono_wasm_diagnostic_server_create_stream", "number", []],

//DOTNET
[true, "mono_wasm_string_from_js", "number", ["string"]],

//INTERNAL
[false, "mono_wasm_exit", "void", ["number"]],
[true, "mono_wasm_getenv", "number", ["string"]],
Expand Down Expand Up @@ -146,11 +137,6 @@ export interface t_Cwraps {
mono_wasm_load_runtime(unused: string, debugLevel: number): void;
mono_wasm_change_debugger_log_level(value: number): void;

/**
* @deprecated Not GC or thread safe
*/
mono_wasm_string_get_data(string: MonoString, outChars: CharPtrPtr, outLengthBytes: Int32Ptr, outIsInterned: Int32Ptr): void;

// BINDING
mono_wasm_get_corlib(): MonoAssembly;
mono_wasm_assembly_load(name: string): MonoAssembly;
Expand All @@ -160,10 +146,6 @@ export interface t_Cwraps {
mono_wasm_assembly_find_type(assembly: MonoAssembly, namespace: string, name: string): MonoType;
mono_wasm_assembly_find_method(klass: MonoClass, name: string, args: number): MonoMethod;
mono_wasm_invoke_method_ref(method: MonoMethod, this_arg: MonoObjectRef, params: VoidPtr, out_exc: MonoObjectRef, out_result: MonoObjectRef): void;
/**
* @deprecated Not GC or thread safe
*/
mono_wasm_string_get_utf8(str: MonoString): CharPtr;
mono_wasm_string_from_utf16_ref(str: CharPtr, len: number, result: MonoObjectRef): void;

mono_wasm_array_length_ref(array: MonoObjectRef): number;
Expand All @@ -178,27 +160,14 @@ export interface t_Cwraps {
mono_wasm_string_array_new_ref(size: number, result: MonoObjectRef): void;
mono_wasm_typed_array_new_ref(arr: VoidPtr, length: number, size: number, type: number, result: MonoObjectRef): void;
mono_wasm_class_get_type(klass: MonoClass): MonoType;
mono_wasm_type_get_class(ty: MonoType): MonoClass;
mono_wasm_get_delegate_invoke_ref(delegate: MonoObjectRef): MonoMethod;
mono_wasm_get_type_name(ty: MonoType): string;
mono_wasm_get_type_aqn(ty: MonoType): string;

/**
* @deprecated Not GC or thread safe
*/
mono_wasm_get_obj_type(str: MonoObject): number;
/**
* @deprecated Not GC or thread safe
*/
mono_wasm_invoke_method(method: MonoMethod, this_arg: MonoObject, params: VoidPtr, out_exc: MonoObjectRef): MonoObject;
/**
* @deprecated Not GC or thread safe
*/
mono_wasm_obj_array_new(size: number): MonoArray;
/**
* @deprecated Not GC or thread safe
*/
mono_wasm_array_get(array: MonoArray, idx: number): MonoObject;
/**
* @deprecated Not GC or thread safe
*/
Expand All @@ -213,12 +182,6 @@ export interface t_Cwraps {
mono_wasm_diagnostic_server_post_resume_runtime(): void;
mono_wasm_diagnostic_server_create_stream(): VoidPtr;

//DOTNET
/**
* @deprecated Not GC or thread safe
*/
mono_wasm_string_from_js(str: string): MonoString;

//INTERNAL
mono_wasm_exit(exit_code: number): number;
mono_wasm_getenv(name: string): CharPtr;
Expand Down
114 changes: 0 additions & 114 deletions src/mono/wasm/runtime/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,28 +736,6 @@ mono_wasm_invoke_method_ref (MonoMethod *method, MonoObject **this_arg_in, void
MONO_EXIT_GC_UNSAFE;
}

// deprecated
MonoObject*
mono_wasm_invoke_method (MonoMethod *method, MonoObject *this_arg, void *params[], MonoObject **out_exc)
{
PVOLATILE(MonoObject) result = NULL;
mono_wasm_invoke_method_ref (method, &this_arg, params, out_exc, (MonoObject **)&result);

if (result) {
MONO_ENTER_GC_UNSAFE;
MonoMethodSignature *sig = mono_method_signature (method);
MonoType *type = mono_signature_get_return_type (sig);
// If the method return type is void return null
// This gets around a memory access crash when the result return a value when
// a void method is invoked.
if (mono_type_get_type (type) == MONO_TYPE_VOID)
result = NULL;
MONO_EXIT_GC_UNSAFE;
}

return result;
}

EMSCRIPTEN_KEEPALIVE MonoObject*
mono_wasm_invoke_method_bound (MonoMethod *method, void* args)// JSMarshalerArguments
{
Expand Down Expand Up @@ -841,28 +819,6 @@ mono_wasm_assembly_get_entry_point (MonoAssembly *assembly, int auto_insert_brea
return method;
}

// TODO: ref
EMSCRIPTEN_KEEPALIVE char *
mono_wasm_string_get_utf8 (MonoString *str)
{
char * result;
MONO_ENTER_GC_UNSAFE;
result = mono_string_to_utf8 (str); //XXX JS is responsible for freeing this
MONO_EXIT_GC_UNSAFE;
return result;
}

EMSCRIPTEN_KEEPALIVE MonoString *
mono_wasm_string_from_js (const char *str)
{
PVOLATILE(MonoString) result = NULL;
MONO_ENTER_GC_UNSAFE;
if (str)
result = mono_string_new (root_domain, str);
MONO_EXIT_GC_UNSAFE;
return result;
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_string_from_utf16_ref (const mono_unichar2 * chars, int length, MonoString **result)
{
Expand Down Expand Up @@ -1025,51 +981,6 @@ _marshal_type_from_mono_type (int mono_type, MonoClass *klass, MonoType *type)
}
}

// FIXME: Ref
EMSCRIPTEN_KEEPALIVE MonoClass *
mono_wasm_get_obj_class (MonoObject *obj)
{
if (!obj)
return NULL;

return mono_object_get_class (obj);
}

// This code runs inside a gc unsafe region
static int
_wasm_get_obj_type_ref_impl (PPVOLATILE(MonoObject) obj)
{
if (!obj || !*obj)
return 0;

/* Process obj before calling into the runtime, class_from_name () can invoke managed code */
MonoClass *klass = mono_object_get_class (*obj);
if (!klass)
return MARSHAL_ERROR_NULL_CLASS_POINTER;
if ((klass == mono_get_string_class ()) &&
mono_string_instance_is_interned ((MonoString *)*obj))
return MARSHAL_TYPE_STRING_INTERNED;

MonoType *type = mono_class_get_type (klass);
if (!type)
return MARSHAL_ERROR_NULL_TYPE_POINTER;

int mono_type = mono_type_get_type (type);

return _marshal_type_from_mono_type (mono_type, klass, type);
}

// FIXME: Ref
EMSCRIPTEN_KEEPALIVE int
mono_wasm_get_obj_type (MonoObject *obj)
{
int result;
MONO_ENTER_GC_UNSAFE;
result = _wasm_get_obj_type_ref_impl(&obj);
MONO_EXIT_GC_UNSAFE;
return result;
}

// This code runs inside a gc unsafe region
static int
_mono_wasm_try_unbox_primitive_and_get_type_ref_impl (PVOLATILE(MonoObject) obj, void *result, int result_capacity) {
Expand Down Expand Up @@ -1226,12 +1137,6 @@ mono_wasm_array_length_ref (MonoArray **array)
return mono_array_length (*array);
}

EMSCRIPTEN_KEEPALIVE MonoObject*
mono_wasm_array_get (MonoArray *array, int idx)
{
return mono_array_get (array, MonoObject*, idx);
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_array_get_ref (PPVOLATILE(MonoArray) array, int idx, PPVOLATILE(MonoObject) result)
{
Expand Down Expand Up @@ -1347,13 +1252,6 @@ mono_wasm_string_get_data_ref (
MONO_EXIT_GC_UNSAFE;
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_string_get_data (
MonoString *string, mono_unichar2 **outChars, int *outLengthBytes, int *outIsInterned
) {
mono_wasm_string_get_data_ref(&string, outChars, outLengthBytes, outIsInterned);
}

EMSCRIPTEN_KEEPALIVE MonoType *
mono_wasm_class_get_type (MonoClass *klass)
{
Expand All @@ -1366,18 +1264,6 @@ mono_wasm_class_get_type (MonoClass *klass)
return result;
}

EMSCRIPTEN_KEEPALIVE MonoClass *
mono_wasm_type_get_class (MonoType *type)
{
if (!type)
return NULL;
MonoClass *result;
MONO_ENTER_GC_UNSAFE;
result = mono_type_get_class (type);
MONO_EXIT_GC_UNSAFE;
return result;
}

EMSCRIPTEN_KEEPALIVE char *
mono_wasm_get_type_name (MonoType * typePtr) {
return mono_type_get_name_full (typePtr, MONO_TYPE_NAME_FORMAT_REFLECTION);
Expand Down