-
Notifications
You must be signed in to change notification settings - Fork 63
Low Level Primitives
Higgs provides a way to call directly into low-level IR primitives the JIT compiler understands (see source/ir/ops.d). These are the building blocks from which the JS runtime library is built.
Word/type manipulation primitives
- $ir_make_value
- $ir_get_word
- $ir_get_type
Type tag tests
- $ir_is_int32
- $ir_is_int64
- $ir_is_float64
- $ir_is_string
- $ir_is_rope
- $ir_is_object
- $ir_is_array
- $ir_is_closure
- $ir_is_refptr
- $ir_is_rawptr
- $ir_is_const
Type conversion
- $ir_i32_to_f64
- $ir_f64_to_i32
Integer arithmetic
- $ir_add_i32
- $ir_sub_i32
- $ir_mul_i32
- $ir_div_i32
- $ir_mod_i32
Bitwise operations
- $ir_and_i32
- $ir_or_i32
- $ir_xor_i32
- $ir_lsft_i32
- $ir_rsft_i32
- $ir_ursft_i32
- $ir_not_i32
Floating-point arithmetic
- $ir_add_f64
- $ir_sub_f64
- $ir_mul_f64
- $ir_div_f64
- $ir_mod_f64
Higher-level floating-point functions
- $ir_sin_f64
- $ir_cos_f64
- $ir_sqrt_f64
- $ir_ceil_f64
- $ir_floor_f64
- $ir_log_f64
- $ir_exp_f64
- $ir_pow_f64
Integer operations with overflow handling
- $ir_add_i32_ovf
- $ir_sub_i32_ovf
- $ir_mul_i32_ovf
- $ir_lsft_i32_ovf
Integer comparison instructions
- $ir_eq_i32
- $ir_ne_i32
- $ir_lt_i32
- $ir_gt_i32
- $ir_le_i32
- $ir_ge_i32
- $ir_eq_i8
Pointer comparison instructions
- $ir_eq_refptr
- $ir_ne_refptr
- $ir_eq_rawptr
- $ir_ne_rawptr
Constant comparison instructions
- $ir_eq_const
- $ir_ne_const
Floating-point comparison instructions
- $ir_eq_f64
- $ir_ne_f64
- $ir_lt_f64
- $ir_gt_f64
- $ir_le_f64
- $ir_ge_f64
Load instructions
- $ir_load_u8
- $ir_load_u16
- $ir_load_u32
- $ir_load_u64
- $ir_load_i8
- $ir_load_i16
- $ir_load_f64
- $ir_load_refptr
- $ir_load_rawptr
- $ir_load_funptr
Store instructions
- $ir_store_u8
- $ir_store_u16
- $ir_store_u32
- $ir_store_u64
- $ir_store_i8
- $ir_store_i16
- $ir_store_f64
- $ir_store_refptr
- $ir_store_rawptr
- $ir_store_funptr
- $ir_store_mapptr
Unconditional jump
- $ir_jump
Branch based on a boolean value
- $ir_if_true
Test if a closure is an instance of a given function and branch based on the result This instruction is used for conditional inlining
- $ir_if_eq_fun
Implements JS function calls. Makes the execution go to the callee entry. Pushes arguments and a return address on the stack.
- $ir_call
Call with an array of arguments (used by Function.prototype.apply)
- $ir_call_apply
Call a primitive function by name (note: the second argument is a cached function reference)
- $ir_call_prim
Pops the callee frame (size known by context)
- $ir_ret
Throws an exception, unwinds the stack
- $ir_throw
Access visible arguments by index
- $ir_get_arg
Special implementation object/value access instructions
- $ir_get_obj_proto
- $ir_get_arr_proto
- $ir_get_fun_proto
- $ir_get_global_obj
- $ir_get_heap_size
- $ir_get_heap_free
- $ir_get_gc_count
Allocate a block of memory on the heap
- $ir_heap_alloc
Trigger a garbage collection
- $ir_gc_collect
Create a link table entry associated with this instruction
- $ir_make_link
Set the value of a link table entry
- $ir_set_link
Get the value of a link table entry
- $ir_get_link
Compute the hash code for a string and try to find the string in the string table
- $ir_get_str
Create a new closure from a function's AST node
- $ir_new_clos
Load a source code unit from a file
- $ir_load_file
Evaluate a source string in the global scope
- $ir_eval_str
Print a string to standard output
- $ir_print_str
Get a string representation of a function's AST
- $ir_get_ast_str
Get a string representation of a function's IR
- $ir_get_ir_str
Format a floating-point value as a string
- $ir_f64_to_str
Format a floating-point value as a string (long)
- $ir_f64_to_str_lng
Get the time in milliseconds since process start
- $ir_get_time_ms
Load a shared lib
- $ir_load_lib
Close shared lib
- $ir_close_lib
Lookup symbol in shared lib
- $ir_get_sym
Call C function in shared lib
- $ir_call_ffi