SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 19/03/2012, 03:24 PM   #1
Zeex_
Guest
 
Posts: n/a
Default JIT compiler

This is a Just-In-Time (JIT) compiler for AMX.

It translates AMX bytecode (the code produced by Pawn compiler) to native x86 code at run time to speed up script execution. You can read more about JIT compilation here.

Download

Changelog:

Code:
v0.3.2 - 27/03/2012
- Fixed crash of HALT/BOUNDS instructions
- Fixed crash if native function is not found - now a runtime error 19 is shown instead

v0.3.1 - 26/03/2012
- Fixed crash during compilation if script contains an empty switch statement
- Fixed crash if server.cfg contains non-ASCII characters
- Added support for LCTRL 6/SCTRL 6
- Added support for CALL.pri/JUMP.pri

v0.3 - 25/03/2012
- Now the whole script is compiled at once, when AMX is loaded. If an error occurs 
  during JIT compilation, a message is printed and the code is run as usually i.e. 
  without JIT.
- Mad it possible to set the size of stack on which JIT code is executed via the 
  "jit_stack" option in server.cfg. 
- Reduced CALL overhead of recursive functions, thanks to first item. 
- Made it possible for JUMP/JCC to jump outside of function bounds.

v0.2 - 23/03/2012
- Ported to AsmJit - http://code.******.com/p/asmjit/
- which automatically fixed a few issues

v0.1 - 19/03/2012
- Initial release


If JIT suddenly crashes your server consider running samp-server.exe under ProcDump and submitting the .dmp file to me. To do that open command prompt, cd to you server directory and run this command

Code:
path/to/procdump.exe -e -ma -x samp-server.exe samp-server.dmp

Last edited by KingJ; 25/03/2013 at 02:40 PM. Reason: Updated URL
  Reply With Quote
Old 19/03/2012, 03:30 PM   #2
Anzipane!
Big Clucker
 
Anzipane!'s Avatar
 
Join Date: Jul 2010
Location: Ravenna, Italy
Posts: 80
Reputation: 5
Default Re: JIT compiler

Amazing?
Great job! That's awesome!
__________________







- Hi, I'm a electronic/techno music producer, listen to my songs on my YouTube channel!
Anzipane! is offline   Reply With Quote
Old 19/03/2012, 03:46 PM   #3
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,423
Reputation: 251
Default Re: JIT compiler

What exactly performe? It saves RAM memory usage?
__________________
TheArcher is offline   Reply With Quote
Old 19/03/2012, 04:00 PM   #4
Ricop522
High-roller
 
Ricop522's Avatar
 
Join Date: Feb 2010
Location: ES
Posts: 2,661
Reputation: 156
Default Re: JIT compiler

Looks cool
__________________
"Any fool can write code that a
computer can understand. Good
programmers write code that
humans can understand."

AJUDA! Programação
Github
Ricop522 is offline   Reply With Quote
Old 19/03/2012, 04:44 PM   #5
asdfgh98
Big Clucker
 
Join Date: Mar 2009
Posts: 94
Reputation: 0
Default AW: JIT compiler

In english -> It will speed up your code/server?
asdfgh98 is offline   Reply With Quote
Old 19/03/2012, 04:58 PM   #6
Mauzen
Godfather
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 5,118
Reputation: 1535
Default Re: JIT compiler

Ehm, okay. Two words: great work.
This really works, and can boost functions by more than 300%, in my opinion this is a must for every server, if it works bugfree, and could even be integrated in the samp server's amx loader.

Here are some benchmark results (floatrandom is pure pawn calculation, the rest contains more or less native functions)
Without JIT
Code:
Test "floatrandom1" finished: 2684ms (3725782.5/sec)
Test "IsPlayerAimingAt" finished: 3004ms (332889.5/sec)
Test "GetPlayerCameraAimVector" finished: 192ms (5208333.5/sec)
With JIT (windows version)
Code:
Test "floatrandom1" finished: 715ms (13986014.0/sec)
Test "IsPlayerAimingAt" finished: 2301ms (434593.6/sec)
Test "GetPlayerCameraAimVector" finished: 22ms (45454548.0/sec)

Hm, my server crashes on connection when using this, Ill try to spot the problem:
Code:
SA-MP Server: 0.3d

Exception At Address: 0x6C1D826E

Registers:
EAX: 0x00000001	EBX: 0x03FD35E8	ECX: 0xFC2C3F14	EDX: 0x021346B8
ESI: 0x03FA0778	EDI: 0x03ECC7DC	EBP: 0x00000000	ESP: 0x0018EAE4
EFLAGS: 0x00010202

Stack:
+0000: 0x00000008   0x00000000   0x00000004   0x00000002
+0010: 0x032E6E08   0x0327ECE8   0x00000034   0x0327ECE8
+0020: 0x08A50000   0x00000008   0xFFFFFFFF   0x0018EB2C
+0030: 0x6C1D830A   0x00043248   0x03FD35E8   0x0018EFC4
+0040: 0x00000000   0x02185EE0   0x0018EB3C   0x6C1DDC50
+0050: 0x00000034   0x0018EF98   0x0018EFA8   0x004718AE
+0060: 0x02185EE0   0x0018EF98   0x00000034   0x00470069
+0070: 0x65747449   0x6E4F5F72   0x79616C50   0x6F437265
+0080: 0x63656E6E   0x00470074   0x00000001   0x032E6CA8
+0090: 0x03FD35F0   0x00000000   0x00000000   0x00000000
+00A0: 0x00000000   0x00000000   0x00000000   0x00000000
+00B0: 0x00000000   0x00000000   0x00000000   0x00000000
+00C0: 0x00000000   0x00000000   0x00000000   0x00000000
+00D0: 0x00000000   0x04980000   0x84001800   0x5E0018D8
+00E0: 0xC86C1BFB   0x000018D8   0xFF000000   0xD5FFFFFF
+00F0: 0x00CF9452   0x00400219   0xFFFF0000   0x0000FFFF
+0100: 0x00000000   0x00000000   0x00000000   0x8B000000
+0110: 0x00100003   0x00000000   0x00400000   0xFFF00000
+0120: 0x0000FFFF   0x00000000   0x00980000   0x00000074
+0130: 0x00000001   0x03282DCC   0x033D0000   0x033DEFA8
Trying to use the crashdetect plugin right now...
Mauzen is offline   Reply With Quote
Old 19/03/2012, 05:10 PM   #7
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,257
Reputation: 137
Default Re: JIT compiler

Basically, I can add this to my public server with no worry's and my server will speed up?
wups is offline   Reply With Quote
Old 19/03/2012, 05:16 PM   #8
SPAWN_METAL
Gangsta
 
SPAWN_METAL's Avatar
 
Join Date: Dec 2010
Posts: 548
Reputation: 53
Default Re: JIT compiler

Quote:
Basically, I can add this to my public server with no worry's and my server will speed up?
In theory yes, but I think there is bugs.

my server start and OnGameModeInit can't called
memory of server going from 80 Mb to 150 and more with step 500kb every second.

Will test it.

Size of amx file - 30 MB

If i delete OnGameModeInit my server will crash with plugin
__________________
][Noname][ Owner of Absolute Play and SAMP Addon
SPAWN_METAL is online now   Reply With Quote
Old 19/03/2012, 05:24 PM   #9
Mauzen
Godfather
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 5,118
Reputation: 1535
Default Re: JIT compiler

Code:
[17:25:12] [debug] Server crashed due to an unknown error
I cant really find a specific line that causes the crash. OnGameModeInit is working fine for me btw, just a connecting player crashes the server.
Mauzen is offline   Reply With Quote
Old 19/03/2012, 05:27 PM   #10
Rock1
Little Clucker
 
Rock1's Avatar
 
Join Date: Sep 2011
Posts: 29
Reputation: 0
Default Re: JIT compiler

When i open "sa-mp server.exe" i get this:
Code:
--------------------------

SA-MP Server: 0.3d-R2



Exception At Address: 0x01C60011



Registers:

EAX: 0x0012F7CC	EBX: 0x0134F770	ECX: 0x0012F7BC	EDX: 0x01C60000

ESI: 0x00B1B838	EDI: 0x00000000	EBP: 0x0012F7A4	ESP: 0x0012F7A4

EFLAGS: 0x00010206



Stack:

+0000: 0x0012F7BC   0x01C70095   0x0000000C   0x00003E10

+0010: 0x00000001   0x00000010   0x0012F7D0   0x01D00013

+0020: 0x00000008   0x00000000   0x0000B878   0x0012F7FC

+0030: 0x00C1826E   0x00000000   0x00000000   0x00B1B838

+0040: 0x00B15528   0x0000000C   0x00B15528   0x01D00000

+0050: 0x00000000   0xFFFFFFFF   0x0012F818   0x00C1830A

+0060: 0x0000AAD0   0x0134F770   0x00000000   0x00000000

+0070: 0x01330FB8   0x0012F828   0x00C1DC50   0x0000000C

+0080: 0x0012FC84   0x0012FC94   0x004718DE   0x01330FB8

+0090: 0x0012FC84   0x0000000C   0x41435353   0x4F5F464E

+00A0: 0x6C69466E   0x53726574   0x70697263   0x696E4974

+00B0: 0x00470074   0x00000000   0x00B155C0   0x0134F774

+00C0: 0x00000000   0x00000000   0x00000000   0x00000000

+00D0: 0x00000000   0x00000000   0x00000000   0x00000000

+00E0: 0x00000000   0x00000000   0x00000000   0x00000000

+00F0: 0x00000000   0x00000000   0x00000000   0x00000000

+0100: 0x5E0012E5   0xAC00BFFB   0x000012E5   0xFF000000

+0110: 0xFCFFFFFF   0xB1E25620   0x00400219   0xFFFF0000

+0120: 0x0000FFFF   0x00000000   0x00000000   0x00000000

+0130: 0x00000000   0x000C0003   0x00000000   0x00400000
Any ideea why?

If i delete "jit" from server.cfg/plugins it works perfectly!
__________________
Signature not available!
Rock1 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PAWN Compiler Error Unable to execute Compiler.. Geeboi_Mehdi General 13 07/11/2015 05:26 PM
Zeex's compiler or original compiler? And why? Rodney Francalim Scripting Help 1 23/09/2014 01:26 AM
Please help ( PAWN Compiler "Error Unable to execute Compiler...") morocco Scripting Help 4 05/02/2013 04:34 PM
about the compiler Geeboi_Mehdi Scripting Help 1 13/08/2012 05:35 PM
[Pawno Compiler] Unable to Execute the Compiler Fabio11 Client Support 6 26/09/2010 10:37 PM


All times are GMT. The time now is 02:24 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.