-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Extend preinitialization interpreter to support calling string::Length
#78680
Conversation
* Support `callvirt` to a non-virtual method * Support accessing string's fields
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue Details
A bit of progress towards #78093 (comment). Cc @dotnet/ilc-contrib
|
@@ -598,6 +607,11 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack<Method | |||
return Status.Fail(methodIL.OwningMethod, opcode, "Reference field"); | |||
} | |||
|
|||
if (field.FieldType.IsByRef) | |||
{ | |||
return Status.Fail(methodIL.OwningMethod, opcode, "Byref field"); |
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 is not strictly necessary because we would throw/catch exception later, but ideally we should only do throw/catch on invalid programs.
Debug.Assert(firstCharField.FieldType.IsWellKnownType(WellKnownType.Char) | ||
&& firstCharField.Offset.AsInt == pointerSize + sizeof(int) /* length */); | ||
|
||
value.CopyTo(MemoryMarshal.Cast<byte, char>(((Span<byte>)bytes).Slice(firstCharField.Offset.AsInt))); |
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 would not work for little-endian/big-endian cross-compilation, but it is not the first problem of this kind in the aot interpreter.
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.
LGTM. Thanks!
callvirt
to a non-virtual methodA bit of progress towards #78093 (comment).
Cc @dotnet/ilc-contrib