Skip to content

Commit

Permalink
make more conservative
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Feb 2, 2023
1 parent 9e8d0a8 commit 378e801
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9236,11 +9236,20 @@ void Compiler::impImportBlockCode(BasicBlock* block)
{
// Loading a static valuetype field usually will cause a JitHelper to be called
// for the static base. This will bloat the code.
compInlineResult->Note(InlineObservation::CALLEE_LDFLD_STATIC_VALUECLASS);

if (compInlineResult->IsFailure())
// Make an exception - small getters (6 bytes of IL) returning initialized fields, e.g.:
//
// static DateTime Foo { get; } = DateTime.Now;
//
bool isInitedFld = (opcode == CEE_LDSFLD) && (info.compILCodeSize <= 6) &&
(fieldInfo.fieldFlags & CORINFO_FLG_FIELD_FINAL);
if (!isInitedFld)
{
return;
compInlineResult->Note(InlineObservation::CALLEE_LDFLD_STATIC_VALUECLASS);
if (compInlineResult->IsFailure())
{
return;
}
}
}
}
Expand Down

0 comments on commit 378e801

Please sign in to comment.