Welcome, Guest. Please login or register.

Author Topic: Question about JIT  (Read 2586 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline AtheistTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 820
    • Show only replies by Atheist
Question about JIT
« on: September 04, 2003, 03:33:01 PM »
JIT, "Just In Time", the conversion of instructions from 680x0 instructions to a combination of PPC RISC instrutions that achieve the same thing in the CPU.

Can this be done, a 680x0 program, be run through a RISC JIT, and then that combination of commands be saved back to disk as a new file. Then just run that "RISCed" program, from then on? Could this be done to a BASIC program?

On one end its CISC command A, then it gets converted to RISC command B (C, (D)), just save it then to disk and build the new program. It would have to examine the branches as well.
\\"Which would you buy? The Crappy A1200, 15 years out of date... or the Mobile Phone that I have?\\" -- bloodline
So I guess that A500, 600, 1000, 2000, CDTV, CD32, are pure garbage then? Thanks for posting here.
 

Offline xeron

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: Question about JIT
« Reply #1 on: September 04, 2003, 03:44:54 PM »
In theory this is perfectly possible. It would just be a compiler for the "68000" language.
Playstation Network ID: xeron6
 

Offline Warface

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 970
    • Show only replies by Warface
    • http://www.spacehawks.hu
Re: Question about JIT
« Reply #2 on: September 04, 2003, 03:54:14 PM »
AFAIR Coyoteflux or some other group made a 68K->PPC converter or the like. Never heard overly positive reports though, and I myself never tried it.
 

Offline PiR

  • Full Member
  • ***
  • Join Date: Apr 2003
  • Posts: 148
    • Show only replies by PiR
Re: Question about JIT
« Reply #3 on: September 04, 2003, 05:51:55 PM »
Well, I think it could be done but...
for what purpose? :-)

If you have the binary - leave it as it is. It was the best thing programmer and original compiler could think of. Mayby after few years you'll have better JIT tool, so why to spoil the binary with something worse? And if you want native code - better take the sources and the native compiler IMO. The result will be MUCH better.

Speaking about BASIC - there was (and still is) a tool for Amiga (and ST) called GFA BASIC that compiled the BASIC code, before running it.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Question about JIT
« Reply #4 on: September 04, 2003, 08:13:10 PM »
@Atheist,

I can see what youre getting at but there wouldn't be a lot of point. The only real bottleneck in many JIT systems is the transcription time, which you would eliminate this way. However, as any winuae user could point out, the transcription overhead really isnt noticable at all. Even this grumpy old K6-2 outperforms a genuine 68060 by a factor of 4x or so. I can imagine a well written PPC JIT for 680x0 emulation could be a lot better still (eg, you could keep the 680x0 registers in PPC registers and still have room to manouvre).

Quote

xeron wrote:
In theory this is perfectly possible. It would just be a compiler for the "68000" language.


Agreed, but I can see some real nasty problems with any form of self modifying code, or code that makes assumptions about address spaces etc.


As for that CoyoteFlux thing, it was called PPC680x0 and worked at source code level only, IIRC.
int p; // A
 

Offline yoodoo

  • Full Member
  • ***
  • Join Date: Apr 2002
  • Posts: 130
    • Show only replies by yoodoo
Re: Question about JIT
« Reply #5 on: September 04, 2003, 08:43:43 PM »
Speaking of GFA BASIC...

I'm always surprised it never pops up more when everyone clamours for an "easy" language for AOS4/MOS.  It always seemed quite cleanly implemented (compared to AMOS) and not quite so hacky (compared to Blitz).

Time to fire up another porting/release the code petition on ANN ;)

 

Offline Warface

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 970
    • Show only replies by Warface
    • http://www.spacehawks.hu
Re: Question about JIT
« Reply #6 on: September 05, 2003, 10:37:42 AM »
Quote
The only real bottleneck in many JIT systems is the transcription time, which you would eliminate this way. However, as any winuae user could point out, the transcription overhead really isnt noticable at all.


Thinking more about the issue...

Dunno about WinUAE JIT, but on morphos Trance is a task in the background, and fiddles with the code in the spare time of the CPU, so you can't notice stops in the code running - only that it gets hell a lotsa more faster after the first 2-4 loops.

The two goals with "precompiling" 68K binaries into JIT PPC code can be the following two: speed and lessening memory consumption (no use of JIT buffers).

However:

The speed issue - the only extra speed you gain is the first 2-4 loops run by the non-JIT compile. That's not that much to make all the fuss worth it. The non looping code is pretty irrevelant speed wise.

The memory usage issue: JIT only buffers the looping code, and the non-JIT 68K emulator uses some memory too. It seems that a precompiled program can gain a lot - but it's a false impression. PPC code is occupying much larger space usually than 68K code (it's because of cache aligning issues and others(

So all in all, having precompiled JIT code is not that big idea at all, and have little advantages, not to mention, it even has some drawbacks...
 

Offline iamaboringperson

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 5744
    • Show only replies by iamaboringperson
Re: Question about JIT
« Reply #7 on: September 05, 2003, 10:45:33 AM »
What I'm thinking, is if you are talking about basic programs, wouldn't it be a better option to just write a ppc base basic compiler? To me that would be a much better option than just a 68k->ppc compiler.

Are you refering to source code you have?
 

Offline Dr_Righteous

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 1345
    • Show only replies by Dr_Righteous
Re: Question about JIT
« Reply #8 on: September 05, 2003, 11:18:50 AM »
You can always run it through a disassembler then run it through the PPC converter... Dunno how well that'd work, but hey...
- Doc

A4000D, A3640 OC-36.3MHz, custom tower, Mediator A4000D. Diamond Banshee 16M, Indivision AGA 4000, GVP HC+8.

Mac Mini 1.5GHz, that might run MorphOS someday, when the fools who own it come to the realization that 30 minutes just isn\'t enough time to play with it enough to decide whether or not you like it enough to cough up $200.

 - Someone please design SOME kind of DIY accelerator for the A4000. :D -
 

Offline AtheistTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 820
    • Show only replies by Atheist
Re: Question about JIT
« Reply #9 on: September 05, 2003, 11:20:58 AM »
Quote

iamaboringperson wrote:
Are you refering to source code you have?


For instance Power Packer, the source might not be available, so the JIT converts every instruction to PPC then runs it. I thought the JIT could be used to run the program, command by command, but instead of running, it saves the resulting commands into a file. Effectively converting it into a PPC program.


A1!
\\"Which would you buy? The Crappy A1200, 15 years out of date... or the Mobile Phone that I have?\\" -- bloodline
So I guess that A500, 600, 1000, 2000, CDTV, CD32, are pure garbage then? Thanks for posting here.
 

Offline ncafferkey

  • Sr. Member
  • ****
  • Join Date: Feb 2003
  • Posts: 387
    • Show only replies by ncafferkey
Re: Question about JIT
« Reply #10 on: September 05, 2003, 09:31:09 PM »
Quote

Atheist wrote:

For instance Power Packer, the source might not be available, so the JIT converts every instruction to PPC then runs it. I thought the JIT could be used to run the program, command by command, but instead of running, it saves the resulting commands into a file. Effectively converting it into a PPC program.


This is known as static translation rather than JIT's dynamic translation. There are several problems in getting this approach to work at all, including the difficulty of finding all the code, and self-modifying code (but any program in this category isn't properly written anyway).

I agree that there usually won't be much advantage over JIT in speed, but I'm not so sure about memory. Isn't it the case that UAE and Amithlon require many megabytes of JIT cache to perform well? Not many binaries are that large!

I've written a static translator for the Atari VCS, but that was relatively simple because the VCS is so basic and has it's code in ROM.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Question about JIT
« Reply #11 on: September 05, 2003, 09:37:27 PM »
Quote

ncafferkey wrote:
I agree that there usually won't be much advantage over JIT in speed, but I'm not so sure about memory. Isn't it the case that UAE and Amithlon require many megabytes of JIT cache to perform well?


Well, WinUAE has from 1-8Mb cache for the JIT, so you could argue it's not that much. It works very much like an instruction cache on a CPU, the most recently/frequently used code is cached there. I have experimented with the size to see what difference it makes. Overall bigger is better but to be honest, I haven't noticed much difference between them. I just set it to 8Mb to reduce the transcription overhead (I guess it covers the kernel and whatever application I am running), but even with a 1Mb cache it seems to run pretty well. No doubt compact amiga code helps there ;-) The code part of any program is usually fairly small...
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Question about JIT
« Reply #12 on: September 05, 2003, 09:42:28 PM »
Quote

Atheist wrote:
For instance Power Packer, the source might not be available, so the JIT converts every instruction to PPC then runs it. I thought the JIT could be used to run the program, command by command, but instead of running, it saves the resulting commands into a file. Effectively converting it into a PPC program.


Not quite. A JIT usually works on blocks of code. A block is transcripted the first time it is used and the transcripted block is then stored for later re-use. It can be purged if not used again and replaced with something else. This way the amount of memory needed is reduced, we simply cache upto a predefined amount of transcripted code.
int p; // A