Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove VM_FIELD macros and Il2CppMonoClassField #737

Closed
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
60 changes: 30 additions & 30 deletions mono/mini/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -7281,9 +7281,9 @@ static void buffer_add_value_full(Buffer *buf, MonoType *t, void *addr, MonoDoma
iter = NULL;
while ((f = mono_class_get_fields(klass, &iter)))
{
if (VM_FIELD_GET_TYPE(f)->attrs & FIELD_ATTRIBUTE_STATIC)
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
continue;
if (VM_FIELD_IS_DELETED(f))
if (mono_field_is_deleted(f))
continue;
nfields++;
}
Expand All @@ -7292,11 +7292,11 @@ static void buffer_add_value_full(Buffer *buf, MonoType *t, void *addr, MonoDoma
iter = NULL;
while ((f = mono_class_get_fields(klass, &iter)))
{
if (VM_FIELD_GET_TYPE(f)->attrs & FIELD_ATTRIBUTE_STATIC)
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
continue;
if (VM_FIELD_IS_DELETED(f))
if (mono_field_is_deleted(f))
continue;
buffer_add_value_full(buf, VM_FIELD_GET_TYPE(f), (guint8*)addr + VM_FIELD_GET_OFFSET(f) - sizeof(MonoObject), domain, FALSE, parent_vtypes);
buffer_add_value_full(buf, f->type, (guint8*)addr + f->offset - sizeof(MonoObject), domain, FALSE, parent_vtypes);
}

if (boxed_vtype)
Expand Down Expand Up @@ -7381,11 +7381,11 @@ decode_vtype (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8

nfields = decode_int (buf, &buf, limit);
while ((f = mono_class_get_fields (klass, &iter))) {
if (VM_FIELD_GET_TYPE(f)->attrs & FIELD_ATTRIBUTE_STATIC)
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC)
continue;
if (VM_FIELD_IS_DELETED(f))
if (mono_field_is_deleted(f))
continue;
err = decode_value (VM_FIELD_GET_TYPE(f), domain, (guint8*)addr + VM_FIELD_GET_OFFSET(f) - sizeof (MonoObject), buf, &buf, limit);
err = decode_value (f->type, domain, (guint8*)addr + f->offset - sizeof (MonoObject), buf, &buf, limit);
if (err != ERR_NONE)
return err;
nfields --;
Expand Down Expand Up @@ -9591,7 +9591,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint

while ((f = mono_class_get_fields (klass, &iter))) {
buffer_add_fieldid (buf, domain, f);
buffer_add_string (buf, VM_FIELD_GET_NAME(f));
buffer_add_string (buf, f->name);
buffer_add_typeid (buf, domain, mono_class_from_mono_type (mono_field_get_type(f)));
buffer_add_int (buf, mono_field_get_type(f)->attrs);
i ++;
Expand Down Expand Up @@ -9715,11 +9715,11 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
if (err != ERR_NONE)
return err;

if (!(VM_FIELD_GET_TYPE(f)->attrs & FIELD_ATTRIBUTE_STATIC))
if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC))
return ERR_INVALID_FIELDID;

#ifdef IL2CPP_MONO_DEBUGGER
if (!thread && VM_FIELD_GET_OFFSET(f) == THREAD_STATIC_FIELD_OFFSET)
if (!thread && f->offset == THREAD_STATIC_FIELD_OFFSET)
return ERR_INVALID_FIELDID;
#else
special_static_type = mono_class_field_get_special_static_type (f);
Expand All @@ -9731,20 +9731,20 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
/* Check that the field belongs to the object */
found = FALSE;
for (k = klass; k; k = k->parent) {
if (k == VM_FIELD_GET_PARENT(f)) {
if (k == f->parent) {
found = TRUE;
break;
}
}
if (!found)
return ERR_INVALID_FIELDID;

vtable = mono_class_vtable (domain, VM_FIELD_GET_PARENT(f));
val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (VM_FIELD_GET_TYPE(f))));
vtable = mono_class_vtable (domain, f->parent);
val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
mono_field_static_get_value_for_thread (thread ? thread : mono_thread_internal_current (), vtable, f, val, &error);
if (!is_ok (&error))
return ERR_INVALID_FIELDID;
buffer_add_value (buf, VM_FIELD_GET_TYPE(f), val, domain);
buffer_add_value (buf, f->type, val, domain);
g_free (val);
}
break;
Expand Down Expand Up @@ -11260,30 +11260,30 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
/* Check that the field belongs to the object */
found = FALSE;
for (k = obj_type; k; k = k->parent) {
if (k == VM_FIELD_GET_PARENT(f)) {
if (k == f->parent) {
found = TRUE;
break;
}
}
if (!found)
return ERR_INVALID_FIELDID;

if (VM_FIELD_GET_TYPE(f)->attrs & FIELD_ATTRIBUTE_STATIC) {
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) {
guint8 *val;
MonoVTable *vtable;

if (mono_class_field_is_special_static (f))
return ERR_INVALID_FIELDID;

g_assert (VM_FIELD_GET_TYPE(f)->attrs & FIELD_ATTRIBUTE_STATIC);
vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), VM_FIELD_GET_PARENT(f));
val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (VM_FIELD_GET_TYPE(f))));
g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC);
vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), f->parent);
val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
mono_field_static_get_value_checked (vtable, f, val, &error);
if (!is_ok (&error)) {
mono_error_cleanup (&error); /* FIXME report the error */
return ERR_INVALID_OBJECT;
}
buffer_add_value (buf, VM_FIELD_GET_TYPE(f), val, VM_OBJECT_GET_DOMAIN(obj));
buffer_add_value (buf, f->type, val, VM_OBJECT_GET_DOMAIN(obj));
g_free (val);
} else {
guint8 *field_value = NULL;
Expand All @@ -11301,9 +11301,9 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
#endif
}
else
field_value = VM_FIELD_GET_ADDRESS(obj, f);
field_value = (guint8*)(obj) + f->offset;

buffer_add_value (buf, VM_FIELD_GET_TYPE(f), field_value, VM_OBJECT_GET_DOMAIN(obj));
buffer_add_value (buf, f->type, field_value, VM_OBJECT_GET_DOMAIN(obj));
}
}
break;
Expand All @@ -11318,34 +11318,34 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
/* Check that the field belongs to the object */
found = FALSE;
for (k = obj_type; k; k = k->parent) {
if (k == VM_FIELD_GET_PARENT(f)) {
if (k == f->parent) {
found = TRUE;
break;
}
}
if (!found)
return ERR_INVALID_FIELDID;

if (VM_FIELD_GET_TYPE(f)->attrs & FIELD_ATTRIBUTE_STATIC) {
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) {
guint8 *val;
MonoVTable *vtable;

if (mono_class_field_is_special_static (f))
return ERR_INVALID_FIELDID;

g_assert (VM_FIELD_GET_TYPE(f)->attrs & FIELD_ATTRIBUTE_STATIC);
vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), VM_FIELD_GET_PARENT(f));
g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC);
vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), f->parent);

val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (VM_FIELD_GET_TYPE(f))));
err = decode_value (VM_FIELD_GET_TYPE(f), VM_OBJECT_GET_DOMAIN(obj), val, p, &p, end);
val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type)));
err = decode_value (f->type, VM_OBJECT_GET_DOMAIN(obj), val, p, &p, end);
if (err != ERR_NONE) {
g_free (val);
return err;
}
mono_field_static_set_value (vtable, f, val);
g_free (val);
} else {
err = decode_value (VM_FIELD_GET_TYPE(f), VM_OBJECT_GET_DOMAIN(obj), (guint8*)obj + VM_FIELD_GET_OFFSET(f), p, &p, end);
err = decode_value (f->type, VM_OBJECT_GET_DOMAIN(obj), (guint8*)obj + f->offset, p, &p, end);
if (err != ERR_NONE)
return err;
}
Expand Down
4 changes: 2 additions & 2 deletions mono/mini/il2cpp-c-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#define MonoClass Il2CppClass
#define MonoImage Il2CppImage
#define MonoMethod MethodInfo
#define MonoClassField FieldInfo

//still stubs everywhere
typedef struct _Il2CppMonoAssemblyName Il2CppMonoAssemblyNameReplacement;
typedef struct _Il2CppMonoAssembly Il2CppMonoAssembly;
typedef struct _Il2CppMonoDomain Il2CppMonoDomain;
typedef struct _Il2CppMonoMethodSignature Il2CppMonoMethodSignature;
typedef struct FieldInfo Il2CppMonoClassField;
typedef struct Il2CppArrayType Il2CppMonoArrayType;
typedef struct Il2CppGenericParam Il2CppMonoGenericParam;
typedef struct Il2CppGenericInst Il2CppMonoGenericInst;
Expand Down Expand Up @@ -71,7 +71,7 @@ struct _Il2CppMonoExceptionClause
struct _Il2CppCattrNamedArg
{
MonoType *type;
Il2CppMonoClassField *field;
MonoClassField *field;
Il2CppMonoProperty *prop;
};

Expand Down
40 changes: 14 additions & 26 deletions mono/mini/il2cpp-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@
#define VM_METHOD_IS_STRING_CTOR(method) il2cpp_method_is_string_ctor(method)
#define VM_INFLATED_METHOD_GET_DECLARING(imethod) il2cpp_method_get_generic_definition(imethod)
#define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) il2cpp_method_get_generic_class_inst(imethod)
#define VM_FIELD_GET_NAME(field) il2cpp_mono_field_get_name(field)
#define VM_FIELD_GET_PARENT(field) il2cpp_field_get_parent(field)
#define VM_FIELD_GET_TYPE(field) il2cpp_field_get_type(field)
#define VM_FIELD_GET_ADDRESS(obj, field) il2cpp_field_get_address(obj, field)
#define VM_FIELD_IS_DELETED(field) il2cpp_field_is_deleted(field)
#define VM_FIELD_GET_OFFSET(field) il2cpp_field_get_offset(field)
#define VM_OBJECT_GET_DOMAIN(object) il2cpp_mono_domain_get()
#define VM_OBJECT_GET_CLASS(object) il2cpp_object_get_class(object)
#define VM_OBJECT_GET_TYPE(object) il2cpp_mono_object_get_type(object)
Expand Down Expand Up @@ -95,12 +89,6 @@
#define VM_METHOD_IS_STRING_CTOR(method) method->string_ctor
#define VM_INFLATED_METHOD_GET_DECLARING(imethod) (imethod)->declaring
#define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) (imethod)->context.class_inst
#define VM_FIELD_GET_NAME(field) field->name
#define VM_FIELD_GET_PARENT(field) (field)->parent
#define VM_FIELD_GET_TYPE(field) (field)->type
#define VM_FIELD_GET_ADDRESS(obj, field) (guint8*)(obj) + (f)->offset
#define VM_FIELD_IS_DELETED(field) mono_field_is_deleted(field)
#define VM_FIELD_GET_OFFSET(field) (field)->offset
#define VM_OBJECT_GET_DOMAIN(object) ((MonoObject*)object)->vtable->domain
#define VM_OBJECT_GET_CLASS(object) ((MonoObject*)object)->vtable->klass
#define VM_OBJECT_GET_TYPE(object) ((MonoReflectionType*)object->vtable->type)->type
Expand Down Expand Up @@ -133,7 +121,6 @@
#define MonoAppDomain Il2CppMonoAppDomain
#define MonoDomain Il2CppMonoDomain
#define MonoMethodSignature Il2CppMonoMethodSignature
#define MonoClassField Il2CppMonoClassField
#define MonoArrayType Il2CppMonoArrayType
#define MonoGenericParam Il2CppMonoGenericParam
#define MonoGenericInst Il2CppMonoGenericInst
Expand Down Expand Up @@ -378,6 +365,7 @@
#define mono_method_get_token il2cpp_method_get_token
#define mono_method_is_generic il2cpp_method_is_generic
#define mono_method_is_inflated il2cpp_method_is_inflated
#define mono_field_is_deleted il2cpp_field_is_deleted

#define mono_domain_assemblies_lock
#define mono_domain_assemblies_unlock
Expand All @@ -397,7 +385,7 @@ mono_bool il2cpp_mono_type_generic_inst_is_valuetype (MonoType *type);
Il2CppMonoMethodHeader* il2cpp_mono_method_get_header_checked (MonoMethod *method, MonoError *error);
gboolean il2cpp_mono_class_init (MonoClass *klass);
Il2CppMonoVTable* il2cpp_mono_class_vtable (Il2CppMonoDomain *domain, MonoClass *klass);
Il2CppMonoClassField* il2cpp_mono_class_get_field_from_name (MonoClass *klass, const char *name);
MonoClassField* il2cpp_mono_class_get_field_from_name (MonoClass *klass, const char *name);
int32_t il2cpp_mono_array_element_size (MonoClass *ac);
int32_t il2cpp_mono_class_instance_size (MonoClass *klass);
int32_t il2cpp_mono_class_value_size (MonoClass *klass, uint32_t *align);
Expand All @@ -406,10 +394,10 @@ MonoClass* il2cpp_mono_class_from_mono_type (MonoType *type);
int il2cpp_mono_class_num_fields (MonoClass *klass);
int il2cpp_mono_class_num_methods (MonoClass *klass);
int il2cpp_mono_class_num_properties (MonoClass *klass);
Il2CppMonoClassField* il2cpp_mono_class_get_fields (MonoClass* klass, gpointer *iter);
MonoClassField* il2cpp_mono_class_get_fields (MonoClass* klass, gpointer *iter);
MonoMethod* il2cpp_mono_class_get_methods (MonoClass* klass, gpointer *iter);
Il2CppMonoProperty* il2cpp_mono_class_get_properties (MonoClass* klass, gpointer *iter);
const char* il2cpp_mono_field_get_name (Il2CppMonoClassField *field);
const char* il2cpp_mono_field_get_name (MonoClassField *field);
mono_unichar2* il2cpp_mono_string_chars (Il2CppMonoString *s);
int il2cpp_mono_string_length (Il2CppMonoString *s);
char* il2cpp_mono_array_addr_with_size (Il2CppMonoArray *array, int size, uintptr_t idx);
Expand All @@ -420,8 +408,8 @@ Il2CppMonoString* il2cpp_mono_string_new_checked (Il2CppMonoDomain *domain, cons
char* il2cpp_mono_string_to_utf8_checked (Il2CppMonoString *string_obj, MonoError *error);
int il2cpp_mono_object_hash (Il2CppMonoObject* obj);
void* il2cpp_mono_object_unbox (Il2CppMonoObject *obj);
void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, Il2CppMonoClassField *field, void *value);
void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, Il2CppMonoClassField *field, void *value);
void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, MonoClassField *field, void *value);
void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, MonoClassField *field, void *value);
uint32_t il2cpp_mono_gchandle_new_weakref (Il2CppMonoObject *obj, mono_bool track_resurrection);
Il2CppMonoObject* il2cpp_mono_gchandle_get_target (uint32_t gchandle);
void il2cpp_mono_gchandle_free (uint32_t gchandle);
Expand Down Expand Up @@ -465,8 +453,8 @@ int il2cpp_mono_class_interface_offset_with_variance(MonoClass* klass, MonoClass
void il2cpp_mono_class_setup_supertypes(MonoClass* klass);
void il2cpp_mono_class_setup_vtable(MonoClass* klass);
void il2cpp_mono_class_setup_methods(MonoClass* klass);
gboolean il2cpp_mono_class_field_is_special_static(Il2CppMonoClassField* field);
guint32 il2cpp_mono_class_field_get_special_static_type(Il2CppMonoClassField* field);
gboolean il2cpp_mono_class_field_is_special_static(MonoClassField* field);
guint32 il2cpp_mono_class_field_get_special_static_type(MonoClassField* field);
Il2CppMonoGenericContext* il2cpp_mono_class_get_context(MonoClass* klass);
Il2CppMonoGenericContext* il2cpp_mono_method_get_context(MonoMethod* method);
Il2CppMonoGenericContainer* il2cpp_mono_method_get_generic_container(MonoMethod* method);
Expand Down Expand Up @@ -498,9 +486,9 @@ Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks();
void il2cpp_mono_reflection_create_custom_attr_data_args(MonoImage* image, MonoMethod* method, const guchar* data, guint32 len, Il2CppMonoArray** typed_args, Il2CppMonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error);
void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, MonoClass* klass);
Il2CppMonoObject* il2cpp_mono_value_box_checked(Il2CppMonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error);
void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error);
void il2cpp_mono_field_static_get_value_for_thread(Il2CppMonoInternalThread* thread, Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error);
Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, Il2CppMonoClassField* field, Il2CppMonoObject* obj, MonoError* error);
void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error);
void il2cpp_mono_field_static_get_value_for_thread(Il2CppMonoInternalThread* thread, Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error);
Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, MonoClassField* field, Il2CppMonoObject* obj, MonoError* error);
Il2CppMonoObject* il2cpp_mono_object_new_checked(Il2CppMonoDomain* domain, MonoClass* klass, MonoError* error);
Il2CppMonoString* il2cpp_mono_ldstr_checked(Il2CppMonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error);
Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error);
Expand All @@ -519,7 +507,7 @@ MonoType* il2cpp_mono_reflection_get_type_checked(MonoImage* rootimage, MonoImag
Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(MonoMethod* method, MonoError* error);
Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(MonoClass* klass, MonoError* error);
Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(MonoClass* klass, Il2CppMonoProperty* property, MonoError* error);
Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* klass, Il2CppMonoClassField* field, MonoError* error);
Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* klass, MonoClassField* field, MonoError* error);
Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, Il2CppMonoAssembly* assembly, MonoError* error);
Il2CppMonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, MonoType* type, MonoError* error);
void il2cpp_mono_network_init();
Expand Down Expand Up @@ -587,7 +575,7 @@ mono_byte il2cpp_assembly_name_public_key_token(Il2CppMonoAssembly *monoAssembly
const char* il2cpp_assembly_name_public_key_token_string(Il2CppMonoAssembly *monoAssembly);
uint32_t il2cpp_assembly_name_flags(Il2CppMonoAssembly *monoAssembly);
const char* il2cpp_image_name(MonoImage *monoImage);
guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, Il2CppMonoClassField *monoField);
guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, MonoClassField *monoField);
MonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object);
MonoClass* il2cpp_defaults_exception_class();
MonoImage* il2cpp_defaults_corlib_image();
Expand All @@ -596,7 +584,7 @@ bool il2cpp_method_is_string_ctor (const MonoMethod * method);
MonoClass* il2cpp_defaults_void_class();
void il2cpp_set_var(guint8* newValue, void *value, MonoType *localVariableTypeMono);
MonoMethod* il2cpp_get_interface_method(MonoClass* klass, MonoClass* itf, int slot);
gboolean il2cpp_field_is_deleted(Il2CppMonoClassField *field);
gboolean il2cpp_field_is_deleted(MonoClassField *field);
MonoClass* il2cpp_iterate_loaded_classes(void* *iter);
Il2CppMonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter);
const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count);
Expand Down
Loading