Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/android-clr-host-local
Browse files Browse the repository at this point in the history
* main:
  JIT: Set PGO data inconsistent when flow disappears in cast expansion (dotnet#112147)
  [H/3] Fix handling H3_NO_ERROR (dotnet#112125)
  Change some workflows using `pull_request` to use `pull_request_target` instead (dotnet#112161)
  Annotate ConfiguredCancelableAsyncEnumerable T with allows ref struct and update extensions (dotnet#111953)
  Delete copy of performance pipelines in previous location (dotnet#112113)
  Optimize BigInteger.Divide (dotnet#96895)
  Use current STJ in HostModel and remove unnecessary audit suppressions (dotnet#109852)
  JIT: Unify handling of InstParam argument during inlining (dotnet#112119)
  Remove unneeded DiagnosticSource content (dotnet#112116)
  Improve compare-and-branch sequences produced by Emitter (dotnet#111797)
  Jit: Conditional Escape Analysis and Cloning (dotnet#111473)
  Re-enable HKDF-SHA3 on Azure Linux
  Remove fstream usage from corehost (dotnet#111859)
  • Loading branch information
grendello committed Feb 5, 2025
2 parents 5c29dad + ff604c2 commit be6a3e7
Show file tree
Hide file tree
Showing 64 changed files with 4,154 additions and 615 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@
/docs/area-owners.* @jeffhandley
/docs/issue*.md @jeffhandley
/.github/policies/ @jeffhandley @mkArtakMSFT
/.github/workflows/ @dotnet/runtime-infrastructure
6 changes: 6 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Workflows

General guidance:

- Please make sure to include the @dotnet/runtime-infrastructure group as a reviewer of your PRs.
- Do not use the `pull_request` event. Use `pull_request_target` instead, as documented in [Workflows in forked repositories](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflows-in-forked-repositories) and [pull_request_target](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target).
4 changes: 2 additions & 2 deletions .github/workflows/check-no-merge-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ permissions:
pull-requests: read

on:
pull_request:
types: [opened, edited, reopened, labeled, unlabeled, synchronize]
pull_request_target:
types: [labeled, unlabeled]
branches:
- 'main'
- 'release/**'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-service-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ permissions:
pull-requests: read

on:
pull_request:
types: [opened, edited, reopened, labeled, unlabeled, synchronize]
pull_request_target:
types: [labeled, unlabeled]
branches:
- 'release/**'

Expand Down
804 changes: 804 additions & 0 deletions docs/design/coreclr/jit/DeabstractionAndConditionalEscapeAnalysis.md

Large diffs are not rendered by default.

78 changes: 0 additions & 78 deletions eng/pipelines/coreclr/perf.yml

This file was deleted.

67 changes: 0 additions & 67 deletions eng/pipelines/coreclr/perf_slow.yml

This file was deleted.

45 changes: 0 additions & 45 deletions eng/pipelines/runtime-wasm-perf.yml

This file was deleted.

57 changes: 57 additions & 0 deletions src/coreclr/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,61 @@ class CodeGen final : public CodeGenInterface

void genExitCode(BasicBlock* block);

#if defined(TARGET_ARM64)
BasicBlock* genGetThrowHelper(SpecialCodeKind codeKind);

// genEmitInlineThrow: Generate code for an inline exception.
void genEmitInlineThrow(SpecialCodeKind codeKind)
{
genEmitHelperCall(compiler->acdHelper(codeKind), 0, EA_UNKNOWN);
}

// throwCodeFn callback follows concept -> void(*)(BasicBlock* target, bool isInline)
//
// For conditional jumps:
// If `isInline`, invert the condition for throw and fall into the exception block.
// Otherwise emit compare and jump with the normal throw condition.
// For unconditional jumps:
// Only emit the unconditional jump when `isInline == false`.
// When `isInline == true` the code will fallthrough to throw without any jump added.
//
// Parameter `target` gives a label to jump to, which is the throw block if
// `isInline == false`, else the continuation.
template <typename throwCodeFn>
void genJumpToThrowHlpBlk(SpecialCodeKind codeKind, throwCodeFn emitJumpCode, BasicBlock* throwBlock = nullptr)
{
if (!throwBlock)
{
// If caller didn't supply a target block, then try to find a helper block.
throwBlock = genGetThrowHelper(codeKind);
}

if (throwBlock)
{
// check:
// if (checkPassed)
// goto throw;
// ...
// throw:
// throw();
emitJumpCode(throwBlock, false);
}
else
{
// check:
// if (!checkPassed)
// goto continue;
// throw();
// continue:
// ...
BasicBlock* over = genCreateTempLabel();
emitJumpCode(over, true);
genEmitInlineThrow(codeKind);
genDefineTempLabel(over);
}
}
#endif

void genJumpToThrowHlpBlk(emitJumpKind jumpKind, SpecialCodeKind codeKind, BasicBlock* failBlk = nullptr);

#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
Expand Down Expand Up @@ -1285,6 +1340,8 @@ class CodeGen final : public CodeGenInterface
#endif
#if defined(TARGET_ARM64)
void genCodeForJumpCompare(GenTreeOpCC* tree);
void genCompareImmAndJump(
GenCondition::Code cond, regNumber reg, ssize_t compareImm, emitAttr size, BasicBlock* target);
void genCodeForBfiz(GenTreeOp* tree);
#endif // TARGET_ARM64

Expand Down
58 changes: 55 additions & 3 deletions src/coreclr/jit/codegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3622,9 +3622,10 @@ void CodeGen::genCodeForDivMod(GenTreeOp* tree)
}
else
{
// Check if the divisor is zero throw a DivideByZeroException
emit->emitIns_R_I(INS_cmp, size, divisorReg, 0);
genJumpToThrowHlpBlk(EJ_eq, SCK_DIV_BY_ZERO);
genJumpToThrowHlpBlk(SCK_DIV_BY_ZERO, [&](BasicBlock* target, bool invert) {
GenCondition::Code cond = invert ? GenCondition::NE : GenCondition::EQ;
genCompareImmAndJump(cond, divisorReg, 0, size, target);
});
}
}

Expand Down Expand Up @@ -5071,6 +5072,34 @@ void CodeGen::genCodeForJumpCompare(GenTreeOpCC* tree)
}
}

void CodeGen::genCompareImmAndJump(
GenCondition::Code cond, regNumber reg, ssize_t compareImm, emitAttr size, BasicBlock* target)
{
// For ARM64 we only expect equality comparisons.
assert((cond == GenCondition::EQ) || (cond == GenCondition::NE));

if (compareImm == 0)
{
// We can use cbz/cbnz
instruction ins = (cond == GenCondition::EQ) ? INS_cbz : INS_cbnz;
GetEmitter()->emitIns_J_R(ins, size, target, reg);
}
else if (isPow2(compareImm))
{
// We can use tbz/tbnz
instruction ins = (cond == GenCondition::EQ) ? INS_tbz : INS_tbnz;
int imm = genLog2((size_t)compareImm);
GetEmitter()->emitIns_J_R_I(ins, size, target, reg, imm);
}
else
{
// Emit compare and branch pair default.
emitJumpKind jumpKind = (cond == GenCondition::EQ) ? EJ_eq : EJ_ne;
GetEmitter()->emitIns_R_I(INS_cmp, size, reg, compareImm);
inst_JMP(jumpKind, target);
}
}

//---------------------------------------------------------------------
// genSPtoFPdelta - return offset from the stack pointer (Initial-SP) to the frame pointer. The frame pointer
// will point to the saved frame pointer slot (i.e., there will be frame pointer chaining).
Expand Down Expand Up @@ -5939,4 +5968,27 @@ insOpts CodeGen::ShiftOpToInsOpts(genTreeOps shiftOp)
}
}

//---------------------------------------------------------------------------------
// genGetThrowHelper: Search for the throw helper for the exception kind `codeKind`
BasicBlock* CodeGen::genGetThrowHelper(SpecialCodeKind codeKind)
{
BasicBlock* excpRaisingBlock = nullptr;
if (compiler->fgUseThrowHelperBlocks())
{
// For code with throw helper blocks, find and use the helper block for
// raising the exception. The block may be shared by other trees too.
Compiler::AddCodeDsc* add = compiler->fgFindExcptnTarget(codeKind, compiler->compCurBB);
PREFIX_ASSUME_MSG((add != nullptr), ("ERROR: failed to find exception throw block"));
assert(add->acdUsed);
excpRaisingBlock = add->acdDstBlk;
#if !FEATURE_FIXED_OUT_ARGS
assert(add->acdStkLvlInit || isFramePointerUsed());
#endif // !FEATURE_FIXED_OUT_ARGS

noway_assert(excpRaisingBlock != nullptr);
}

return excpRaisingBlock;
}

#endif // TARGET_ARM64
17 changes: 17 additions & 0 deletions src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,23 @@ void CodeGen::genRangeCheck(GenTree* oper)
src1 = arrLen;
src2 = arrIndex;
jmpKind = EJ_ls;

#if defined(TARGET_ARM64)
if (arrIndex->IsIntegralConst(0))
{
assert(!arrLen->isContained());
// For (index == 0), we can just test if (length == 0) as this is the only case that would throw.
// This may lead to an optimization by using cbz/tbnz.
genJumpToThrowHlpBlk(
bndsChk->gtThrowKind,
[&](BasicBlock* target, bool isInline) {
genCompareImmAndJump(isInline ? GenCondition::NE : GenCondition::EQ, arrLen->GetRegNum(), 0,
emitActualTypeSize(arrLen), target);
},
bndsChk->gtIndRngFailBB);
return;
}
#endif
}
else
{
Expand Down
Loading

0 comments on commit be6a3e7

Please sign in to comment.