21.1 C requirement
21.2 JVM requirement
21.3 Linking
21.4 The compiler environment and options
Copyright
Acknowledgements
1. Table of contents
2. Overview of Bigloo
3. Modules
4. Core Language
5. Standard Library
6. Pattern Matching
7. Object System
8. Threads
9. Regular parsing
10. Lalr(1) parsing
11. Errors and Assertions
12. Eval and code interpretation
13. Macro expansion
14. Command Line Parsing
15. Explicit typing
16. The C interface
17. The Java interface
18. Bigloo Libraries
19. SRFIs
20. DSSSL support
21. Compiler description
22. User Extensions
23. Bigloo Development Environment
24. Global Index
25. Library Index
Bibliography
|
Instead of producing assembly code, Bigloo produces C code.
This C code is ISO-C compliant [IsoC]. So, it is necessary
to have an ISO-C compiler. The current version has been
developed with gcc [Stallman95].
In order to compile the Bigloo JVM back-end, you have to be provided
with a JDK 1.2 or more recent (available at http://www.javasoft.com ).
The JVM must support for -noverify option because, by default,
Bigloo produces JVM code that is not conform to the rules enforced by
the Java byte code verifiers.
Only Bigloo can be used to link object files which have been
compiled by Bigloo. An easy way to perform this operation is,
after having compiled all the files using the -c option,
to invoke Bigloo with the name of the compiled files.
When Bigloo is only given object file name as argument, it
searches in the current directory and the directory named in the
*load-path* list the Scheme source file in order to
perform a correct link. Scheme source files are supposed to be
ended by the suffix .scm . Additional suffixes can be added
using the -suffix option. Hence, if source files are named
foo1.sc and foo2.sc, a link command line could look like:
bigloo -suffix sc foo1.o foo2.o -o foo |
21.4 The compiler environment and options
|
There are four ways to change the behaviour of Bigloo. Flags on the
command line, the option module clause runtime-command file and
environment variables See Modules. When the compiler is invoked, it
first gets the environment variables, then it scans the
runtime-command file and, at end, it parses the command line. If the
same option is set many times, Bigloo uses the last one.
21.4.1 Efficiency
In order to get maximum speed, compile with the -Obench option.
This will enable all compiler optimization options and disable dynamic
type checks. To improve arithmetic performance see next section.
21.4.2 Stack allocation
When the -fstack flag is enabled, the compiler may automatically
replace some heap allocations with stack allocations. This may improve
performance because stack allocations are handled more efficiently than
heap allocations. On some cases, -fstack may also cause slow down
or memory extra retentions. In this last case, when compile
using -fstack the program will consume more memory. Unfortunately,
this is nasty phenomenon is unpredictable (it depends on the nature of
the source file).
21.4.3 Genericity of arithmetic procedures
By default, arithmetic procedures are generic. This means that it is
allowed to use them with flonum and fixnum. This feature, of course,
implies performances penalty. To improve performance, you may use
specialized procedures (such as +fx , =fx , ... or
+fl , =fl , ...) but, it is possible to suppress the
genericity and to make all generic arithmetic procedures (= for
example) fixnum ones. For this you must use the compiler option
-farithmetic , or add the following module clause (option
(set! *genericity* #f)) in your module declaration.
21.4.4 Safety
It is possible to generate safe or unsafe code.
The safety's scope is type , arity , version and
range .
Let's see an example:
(define (foo f v indice)
(car (f (vector-ref v indice))))
|
In safe mode, the result of the compilation will be:
(define (foo f v indice)
(let ((pair
(if (and (procedure? f)
;; type check
(= (procedure-arity f) 1))
;; arity check
(if (vector? v)
;; type check
(if (and (integer? k)
;; type check
(>= k 0)
;; range check
(< k (vector-length v)))
;; range check
(f (vector-ref v indice))
(error ...))
(error ...))
(error ...))))
(if (pair? pair)
;; type check
(car pair)
(error ...))))
|
It is possible to remove some or all safe checks. For example, here is
the result of the compilation where safe check on types have been removed:
(define (foo f v indice)
(let ((pair (if (= (procedure-arity f) 1)
;; arity check
(if (and (>= k 0)
;; range check
(< k (vector-length v)))
;; range check
(f (vector-ref v indice))
(error ...))
(error ...))))
(car pair)))
|
21.4.5 The runtime-command file
Each Bigloo's user can use a special configuration file. This file must
be named ``.bigloorc '' or ``~/.bigloorc ''. Bigloo tries to
load one of these in this order. This file is a Scheme file. Bigloo
exports variables which allow the user to change the behavior of the
compiler. All these variables can be checked using the -help2 option.
The Bigloo's runtime command file is read before the arguments are parsed.
21.4.6 The Bigloo command line
If no input file is specified, Bigloo enters its interpreter.
Here is the exhaustive list of Bigloo options and configuration variables:
usage: bigloo [options] [name.suf]
Misc:
- -- Read source code on current input channel
-help -- This help message
-help2 -- The exhaustive help message
-help-manual -- The help message formatted for the manual
-o <dst> -- Name the output file <dst>
--to-stdout -- Write C code on current output channel
-c -- Suppress linking and produce a .o file
-suffix <suffix> -- Recognize suffix as Scheme source
-afile <file> -- Set name of the access file (default .afile)
-access <module> <file> -- Set access between module and file
-jfile <file> -- Set name of the Jvm package file (default .jfile)
-jadd <module> <qtype> -- Set JVM qualifed type name for module
-main <fun> -- Set the main function
-with <module> -- Import addition module
-multiple-inclusion -- Enables multiple inclusion of the same Bigloo include
-library <library> -- Compile (and link) with additional library
-dload-sym -- Emit a Bigloo dynamic loading entry point
-heapsize <size> -- Set the initial heap size value (in megabyte)
Configuration and path:
-version -- The current release
-revision -- The current release (short format)
-query -- Dump the current configuration
-q -- Do not load any rc file
-eval <string> -- Evaluate <string>
-I <name> -- Add <name> to the load path
-lib-dir <name> -- Set lib-path to <name>
-L <name> -- Set additional library path
-jvm-classpath <name> -- Set the JVM classpath
-jvm-directory <name> -- Directory where to store class files.
-jvm-jarpath <name> -- Set the JVM classpath for the produced jar file
Dialect:
-nil -- Evaluate '() as #f in `if' expression
-call/cc -- Enable call/cc function
-hygien -- Enable r5rs macros
-fno-reflection -- Disable reflection code production
+fno-reflection -- Enable reflection code production
-farithmetic -- Suppress genericity of arithmetic operators
-fcase-sensitive -- Case sensitive reader (default)
-fcase-insensitive -- Case insensitive reader (downcase symbols)
Back-end:
-native -- Produce a native object file (via C)
-jvm -- Produce JVM .class files instead of a C file
-jvm-shell <shell> -- Shell to be used for running JVM applications (either "sh" or "msdos")
-jvm-purify -- Produce byte code verifier compliant JVM code
-no-jvm-purify -- Don't care about JVM code verifier (default)
-i -- Don't compile but interprete
-target <lang> -- DON'T USE, see -native or -jvm option
Optimization:
-Obench -- Benchmarking mode
-O[2..6] -- Optimization modes
-fcfa-arithmetic -- Enable arithmetic spec. (enabled from -O2)
-fno-cfa-arithmetic -- Disable arithmetic spec.
-funroll-loop -- Enable loop unrolling (enabled from -O3)
-fno-unroll-loop -- Disable loop unrolling
-fno-loop-inlining -- Disable loop inlining
-floop-inlining -- Enable loop inlining (default)
-fno-inlining -- Disable inline optimization
-fno-user-inlining -- Disable user inline optimization
-fbeta-reduce -- Enable simple beta reduction. (enable from -O3)
-fno-beta-reduce -- Disable simple beta reduction
-fdataflow -- Enable dataflow optimizations. (enable from -O)
-fno-dataflow -- Disable dataflow optimizations
-fO-macro -- Enable Optimization macro (default)
-fno-O-macro -- Disable Optimization macro
Compilation modes:
<-/+>rm -- Don't or force removing C file
-extend <name> -- Extend the compiler
-fsharing -- Attempt to share constant data
-fno-sharing -- Do not attempt to share constant data
-fmco -- Produce an .mco file
-fmco-include-path <path> -- Add dir to mco C include path
Safety:
-unsafe[atrsvl] -- Don't check [type/arity/range/struct/version]
Debug:
-gbdb-no-line -- Don't emit Cpp # line directives
-gbdb[23] -- Compile with bdb debug informations
-gself -- Enables self compiler debug options
-gheap -- Enables heap debugging (set with -gbdb2)
-gmodule -- Debug module initialization
-g[234] -- Produce Bigloo debug informations
-cg -- Compile C files with debug option
-export-all -- Eval export-all all routines
-export-exports -- Eval export-exports all routines
-export-mutable -- Enables Eval redefinition of all routines
Profiling:
-p[2] -- Compile files for profiling
-pg -- Compile files with profiling option
Verbosity:
-s -- Be silent and inhibit all warning messages
-v[23] -- Be verbose
-no-hello -- Dont' say hello even in verbose mode
-w -- Inhibit all warning messages
-wslots -- Inhibit overriden slots warning messages
-Wall -- warn about all possible type errors
Native specific options:
-cc <compiler> -- Specify the C compiler
-stdc -- Generate strict ISO C code
-copt <string> -- Invoke cc with <string>
-ldopt <string> -- Invoke ld with <string>
--force-cc-o -- Force the C compiler to use -o instead of mv
-ld-relative -- Link using -l notation for libraries
-ld-absolute -- Link using absolute path names for libraries
-static-bigloo -- Link with the static bigloo library
-ld-libs1 -- include once the user libraries when linking
-ld-libs2 -- include twice the user libraries when linking (default)
-l<library> -- Link with host library
Jvm specific options:
-fjvm-inlining -- Enable JVM back-end inlining
-fjvm-constr-inlining -- Enable JVM back-end inlining for constructors
-fno-jvm-inlining -- Disable JVM back-end inlining
-fno-jvm-constr-inlining -- Disable JVM back-end inlining for constructors
-fjvm-peephole -- Enable JVM back-end peephole
-fno-jvm-peephole -- Disable JVM back-end peephole
-fjvm-branch -- Enable JVM back-end branch
-fno-jvm-branch -- Disable JVM back-end branch
-fjvm-fasteq -- EQ? no longer works on integers (use =FX)
-fno-jvm-fasteq -- Disable JVM back-end fasteq transformation
-jvm-env <var> -- Make the shell variable visible to GETENV
-jvm-jar -- Produce a JVM jar file when linking
-no-jvm-jar -- Don't produce a JVM jar file when linking (default)
-jvm-java <string> -- Use <file> as JVM
-jvm-opt <string> -- Invoke JVM with <string>
Traces:
-t[2|3|4] -- Generate a trace file (*)
+t<pass> -- Force pass to be traced
-shape[mktalu] -- Some debugging tools (private)
Compilation stages:
-syntax -- Stop after the syntax stage (see -hygien)
-expand -- Stop after the preprocessing stage
-ast -- Stop after the ast construction stage
-bdb-spread-obj -- Stop after the bdb obj spread stage
-trace -- Stop after the trace pass
-callcc -- Stop after the callcc pass
-bivalue -- Stop after the bivaluation stage
-inline -- Stop after the inlining stage
-inline+ -- Stop after the 2nd inlining stage
-fail -- Stop after the failure replacement stage
-fuse -- Stop after the fuse stage
-user -- Stop after the user pass
-coerce -- Stop after the type coercing stage
-effect -- Stop after the effect stage
-effect+ -- Stop after the 2nd effect stage
-reduce -- Stop after the reduction opt. stage
-reduce+ -- Stop after the 2nd reduction opt. stage
-assert -- Stop after the assertions stage
-cfa -- Stop after the cfa stage
-closure -- Stop after the globalization stage
-recovery -- Stop after the type recovery stage
-bdb -- Stop after the Bdb code production
-cnst -- Stop after the constant allocation
-integrate -- Stop after the integration stage
-hgen -- Produce a C header file with class definitions
-cgen -- Do not C compile and produce a .c file
-jvmas -- Produce a JVM .jas file instead of a C file
-indent -- Produce an indented .c file
-mco -- Stop after .mco production
Constant initialization:
-init-<lib/read/intern> -- Constants initialization mode
Bootstrap and setup:
-mklib -- Compile a library module
-mkaddlib -- Compile an additional library module
-mkheap -- Build an heap file
-mkaddheap -- Build an additional heap file
-mkdistrib -- Compile a main file for a distribution
-license -- Display the Bigloo license and exit
-LICENSE -- Add the license to the generated C files
-heap <name> -- Specify an heap file (or #f to not load heap)
-dump-heap -- Dump the contains of a heap
-dheap <name> -- Dump the contains of a heap
-addheap <name> -- Specify an additional heap file
-fread-internal -- Read source from binary interned file
-fread-plain -- Read source from plain text file
* : only available in developing mode
. : option enabled from -O3 mode
Shell Variables:
- TMPDIR
tmp directory (default "/tmp")
- BIGLOOLIB
libraries' directory
- BIGLOOHEAP
the initial heap size in megabytes (4 MB by default)
- BIGLOOSTACKDEPTH
the error stack depth printing
- BIGLOOLIVEPROCESS
the maximum number of Bigloo live processes
Runtime Command file:
- ~/.bigloorc
Bigloo Control Variables:
All the Bigloo control variables can be changed from the
interpreter, by the means of the `-eval' option, or using
the module clause `option'. For instance the option
"-eval '(set! *strip* #t)'" will set the variable
`*strip*' to the value `#t'.
These variables are:
- *bigloo-version* :
The Bigloo major release number
default: "2.5a"
- *bigloo-name* :
The Bigloo name
default: "Bigloo (2.5a)"
- *bigloo-tmp* :
The tmp directory name
default: "/users/serrano/tmp"
- *bigloo-licensing?* :
Add the Bigloo license ?
default: #f
- *verbose* :
The verbosity level
default: 0
- *hello* :
Say hello (when verbose)
default: #t
- *src-files* :
The sources files
default: ()
- *dest* :
The target name
default: #f
- *shell* :
The shell to exec C compilations
default: "/bin/sh"
- *cc* :
The C compiler
default: "gcc"
- *cflags* :
The C compiler option
default: ""
- *cflags-optim* :
The C compiler optimization option
default: "-O3 "
- *cflags-prof* :
The C compiler profiling option
default: "-pg -fno-inline "
- *stdc* :
Shall we produced ISO C?
default: #f
- *cc-options* :
cc options
default: ""
- *rm-c-files* :
Shall we remove the C produced file?
default: #t
- *ld-options* :
ld options
default: ""
- *cc-move* :
Use mv or -o when C compiling
default: #t
- *ld-relative* :
Relative or absolute path names for libraries
default: #f
- *strip* :
Shall we strip the executable?
default: #t
- *default-lib-dir* :
The default lib dir path (without version)
default: "/users/serrano/prgm/project/bigloo/lib/2.5a"
- *lib-dir* :
The lib dir path
default: ("." "/users/serrano/prgm/project/bigloo/lib/2.5a")
- *lib-src-dir* :
The lib dir path
default: "./runtime"
- *bigloo-lib-base-name* :
The Bigloo library base name
default: "bigloo"
- *bigloo-lib* :
The Bigloo library
default: "bigloo"
- *gc-lib* :
The Gc library
default: "gc"
- *static-bigloo?* :
Do we use the static Bigloo library
default: #f
- *double-ld-libs?* :
Do we include twice the additional user libraries
default: #t
- *bigloo-user-lib* :
The user extra C libraries
default: ("-lm")
- *additional-bigloo-libraries* :
The user extra Bigloo libraries
default: ()
- *additional-bigloo-zips* :
The user extra Bigloo Zip files
default: ()
- *include-multiple* :
Enable/disable multiple inclusion of same file
default: #f
- *include-foreign* :
The C included files
default: ("bigloo.h")
- *additional-include-foreign* :
The additional C included files
default: ()
- *heap-base-name* :
The Bigloo heap base name
default: "bigloo"
- *heap-name* :
The Bigloo heap file name
default: "bigloo.heap"
- *heap-jvm-name* :
The Bigloo heap file name for the JVM backend
default: "bigloo.jheap"
- *heap-dump-names* :
The name of the heap to be dumped
default: ()
- *jvm-foreign-class-id* :
The identifier of the Jlib foreign class
default: foreign
- *jvm-foreign-class-name* :
The name of the Jlib foreign class
default: "bigloo.foreign"
- *additional-heap-name* :
A name of an additional heap file name to be build
default: #f
- *additional-heap-names* :
A list of Bigloo additional heap file name
default: ()
- *indent* :
The name of the C beautifier
default: "stdindent"
- *compiler-debug* :
Debugging level
default: 0
- *compiler-sharing-debug?* :
Compiler self sharing debug
default: #f
- *debug-module* :
Module initilazation debugging
default: 0
- *c-debug* :
C debugging mode?
default: #f
- *c-debug-option* :
cc debugging option
default: "-g"
- *jvm-debug* :
JVM debugging mode?
default: #f
- *bdb-debug* :
Bdb debugging mode
default: 0
- *heap-debug* :
Heap debugging mode
default: 0
- *heap-debug-copt* :
Heap debugging C flags
default: "-DKEEP_BACK_PTRS"
- *profile-mode* :
Bigloo profile mode
default: 0
- *prof-table-name* :
Bprof translation table file name
default: "bmon.out"
- *access-file* :
The access file name
default: #f
- *access-file-default* :
The default access file name
default: ".afile"
- *qualified-type-file* :
The qualifed-type association file name
default: #f
- *qualified-type-file-default* :
The qualifed-type association file name
default: ".jfile"
- *o-files* :
The additional obect files
default: ()
- *c-files* :
The C source files
default: ()
- *with-files* :
The additional modules
default: ()
- *interpreter* :
Shall we interprete the source file?
default: #f
- *startup-file* :
A startup file for the interpreter
default: #f
- *call/cc?* :
Shall we enable call/cc?
default: #f
- *reflection?* :
Shall we produce refection code for classes
default: #t
- *pass* :
Stop after the pass
default: ld
- *jvm-jar?* :
Enable/disable a JAR file production for the JVM back-end
default: #f
- *jvm-shell* :
Shell to be used when producing JVM run scripts
default: "sh"
- *jvm-java* :
JVM to be used to run Java programs
default: "java"
- *jvm-options* :
JVM options
default: ""
- *jvm-classpath* :
JVM classpath
default: #f
- *jvm-jarpath* :
JVM jarpath
default: #f
- *jvm-directory* :
JVM object directory
default: #f
- *module-checksum-object?* :
Produce a module checksum object (.mco)
default: #f
- *garbage-collector* :
The garbage collector
default: boehm
- *unsafe-type* :
Runtime type safety
default: #f
- *unsafe-arity* :
Runtime type arity safety
default: #f
- *unsafe-range* :
Runtime range safety
default: #f
- *unsafe-struct* :
Runtime struct range safety
default: #f
- *unsafe-version* :
Module version safety
default: #f
- *unsafe-library* :
Use the unsafe library version
default: #f
- *warning-overriden-slots* :
Set to #t to warn about virtual slot overriding
default: #t
- *profile-library* :
Use the profiled library version
default: #f
- *max-stack-alloc-size* :
Maximum size of stack allocated objects
default: #f
- *shared-cnst?* :
Shared constant compilation?
default: #t
- *lib-mode* :
Lib-mode compilation?
default: #f
- *init-mode* :
Module initialization mode
default: read
- *dlopen-init* :
Emit a standard Bigloo dynamic loading init entry point
default: #f
- *max-c-token-length* :
Max c token length
default: 1024
- *max-c-foreign-arity* :
Max C function arity
default: 16
- *trace-name* :
Trace file name
default: "trace"
- *trace-write-length* :
Trace dumping max level
default: 80
- *optim* :
Optimization level
default: 0
- *optim-stack?* :
Stack allocation optimization
default: #unspecified
- *optim-unroll-loop?* :
Loop unrolling optimization
default: #unspecified
- *optim-loop-inlining?* :
Loop inlining optimization
default: #t
- *optim-O-macro?* :
Enable optimization by macro-expansion
default: #f
- *optim-jvm-inlining* :
Enable JVM inlining
default: 0
- *optim-jvm-constructor-inlining* :
Enable JVM inlining for constructors
default: 0
- *optim-jvm-peephole* :
Enable JVM peephole optimization
default: 0
- *optim-jvm-branch* :
Enable JVM branch tensioning
default: 0
- *optim-jvm-fasteq* :
EQ? no longer works on integers (use =FX instead)
default: #f
- *jvm-purify* :
Produce byte code verifier compliant JVM code
default: #f
- *jvm-env* :
List of environment variables to be available in the compiled code
default: ()
- *optim-jvm* :
Enable optimization by inlining jvm code
default: 0
- *optim-cfa-arithmetic?* :
Enable refined arithmetic specialization
default: #f
- *optim-dataflow?* :
Enable simple dataflow optimization
default: #f
- *optim-reduce-beta?* :
Enable simple beta reduction
default: #f
- *inlining?* :
Inlining optimization
default: #t
- *user-inlining?* :
User inlining optimization
default: #t
- *inlining-kfactor* :
Inlining growth factor
default: #<procedure:8050c30.1>
- *inlining-reduce-kfactor* :
Inlinine growth factor reductor
default: #<procedure:8050b80.1>
- *extend-entry* :
Extend entry
default: #f
- *src-suffix* :
Scheme legal suffixes
default: ("scm" "bgl")
- *c-suffix* :
C legal suffixes
default: ("c")
- *obj-suffix* :
Object legal suffixes
default: ("o")
- *mco-suffix* :
Module checksum object legal suffixes
default: ("mco")
- *mco-include-path* :
Module checksum C include path
default: (".")
- *auto-mode* :
auto-mode (extend mode) list
default: (("ml" . "caml") ("mli" . "caml") ("oon" . "meroon"))
- *ast-case-sensitive* :
Case sensitivity
default: #t
- *user-heap-size* :
Heap size (in MegaByte) or #f for default value
default: #f
- *reader* :
The way the reader reads input file ('plain or 'intern)
default: plain
- *target-language* :
The target language (either C or JVM)
default: native
- *use-private?* :
Use private construction instead of pragma
default: #f
- *eval-options* :
A user variable to store dynamic command line options
default: ()
- *load-path* :
The load path
default: ("." "/users/serrano/prgm/project/bigloo/lib/2.5a")
- *user-pass* :
The user specific compilation pass
default: #unspecified
- *debug* :
The debugging level
default: 0
- *warning* :
The warning level
default: #t
- *hygien?* :
Hygienic r5rs macro expansion activation
default: #f |
|