GithubHelp home page GithubHelp logo

tltneon / samp-plugin-jit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zeex/samp-plugin-jit

0.0 1.0 0.0 4.06 MB

JIT plugin for SA-MP server

Home Page: http://forum.sa-mp.com/showthread.php?t=326980

License: BSD 2-Clause "Simplified" License

CMake 7.51% Pawn 3.58% C 11.14% C++ 77.77%

samp-plugin-jit's Introduction

Version Build Status Build Status - Windows

This is a Just-in-Time (JIT) compiler for AMX 3.x and a plugin for the SA-MP server. It compiles AMX bytecode that is produced by the Pawn compiler into native x86 code at runtime for increased performance.

Installing

  1. Download a compiled plugin form the Relaeses page on Github or build it yourself from source code (see below).
  2. Extract/copy jit.so or jit.dll to <sever>/plugins/.
  3. Add jit (Windows) or jit.so (Linux) to the plugins line of your server.cfg.

Building on Linux

Install gcc and g++, make and cmake. On Ubuntu you would do that with:

sudo apt-get install gcc g++ make cmake

If you're building on a 64-bit system you'll need multilib packages for gcc and g++:

sudo apt-get install gcc-multilib g++-multilib

If you're building on CentOS, install the following packages:

yum install gcc gcc-c++ cmake28 make

Now you're ready to build JIT:

cd jit
mkdir build && cd build
cmake ../ -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
make

Building on Windows

You'll need to install CMake and Visual Studio (Express edition will suffice). After that, either run cmake from the command line:

cd jit
mkdir build && cd build
path/to/cmake.exe ../ -DBUILD_TESTING=OFF

or do the same from cmake-gui. This will generate a Visual Studio project in the build folder.

To build the project:

path/to/cmake.exe --build . --config Release

You can also build it from within Visual Studio: open build/jit.sln and go to menu -> Build -> Build Solution (or just press F7).

Limitations

Everything that doesn't use #emit will probably work okay. Otherwise, it depends on the code. There are some advanced #emit hacks that simply won't work with this JIT. Self-modifying code is one example (although in some caes it's possible to fix, see Detecting JIT at runtime).

If you're using YSI this plugin most likely will not work for you and simply crash your server.

How it works

It's a pretty simple JIT. Code is compiled once and stored in memory for the lifetime of the server, or until the script gets unloaded in case of filterscripts. Thus there may be a small delay during the server startup.

Most of the compilation process is a mere translation of AMX opcodes into seuquences of corresponding machine instructions using essentially a giant switch statement. There are some places though where the compiler tries to be a little bit smarter: for instance, it will replace calls to common floating-point functions (those found in float.inc) with equivalent code using the x87 FPU instruction set.

Native code generation is done via AsmJit, a wonderful assembler library for x86/x86-64 ๐Ÿ‘. There also was an attempt to use LLVM as an alternative backend but it was quickly abandoned...

License

Licensed under the 2-clause BSD license. See the LICENSE.txt file.

samp-plugin-jit's People

Contributors

zeex avatar

Watchers

Neon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.