newsViua Virtual Machine - News: Release 0.8.3

 
 
Latest News
4096 commits posted by maelkum, Mon 05 Sep 2016 09:20:30 PM UTC
Release 0.8.4 posted by maelkum, Sun 28 Aug 2016 02:56:01 PM UTC
Release 0.8.3 posted by maelkum, Fri 05 Aug 2016 09:25:18 PM UTC

Release 0.8.3

Item posted by Marek Marecki <maelkum> on Fri 05 Aug 2016 09:25:18 PM UTC.

NEWS

With 141 commits since 0.8.2 this release is mostly a gradual
Release 0.8.3 is mostly a gradual improvement over 0.8.2, the 141 commits pushed
to the repository introduce some new but not revolutionary features, and
a bunch of minor fixes.

The big things release brings are vector packing, multiple FFI schedulers, and
possibility of embedding metadata in Viua VM bytecode files.

NEW COMMENT SYNTAX

The assembler supports Lua-style comments beginning with `--` and
running till the end of line.
Semicolon comments are not deprecated and can still be used.

EXTERNAL FUNCTION AND BLOCK SIGNATURES INCLUDED IN BYTECODE DISASSEMBLY

Before 0.8.3 the disassembler did not emit signatures for functions and
blocks linked from external to the analysed translation units.
This proved to be extremely inconvenient and was fixed in this release.
Viua VM bytecode files now be freely disassembled and reassembled without
worrying about missing signatures during reassembling.

EMBEDDING METADATA IN BYTECODE FILES

Starting with this release Viua VM bytecode format supports embedding metadata in
bytecode files by employing `.info:` assembler directive.
Example line:

    .info: license "GNU GPL v3"

Metadata is stored in a simple map where keys are restricted ASCII identifiers, and
values are strings.
String is currently the only embeddable value type.

COMPILE-TIME JUMP TARGET VERIFICATION

Jump targets are now verified at compile-time and assembler refuses to generate bytecode when
it detects jump errors in input source code.
Some absolute jumps cannot currently be verified by assembler and their verification is
perfoemed at runtime (e.g. absolute forward jumps).

COMPILE-TIME BLOCK CHECKING

Assembler checks if signatures for blocks used in a translation unit are present, and
refuses to compile code when input source code contains references to undefined blocks.

VECTOR PACKING

`vec` instruction can now be used to pack objects during vector creation.
Until this release vectors had to be created by spawning a vector object, and
then pushing objects one by one to the newly created container.

    vec 1
    vpush 1 (istore 2 40)
    vpush 1 (istore 2 41)
    vpush 1 (istore 2 42)

This proved to be cumbersome, so `vec` instruction was augmented to support packing.
Now, vec instruction receives three operands instead of one (the second and
the third operands are optional, and default to zero).

    istore 2 40
    istore 3 41
    istore 4 42
    vec 1 2 3

Second operand to the vec instruction is the index of the first register to be packed,
the third is the number of registers to be packed.
Above code creates a vector in register 1, and packs three objects starting from register 2.
Packed objects are moved inside the vector, leaving input registers empty.

By placing objects into registers carefully vector packing can be used to speed up
multiple-value returns from functions.

REMOVE RACE CONDITION WHEN REGISTERING EXCEPTIONS THROWN BY FFI CALLS

This release removes a race condition from the code that could cause the machine to lose
exceptions that were thrown by FFI calls.

The race condition was triggering a bug when an exception was registered in a process by the
FFI scheduler while VP scheduler was inspecting the process's state after executing it.
If the exception was registered between checks for terminated-status, and stopped-status the
exception has been quietly dropped and the process removed from the pool;
the precise order of events that triggered the bug was:

- exception has been thrown in FFI call, but the FFI scheduler did not yet register it in the
  process that requested the call
- VP scheduler did not mark the process as terminated (and so the exception handling routines
  have not been invoked)
- FFI scheduler registered an exception (which pushed the process into a terminated-stopped
  state)
- VP scheduler checked if the process stopped and removed it from the list of running
  processes

MULTIPLE FFI SCHEDULERS

As of 0.8.3 Viua VM is now able to spawn and utilise multiple FFI schedulers (their number
configurable at compile time, by default the VM spawns two).
This means that several FFI calls can be serviced in parallel, so the machine blocks less and
is able to execute FFI-intensive programs faster.

By default Viua spawns three C++ threads now, which causes overscheduling on systems with single
or dual-core CPUs.
VM configuration can be adjusted if this is undesirable.

 

Back to the top

Powered by Savane 3.13-f8d8.
Corresponding source code