Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!194.255.237.131.MISMATCH!newsfeed101.telia.com!starscream.dk.telia.net!news.tele.dk!feed118.news.tele.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail From: torbenm@diku.dk (Torben Ægidius Mogensen) Newsgroups: comp.arch Subject: Re: Beyond binary compatibility References: Date: Thu, 19 May 2011 12:49:06 +0200 Message-ID: <7zsjsbartp.fsf@ask.diku.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:NZ6ompcrxJcMvLhbWoTwncuGU6Q= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 35 Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 130.225.96.225 X-Trace: news.sunsite.dk DXC=bFfHIJ5V?\Pe3jRo4OW[0]YSB=nbEKnk[\6?24NQE_0\eA0c^o`FO0TNW[cF@L;gDWF5\^6VX=jYToFS1NVQYoK^SGI?^@?lEaU X-Complaints-To: staff@sunsite.dk Xref: x330-a1.tempe.blueboxinc.net comp.arch:1688 "Paul A. Clayton" writes: > It seems that there are some areas of incompatibility which > are easier to handle than others. E.g., an ISA with the > same semantics as another would be easier to automatically > translate, especially if the instructions are the same > size. [...] > > There might be some advantage to being able to translate in > place at the granularity of instructions in the old ISA. This is what Intel did in the transition from 8080 to 8086: 8086 was not binary compatible, but you could do an instruction-by-instructions translation that didn't expand the code size, so you could preserve addresses. In any case, it is in most cases not too difficult to find the branch targets by analysing code, so translation that doesn't preserve addresses is usually O.K. And in the cases where this isn't enough, you can construct a table that translates old addresses to new addresses and use this at runtime for computed and indirect jumps. This, obviously, requires that you don't combine two or more instructions in the old code to one instruction in the new code, reorder instructions, and so on. This might reduce the efficiency of the translated code, but probably not by a lot. Instead of keeping a table, you can do the normal branch-target ananlysis and translate all branches to known target normally but also keep a (hashed) table that maps the known old branch targets to new addresses. If there is an indirect jump, you look up in this table. If you get a hit, you jump, but otherwise you translate a basic block starting at the previously-unknown branch target and add this to the code. Torben