Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 28 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7405,6 +7405,34 @@ class Compiler

unsigned Data() const { return acdData; }

// Region-kind flag bits packed into acdData by bbThrowIndex.
static const unsigned AcdHandlerFlag = 0x40000000;
static const unsigned AcdFilterFlag = 0x80000000;

// The EH region kind that keys this helper.
AcdKeyDesignator Designator() const
{
if (acdData == 0)
{
return AcdKeyDesignator::KD_NONE;
}
if ((acdData & AcdFilterFlag) != 0)
{
return AcdKeyDesignator::KD_FLT;
}
if ((acdData & AcdHandlerFlag) != 0)
{
return AcdKeyDesignator::KD_HND;
}
return AcdKeyDesignator::KD_TRY;
}

// The 0-based EH region index this helper is keyed to (not valid for KD_NONE).
unsigned RegionIndex() const
{
return (acdData & ~(AcdHandlerFlag | AcdFilterFlag)) - 1;
}

private:

SpecialCodeKind acdKind;
Expand Down
19 changes: 15 additions & 4 deletions src/coreclr/jit/fgwasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,30 @@ BasicBlockVisit FgWasm::VisitWasmSuccs(Compiler* comp, BasicBlock* block, TFunc
Compiler::AddCodeDscMap* const acdMap = comp->fgGetAddCodeDscMap();
if (acdMap != nullptr)
{
const bool isTrySideEntry = isGeneralizedTryEntry(block);

// Behave as if these blocks have edges from their respective region entry blocks.
//
if ((block == comp->fgFirstBB) || comp->bbIsFuncletBeg(block) || isGeneralizedTryEntry(block))
if ((block == comp->fgFirstBB) || comp->bbIsFuncletBeg(block) || isTrySideEntry)
Comment thread
AndyAyersMS marked this conversation as resolved.
{
Compiler::AcdKeyDesignator dsg;
const unsigned blockData = comp->bbThrowIndex(block, &dsg);

for (const Compiler::AddCodeDscKey& key : Compiler::AddCodeDscMap::KeyIteration(acdMap))
{
if (key.Data() == blockData)
const unsigned acdData = key.Data();
bool matches = (acdData == blockData);

if (!matches && isTrySideEntry && (key.Designator() == Compiler::AcdKeyDesignator::KD_TRY))
{
// Also add edges from all enclosing try regions
matches = comp->bbInTryRegions(key.RegionIndex(), block);
}
Comment thread
AndyAyersMS marked this conversation as resolved.

if (matches)
{
// This ACD refers to a throw helper block in the right region.
// Make the block a successor.
// This ACD refers to a throw helper block in this or an enclosed try region.
// Make the throw helper block a successor of the try entry.
Comment thread
AndyAyersMS marked this conversation as resolved.
//
Compiler::AddCodeDsc* acd = nullptr;
acdMap->Lookup(key, &acd);
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3898,11 +3898,11 @@ unsigned Compiler::bbThrowIndex(BasicBlock* blk, AcdKeyDesignator* dsg)
if (ehGetDsc(hndIndex - 1)->InFilterRegionBBRange(blk))
{
*dsg = AcdKeyDesignator::KD_FLT;
return hndIndex | 0x80000000;
return hndIndex | AddCodeDscKey::AcdFilterFlag;
}

*dsg = AcdKeyDesignator::KD_HND;
return hndIndex | 0x40000000;
return hndIndex | AddCodeDscKey::AcdHandlerFlag;
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -3956,10 +3956,10 @@ Compiler::AddCodeDscKey::AddCodeDscKey(AddCodeDsc* add)
acdData = add->acdTryIndex;
break;
case AcdKeyDesignator::KD_HND:
acdData = add->acdHndIndex | 0x40000000;
acdData = add->acdHndIndex | AcdHandlerFlag;
break;
case AcdKeyDesignator::KD_FLT:
acdData = add->acdHndIndex | 0x80000000;
acdData = add->acdHndIndex | AcdFilterFlag;
break;
default:
unreached();
Expand Down
Loading