Skip to content

Specialize code generation for(build time) compiled Machines #964

Open

Description

@andreaTP

Currently we pay the price of boxing and unboxing the arguments even if when not needed.

In the generated ModuleExports class we are invoking functions using the generic lookup mechanism:

instance.exports().function("xyz");

When the module is compiled(especially build-time), we can optimize and generate the direct invocation without boxing/unboxing, something like:

MyModuleMachineFuncGroup_0.func_123(arg0, arg1);

Activity

  1. chirino commented on Jul 8, 2025

    @chirino
    Collaborator

    @andreaTP what would you like the interface to get that information look like? Maybe a json resource file:

    Maybe something like:

    namespace.MyModuleMachine.json:

    {
        "function_groups": {
            "namespace.MyModuleMachineFuncGroup_0": {
               "func_123": {
                   "index": 123,     
                   "args": ["int", "long"],
                   "return": "long"
               }
            }
        } 
    }
  2. andreaTP commented on Jul 8, 2025

    @andreaTP
    CollaboratorAuthor

    Ideally we should not introduce extra dependencies ...
    Maybe using a custom section and injecting it in the .meta file?
    We already have the type info in the type section, the missing piece of information, I think, is only the Group number

  3. chirino commented on Jul 8, 2025

    @chirino
    Collaborator

    So are you saying something like a .meta section that is an array of int where the index is the function id and value is the group number?

  4. andreaTP commented on Jul 8, 2025

    @andreaTP
    CollaboratorAuthor

    We are producing a .meta file which is a valid Wasm payload, we can write, in it, a Custom Section containing this information.
    Haven't thought deeply about it ... just a proposal.

  5. chirino commented on Jul 9, 2025

    @chirino
    Collaborator

    Started a branch at https://github.com/chirino/chicory/tree/func-group-section that adds that data the annotation processor would need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions