Skip to content

Remove null-check in generated code for call_indirect (and call_ref soon) #5291

@alexcrichton

Description

@alexcrichton

Currently when translating the call_indirect instruction Wasmtime will insert a null-check to ensure that we're not calling a null function pointer. Because our representation of a null function pointer is literally a null pointer, however, I think we can actually skip this check entirely due to the next instruction being guaranteed to segfault if it's actually a null pointer.

I don't think this is necessarily as easy as simply removing the null pointer check, however, since I think the load needs to at least somehow be annotated with the proper trap code and probably "this can segfault", which I'm not precisely sure how to do. This could be a nice way to clean up the generated code for call_indirect slightly thought which is already somewhat large I believe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    craneliftIssues related to the Cranelift code generatorperformance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions