Jump to content
  • Advertisement
Sign in to follow this  

[PATCH] Use vftable for interface methods.

This topic is 2146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A short one this time ;)


This appends chunks to the end of script object types' virtual function tables corresponding to the methods of the interfaces it implements, and records the offset of each of its interfaces into its table. That is, it stores a virtual function at the index of (interface offset + index of method in interface). I co-opted the vfTableIdx member for asFUNC_INTERFACE functions to indicate the local index of the method in the interface to easily access that.


This turns a CALLINTF on an interface function from a full O(n) search on all methods in the class to a short linear search on the interfaces implemented by the class, and then a lookup into the virtual function table. It would be possible to use a map for the interface offsets to lower the complexity of that particular search, but because the amount of interfaces implemented by a class is usually low, the added complication of the map logic is probably not worth it.


We do not use bytecode saving, so the as_restore bits have not gone through real-world testing, but the angelscript tests pass using it and it isn't terribly complex. 

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!