IDL interfaces

Jonathan S. Shapiro shap@eros-os.org
Sun, 23 Jul 2000 13:18:33 -0400


> I was thinking of stub generators, which generate code which then must
> be edited to do what you want.  I was thinking Jonathan's generator was
> of this type.  I suppose I should look instead of assuming.  :)

I assume so. :-) [Couldn't resist.]

Seriously, though, the rubber has to meet the road somewhere, and an IDL
compiler that just stuffs things in a predefined structure simply isn't very
helpful. The problem is that I then need some piece of microstub code that
moves the values from the structure to the registers. Surprisingly, it
frequently turns out that they were in the right registers to begin with.

Even if they were not, the cost to move them to the right registers is
generally *lower* than the cost to put them in a structure.

That said, let's assume we have such a structure (as the current system
does) and examine the cost to get from structure to registers (sender side)
and back (receiver side) on the x86.

Sender side:

First, we need to save the current register set. To do this we need to
create a call frame. All told, perhaps 10 cycles here.

Then we must shuffle the values into the right registers. There are four
registers to be transferred, plus string size plus key registers plus the
invocation type. Also, we need to set up the receive area. All told this
ends up at about 16 cycles, because we are register starved and some
shuffling is needed.

On return, we will decode the return values and move the register values and
receive string length back into the structure we will then restore the
original registers and return from the procedure. Approximately another 18
cycles, because we don't have to worry about register shuffling here.

Call the sender-side total 44 cycles.

Receiver side pretty much needs to do all of the above too, but in the
opposite order. Call this about 40 cycles.

So the user-level per-invocation cost of using a standardized invocation
structure is nearly 90 cycles by the time all is said and done. This roughly
*doubles* the total cost of the invocation.

Don't get me wrong -- I'ld be glad to go to an interim structure for now and
improve matters later. I just want to be clear about why ultimately this
isn't the right way to go.

shap