[Development] V4 porting

Hausmann Simon Simon.Hausmann at theqtcompany.com
Thu Dec 24 15:01:14 CET 2015


The method parse implies a transformation from source code to a form that we can interpret, so technically the name of the method isn't quite accurate. Nevertheless it does what you can see in the implementation, which includes parsing into a syntax tree structure, transformation into an intermediate representation (codegen), optimizations in that IR and finally register allocation and native code generation or byte code generation.

I'm afraid that I don't have a road map for your porting efforts.


From: Dmitriy -
Sent: Thursday, December 24, 2015 12:42
To: Hausmann Simon
Cc: development at qt-project.org
Subject: Re: [Development] V4 porting

I want to port JIT. Where should I start?
You have any roadmap for this?

Now I'm using qmljs tool for testing purpose.
I has seen in qt-5.5.1/qtdeclarative/src/qml/jsruntime/qv4script.cpp:


RuntimeCodegen cg(v4, strictMode);

cg.generateFromProgram(sourceFile, sourceCode, program, &module, QQmlJS::Codegen::EvalCode, inheritedLocals);

if (v4->hasException) return;

QV4::Compiler::JSUnitGenerator jsGenerator(&module);

QScopedPointer<EvalInstructionSelection> isel(...);


QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit = isel->compile();

vmFunction = compilationUnit->linkToEngine(v4);


Why do you compile script while parse it? Do you use AOT compiling?

On Thu, Dec 24, 2015 at 5:18 PM, Hausmann Simon <Simon.Hausmann at theqtcompany.com<mailto:Simon.Hausmann at theqtcompany.com>> wrote:

Moth is the portable interpreter that will be used instead of the just-in-time compiler if your platform doesn't support it. It should be chosen automatically for you according to the #ifdefs in qv4global_p.h.

So if you have qtbase compiling, then qml should also work. If you want things to run faster, then you will have to port the JIT.


From: Dmitriy -
Sent: Thursday, December 24, 2015 10:47
To: development at qt-project.org<mailto:development at qt-project.org>
Subject: [Development] V4 porting

I want to port v4 engine to the new platform. The platform is Linux OS and new processor. The processor looks like intel itanium. It is VLIW and EPIC.
I have a c++/c compilers for the new architecture.

I want to design qt quic qml application for the new platform. As a can see in code, I need v4vm backend for this purpose.

I'm see this:

case use_moth: {
        QV4::EvalISelFactory* iSelFactory = 0;
        if (mode == use_moth) {
            iSelFactory = new QV4::Moth::ISelFactory;
#ifdef V4_ENABLE_JIT
        } else {
            iSelFactory = new QV4::JIT::ISelFactory;
#endif // V4_ENABLE_JIT

        QV4::ExecutionEngine vm(iSelFactory);

        QV4::Scope scope(&vm);
        QV4::ScopedContext ctx(scope, vm.rootContext());

As I understand v4vm has two backends - Moth and Masm.

What is Moth?

Dmitry Bezheckov.

Dmitry Bezheckov.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20151224/004c0da0/attachment.html>

More information about the Development mailing list