WASM: Add intrinsic implementation for ByReference<T> ctor and fix the Value getter (#5987)
This commit is contained in:
Родитель
7c79aac014
Коммит
755f9d4193
|
@ -1562,6 +1562,23 @@ namespace Internal.IL
|
|||
return true;
|
||||
}
|
||||
break;
|
||||
case ".ctor":
|
||||
if (metadataType.IsByReferenceOfT)
|
||||
{
|
||||
StackEntry byRefValueParamHolder = _stack.Pop();
|
||||
|
||||
// Allocate a slot on the shadow stack for the ByReference type
|
||||
int spillIndex = _spilledExpressions.Count;
|
||||
SpilledExpressionEntry spillEntry = new SpilledExpressionEntry(StackValueKind.ByRef, "byref" + _currentOffset, metadataType, spillIndex, this);
|
||||
_spilledExpressions.Add(spillEntry);
|
||||
LLVMValueRef addrOfValueType = LoadVarAddress(spillIndex, LocalVarKind.Temp, out TypeDesc unused);
|
||||
var typedAddress = CastIfNecessary(_builder, addrOfValueType, LLVM.PointerType(LLVM.Int32Type(), 0));
|
||||
LLVM.BuildStore(_builder, byRefValueParamHolder.ValueForStackKind(StackValueKind.ByRef, _builder, false), typedAddress);
|
||||
|
||||
_stack.Push(spillEntry);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -294,6 +294,22 @@ internal static class Program
|
|||
PrintLine("float comparison: Ok.");
|
||||
}
|
||||
|
||||
// Create a ByReference<char> through the ReadOnlySpan ctor and call the ByReference.Value via the indexer.
|
||||
var span = "123".AsSpan();
|
||||
if (span[0] != '1'
|
||||
|| span[1] != '2'
|
||||
|| span[2] != '3')
|
||||
{
|
||||
PrintLine("ByReference intrinsics exercise via ReadOnlySpan failed");
|
||||
PrintLine(span[0].ToString());
|
||||
PrintLine(span[1].ToString());
|
||||
PrintLine(span[2].ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintLine("ByReference intrinsics exercise via ReadOnlySpan OK.");
|
||||
}
|
||||
|
||||
// This test should remain last to get other results before stopping the debugger
|
||||
PrintLine("Debugger.Break() test: Ok if debugger is open and breaks.");
|
||||
System.Diagnostics.Debugger.Break();
|
||||
|
|
Загрузка…
Ссылка в новой задаче