4 Running Programs

4.1 Run Command Syntax

cminor run [run-options] PROGRAM.cminora [program-arguments]

Runs program in virtual machine with given program-arguments.

4.2 Running Programs by Interpreting the Intermediate Code

For example, to run program hello.cminora by interpreting the intermediate code, use the following command:

> cminor run assembly\debug\hello.cminora
Hello, world!

4.3 Running Programs Compiled to Native Code

For example, to run program args.cminora compiled to native code, and give it arguments foo and bar, use the following command:

> cminor run --native assembly\debug\args.cminora foo bar
foo
bar

4.4 Printing Execution Statistics

For example, to run program hello.cminora compiled to native code and print the execution statistics for it, use the following command:

> cminor run --native --stats assembly\debug\hello.cminora
Hello, world!

STATISTICS

load time : 343 ms ( 93.2 % of startup time)
link time : 8 ms ( 2.1 % of startup time)
prepare time : 17 ms ( 4.6 % of startup time)
startup time : 368 ms ( 84.7 % of total vm time)
-------------------------------------------------------------------------------
gen1 gc time : 0 ms ( 0.0 % of total gc time) [ 0 gc pauses]
full gc time : 0 ms ( 0.0 % of total gc time) [ 0 gc pauses]
total gc time : 0 ms ( 0.0 % of run time) [ 0 gc pauses]
run time : 2 ms ( 0.4 % of total vm time)
-------------------------------------------------------------------------------
total vm time : 434 ms (100.0 % of startup time + run time + extra time)

4.5 Setting Virtual Machine Parameters

Size of Garbage Collected Memory Segment

The default size of the garbage collected memory segment is 16 MB.

To use different garbage collected memory segment size, use the following command:

> cminor run --segment-size=32 assembly\debug\hello.cminora

Sets the size of the garbage collected memory segment to 32 megabytes.

Number of Thread-Specific Memory Allocation Pages.

The memory allocator of the virtual machine allocates extra memory for a thread making an allocation. That thread can consume this extra memory without any locking.

The default number of thread-specific memory allocation context pages is 2. For typical virtual memory page size of 4K, this means that each thread can allocate additional 8K without locking for each allocation that requires locking.

To use different number of thread-specific memory allocation context pages, use the following command:

> cminor run --thread-pages=4 assembly\debug\hello.cminora

4.6 Virtual Machine Debugging Options

To print garbage collection actions to stderr, use the following command:

> cminor run --gcactions assembly\debug\hello.cminora

This prints "[G]" each time that garbage collection occurs, and additional "[F]" when the garbage collector is performing full collection.

To run a program in the debug version of the virtual machine, use the following command:

> cminor run --debug assembly\debug\hello.cminora

To trace execution of a program compiled to native code to stderr, use the following command:

> cminor run --native --trace assembly\debug\hello.cminora