Path: utzoo!attcan!uunet!mcvax!kth!draken!tut!santra!kampi!jmunkki From: jmunkki@kampi.hut.fi (Juri Munkki) Newsgroups: comp.sys.mac.programmer Subject: Re: Re: Legal Tail Patches Message-ID: <19971@santra.UUCP> Date: 25 Feb 89 10:46:01 GMT References: <1285@ccnysci.UUCP> <10050076@accuvax.nwu.edu> <19886@santra.UUCP> <26341@apple.Apple.COM> Sender: news@santra.UUCP Reply-To: jmunkki@kampi.UUCP (Juri Munkki) Organization: Helsinki University of Technology, Finland Lines: 48 In article <26341@apple.Apple.COM> tecot@Apple.COM (Ed Tecot) writes: >In article <19886@santra.UUCP> jmunkki@kampi.hut.fi.UUCP (Juri Munkki) writes: >>To illustrate: >>Before patching After patching >>_______________ ______________ >>Program calls a trap Program calls a trap >>Trap dispatcher calls routine Trap dispatcher calls routine >>Come-from patch does something Come-from patch does something >>Come-from patch calls ROM Come-from patch calls new patch. >> New patch calls ROM... >> >>Apple: Please implement this in the next system release... > >The major problem with this is that it will make the trap dispatcher >significantly slower. Considering that it is the most executed code in >Macintosh, it would probably translate into a significant performance >degradation. So I ask, is it worth it? Why would it slow down the trap dispatcher? You wouldn't have to change the trap dispatcher. Here's how you would do it... 1. Normally apple patches have jmp instructions directly into the ROM after they check for tail patches. Change this so that they jump into a table of jmp instructions into ROM. This doesn't significantly slow down the system. 2. Change SetTrapAddress so that it first checks to see if the trap needs come-from patching. If it does, don't change the trap dispatch table, but write the new address into a jump table within the system patches. You have to clear the cache in order to safely write into the jump table, but apple has the right to do stuff like this... 3. Change GetTrapAddress so that it first checks if the trap does come-from patching. If it does, return the address that is contained in the jump table. If the routine only has the apple patch, the ROM address will be returned. So, why would this scheme slow down the trap dispatcher? BTW: MacTutor once published the code for the MacPlus trap dispatcher. I looked at it and could see an improvement of 2 cycles... Maybe I was wrong... maybe I should have tried it. _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ | Juri Munkki jmunkki@hut.fi jmunkki@fingate.bitnet I Want Ne | | Helsinki University of Technology Computing Centre My Own XT | ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^