|
x-engine-c v0.2.13
The C engine for x-lang
|
Non-inline wrappers for JIT-compiled code. More...
#include "x-obj.h"#include "x-prim.h"#include "x-type/buffer.h"#include "x-type/int.h"#include "x-type/pair.h"#include "x-type/prim.h"#include "x-type/ptr.h"Functions | |
| x_obj_t * | jit_mkint (x_obj_t *p_base, long value) |
| x_obj_t * | jit_mkpair (x_obj_t *p_base, x_obj_t *a, x_obj_t *b) |
| x_obj_t * | jit_firstobj (x_obj_t *p) |
| x_obj_t * | jit_restobj (x_obj_t *p) |
| long | jit_atomint (x_obj_t *p) |
| x_obj_t * | jit_eval_arg (x_obj_t *p_base, x_obj_t *p_expr) |
| x_obj_t * | jit_build_args (x_obj_t *p_base, long nargs, long a0, long a1, long a2, long a3) |
| x_obj_t * | jit_score_set (x_obj_t *score, long sign, x_obj_t *buffer) |
| x_obj_t * | jit_score_variant (x_obj_t *score, long variant) |
| x_obj_t * | jit_buffer_unread (x_obj_t *buffer) |
| long | jit_buffer_len (x_obj_t *buffer) |
| long | jit_buffer_last_char (x_obj_t *buffer) |
| x_obj_t * | jit_make_prim (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | jit_call_value (x_obj_t *p_base, x_obj_t *p_args) |
Non-inline wrappers for JIT-compiled code.
These thin wrappers expose macro/inline operations as real functions that JIT code can call via dlsym + BLR.
| long jit_atomint | ( | x_obj_t * | p | ) |
Unbox an integer atom to a raw long.
| p | x_obj_t* – Integer atom |
| long jit_buffer_last_char | ( | x_obj_t * | buffer | ) |
Return the buffer's most recently read character as a raw long.
The tokenizer's delimiter handlers test the last character consumed; exposing it here lets those handlers JIT-compile through the same lane the tower's numeric analysers use, instead of running interpreted per character. Peer of jit_buffer_len (a different buffer macro, same shape).
| buffer | x_obj_t* – Token buffer object |
| long jit_buffer_len | ( | x_obj_t * | buffer | ) |
Return the current buffer length as a raw long.
| buffer | x_obj_t* – Token buffer object |
Decrement the buffer read pointer (unread one character).
| buffer | x_obj_t* – Token buffer object |
Build an x-lang argument list from up to 4 raw integers.
Constructs a proper list with nil as self placeholder followed by boxed integer atoms for each argument.
| p_base | x_obj_t* – Base (execution context) |
| nargs | long – Number of arguments (0..4) |
| a0 | long – First raw argument |
| a1 | long – Second raw argument |
| a2 | long – Third raw argument |
| a3 | long – Fourth raw argument |
Call a callable the compiled code CHOSE at run time.
The lane's other calls branch to an address fixed when the code was generated – the self-call trampoline, or an fvar's prim baked as an immediate. This one takes the callee out of the argument list it was handed, which is where a computed head lands: the emitter builds (callee arg0 arg1 ...) exactly as the prim ABI wants it, so the callee is simply the first element and no second register is needed to carry it across the list construction.
THE TYPE CHECK IS THE POINT. x_primval is the object's first word; on anything that is not a PRIMITIVE that word is a length, a character, a pair – and branching to it is a SIGSEGV with no relation to the call site, the same failure mode the emitter's "refuse loudly at generation" rule exists to prevent. A head is only known at run time, so the refusal has to happen here. It lives in C rather than in emitted instructions because the type name it consults is the type system's business, not a layout offset the emitter should be baking in.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – (callee arg0 arg1 ...), the prim ABI shape |
Evaluate an expression for JIT code.
| p_base | x_obj_t* – Base (execution context) |
| p_expr | x_obj_t* – Expression to evaluate |
Extract the first element of a pair.
| p | x_obj_t* – Pair object |
Create a proper x-lang prim callable from a JIT function address.
Registered as an x-lang primitive so the return value flows through dispatch and is usable as a normal x-lang value.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – (self fn-addr-ptr) |
Allocate an integer atom for JIT code.
| p_base | x_obj_t* – Base (execution context) |
| value | long – Integer value |
Allocate a pair for JIT code.
| p_base | x_obj_t* – Base (execution context) |
| a | x_obj_t* – First element |
| b | x_obj_t* – Rest element |
Extract the rest element of a pair.
| p | x_obj_t* – Pair object |
Set a tokenizer score to sign * buffer-length.
| score | x_obj_t* – Score integer atom (mutated in place) |
| sign | long – Sign multiplier (+1 or -1) |
| buffer | x_obj_t* – Token buffer object |
Declare the VARIANT an analyser accepted – written into the variant cell x_token_analyse hangs off the score's rest, and handed to the type's reader as its second argument (x-token.h). Peer of jit_score_set: the other half of the score cell, the same three-line shape.
| score | x_obj_t* – Score cell (its rest is the variant cell) |
| variant | long – The variant, a non-zero integer of the type's choosing |