Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FFI] Avoid creating duplciate ffi_types for the same structs in preparing the cif data for downcall #19714

Open
ChengJin01 opened this issue Jun 15, 2024 · 1 comment
Assignees
Labels
comp:vm project:panama Used to track Project Panama related work

Comments

@ChengJin01
Copy link
Contributor

ChengJin01 commented Jun 15, 2024

This leftover issue is created to follow up the discussion at #13315 (comment) when implementing the struct support in downcall.

Technically, we should be able to return the same ffi_type for the same structs instead of creating duplicate ffi_types. e.g.

struct A {
    int a1;
    int a2;
}

struct B {
    int x;
    int y;
}

One of the challenges in this optimization is how to deal with the nested structs correctly under such circumstances. e.g.

struct A {
    int a1;
    int a2;
}

struct B {
    int x;
    struct C {  <------- struct A and C share the same ffi_type
      int c1;
      int c2;
   }
}

In addition, we probably need to ensure that the same the ffi_type for structs is shared in multithreading given these ffi_types are only released when JVM exits. That being said, we need to figure out a smart way to cover all cases to get it working to meet our anticipations.

FYI: @tajila, @pshipton

@ChengJin01 ChengJin01 added comp:vm project:panama Used to track Project Panama related work labels Jun 15, 2024
@ChengJin01 ChengJin01 self-assigned this Jun 15, 2024
@ChengJin01
Copy link
Contributor Author

I will need to create a couple of test case as above to go through in the existing code in debugging to better understand how everything with ffi_type is set for native signature before proposing any solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:vm project:panama Used to track Project Panama related work
Projects
None yet
Development

No branches or pull requests

1 participant