Skip to content

NodeppOfficial/nodepp-jit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Nodepp-JIT

The Nodepp project provides a C++ library for advanced runtime code manipulation and execution. This library offers two core components: one for dynamic linking of shared libraries and another for executing raw machine code in memory.

dll_t: Dynamic Library Loader

The dll_t class provides a way to load and execute .dll and .so, within your c++ program.

create a dll

extern "C" { int add( int a, int b ){ return a + b; } }
// compile (Linux)  : g++ -shared -fPIC -o dll.so dll.cpp
// compile (Windows): g++ -shared -o dll.dll dll.cpp
#include <nodepp/nodepp.h>
#include <jit/dll.h>

using namespace nodepp;

void onMain() {

    dll_t dll( "./dll.so" );
    auto out = dll.emit<int>( "add", 10, 20 );
    console::log( "<>", out );

}

Code Execution:

The exec_t class provides a way to create and execute machine code at runtime.

extern "C" { int add( int a, int b ){ return a + b; } }
// compile : g++ -c -fPIC -o code.o code.cpp ; objcopy -O binary --only-section=.text code.o code.bin
#include <nodepp/nodepp.h>
#include <jit/exec.h>

using namespace nodepp;

void onMain() {

    string_t code = fs::read_file("code.bin");
    exec_t jit( code );

    int result = jit.emit<int>( 5, 10 );
    console::log( "<>", result );
    
}

About

Nodepp-JIT is a C++ library that enables advanced runtime code manipulation and execution.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published