From c87d02f658322b5e433f71316cea52d425482bbc Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Thu, 19 Sep 2024 16:54:06 -0700 Subject: [PATCH] Update InlineArrayAttribute.md --- docs/design/features/InlineArrayAttribute.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/design/features/InlineArrayAttribute.md b/docs/design/features/InlineArrayAttribute.md index 7b1f9eb21f1a0..5894088044529 100644 --- a/docs/design/features/InlineArrayAttribute.md +++ b/docs/design/features/InlineArrayAttribute.md @@ -53,13 +53,13 @@ struct MyArray The memory layout of a struct instance decorated with `InlineArray` attribute closely matches the layout of the element sequence of an array `T[]` with length == `Length`. In particular (using the `MyArray` example defined above): -* In unboxed form there is no object header or any other data before the first element. +* In unboxed form there is no object header or any other data before the first element. Example: assuming the instance is not GC-movable, the following holds: `(byte*)*inst == (byte*)inst._element0` -* There is no additional padding between elements. +* There is no additional padding between elements. Example: assuming the instance is not GC-movable and `Length > 1`, the following will yield a pointer to the second element: `(byte*)inst._element0 + sizeof(T)` -* The size of the entire instance is the size of its element type multiplied by the `Length` +* The size of the entire instance is the size of its element type multiplied by the `Length` Example: the following holds: `sizeof(MyArray) == Length * sizeof(T)` -* Just like with any other struct, the boxed form will contain the regular object header followed by an entire unboxed instance. +* Just like with any other struct, the boxed form will contain the regular object header followed by an entire unboxed instance. Example: boxing/unboxing will result in exact copy on an entire instance: `object o = inst; MyArray inst1copy = (MyArray)o` Type T can be a reference type and can contain managed references. The runtime will ensure that objects reachable through elements of an inline array instance can be accessed in a type-safe manner.