Stack Trace

Stack traces are compiled into the program when build_options.stack_trace = true, which is true by default. These can be turned off for release builds. When enabled, every time a procedure is called, code is generated to output a Stack_Trace_Node on the stack and link it up, and unlink it when the procedure returns.

Stack traces are good for writing instrumentation code such as a profiler or memory debugger. The definition for stack traces can be found in modules/Preload.jai.

Here is some example code to use stack traces:

print_stack_trace :: (node: *Stack_Trace_Node) {
  while node {
    if {
      print("[%] at %:%. call depth %\n", 
    node =;

f :: (x: int) {
  if x < 1 {
  } else {