Skip to content

Commit

Permalink
JIT: fixes for EH Write Thru and OSR (dotnet#35550)
Browse files Browse the repository at this point in the history
For EH Write Thru: make sure to initialize the stack home for any EH live
register parameters. Fixes some runtime errors.

For OSR: don't allocate the patchpoint counter local until we're going to
transform a patchpoint. Fixes a post-phase assert.
  • Loading branch information
AndyAyersMS authored Apr 28, 2020
1 parent 7cbf0a7 commit 9491e7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3851,7 +3851,7 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere
#endif // !TARGET_64BIT
{
// If this arg is never on the stack, go to the next one.
if (!regArgTab[argNum].stackArg)
if (!regArgTab[argNum].stackArg && !regArgTab[argNum].writeThru)
{
continue;
}
Expand Down
22 changes: 13 additions & 9 deletions src/coreclr/src/jit/patchpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,17 @@
//
// * no patchpoints in handler regions
// * no patchpoints for localloc methods
// * no patchpoints in try regions (workaround)
// * no patchpoints for synchronized methods (workaround)
//
class PatchpointTransformer
{
unsigned ppCounterLclNum;
const int HIGH_PROBABILITY = 99;
unsigned ppCounterLclNum;
Compiler* compiler;

public:
PatchpointTransformer(Compiler* compiler) : compiler(compiler)
PatchpointTransformer(Compiler* compiler) : ppCounterLclNum(BAD_VAR_NUM), compiler(compiler)
{
ppCounterLclNum = compiler->lvaGrabTemp(true DEBUGARG("patchpoint counter"));
compiler->lvaTable[ppCounterLclNum].lvType = TYP_INT;
}

//------------------------------------------------------------------------
Expand All @@ -53,11 +50,8 @@ class PatchpointTransformer
compiler->fgEnsureFirstBBisScratch();
}

BasicBlock* block = compiler->fgFirstBB;
TransformEntry(block);

int count = 0;
for (block = block->bbNext; block != nullptr; block = block->bbNext)
for (BasicBlock* block = compiler->fgFirstBB->bbNext; block != nullptr; block = block->bbNext)
{
if (block->bbFlags & BBF_PATCHPOINT)
{
Expand Down Expand Up @@ -119,6 +113,16 @@ class PatchpointTransformer
//
void TransformBlock(BasicBlock* block)
{
// If we haven't allocated the counter temp yet, set it up
if (ppCounterLclNum == BAD_VAR_NUM)
{
ppCounterLclNum = compiler->lvaGrabTemp(true DEBUGARG("patchpoint counter"));
compiler->lvaTable[ppCounterLclNum].lvType = TYP_INT;

// and initialize in the entry block
TransformEntry(compiler->fgFirstBB);
}

// Capture the IL offset
IL_OFFSET ilOffset = block->bbCodeOffs;
assert(ilOffset != BAD_IL_OFFSET);
Expand Down

0 comments on commit 9491e7a

Please sign in to comment.