Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

[PATCH] Use vftable for interface methods.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 GGLucas   Members   -  Reputation: 140

Like
0Likes
Like

Posted 16 November 2013 - 12:28 PM

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. 

Attached Files



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3366

Like
0Likes
Like

Posted 16 November 2013 - 01:59 PM

Thanks a lot for the patch. I'll see if I can have it included with 2.28.1.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Andreas Jonsson   Moderators   -  Reputation: 3366

Like
0Likes
Like

Posted 07 December 2013 - 09:20 AM

I've added this improvement in revision 1795.

 

Thanks,

Andreas


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS