Next: , Previous: , Up: compiler   [Index]


17.14 Safe to unsafe core primitive applications

This optional compiler pass recognises the application of safe core primitive functions having operands of the correct type and replaces them with the corresponding application of unsafe core primitive functions or operations; the result is faster code.

NOTE A safe core primitive validates its arguments and raises an exception it they have the wrong type; an unsafe core primitive assumes its operands are correct and just attempts to perform the algorithm.

NOTE At present (Jul 23, 2016), this compiler pass is performed only if the configured compiler’s optimisation level is ‘1’ or above. When Vicare is run with the option -O0: this compiler pass is skipped.

It makes sense to perform this compiler pass only if core-type-inference has been performed first: it is the “type inference” pass that introduces the type descriptions consumed by the “unsafe primitives introduction” pass. Performing this pass could be useless because:

nevertheless, it is technologically possible to compose core language expressions by means different from applying the expander to source code; in such scenario this compiler pass makes sense, because there are core primitives implemented only as functions (not operations) that still have an unsafe variant.

Function: pass-introduce-unsafe-primrefs input

Perform code transformations traversing the whole hierarchy in input, which must be a struct instance representing recordised code, and building a new hierarchy of recordised code; return the new hierarchy.

Parameter: perform-unsafe-primrefs-introduction?

When true the pass introduce-unsafe-primrefs is performed, else it is skipped. Defaults to #t.


Next: , Previous: , Up: compiler   [Index]