Skip to content

Commit

Permalink
Represent the helper as an indirection
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky authored and jakobbotsch committed Jan 20, 2022
1 parent dfa28e1 commit e07386f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
12 changes: 0 additions & 12 deletions src/coreclr/nativeaot/Runtime/amd64/MiscStubs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ EXTERN memcpyGCRefsWithWriteBarrier : PROC
EXTERN memcpyAnyWithWriteBarrier : PROC
EXTERN RhpGetThreadStaticBaseForTypeSlow : PROC

EXTERN __guard_check_icall_fptr : QWORD
EXTERN __guard_dispatch_icall_fptr : QWORD

LEAF_ENTRY __guard_check_icall_fptrHack, _TEXT
jmp qword ptr [__guard_check_icall_fptr]
LEAF_END __guard_check_icall_fptrHack, _TEXT

LEAF_ENTRY __guard_dispatch_icall_fptrHack, _TEXT
jmp qword ptr [__guard_dispatch_icall_fptr]
LEAF_END __guard_dispatch_icall_fptrHack, _TEXT


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; void* RhpCopyMultibyteNoGCRefs(void*, void*, size_t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ namespace ILCompiler.DependencyAnalysis
/// Represents a symbol that is defined externally and statically linked to the output obj file.
/// </summary>
public class ExternSymbolNode : SortableDependencyNode, ISortableSymbolNode
{
private Utf8String _name;
{
private readonly Utf8String _name;
private readonly bool _isIndirection;

public ExternSymbolNode(Utf8String name)
public ExternSymbolNode(Utf8String name, bool isIndirection = false)
{
_name = name;
_isIndirection = isIndirection;
}

protected override string GetName(NodeFactory factory) => $"ExternSymbol {_name.ToString()}";
protected override string GetName(NodeFactory factory) => $"ExternSymbol {_name.ToString()}{(_isIndirection ? " (indirected)" : "")}";

public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
{
sb.Append(_name);
}
public int Offset => 0;
public virtual bool RepresentsIndirectionCell => false;
public virtual bool RepresentsIndirectionCell => _isIndirection;

public override bool InterestingForDynamicDependencyAnalysis => false;
public override bool HasDynamicDependencies => false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ private void CreateNodeCaches()
{
return new ExternSymbolNode(name);
});
_externIndirectSymbols = new NodeCache<string, ExternSymbolNode>((string name) =>
{
return new ExternSymbolNode(name, isIndirection: true);
});

_pInvokeModuleFixups = new NodeCache<PInvokeModuleData, PInvokeModuleFixupNode>((PInvokeModuleData moduleData) =>
{
Expand Down Expand Up @@ -741,6 +745,13 @@ public ISortableSymbolNode ExternSymbol(string name)
return _externSymbols.GetOrAdd(name);
}

private NodeCache<string, ExternSymbolNode> _externIndirectSymbols;

public ISortableSymbolNode ExternIndirectSymbol(string name)
{
return _externIndirectSymbols.GetOrAdd(name);
}

private NodeCache<PInvokeModuleData, PInvokeModuleFixupNode> _pInvokeModuleFixups;

public ISymbolNode PInvokeModuleFixup(PInvokeModuleData moduleData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,9 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum)
break;

case CorInfoHelpFunc.CORINFO_HELP_VALIDATE_INDIRECT_CALL:
return _compilation.NodeFactory.ExternSymbol("__guard_check_icall_fptrHack");
return _compilation.NodeFactory.ExternIndirectSymbol("__guard_check_icall_fptr");
case CorInfoHelpFunc.CORINFO_HELP_DISPATCH_INDIRECT_CALL:
return _compilation.NodeFactory.ExternSymbol("__guard_dispatch_icall_fptrHack");
return _compilation.NodeFactory.ExternIndirectSymbol("__guard_dispatch_icall_fptr");

default:
throw new NotImplementedException(ftnNum.ToString());
Expand Down

0 comments on commit e07386f

Please sign in to comment.