Get rid of redundant type member from V4 instructions
authorKent Hansen <kent.hansen@nokia.com>
Thu, 22 Sep 2011 11:40:48 +0000 (13:40 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 23 Sep 2011 09:27:31 +0000 (11:27 +0200)
commit2403b2f5611d6faa2836d0c37327a507612c1620
treef0a40277eb2614c00a4ef492abf397c76884d5de
parent4938e1aef35045554074a4340aed25f9796f65ea
Get rid of redundant type member from V4 instructions

When interpretation is threaded, the type member is
redundant, since we can obtain the type from the
instruction address.

Getting rid of the type member can save at least one
byte per instruction (possibly more because of
alignment). On ia32, the Noop and Block instructions
become 4 bytes smaller.

The compiler has been refactored to leave it up to
the Bytecode class to decide whether the instruction
address or type (enum) should be stored.

To achieve this, the "low-level" Instr union was
renamed to V4Instr, and the new Instr struct
used by the compiler provides typedefs for
instantiating the data used by each particular
instruction. Lastly, the gen() function (instruction
emitter) was made template-based to provide the
instruction type.

The instructions Bool, Int, Real, String were
renamed to Load{Bool,Int,Real,String} to make the
new code more readable.

This approach follows a similar refactoring in the
QML-VME interpreter.

Change-Id: I9bf16b099a85afdfb719a25fb18047408882d61e
Reviewed-on: http://codereview.qt-project.org/5393
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
src/declarative/qml/v4/qdeclarativev4bindings.cpp
src/declarative/qml/v4/qdeclarativev4compiler.cpp
src/declarative/qml/v4/qdeclarativev4compiler_p_p.h
src/declarative/qml/v4/qdeclarativev4instruction.cpp
src/declarative/qml/v4/qdeclarativev4instruction_p.h