You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RyuJIT and static fields initialization in beforefieldinited types #4346
I get used to that JIT normally calls static fields initializer on compiling a method where the static fields are used, so that when the method executes it can access the fields directly without checking if they've been initialized.
RyuJIT seems has changed how it deals with initialization of static fields in beforefieldinited types.
It is intentional change to avoid differences in timing of static constructor invocations across different JIT versions, and between JIT and AOT configurations. These timing differences has been historically source of number of compatibility problems. The behavior is controlled by MethodDesc::RunCCTorAsIfNGenImageExists method.
Yes, it does. Our compatibility requirements between different runtimes (.NET Framework vs. CoreCLR) are not as high as compatibility requirements between versions of the same runtime (v1, v2, ...).
BTW: The new behavior is enabled under a set of quirks even for .NET 4.5.2.
Activity
jkotas commentedon Jul 4, 2015
It is intentional change to avoid differences in timing of static constructor invocations across different JIT versions, and between JIT and AOT configurations. These timing differences has been historically source of number of compatibility problems. The behavior is controlled by
MethodDesc::RunCCTorAsIfNGenImageExistsmethod.omariom commentedon Jul 4, 2015
But doesn't this change itself introduce another difference in timing?
Compared with .NET 4(.5.2).
jkotas commentedon Jul 4, 2015
Yes, it does. Our compatibility requirements between different runtimes (.NET Framework vs. CoreCLR) are not as high as compatibility requirements between versions of the same runtime (v1, v2, ...).
BTW: The new behavior is enabled under a set of quirks even for .NET 4.5.2.
omariom commentedon Jul 5, 2015
@jkotas Does it all mean that in .NET 4.6 RTM static readonly fields of scalar types won't be treated as JIT time constants?
jkotas commentedon Jul 5, 2015
They should be still treated as JIT time constants in methods that are JITed after the static constructor has run.
omariom commentedon Jul 5, 2015
Ahaaa.. Now I see..:eyes:
Test method:
The same method if s_flag is a readonly field:
omariom commentedon Jul 5, 2015