Skip to content

Commit

Permalink
Addressed some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
svick committed Oct 14, 2021
1 parent 654aba8 commit 70dd5b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,23 @@ private void EmitStackAllocBlockMultiByteInitializer(ImmutableArray<byte> data,
{
// get helpers
var definition = (MethodSymbol)_module.Compilation.GetWellKnownTypeMember(WellKnownMember.System_ReadOnlySpan_T__GetPinnableReference)!;
var getPinnableReference = definition.AsMember(definition.ContainingType.Construct(elementType)).GetCciAdapter();
var readOnlySpan = ((NamedTypeSymbol)_module.Compilation.CommonGetWellKnownType(WellKnownType.System_ReadOnlySpan_T)).Construct(elementType).GetCciAdapter();
var getPinnableReference = definition.AsMember(definition.ContainingType.Construct(elementType));
var readOnlySpan = ((NamedTypeSymbol)_module.Compilation.CommonGetWellKnownType(WellKnownType.System_ReadOnlySpan_T)).Construct(elementType);

// emit call to the helper
_builder.EmitOpCode(ILOpCode.Dup);
_builder.EmitCreateSpan(data, elementType.GetPublicSymbol(), syntaxNode, diagnostics);

var temp = _builder.LocalSlotManager.AllocateSlot(readOnlySpan, LocalSlotConstraints.None);
var temp = AllocateTemp(readOnlySpan, syntaxNode);
_builder.EmitLocalStore(temp);
_builder.EmitLocalAddress(temp);
_builder.LocalSlotManager.FreeSlot(temp);
FreeTemp(temp);

// TODO: is this safe without pinning?
// PROTOTYPE: is this safe without pinning?
_builder.EmitOpCode(ILOpCode.Call, 0);
_builder.EmitToken(getPinnableReference, syntaxNode, diagnostics);
EmitSymbolToken(getPinnableReference, syntaxNode, optArgList: null);
_builder.EmitIntConstant(data.Length);
// TODO: is this correct without unaligned.?
// PROTOTYPE: is this correct without unaligned.?
_builder.EmitOpCode(ILOpCode.Cpblk, -3);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override BoundNode VisitConversion(BoundConversion node)
};

if (CodeGen.CodeGenerator.UseCreateSpanForReadOnlySpanInitialization(hasCreateSpanHelper, considerInitblk: !isArrayCreation, elementType, initializerOpt,
/* TODO: how to find out if this is ENC? */ supportsPrivateImplClass: true))
/* PROTOTYPE: how to find out if this is ENC? */ supportsPrivateImplClass: true))
{
return new BoundConvertedStackAllocExpression(node.Operand.Syntax, elementType, count, initializerOpt, rewrittenType);
}
Expand Down

0 comments on commit 70dd5b4

Please sign in to comment.