gilham@polya.Stanford.EDU (Fred Gilham) (04/21/89)
In article <13492@louie.udel.EDU> MROBINSON@wash-vax.bbn.com writes: > >Other than just general interest, I was thinking about writing an editor, >and in the far future worrying about making it resident, or making the >kernel a shared library. I've thought about this as a solution to the problem of running compiled lisp code in a lisp environment. How does the compiled code figure out where the builtins in the lisp interpreter are? Certainly you don't want to have the code for car or print or whatever in every compiled program. So just have everyone call a shared lisp-kernel library. The thing that concerns me about this is the performance hit. I read somewhere that the cost of a library call is about 100us. You really can't do anything about this, either; no optimization possible. The cost of a procedure call should be smaller (right?). I hope I'm not spouting nonsense... -Fred Gilham
bader+@andrew.cmu.edu (Miles Bader) (04/22/89)
gilham@polya.Stanford.EDU (Fred Gilham) writes: > The thing that concerns me about this is the performance hit. I read > somewhere that the cost of a library call is about 100us. You really > can't do anything about this, either; no optimization possible. The > cost of a procedure call should be smaller (right?). I thought that a "library" call involved only the extra overhead of the jmp instruction in the library entry vector, which is 12 cycles on a 68000. Your JSR also has to be relative to the library pointer, but this is CHEAPER than an absolute one. You also have the overhead of moving the pointer into register a6 (?), which is typically 16 cycles if needed-- the compiler should be keeping it there across multiple calls. So, as far as I can see, there's a max of around 28 extra cycles or about 4us on the amiga. You may be thinking of the extra overhead of a stub to move the arguments into registers when calling from a c program, but this isn't really necessary, as the lattice #pragma for making direct library calls illustrates. -Miles
new@udel.EDU (Darren New) (04/22/89)
In article <8635@polya.Stanford.EDU> gilham@polya.Stanford.EDU (Fred Gilham) writes: >The thing that concerns me about this is the performance hit. I read >somewhere that the cost of a library call is about 100us. You really >can't do anything about this, either; no optimization possible. The >cost of a procedure call should be smaller (right?). >-Fred Gilham On the Amiga, a procedure call would just be the one call instruction (assuming it was available at link time). On a shared library, you must first load the address of the library into A6, then call a word at some offset relative to A6. JSR -60(A6) ; or whatever the mnemonic is (Sorry, but it has been a while since I hit MC68000 assemblers.) At that address is (usually) stored a JMP.L to the actual code in the library. If you need optimization, you can probably keep A6 loaded with your lisp library. However, the overhead is nothing like an OS call on a Mac or PC where you need an interrupt on the call. The overhead is the time to load A6 (if any) and the extra jump instructin in the LibraryBase (plus the addressing mode overhead). If you have a manual handy, you can figure this out. You may wish to consider using inline code for things like CAR and CDR unless you detect NIL. Then jump to the library to handle it. Things like APPEND, MAPCAR, and so on could be library calls because of their relatively large size and long execution time. -- Darren
perry@madnix.UUCP (Perry Kivolowitz) (04/22/89)
In article <8635@polya.Stanford.EDU> gilham@polya.Stanford.EDU (Fred Gilham) writes: >The thing that concerns me about this is the performance hit. I read >somewhere that the cost of a library call is about 100us. You really Discounting the overhead of parameter passing a library call which in C would like like so: Result = LibFoo(); will be translated into: move.l _FooLibBase,A6 jsr LibFoosOffset(A6) the next instruction to be executed would be: jmp ToTheActualLibFooCode and then... TheActualLibFooInstructions.... So...the overhead of a library call (irrespective of parameter passing which would have to be accomplished if you were calling a function or library) is quite low. ----- Can anyone take the strain? Imagine...a non-commercial message from pk. Next he'll be writing public domain software again. -- Perry Kivolowitz, ASDG Inc. ARPA: madnix!perry@cs.wisc.edu {uunet|ncoast}!marque! UUCP: {harvard|rutgers|ucbvax}!uwvax!astroatc!nicmad!madnix!perry CIS: 76004,1765 (what was that about ``giggling teenagers''?)
new@udel.EDU (Darren New) (04/24/89)
Also, you can "cheat" if you are calling your own support library from your own code by caching the absolute address of the routines once you have openned the library. I don't recommend this because later SetFunction calls and possibly OS upgrades will screw up your older code. It is DISTINCTLY against the programming guidelines for the Amiga. But if 28 clock cycles spell the difference between a comercial product and going out of business, you might consider it.
karl@sugar.hackercorp.com (Karl Lehenbauer) (04/26/89)
In article <13880@louie.udel.EDU>, new@udel.EDU (Darren New) writes: > ...But if 28 clock cycles spell the difference between > a comercial product and going out of business, you might consider it. Hmm, that's about 4 microseconds...it'll be an awfully short-lived company ;-) -- -- uunet!sugar!karl | "Nobody hipped me to that, dude." -- Pee Wee -- Usenet BBS (713) 438-5018