Skip to main content
GameDev.net gamedev.net
🔒 Locked

COM

Started by walkingcarcass Sep 27, 2002 at 11:39 AM 4 replies 250+ views
Original Post
walkingcarcass
walkingcarcass
i dont know a lot about the internals of COM calls but i understand they use lookup tables, call into DLLs and are SLOW! is there an easy way to get the DLL function pointer to speed up calls? how many cycles would it save? ******** A Problem Worthy of Attack Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...
Jim Adams
Jim Adams
Not really, as COM/DCOM interfaces use pointers to functions, just as a typical class might (not a real COM object):

class IMyClass : public IUnknown
{
public:
IMyClass();
HRESULT (*MyFunction)();
};

When you create an IMyClass object, the COM server checks if it''s the first instance, and if so, it loads the .DLL file that contains the functions. It then sets its function pointers (MyFunction for example) to point to the DLL code.
Shannon Barber
Shannon Barber
quote:
Original post by walkingcarcass
i dont know a lot about the internals of COM calls but i understand they use lookup tables, call into DLLs and are SLOW!

is there an easy way to get the DLL function pointer to speed up calls? how many cycles would it save?


You are describing IDispatch - the dynamic-binding/OLE Automation aspect of COM, and it is slow.

Most of the time you use vtable binding, which is slower than inlined code, but the cost of dereferencing the vtable and jumping is mitigated on modern x86 processors, as they can perform the dereferencing and vectoring in the same op code.

The only time you pay a serious penalty, is if jumping to the code results in a hard or soft page-fault - which is no different than a normal function call.

Default creation of COM objects is god-awfully slow becase CoCreate looks up a pile of crap in the registery.

P.S. DirectX uses COM.
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Arild Fines
Arild Fines
quote:
Original post by Magmai Kai Holmlor
P.S. DirectX uses COM.

If you take a look at which forum he posted in, I think it''s pretty safe to say he already knew that



The world holds two classes of men -- intelligent men without religion, and religious men without intelligence. - Abu''l-Ala-Al-Ma''arri (973-1057; Syrian poet)
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
walkingcarcass
walkingcarcass
i dont know anything about IDispatch but can i just gather the function pointers of all COM functions i intend to use?

Magmai Kai Holmlor, do you mean "CALL dword ptr [lookuplable+[functionID]]" is a legal instruction?

********


A Problem Worthy of Attack
Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...
thona
thona
Sure you can. You can query for the functions and cache the results.

But why - nearly ALL classes that implement IDispatch also implement a "sensible interface".


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)
RegardsThomas TomiczekTHONA Consulting Ltd.(Microsoft MVP C#/.NET)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.