Skip to content

Commit

Permalink
Merge branch 'main' into browser_test_mt
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed Apr 9, 2024
2 parents e6a337e + 4c9db8a commit 2854140
Show file tree
Hide file tree
Showing 214 changed files with 4,628 additions and 4,033 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static partial class Marshal
/// <summary>
/// IUnknown is {00000000-0000-0000-C000-000000000046}
/// </summary>
internal static Guid IID_IUnknown = new Guid(0, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
internal static readonly Guid IID_IUnknown = new Guid(0, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
#endif //FEATURE_COMINTEROP

internal static int SizeOfHelper(RuntimeType t, [MarshalAs(UnmanagedType.Bool)] bool throwIfNotMarshalable)
Expand Down Expand Up @@ -929,7 +929,7 @@ public static object BindToMoniker(string monikerName)
ThrowExceptionForHR(MkParseDisplayName(bindctx, monikerName, out _, out IntPtr pmoniker));
try
{
ThrowExceptionForHR(BindMoniker(pmoniker, 0, ref IID_IUnknown, out IntPtr ptr));
ThrowExceptionForHR(BindMoniker(pmoniker, 0, in IID_IUnknown, out IntPtr ptr));
try
{
return GetObjectForIUnknown(ptr);
Expand All @@ -956,7 +956,7 @@ public static object BindToMoniker(string monikerName)
private static partial int MkParseDisplayName(IntPtr pbc, [MarshalAs(UnmanagedType.LPWStr)] string szUserName, out uint pchEaten, out IntPtr ppmk);

[LibraryImport(Interop.Libraries.Ole32)]
private static partial int BindMoniker(IntPtr pmk, uint grfOpt, ref Guid iidResult, out IntPtr ppvResult);
private static partial int BindMoniker(IntPtr pmk, uint grfOpt, in Guid iidResult, out IntPtr ppvResult);

[SupportedOSPlatform("windows")]
public static void ChangeWrapperHandleStrength(object otp, bool fIsWeak)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/gcdump/i386/gcdumpx86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@ size_t GCDump::DumpGCTable(PTR_CBYTE table,
/* non-ptr arg push */

curOffs += (val & 0x07);
#ifndef UNIX_X86_ABI
// For x86/Linux, non-ptr arg pushes can be reported even for EBP frames
#ifndef FEATURE_EH_FUNCLETS
// For funclets, non-ptr arg pushes can be reported even for EBP frames
_ASSERTE(!header.ebpFrame);
#endif // UNIX_X86_ABI
#endif // FEATURE_EH_FUNCLETS
argCnt++;

DumpEncoding(bp, table-bp); bp = table;
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/interop/comwrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,9 @@ HRESULT ManagedObjectWrapper::QueryInterface(
return E_NOINTERFACE;

default:
#if !defined(__clang__) || (__clang_major__ > 13) // Workaround bug in old clang
_ASSERTE(false && "Unknown result value");
#endif
FALLTHROUGH;
case TryInvokeICustomQueryInterfaceResult::FailedToInvoke:
// Set the 'lacks' flag since our attempt to use ICustomQueryInterface
Expand Down
22 changes: 22 additions & 0 deletions src/coreclr/jit/abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ regMaskTP ABIPassingSegment::GetRegisterMask() const
// Return Value:
// Offset relative to the first stack argument.
//
// Remarks:
// On x86, where arguments are pushed in order and thus come in reverse order
// in the callee, this is the offset to subtract from the top of the stack to
// get the argument's address. By top of the stack is meant esp on entry + 4
// for the return address + total size of stack arguments. In varargs methods
// the varargs cookie contains the information required to allow the
// computation of the total size of stack arguments.
//
// Outside x86 this is the offset to add to the first argument's address.
//
unsigned ABIPassingSegment::GetStackOffset() const
{
assert(IsPassedOnStack());
Expand Down Expand Up @@ -208,6 +218,18 @@ bool ABIPassingInformation::HasAnyStackSegment() const
return false;
}

//-----------------------------------------------------------------------------
// HasExactlyOneRegisterSegment:
// Check if this value is passed as a single register segment.
//
// Return Value:
// True if so.
//
bool ABIPassingInformation::HasExactlyOneRegisterSegment() const
{
return (NumSegments == 1) && Segments[0].IsPassedInRegister();
}

//-----------------------------------------------------------------------------
// HasExactlyOneStackSegment:
// Check if this value is passed as a single stack segment.
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ABIPassingSegment
regMaskTP GetRegisterMask() const;

// If this segment is passed on the stack then return the particular stack
// offset, relative to the first stack argument's offset.
// offset, relative to the base of stack arguments.
unsigned GetStackOffset() const;

var_types GetRegisterStoreType() const;
Expand All @@ -53,6 +53,7 @@ struct ABIPassingInformation

bool HasAnyRegisterSegment() const;
bool HasAnyStackSegment() const;
bool HasExactlyOneRegisterSegment() const;
bool HasExactlyOneStackSegment() const;
bool IsSplitAcrossRegistersAndStack() const;

Expand Down
7 changes: 4 additions & 3 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4988,7 +4988,7 @@ void CodeGen::genHomeSwiftStructParameters(bool handleStack)
}

JITDUMP("Homing Swift parameter V%02u: ", lclNum);
const ABIPassingInformation& abiInfo = compiler->lvaParameterPassingInfo[lclNum];
const ABIPassingInformation& abiInfo = compiler->lvaGetParameterABIInfo(lclNum);
DBEXEC(VERBOSE, abiInfo.Dump());

for (unsigned i = 0; i < abiInfo.NumSegments; i++)
Expand Down Expand Up @@ -6520,7 +6520,8 @@ void CodeGen::genFnProlog()
noway_assert(compiler->info.compArgsCount > 0);

// MOV EAX, <VARARGS HANDLE>
GetEmitter()->emitIns_R_S(ins_Load(TYP_I_IMPL), EA_PTRSIZE, REG_EAX, compiler->info.compArgsCount - 1, 0);
assert(compiler->lvaVarargsHandleArg == compiler->info.compArgsCount - 1);
GetEmitter()->emitIns_R_S(ins_Load(TYP_I_IMPL), EA_PTRSIZE, REG_EAX, compiler->lvaVarargsHandleArg, 0);
regSet.verifyRegUsed(REG_EAX);

// MOV EAX, [EAX]
Expand All @@ -6529,7 +6530,7 @@ void CodeGen::genFnProlog()
// EDX might actually be holding something here. So make sure to only use EAX for this code
// sequence.

const LclVarDsc* lastArg = compiler->lvaGetDesc(compiler->info.compArgsCount - 1);
const LclVarDsc* lastArg = compiler->lvaGetDesc(compiler->lvaVarargsHandleArg);
noway_assert(!lastArg->lvRegister);
signed offset = lastArg->GetStackOffset();
assert(offset != BAD_STK_OFFS);
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
codeGen->setVerbose(true);
}

treesBeforeAfterMorph = (JitConfig.TreesBeforeAfterMorph() == 1);
treesBeforeAfterMorph = (JitConfig.JitDumpBeforeAfterMorph() == 1);
morphNum = 0; // Initialize the morphed-trees counting.

expensiveDebugCheckLevel = JitConfig.JitExpensiveDebugCheckLevel();
Expand Down Expand Up @@ -4623,6 +4623,11 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
fgFixEntryFlowForOSR();
}

// Drop back to just checking profile likelihoods.
//
activePhaseChecks &= ~PhaseChecks::CHECK_PROFILE;
activePhaseChecks |= PhaseChecks::CHECK_LIKELIHOODS;

// Enable the post-phase checks that use internal logic to decide when checking makes sense.
//
activePhaseChecks |=
Expand Down
60 changes: 18 additions & 42 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,9 @@ enum class PhaseChecks : unsigned int
CHECK_FG = 1 << 2, // flow graph integrity
CHECK_EH = 1 << 3, // eh table integrity
CHECK_LOOPS = 1 << 4, // loop integrity/canonicalization
CHECK_PROFILE = 1 << 5, // profile data integrity
CHECK_LINKED_LOCALS = 1 << 6, // check linked list of locals
CHECK_LIKELIHOODS = 1 << 5, // profile data likelihood integrity
CHECK_PROFILE = 1 << 6, // profile data full integrity
CHECK_LINKED_LOCALS = 1 << 7, // check linked list of locals
};

inline constexpr PhaseChecks operator ~(PhaseChecks a)
Expand Down Expand Up @@ -1563,6 +1564,12 @@ inline PhaseChecks& operator ^=(PhaseChecks& a, PhaseChecks b)
{
return a = (PhaseChecks)((unsigned int)a ^ (unsigned int)b);
}

inline bool hasFlag(const PhaseChecks& flagSet, const PhaseChecks& flag)
{
return ((flagSet & flag) == flag);
}

// clang-format on

// Specify which dumps should be run after each phase
Expand Down Expand Up @@ -4023,6 +4030,12 @@ class Compiler
return lvaGetDesc(lclVar->GetLclNum());
}

const ABIPassingInformation& lvaGetParameterABIInfo(unsigned lclNum)
{
assert(lclNum < info.compArgsCount);
return lvaParameterPassingInfo[lclNum];
}

unsigned lvaTrackedIndexToLclNum(unsigned trackedIndex)
{
assert(trackedIndex < lvaTrackedCount);
Expand Down Expand Up @@ -4091,18 +4104,7 @@ class Compiler
bool lvaIsOriginalThisReadOnly(); // return true if there is no place in the code
// that writes to arg0

#ifdef TARGET_X86
bool lvaIsArgAccessedViaVarArgsCookie(unsigned lclNum)
{
if (!info.compIsVarArgs)
{
return false;
}

LclVarDsc* varDsc = lvaGetDesc(lclNum);
return varDsc->lvIsParam && !varDsc->lvIsRegArg && (lclNum != lvaVarargsHandleArg);
}
#endif // TARGET_X86
bool lvaIsArgAccessedViaVarArgsCookie(unsigned lclNum);

bool lvaIsImplicitByRefLocal(unsigned lclNum) const;
bool lvaIsLocalImplicitlyAccessedByRef(unsigned lclNum) const;
Expand Down Expand Up @@ -6136,7 +6138,7 @@ class Compiler
void fgDebugCheckDispFlags(GenTree* tree, GenTreeFlags dispFlags, GenTreeDebugFlags debugFlags);
void fgDebugCheckFlagsHelper(GenTree* tree, GenTreeFlags actualFlags, GenTreeFlags expectedFlags);
void fgDebugCheckTryFinallyExits();
void fgDebugCheckProfileWeights();
void fgDebugCheckProfile(PhaseChecks checks = PhaseChecks::CHECK_NONE);
bool fgDebugCheckProfileWeights(ProfileChecks checks);
bool fgDebugCheckIncomingProfileData(BasicBlock* block, ProfileChecks checks);
bool fgDebugCheckOutgoingProfileData(BasicBlock* block, ProfileChecks checks);
Expand Down Expand Up @@ -6281,7 +6283,7 @@ class Compiler
bool fgPgoConsistent;

#ifdef DEBUG
bool fgPgoConsistentCheck;
bool fgPgoDeferredInconsistency;
#endif


Expand Down Expand Up @@ -8022,32 +8024,6 @@ class Compiler
Lowering* m_pLowering; // Lowering; needed to Lower IR that's added or modified after Lowering.
LinearScanInterface* m_pLinearScan; // Linear Scan allocator

/* raIsVarargsStackArg is called by raMaskStkVars and by
lvaComputeRefCounts. It identifies the special case
where a varargs function has a parameter passed on the
stack, other than the special varargs handle. Such parameters
require special treatment, because they cannot be tracked
by the GC (their offsets in the stack are not known
at compile time).
*/

bool raIsVarargsStackArg(unsigned lclNum)
{
#ifdef TARGET_X86

LclVarDsc* varDsc = lvaGetDesc(lclNum);

assert(varDsc->lvIsParam);

return (info.compIsVarArgs && !varDsc->lvIsRegArg && (lclNum != lvaVarargsHandleArg));

#else // TARGET_X86

return false;

#endif // TARGET_X86
}

/*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6680,11 +6680,11 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,

emitFullyInt = fullyInt;
emitFullGCinfo = fullPtrMap;

#ifndef UNIX_X86_ABI
emitFullArgInfo = !emitHasFramePtr;
#if TARGET_X86
// On x86 with funclets we emit full ptr map even for EBP frames
emitFullArgInfo = comp->UsesFunclets() ? fullPtrMap : !emitHasFramePtr;
#else
emitFullArgInfo = fullPtrMap;
emitFullArgInfo = !emitHasFramePtr;
#endif

#if EMITTER_STATS
Expand Down
Loading

0 comments on commit 2854140

Please sign in to comment.