Repository: dotnet/runtime
File: src/coreclr/vm/precode_portable.hpp (C++)

Code before:
    enum PortableEntryPointFlag
    {
        kNone = 0,
        kUnmanagedCallersOnly_Has = 0x1,
        kUnmanagedCallersOnly_Checked = 0x2,
    };
    Volatile<int32_t> _flags;

    // We keep the canary value last to ensure a stable ABI across build flavors
    INDEBUG(size_t _canary);

#ifdef _DEBUG
    bool IsValid() const;
#endif // _DEBUG

public: // static
    static PortableEntryPoint* ToPortableEntryPoint(PCODE addr);

public:
    void Init(MethodDesc* pMD);
    void Init(void* nativeEntryPoint);

    // Check if the entry point represents a method with the UnmanagedCallersOnly attribute.
    // If it does, update the entry point to point to the UnmanagedCallersOnly thunk if not
    // already done.
    bool EnsureUnmanagedCallersOnlyAttribute();

    // Query methods for entry point state.
    bool HasInterpreterCode() const
    {
        LIMITED_METHOD_CONTRACT;
        _ASSERTE(IsValid());
        return _pInterpreterData != nullptr;
    }

    bool HasNativeCode() const
    {
        LIMITED_METHOD_CONTRACT;
        _ASSERTE(IsValid());
        return _pActualCode != nullptr;
    }

    bool IsPreparedForNativeCall() const
    {
        LIMITED_METHOD_CONTRACT;
        _ASSERTE(IsValid());
        // State when interpreted method was prepared to be called from R2R compiled code.
        // pActualCode is a managed calling convention -> interpreter executor call stub in this case.
        return _pInterpreterData != nullptr && _pActualCode != nullptr;
    }
};

Review comment (suggestion):
```suggestion
    bool EnsureCodeForUnmanagedCallersOnly();
```
This is ensuring that the actual code entrypoint is initialized.

Code after:
    enum PortableEntryPointFlag
    {
        kNone = 0,
        kUnmanagedCallersOnly_Has = 0x1,
        kUnmanagedCallersOnly_Checked = 0x2,
    };
    Volatile<int32_t> _flags;

    // We keep the canary value last to ensure a stable ABI across build flavors
    INDEBUG(size_t _canary);

#ifdef _DEBUG
    bool IsValid() const;
#endif // _DEBUG

public: // static
    static PortableEntryPoint* ToPortableEntryPoint(PCODE addr);

public:
    void Init(MethodDesc* pMD);
    void Init(void* nativeEntryPoint);

    // Check if the entry point represents a method with the UnmanagedCallersOnly attribute.
    // If it does, update the entry point to point to the UnmanagedCallersOnly thunk if not
    // already done.
    bool EnsureCodeForUnmanagedCallersOnly();

    // Query methods for entry point state.
    bool HasInterpreterCode() const
    {
        LIMITED_METHOD_CONTRACT;
        _ASSERTE(IsValid());
        return _pInterpreterData != nullptr;
    }

    bool HasNativeCode() const
    {
        LIMITED_METHOD_CONTRACT;
        _ASSERTE(IsValid());
        return _pActualCode != nullptr;
    }

    bool IsPreparedForNativeCall() const
    {
        LIMITED_METHOD_CONTRACT;
        _ASSERTE(IsValid());
        // State when interpreted method was prepared to be called from R2R compiled code.
        // pActualCode is a managed calling convention -> interpreter executor call stub in this case.
        return _pInterpreterData != nullptr && _pActualCode != nullptr;
    }
};