Skip to content

Commit

Permalink
store prop and event from_update bit in attrs
Browse files Browse the repository at this point in the history
The upper 16 bits aren't used for ECMA flags, so grab a bit for metadata-update
  • Loading branch information
lambdageek committed Mar 17, 2022
1 parent 8d129c1 commit 9917ef3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -8012,7 +8012,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint
buffer_add_string (buf, p->name);
buffer_add_methodid (buf, domain, p->get);
buffer_add_methodid (buf, domain, p->set);
buffer_add_int (buf, p->attrs);
buffer_add_int (buf, p->attrs & ~MONO_PROPERTY_META_FLAG_MASK);
i ++;
}
g_assert (i == nprops);
Expand Down
25 changes: 19 additions & 6 deletions src/mono/mono/metadata/class-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,18 @@ struct _MonoProperty {
const char *name;
MonoMethod *get;
MonoMethod *set;
guint32 attrs;
guint32 attrs; /* upper bits store non-ECMA flags */
};

/* non-ECMA flags for the MonoProperty attrs field */
enum {
/* added by metadata-update after class was created;
* not in MonoClassPropertyInfo array - don't do ptr arithmetic */
guint32 from_update : 1;
MONO_PROPERTY_META_FLAG_FROM_UPDATE = 0x00010000,
MONO_PROPERTY_META_FLAG_MASK = 0x00010000,
};


struct _MonoEvent {
MonoClass *parent;
const char *name;
Expand All @@ -207,12 +213,19 @@ struct _MonoEvent {
#ifndef MONO_SMALL_CONFIG
MonoMethod **other;
#endif
guint32 attrs;
guint32 attrs; /* upper bits store non-ECMA flags */
};

/* non-ECMA flags for the MonoEvent attrs field */
enum {
/* added by metadata-update after class was created;
* not in MonoClassEventInfo array - don't do ptr arithmetic */
guint32 from_update : 1;
MONO_EVENT_META_FLAG_FROM_UPDATE = 0x00010000,

MONO_EVENT_META_FLAG_MASK = 0x00010000,
};


/* type of exception being "on hold" for later processing (see exception_type) */
typedef enum {
MONO_EXCEPTION_NONE = 0,
Expand Down Expand Up @@ -1613,13 +1626,13 @@ m_field_is_from_update (MonoClassField *field)
static inline gboolean
m_property_is_from_update (MonoProperty *prop)
{
return prop->from_update != 0;
return (prop->attrs & MONO_PROPERTY_META_FLAG_FROM_UPDATE) != 0;
}

static inline gboolean
m_event_is_from_update (MonoEvent *evt)
{
return evt->from_update != 0;
return (evt->attrs & MONO_EVENT_META_FLAG_FROM_UPDATE) != 0;
}

/*
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -5624,7 +5624,7 @@ mono_property_get_parent (MonoProperty *prop)
guint32
mono_property_get_flags (MonoProperty *prop)
{
return prop->attrs;
return prop->attrs & ~MONO_PROPERTY_META_FLAG_MASK;
}

/**
Expand Down Expand Up @@ -5694,7 +5694,7 @@ mono_event_get_parent (MonoEvent *event)
guint32
mono_event_get_flags (MonoEvent *event)
{
return event->attrs;
return event->attrs & ~MONO_EVENT_META_FLAG_MASK;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -2349,7 +2349,7 @@ ves_icall_RuntimePropertyInfo_get_property_info (MonoReflectionPropertyHandle pr
}

if ((req_info & PInfo_Attributes) != 0)
info->attrs = pproperty->attrs;
info->attrs = (pproperty->attrs & ~MONO_PROPERTY_META_FLAG_MASK);

if ((req_info & PInfo_GetMethod) != 0) {
MonoClass *property_klass = MONO_HANDLE_GETVAL (property, klass);
Expand Down Expand Up @@ -2414,7 +2414,7 @@ ves_icall_RuntimeEventInfo_get_event_info (MonoReflectionMonoEventHandle ref_eve
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, name, MONO_HANDLE_RAW (ev_name));

info->attrs = event->attrs;
info->attrs = event->attrs & ~MONO_EVENT_META_FLAG_MASK;

MonoReflectionMethodHandle rm;
if (event->add) {
Expand Down

0 comments on commit 9917ef3

Please sign in to comment.