Playing with QV4

Playing with QV4

QtDeclarative is where the fun is. Starting with Qt5.2 a JavaScript Engine written by Digia is used. Compared to JavaScriptCore and V8 this engine is very basic but tightly integrated with the QML and Quick code. Motivated by attending the Qt Developer Summit and my work on GNU Smalltalk I started to look at the VM.

There are some environment variables that help to see what the JavaScript VM is doing and also how it is doing things. The below table gives a quick overview of the available flags and what they do. Specially the usage of QV4_SHOW_IR and QV4_SHOW_ASM helps to understand what is going on.

NameFunction
QV4_NO_SSADo not convert the IR::Function to SSA representation. This disables optimizations as well.
QV4_NO_OPTDo not run the optimizer. This disables dead-code-elimination, constant propagation, copy propagation
QV4_SHOW_IRShow the Intermediate Representation at the various stages of the compilation/optimization.
QV4_SHOW_ASMShow the disassembled code. This requires QtDeclrative to be compiled with CONFIG+=disassembler and without PCH
QV4_NO_REGALLOCDo not use the linear register allocator
QV4_FORCE_INTERPRETERDo not use the JIT but force the interpreter
QV4_MM_AGGRESSIVE_GCRun the GC on every allocation
QV4_MM_STATSPrint the time it took to mark and sweep