Skip to content

Commit 378e801

Browse files
committed
make more conservative
1 parent 9e8d0a8 commit 378e801

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/coreclr/jit/importer.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9236,11 +9236,20 @@ void Compiler::impImportBlockCode(BasicBlock* block)
92369236
{
92379237
// Loading a static valuetype field usually will cause a JitHelper to be called
92389238
// for the static base. This will bloat the code.
9239-
compInlineResult->Note(InlineObservation::CALLEE_LDFLD_STATIC_VALUECLASS);
92409239

9241-
if (compInlineResult->IsFailure())
9240+
// Make an exception - small getters (6 bytes of IL) returning initialized fields, e.g.:
9241+
//
9242+
// static DateTime Foo { get; } = DateTime.Now;
9243+
//
9244+
bool isInitedFld = (opcode == CEE_LDSFLD) && (info.compILCodeSize <= 6) &&
9245+
(fieldInfo.fieldFlags & CORINFO_FLG_FIELD_FINAL);
9246+
if (!isInitedFld)
92429247
{
9243-
return;
9248+
compInlineResult->Note(InlineObservation::CALLEE_LDFLD_STATIC_VALUECLASS);
9249+
if (compInlineResult->IsFailure())
9250+
{
9251+
return;
9252+
}
92449253
}
92459254
}
92469255
}

0 commit comments

Comments
 (0)