Next: , Previous: , Up: iklib syntaxes   [Index]


6.8.22 Inspecting optimisation results

Syntax: optimisation-of ?expr

This syntax is mostly for interactive use. Fully expand the given expression in the current lexical environment and apply the compiler’s optimisator to the resulting core language expression; return a symbolic expression representing the resulting invoke code. The expression is not evaluated, only expanded and optimised; this means that the expansion side effects are performed.

NOTE Only expressions are expanded and optimised. It makes no sense to give a standalone define syntax to this macro; when a standalone function definition is expanded and optimised: the function is never called, so it is removed.

Example session at the REPL:

vicare> (print-gensym #f)

vicare> (optimisation-of (+ 1 2))
$1 = 3

NOTE The level of optimisation of source code is configured by the -O options; -O0 turns off the source optimiser. The default is equivalent to -O2.

Syntax: optimisation-of* ?expr0 ?expr

Like optimisation-of, but wrap the input expression as follows:

(internal-body ?expr0 ?expr … (void))

this allows the expansion and optimisation of definition forms. Example of REPL session:

vicare> (pretty-width 65)
vicare> (print-gensym #f)
vicare> (optimisation-of*
   (define-record-type frob)
   (define it (make-frob)))
$1 = (let* ((lex.frob-rtd_0
        (make-record-type-descriptor 'frob '#f '#f '#f '#f '#()))
       (lex.frob-rcd_0
        (make-record-constructor-descriptor lex.frob-rtd_0 '#f
          '#f))
       (lex.make-frob_0 (record-constructor lex.frob-rcd_0)))
  (begin (lex.make-frob_0) '#<void>))
Syntax: further-optimisation-of ?expr

Like optimisation-of, but in addition perform some compiler passes that additionally optimise the code.

Example session:

(further-optimisation-of
  (let ((x (read)))
    (when (fixnum? x)
      (gcd x 2))))
⇒ (let ((x_0 (read)))
     (if (fixnum? x_0)
         ($gcd-fixnum-fixnum
            (known x_0
              (T:fixnum T:non-false T:exact-real T:real
               T:exact-integer T:exact T:number T:immediate
               T:object))
            (known (constant 2)
              (T:fixnum T:positive T:non-false T:exact-real
               T:real T:exact-integer T:exact T:number
               T:immediate T:object)))
         (constant #<void>)))
Syntax: further-optimisation-of* ?expr0 ?expr

Like further-optimisation-of, but wrap the input expression as follows:

(internal-body ?expr0 ?expr … (void))

this allows the expansion and optimisation of definition forms. Example of REPL session:

vicare> (pretty-width 65)
vicare> (print-gensym #f)
vicare> (further-optimisation-of*
   (define-record-type frob)
   (define it (make-frob)))
$1 = (let* ((lex.frob-rtd_0
        (make-record-type-descriptor
          (known 'frob
            (T:symbol T:non-false T:nonimmediate T:object))
          (known '#f (T:false T:boolean T:immediate T:object))
          (known '#f (T:false T:boolean T:immediate T:object))
          (known '#f (T:false T:boolean T:immediate T:object))
          (known '#f (T:false T:boolean T:immediate T:object))
          (known '#()
            (T:vector T:non-false T:nonimmediate T:object))))
       (lex.frob-rcd_0
        (make-record-constructor-descriptor lex.frob-rtd_0
          (known '#f (T:false T:boolean T:immediate T:object))
          (known '#f (T:false T:boolean T:immediate T:object))))
       (lex.make-frob_0 (record-constructor lex.frob-rcd_0)))
  (begin
    ((known lex.make-frob_0
       (T:procedure T:non-false T:nonimmediate T:object)))
    '#<void>))

Next: , Previous: , Up: iklib syntaxes   [Index]