Skip to content

Latest commit

 

History

History
1314 lines (829 loc) · 16.2 KB

runtimeref.md

File metadata and controls

1314 lines (829 loc) · 16.2 KB

LispBM Runtime Extensions Reference Manual

The runtime extensions, if present, can be either compiled in a minimal or a full mode. In the minimal mode only set-eval-quota is present. Minimal mode is the default when compiling LBM. To get the full mode the -DFULL_RTS_LIB flag must be used when compiling.

Environments

env-get

env-get can be used to reify, turn into value, parts of the global environment. The global environment is stored as a hashtable and an index into this hashtable is used to extract the bindings stored under that hash.

Example Result
(env-get 0)
((chapter-gc section 2 "GC" ((newline (section 3 "set-gc-stack-size" ((para ("With `set-gc-stack-size` you can change the size of the stack used for heap traversal" "by the garbage collector.")) (code ((set-gc-stack-size 100))) nil)) newline hline))) (eva
(env-get 1)
((environment-get newline (section 3 "env-get" ((para ("`env-get` can be used to reify, turn into value, parts of the global environment." "The global environment is stored as a hashtable and an index into this hashtable" "is used to extract the bindings 
(env-get 2)
((environment-set newline (section 3 "env-set" ((para ("`env-set` destructively sets an entry in the global environment hashtable.")) (program (((if (eq (env-get 1) nil) (env-set 1 (list (quote (a . 75))))) (env-get 1)))) (para ("Note that in the example 
(env-get 3)
((program-disp closure (c) (list (quote program-disp) c) nil) (to-dot closure (x) (str-merge "digraph SExpression {\n" "   node [shape=ellipse, fontsize=12];\n" "   edge [fontsize=10];\n" (car (cdr (dot-it 1u64 x))) "\n}") nil) (render-program-disp-gif-ta
(env-get 4)
((local-environment-get newline (section 3 "local-env-get" ((para ("`local-env-get` can be used to reify, turn into value, the local environment.")) (code ((local-env-get))) (program (((let ((a 50)) (local-env-get))))) nil)) newline hline) (render-program
(env-get 5)
((chapter-environments section 2 "Environments" ((newline (section 3 "env-get" ((para ("`env-get` can be used to reify, turn into value, parts of the global environment." "The global environment is stored as a hashtable and an index into this hashtable" "
(env-get 6)
((symbol-table-size newline (section 3 "symtab-size" ((para ("`symtab-size` returns the size of the symbol table in bytes.")) (code ((symtab-size))) nil)) newline hline) (render-program-res-pairs closure (rend cs) (match cs (nil t) (((? x) ? xs) (let ((x-
(env-get 7)
((symbol-table-size-flash newline (section 3 "symtab-size-flash" ((para ("`symtab-size-flash` returns the size in bytes of the portion of the symbol table" "that is stored in flash.")) (code ((symtab-size-flash))) nil)) newline hline) (gif-count . 0) (ind
(env-get 8)
((symbol-table-size-names newline (section 3 "symtab-size-names" ((para ("`symtab-size-names` returns the size in bytes of the string names stored in" "the symbol table.")) (code ((symtab-size-names))) nil)) newline hline) (defun macro (name args body) (m
(env-get 9)
((symbol-table-size-names-flash newline (section 3 "symtab-size-names-flash" ((para ("`symtab-size-names` returns the size in bytes of the string names stored in" "the symbol table in flash.")) (code ((symtab-size-names-flash))) nil)) newline hline) (imag
(env-get 10)
((chapter-symboltable section 2 "Symbol table" ((newline (section 3 "symtab-size" ((para ("`symtab-size` returns the size of the symbol table in bytes.")) (code ((symtab-size))) nil)) newline hline) (newline (section 3 "symtab-size-flash" ((para ("`symtab
(env-get 11)
((version newline (section 3 "lbm-version" ((para ("`lbm-version` returns the version of the lbm runtime system.")) (code ((lbm-version))) nil)) newline hline) (info para ("This document was generated by LispBM version 0.29.1")) (str-merge-list closure (s
(env-get 12)
((arch newline (section 3 "is-64bit" ((para ("`is-64bit` returns true if a 64bit version of lbm is running.")) (code ((is-64bit))) nil)) newline hline) (render-program-disp-res-pairs closure (rend cs) (match cs (nil t) (((? x) ? xs) (let ((x-str (if (is-r
(env-get 13)
((word newline (section 3 "word-size" ((para ("`word-size` returns 4 on 32bit LBM  and 8 on 64bits.")) (code ((word-size))) nil)) newline hline) (leading-zeroes closure (n) (if (< n 10) (str-merge "000" (to-str n)) (if (< n 100) (str-merge "00" (to-str n)
(env-get 14)
((chapter-versioning section 2 "Version" ((newline (section 3 "lbm-version" ((para ("`lbm-version` returns the version of the lbm runtime system.")) (code ((lbm-version))) nil)) newline hline) (newline (section 3 "is-64bit" ((para ("`is-64bit` returns tru
(env-get 15)
((manual (section 1 "LispBM Runtime Extensions Reference Manual" ((para ("The runtime extensions, if present, can be either compiled" "in a minimal or a full mode." "In the minimal mode only `set-eval-quota` is present." "Minimal mode is the default when 
(env-get 16)
((render-manual closure nil (let ((h (fopen "runtimeref.md" "w")) (r (lambda (s) (fwrite-str h s)))) (progn (gc) (var t0 (systime)) (render r manual) (print "Runtime reference manual was generated in " (secs-since t0) " seconds"))) nil) (s-exp-graph closu
(env-get 17)
((pretty-aligned-ontop closure (n cs) (match cs (nil [0]) (((? x) ? xs) (str-merge "\n" (pretty-ind n x) (pretty-aligned-ontop n xs)))) nil) (section closure (i str strs) (list (quote section) i str strs) nil))
(env-get 18)
((render-dot closure (filename code) (let ((dot-str (to-dot code)) (name-dot (str-merge "./images/" filename ".dot")) (name-png (str-merge "./images/" filename ".png")) (fp-dot (fopen name-dot "w")) (fp-png (fopen name-png "w"))) (progn (fwrite fp-dot dot
(env-get 19)
((semantic-step closure (c1 c2 prop) (list (quote semantic-step) c1 c2 prop) nil) (render closure (rend ss) (match ss (nil t) (((? x) ? xs) (progn (render-it rend x) (render rend xs)))) nil))
(env-get 20)
((para closure (str) (list (quote para) str) nil) (is-read-eval-txt closure (x) (match x ((read-eval . _) t) (_ nil)) nil))
(env-get 21)
((verb closure (str) (list (quote verb) str) nil))
(env-get 22)
((pretty-list closure (c) (match c (nil [0]) (((? x)) (str-merge " " (pretty nil x))) (((? x) ? y) (if (eq (type-of y) type-list) (str-merge " " (pretty nil x) (pretty-list y)) (str-merge " " (pretty nil x) "." (pretty nil y)))) ((? x) (str-merge " . " (p
(env-get 23)
((newline closure nil (quote newline) nil) (code-examples closure (c) (list (quote code-examples) c) nil))
(env-get 24)
((evaluation-quota newline (section 3 "set-eval-quota" ((para ("`set-eval-quota` sets the number of evaluation steps that is" "given to each context when given turn to execute by the round-robin" "scheduler.")) (code ((set-eval-quota 30))) nil)) newline h
(env-get 25)
((chapter-scheduling section 2 "Scheduling" ((newline (section 3 "set-eval-quota" ((para ("`set-eval-quota` sets the number of evaluation steps that is" "given to each context when given turn to execute by the round-robin" "scheduler.")) (code ((set-eval-
(env-get 26)
((num-free newline (section 3 "mem-num-free" ((para ("`mem-num-free` returns the number of free words in the LBM memory." "This is the memory where arrays and strings are stored.")) (code ((mem-num-free))) nil)) newline hline) (render-code-res-pairs closu
(env-get 27)
((longest-free newline (section 3 "mem-longest-free" ((para ("`mem-longest-free` returns the length in words of the longest" "consecutive sequence of free words in the LBM memory.")) (code ((mem-num-free))) nil)) newline hline) (code closure (c) (list (qu
(env-get 28)
((memory-size newline (section 3 "mem-size" ((para ("`mem-size` returns the size of the LBM memory.")) (code ((mem-size))) nil)) newline hline) (s+ closure (s ss) (cons s ss) nil) (render-code-table closure (rend c) (progn (rend "<table>\n") (rend "<tr>\n
(env-get 29)
((heap-state newline (section 3 "lbm-heap-state" ((para ("`lbm-heap-state` can be used to query information about heap usage.")) (code ((lbm-heap-state (quote get-heap-size)) (lbm-heap-state (quote get-heap-bytes)) (lbm-heap-state (quote get-num-alloc-cel
(env-get 30)
((chapter-memory section 2 "Memory" ((newline (section 3 "mem-num-free" ((para ("`mem-num-free` returns the number of free words in the LBM memory." "This is the memory where arrays and strings are stored.")) (code ((mem-num-free))) nil)) newline hline) (
(env-get 31)
((gc-stack newline (section 3 "set-gc-stack-size" ((para ("With `set-gc-stack-size` you can change the size of the stack used for heap traversal" "by the garbage collector.")) (code ((set-gc-stack-size 100))) nil)) newline hline) (png-file closure nil (pr

env-set

env-set destructively sets an entry in the global environment hashtable.

Example Result
 (if (eq (env-get 1) nil) (env-set 1 (list '(a . 75))))
 (env-get 1)
((environment-get newline (section 3 "env-get" ((para ("`env-get` can be used to reify, turn into value, parts of the global environment." "The global environment is stored as a hashtable and an index into this hashtable" "is used to extract the bindings 

Note that in the example code above there is no guarantee that the symbol a actually hashes to index 1 in the environment table. So a is most likely impossible to look up from this environment. The use case for env-set and env-get are rather that they are together. Use env-get to extract index i from the table, then modify it in some way and end by using env-set to the same index i.


local-env-get

local-env-get can be used to reify, turn into value, the local environment.

Example Result
(local-env-get)
nil
Example Result
 (let ((a 50))
     (local-env-get))
((a . 50))

GC

set-gc-stack-size

With set-gc-stack-size you can change the size of the stack used for heap traversal by the garbage collector.

Example Result
(set-gc-stack-size 100)
t

Memory

mem-num-free

mem-num-free returns the number of free words in the LBM memory. This is the memory where arrays and strings are stored.

Example Result
(mem-num-free)
254550

mem-longest-free

mem-longest-free returns the length in words of the longest consecutive sequence of free words in the LBM memory.

Example Result
(mem-num-free)
254480

mem-size

mem-size returns the size of the LBM memory.

Example Result
(mem-size)
262144

lbm-heap-state

lbm-heap-state can be used to query information about heap usage.

Example Result
(lbm-heap-state 'get-heap-size)
10000000u
(lbm-heap-state 'get-heap-bytes)
80000000u
(lbm-heap-state 'get-num-alloc-cells)
10485u
(lbm-heap-state 'get-num-alloc-arrays)
818u
(lbm-heap-state 'get-gc-num)
1u
(lbm-heap-state 'get-gc-num-marked)
3690u
(lbm-heap-state 'get-gc-num-recovered-cells)
9996310u
(lbm-heap-state 'get-gc-num-recovered-arrays)
0u
(lbm-heap-state 'get-gc-num-least-free)
9996310u
(lbm-heap-state 'get-gc-num-last-free)
9996310u

Scheduling

set-eval-quota

set-eval-quota sets the number of evaluation steps that is given to each context when given turn to execute by the round-robin scheduler.

Example Result
(set-eval-quota 30)
t

Symbol table

symtab-size

symtab-size returns the size of the symbol table in bytes.

Example Result
(symtab-size)
3697u

symtab-size-flash

symtab-size-flash returns the size in bytes of the portion of the symbol table that is stored in flash.

Example Result
(symtab-size-flash)
0u

symtab-size-names

symtab-size-names returns the size in bytes of the string names stored in the symbol table.

Example Result
(symtab-size-names)
1579u

symtab-size-names-flash

symtab-size-names returns the size in bytes of the string names stored in the symbol table in flash.

Example Result
(symtab-size-names-flash)
0u

Version

lbm-version

lbm-version returns the version of the lbm runtime system.

Example Result
(lbm-version)
(0 29 1)

is-64bit

is-64bit returns true if a 64bit version of lbm is running.

Example Result
(is-64bit)
nil

word-size

word-size returns 4 on 32bit LBM and 8 on 64bits.

Example Result
(word-size)
4

This document was generated by LispBM version 0.29.1