Skip to content

MarkInterfacesNeededByBodyStack keeps more interfaces than necessary #1428

@MichalStrehovsky

Description

@MichalStrehovsky

I found this by accident when I failed one of the tests for this and was left scratching my head why the test expects a useless interface to be kept.

The MarkInterfacesNeededByBodyStack logic was introduced in #463. The argument for adding this was that this is necessary to produce correct IL. The IL is correct even without this step. This step is necessary to produce verifiable IL (both "correct" and "verifiable" IL are terms defined in the ECMA-335 spec).

E.g. the implementation of Unsafe.As does exactly this and is unverifiable, but correct.

E.g. here's correctness and verifiabilily of stfld as defined in the ECMA spec:

image

The logic in question is trying to ensure the "verifier-assignable-to" relationship, which is necessary for verifiable IL. Correct IL only requires that the type of the location matches the IL stack type (e.g. we're not trying to store a reference type into a float field).

Do we need linker to produce verifiable IL by default? I think it would be fine to put the MethodBodyScanner heuristic under a switch that is off by default and squeeze out a couple extra kB in savings.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions