-
Notifications
You must be signed in to change notification settings - Fork 505
Wasm: Align classes and arrays with 64 bit types at 8 byte #8255
Changes from 3 commits
9595277
62f5831
6e6aa32
9a31fdd
6a7fd40
38aae2a
b294e94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -274,7 +274,8 @@ public LayoutInt GetObjectAlignment(LayoutInt fieldAlignment) | |
| switch (Architecture) | ||
| { | ||
| case TargetArchitecture.ARM: | ||
| // ARM supports two alignments for objects on the GC heap (4 byte and 8 byte) | ||
| case TargetArchitecture.Wasm32: | ||
| // ARM & Wasm32 support two alignments for objects on the GC heap (4 byte and 8 byte) | ||
| if (fieldAlignment.IsIndeterminate) | ||
| return LayoutInt.Indeterminate; | ||
|
|
||
|
|
@@ -286,8 +287,7 @@ public LayoutInt GetObjectAlignment(LayoutInt fieldAlignment) | |
| case TargetArchitecture.ARM64: | ||
| return new LayoutInt(8); | ||
| case TargetArchitecture.X86: | ||
| case TargetArchitecture.Wasm32: | ||
| return new LayoutInt(4); | ||
| return new LayoutInt(Math.Max(4, fieldAlignment.AsInt)); | ||
|
||
| default: | ||
| throw new NotSupportedException(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -36,7 +36,6 @@ | |||
| #include "GCMemoryHelpers.inl" | ||||
|
|
||||
| #if defined(USE_PORTABLE_HELPERS) | ||||
|
|
||||
| EXTERN_C REDHAWK_API void* REDHAWK_CALLCONV RhpGcAlloc(EEType *pEEType, UInt32 uFlags, UIntNative cbSize, void * pTransitionFrame); | ||||
| EXTERN_C REDHAWK_API void* REDHAWK_CALLCONV RhpPublishObject(void* pObject, UIntNative cbSize); | ||||
|
|
||||
|
|
@@ -88,7 +87,9 @@ COOP_PINVOKE_HELPER(Object *, RhpNewFast, (EEType* pEEType)) | |||
| return pObject; | ||||
| } | ||||
|
|
||||
| #define GC_ALLOC_FINALIZE 0x1 // TODO: Defined in gc.h | ||||
| #define GC_ALLOC_FINALIZE 0x1 // TODO: Defined in gc.h | ||||
| #define GC_ALLOC_ALIGN8_BIAS 0x4 // TODO: Defined in gc.h | ||||
| #define GC_ALLOC_ALIGN8 0x8 // TODO: Defined in gc.h | ||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried including gcinterface.h but that seems to have other dependencies |
||||
|
|
||||
| COOP_PINVOKE_HELPER(Object *, RhpNewFinalizable, (EEType* pEEType)) | ||||
| { | ||||
|
|
@@ -180,36 +181,150 @@ COOP_PINVOKE_HELPER(String *, RhNewString, (EEType * pArrayEEType, int numElemen | |||
|
|
||||
| #endif | ||||
| #if defined(USE_PORTABLE_HELPERS) | ||||
| #if defined(HOST_ARM) || defined(HOST_WASM) | ||||
|
||||
|
|
||||
| GPTR_DECL(EEType, g_pFreeObjectEEType); | ||||
|
|
||||
| #ifdef HOST_ARM | ||||
| COOP_PINVOKE_HELPER(Object *, RhpNewFinalizableAlign8, (EEType* pEEType)) | ||||
| { | ||||
| Object * pObject = nullptr; | ||||
| /* TODO */ ASSERT_UNCONDITIONALLY("NYI"); | ||||
|
||||
| alignment = target.GetObjectAlignment(alignment); |
I thought a class with a long would be enough
class FinalizableClass
{
long l; // requires 8 alignment
~FinalizableClass()
{
l = 1;
if(l == 1) finalizeCalled = true;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. You are right - this is de-facto unreachable. It may be worth it to add a comment about it.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed. I do not see it in the asm version either.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17833,12 +17833,12 @@ uint8_t* gc_heap::find_object (uint8_t* interior) | |
| { | ||
| // this is a pointer to a UOH object | ||
| heap_segment* seg = find_segment (interior, FALSE); | ||
| if (seg | ||
| if (seg) | ||
| { | ||
| #ifdef FEATURE_CONSERVATIVE_GC | ||
| && (GCConfig::GetConservativeGC() || interior <= heap_segment_allocated(seg)) | ||
| if ( interior >= heap_segment_allocated(seg)) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same as merged in dotnet/runtime#39905 . If this complicates merging, I can leave this PR as WIP. |
||
| return 0; | ||
| #endif | ||
| ) | ||
| { | ||
| // If interior falls within the first free object at the beginning of a generation, | ||
| // we don't have brick entry for it, and we may incorrectly treat it as on large object heap. | ||
| int align_const = get_alignment_constant (heap_segment_read_only_p (seg) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Unnecessary WS change