File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments