-
-
Notifications
You must be signed in to change notification settings - Fork 667
Runtime
NOTE: This is a work in progress and the respective PR has not yet been merged into master.
AssemblyScript provides a set of runtime templates to automatically include support for managed objects when compiling a program. As the name says, a runtime template provides functionality that performs certain operations, that cannot be performed at compile time, during runtime, like, for example:
- Include a memory allocator to be able to use
new
expressions / instantiate managed classes - Include a garbage collector that either traces or counts the references of unreachable objects
Previous versions of the compiler didn't include any runtime functionality by default, leaving it up to the developer to import relevant implementations manually, while newer versions of the compiler include a default runtime suitable for most tasks. The runtime template to include can be specified with the --runtime
flag:
-
--runtime default
The runtime that is included by default, consisting of the TLSF memory allocator and the ITCM garbage collector. -
--runtime arena
A very small prototyping runtime without free/GC support. Equivalent to just importingallocator/arena
. -
--runtime none
Just basic runtime functionality likeinstanceof
. Equivalent to the initial bare bones behaviour.
The --runtime
option can also be used to specify an additional entry file relative to baseDir
that sets up custom runtime functionality, i.e. picks another memory allocator or garbage collector, provides additional global functions, you name it.