Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix virtual invokes #127

Open
sc2ad opened this issue Mar 13, 2022 · 0 comments
Open

Fix virtual invokes #127

sc2ad opened this issue Mar 13, 2022 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@sc2ad
Copy link
Owner

sc2ad commented Mar 13, 2022

So due to special method names, our current implementation relies on method name lookups which is bad.

An alternative to this would be to create a method, say, RunVirtualMethod which would take in an instance (that must have a vtable) and MethodInfo* that is looked at for its SLOT and declaring type + params/ret, and will forward to RunMethod... of some variant AFTER the correct method is deduced via slot and instance vtable. The way this will have to be done is by class resolution + interface/base type analysis--

  • A base type must be the first vtable_count slots of the target instance's vtable
  • Interfaces are arranged in the order they are declared in after this
  • Target slot should be found by taking initial offset (0 for base types, or non-zero for any interface, must be deduced) and adding our input slot to that result.
  • Target slot should be looked up in the target vtable ex: target_vtable[target_slot] and the corresponding method pointer should be extracted, then passed into any of the remaining invokes.

This functionality probably should encompass several methods (forwards to multiple RM calls) and probably also support a "conversion" call without invoke (to resolve a given input slot on a given instance to a method pointer)

Some corners can be cut that can be reasonably inferred, but it will be tricky to cut out some others (ex, vtable distributions can't be encoded in an incredibly sane way AOT, deduction almost certainly has to take place on runtime)

@sc2ad sc2ad added the help wanted Extra attention is needed label Mar 13, 2022
@sc2ad sc2ad added this to the 4.0.0 Milestone milestone Mar 17, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant