Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix helloworld work on .net x86 linux
Make managed->managed call use of ecx, edx to pass first two arguments.
Make stack alignment returning after call.
  • Loading branch information
t-mustafin committed Jul 9, 2021
commit d1b646614d5587278cd5624ea3cc97d86da4578e
3 changes: 3 additions & 0 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6423,6 +6423,9 @@ GenTreeCall* Compiler::gtNewCallNode(
GenTreeCall* node = new (this, GT_CALL) GenTreeCall(genActualType(type));

node->gtFlags |= (GTF_CALL | GTF_GLOB_REF);
#ifdef UNIX_X86_ABI
node->gtFlags |= GTF_CALL_POP_ARGS;
#endif // UNIX_X86_ABI
for (GenTreeCall::Use& use : GenTreeCall::UseList(args))
{
node->gtFlags |= (use.GetNode()->gtFlags & GTF_ALL_EFFECT);
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ GenTree* Compiler::fgMorphIntoHelperCall(GenTree* tree, int helper, GenTreeCall:
call->gtCallMoreFlags = GTF_CALL_M_EMPTY;
call->gtInlineCandidateInfo = nullptr;
call->gtControlExpr = nullptr;
#ifdef UNIX_X86_ABI
call->gtFlags |= GTF_CALL_POP_ARGS;
#endif // UNIX_X86_ABI

#if DEBUG
// Helper calls are never candidates.
Expand Down Expand Up @@ -2897,6 +2900,7 @@ void Compiler::fgInitArgInfo(GenTreeCall* call)
// Compute the maximum number of arguments that can be passed in registers.
// For X86 we handle the varargs and unmanaged calling conventions

#ifndef UNIX_X86_ABI
if (call->gtFlags & GTF_CALL_POP_ARGS)
{
noway_assert(intArgRegNum < MAX_REG_ARG);
Expand All @@ -2907,6 +2911,7 @@ void Compiler::fgInitArgInfo(GenTreeCall* call)
if (callHasRetBuffArg)
maxRegArgs++;
}
#endif // UNIX_X86_ABI

if (call->IsUnmanaged())
{
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/vm/i386/jitinterfacex86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,12 @@ void *JIT_TrialAlloc::GenBox(Flags flags)

// Do call to CopyValueClassUnchecked(object, data, pMT)

#ifdef UNIX_X86_ABI
#define STACK_ALIGN_PADDING 12
// Make pad to align esp
sl.X86EmitSubEsp(STACK_ALIGN_PADDING);
#endif // UNIX_X86_ABI

// Pass pMT (still in ECX)
sl.X86EmitPushReg(kECX);

Expand All @@ -507,6 +513,11 @@ void *JIT_TrialAlloc::GenBox(Flags flags)

// call CopyValueClass
sl.X86EmitCall(sl.NewExternalCodeLabel((LPVOID) CopyValueClassUnchecked), 12);
#ifdef UNIX_X86_ABI
// Make pad to align esp
sl.X86EmitAddEsp(STACK_ALIGN_PADDING);
#undef STACK_ALIGN_PADDING
#endif // UNIX_X86_ABI

// Restore the address of the newly allocated object and return it.
// mov eax,ebx
Expand Down