未验证 提交 d79bd033 编写于 作者: D dtomar-rythmos 提交者: GitHub

Merge pull request #1351 from Unity-Technologies/unity-2020.1-mbe-fix-threadstatic-alignment

Ensure special static slots respect alignment (case 1266322)
...@@ -113,6 +113,7 @@ struct _StaticDataFreeList { ...@@ -113,6 +113,7 @@ struct _StaticDataFreeList {
StaticDataFreeList *next; StaticDataFreeList *next;
guint32 offset; guint32 offset;
guint32 size; guint32 size;
gint32 align;
}; };
typedef struct { typedef struct {
...@@ -4290,12 +4291,12 @@ alloc_context_static_data_helper (gpointer key, gpointer value, gpointer user) ...@@ -4290,12 +4291,12 @@ alloc_context_static_data_helper (gpointer key, gpointer value, gpointer user)
} }
static StaticDataFreeList* static StaticDataFreeList*
search_slot_in_freelist (StaticDataInfo *static_data, guint32 size, guint32 align) search_slot_in_freelist (StaticDataInfo *static_data, guint32 size, gint32 align)
{ {
StaticDataFreeList* prev = NULL; StaticDataFreeList* prev = NULL;
StaticDataFreeList* tmp = static_data->freelist; StaticDataFreeList* tmp = static_data->freelist;
while (tmp) { while (tmp) {
if (tmp->size == size) { if (tmp->size == size && tmp->align == align) {
if (prev) if (prev)
prev->next = tmp->next; prev->next = tmp->next;
else else
...@@ -4453,7 +4454,7 @@ free_context_static_data_helper (gpointer key, gpointer value, gpointer user) ...@@ -4453,7 +4454,7 @@ free_context_static_data_helper (gpointer key, gpointer value, gpointer user)
} }
static void static void
do_free_special_slot (guint32 offset, guint32 size) do_free_special_slot (guint32 offset, guint32 size, gint32 align)
{ {
guint32 static_type = ACCESS_SPECIAL_STATIC_OFFSET (offset, type); guint32 static_type = ACCESS_SPECIAL_STATIC_OFFSET (offset, type);
MonoBitSet **sets; MonoBitSet **sets;
...@@ -4486,6 +4487,7 @@ do_free_special_slot (guint32 offset, guint32 size) ...@@ -4486,6 +4487,7 @@ do_free_special_slot (guint32 offset, guint32 size)
item->offset = offset; item->offset = offset;
item->size = size; item->size = size;
item->align = align;
item->next = info->freelist; item->next = info->freelist;
info->freelist = item; info->freelist = item;
...@@ -4500,7 +4502,7 @@ do_free_special (gpointer key, gpointer value, gpointer data) ...@@ -4500,7 +4502,7 @@ do_free_special (gpointer key, gpointer value, gpointer data)
gint32 align; gint32 align;
guint32 size; guint32 size;
size = mono_type_size (field->type, &align); size = mono_type_size (field->type, &align);
do_free_special_slot (offset, size); do_free_special_slot (offset, size, align);
} }
void void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册