~ubuntu-branches/ubuntu/vivid/qtdeclarative-opensource-src-gles/vivid

« back to all changes in this revision

Viewing changes to .pc/QML-Compilation-unit-caching-and-JIT-changes.patch/src/qml/compiler/qv4isel_moth_p.h

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2015-02-26 09:12:59 UTC
  • Revision ID: package-import@ubuntu.com-20150226091259-krq068zh9bwi20or
Tags: 5.4.0-0ubuntu2
Sync package with qtdeclarative-opensource-src - 5.4.0-4ubuntu2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the QtQml module of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:LGPL21$
 
9
** Commercial License Usage
 
10
** Licensees holding valid commercial Qt licenses may use this file in
 
11
** accordance with the commercial license agreement provided with the
 
12
** Software or, alternatively, in accordance with the terms contained in
 
13
** a written agreement between you and Digia. For licensing terms and
 
14
** conditions see http://qt.digia.com/licensing. For further information
 
15
** use the contact form at http://qt.digia.com/contact-us.
 
16
**
 
17
** GNU Lesser General Public License Usage
 
18
** Alternatively, this file may be used under the terms of the GNU Lesser
 
19
** General Public License version 2.1 or version 3 as published by the Free
 
20
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
 
21
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
 
22
** following information to ensure the GNU Lesser General Public License
 
23
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
 
24
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
25
**
 
26
** In addition, as a special exception, Digia gives you certain additional
 
27
** rights. These rights are described in the Digia Qt LGPL Exception
 
28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
29
**
 
30
** $QT_END_LICENSE$
 
31
**
 
32
****************************************************************************/
 
33
 
 
34
#ifndef QV4ISEL_MOTH_P_H
 
35
#define QV4ISEL_MOTH_P_H
 
36
 
 
37
#include <private/qv4global_p.h>
 
38
#include <private/qv4isel_p.h>
 
39
#include <private/qv4isel_util_p.h>
 
40
#include <private/qv4jsir_p.h>
 
41
#include <private/qv4value_p.h>
 
42
#include "qv4instr_moth_p.h"
 
43
 
 
44
QT_BEGIN_NAMESPACE
 
45
 
 
46
namespace QV4 {
 
47
namespace Moth {
 
48
 
 
49
struct CompilationUnit : public QV4::CompiledData::CompilationUnit
 
50
{
 
51
    virtual ~CompilationUnit();
 
52
    virtual void linkBackendToEngine(QV4::ExecutionEngine *engine);
 
53
 
 
54
    QVector<QByteArray> codeRefs;
 
55
 
 
56
};
 
57
 
 
58
class Q_QML_EXPORT InstructionSelection:
 
59
        public IR::IRDecoder,
 
60
        public EvalInstructionSelection
 
61
{
 
62
public:
 
63
    InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator);
 
64
    ~InstructionSelection();
 
65
 
 
66
    virtual void run(int functionIndex);
 
67
 
 
68
protected:
 
69
    virtual QQmlRefPointer<CompiledData::CompilationUnit> backendCompileStep();
 
70
 
 
71
    virtual void visitJump(IR::Jump *);
 
72
    virtual void visitCJump(IR::CJump *);
 
73
    virtual void visitRet(IR::Ret *);
 
74
 
 
75
    virtual void callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Expr *result);
 
76
    virtual void callBuiltinTypeofMember(IR::Expr *base, const QString &name, IR::Expr *result);
 
77
    virtual void callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result);
 
78
    virtual void callBuiltinTypeofName(const QString &name, IR::Expr *result);
 
79
    virtual void callBuiltinTypeofValue(IR::Expr *value, IR::Expr *result);
 
80
    virtual void callBuiltinDeleteMember(IR::Expr *base, const QString &name, IR::Expr *result);
 
81
    virtual void callBuiltinDeleteSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result);
 
82
    virtual void callBuiltinDeleteName(const QString &name, IR::Expr *result);
 
83
    virtual void callBuiltinDeleteValue(IR::Expr *result);
 
84
    virtual void callBuiltinThrow(IR::Expr *arg);
 
85
    virtual void callBuiltinReThrow();
 
86
    virtual void callBuiltinUnwindException(IR::Expr *);
 
87
    virtual void callBuiltinPushCatchScope(const QString &exceptionName);
 
88
    virtual void callBuiltinForeachIteratorObject(IR::Expr *arg, IR::Expr *result);
 
89
    virtual void callBuiltinForeachNextPropertyname(IR::Expr *arg, IR::Expr *result);
 
90
    virtual void callBuiltinPushWithScope(IR::Expr *arg);
 
91
    virtual void callBuiltinPopScope();
 
92
    virtual void callBuiltinDeclareVar(bool deletable, const QString &name);
 
93
    virtual void callBuiltinDefineArray(IR::Expr *result, IR::ExprList *args);
 
94
    virtual void callBuiltinDefineObjectLiteral(IR::Expr *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray);
 
95
    virtual void callBuiltinSetupArgumentObject(IR::Expr *result);
 
96
    virtual void callBuiltinConvertThisToObject();
 
97
    virtual void callValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result);
 
98
    virtual void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr *result);
 
99
    virtual void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args, IR::Expr *result);
 
100
    virtual void convertType(IR::Expr *source, IR::Expr *target);
 
101
    virtual void constructActivationProperty(IR::Name *func, IR::ExprList *args, IR::Expr *result);
 
102
    virtual void constructProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr *result);
 
103
    virtual void constructValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result);
 
104
    virtual void loadThisObject(IR::Expr *e);
 
105
    virtual void loadQmlIdArray(IR::Expr *e);
 
106
    virtual void loadQmlImportedScripts(IR::Expr *e);
 
107
    virtual void loadQmlContextObject(IR::Expr *e);
 
108
    virtual void loadQmlScopeObject(IR::Expr *e);
 
109
    virtual void loadQmlSingleton(const QString &name, IR::Expr *e);
 
110
    virtual void loadConst(IR::Const *sourceConst, IR::Expr *e);
 
111
    virtual void loadString(const QString &str, IR::Expr *target);
 
112
    virtual void loadRegexp(IR::RegExp *sourceRegexp, IR::Expr *target);
 
113
    virtual void getActivationProperty(const IR::Name *name, IR::Expr *target);
 
114
    virtual void setActivationProperty(IR::Expr *source, const QString &targetName);
 
115
    virtual void initClosure(IR::Closure *closure, IR::Expr *target);
 
116
    virtual void getProperty(IR::Expr *base, const QString &name, IR::Expr *target);
 
117
    virtual void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &targetName);
 
118
    virtual void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex);
 
119
    virtual void getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, bool isSingleton, int attachedPropertiesId, IR::Expr *target);
 
120
    virtual void getElement(IR::Expr *base, IR::Expr *index, IR::Expr *target);
 
121
    virtual void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex);
 
122
    virtual void copyValue(IR::Expr *source, IR::Expr *target);
 
123
    virtual void swapValues(IR::Expr *source, IR::Expr *target);
 
124
    virtual void unop(IR::AluOp oper, IR::Expr *source, IR::Expr *target);
 
125
    virtual void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Expr *target);
 
126
 
 
127
private:
 
128
    Param binopHelper(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Expr *target);
 
129
 
 
130
    struct Instruction {
 
131
#define MOTH_INSTR_DATA_TYPEDEF(I, FMT) typedef InstrData<Instr::I> I;
 
132
    FOR_EACH_MOTH_INSTR(MOTH_INSTR_DATA_TYPEDEF)
 
133
#undef MOTH_INSTR_DATA_TYPEDEF
 
134
    private:
 
135
        Instruction();
 
136
    };
 
137
 
 
138
    Param getParam(IR::Expr *e);
 
139
 
 
140
    Param getResultParam(IR::Expr *result)
 
141
    {
 
142
        if (result)
 
143
            return getParam(result);
 
144
        else
 
145
            return Param::createTemp(scratchTempIndex());
 
146
    }
 
147
 
 
148
    void simpleMove(IR::Move *);
 
149
    void prepareCallArgs(IR::ExprList *, quint32 &, quint32 * = 0);
 
150
 
 
151
    int scratchTempIndex() const { return _function->tempCount; }
 
152
    int callDataStart() const { return scratchTempIndex() + 1; }
 
153
    int outgoingArgumentTempStart() const { return callDataStart() + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value); }
 
154
    int frameSize() const { return outgoingArgumentTempStart() + _function->maxNumberOfArguments; }
 
155
 
 
156
    template <int Instr>
 
157
    inline ptrdiff_t addInstruction(const InstrData<Instr> &data);
 
158
    ptrdiff_t addInstructionHelper(Instr::Type type, Instr &instr);
 
159
    void patchJumpAddresses();
 
160
    QByteArray squeezeCode() const;
 
161
 
 
162
    QQmlEnginePrivate *qmlEngine;
 
163
 
 
164
    bool blockNeedsDebugInstruction;
 
165
    uint currentLine;
 
166
    IR::BasicBlock *_block;
 
167
    IR::BasicBlock *_nextBlock;
 
168
 
 
169
    QHash<IR::BasicBlock *, QVector<ptrdiff_t> > _patches;
 
170
    QHash<IR::BasicBlock *, ptrdiff_t> _addrs;
 
171
 
 
172
    uchar *_codeStart;
 
173
    uchar *_codeNext;
 
174
    uchar *_codeEnd;
 
175
 
 
176
    QSet<IR::Jump *> _removableJumps;
 
177
    IR::Stmt *_currentStatement;
 
178
 
 
179
    QScopedPointer<CompilationUnit> compilationUnit;
 
180
    QHash<IR::Function *, QByteArray> codeRefs;
 
181
};
 
182
 
 
183
class Q_QML_EXPORT ISelFactory: public EvalISelFactory
 
184
{
 
185
public:
 
186
    virtual ~ISelFactory() {}
 
187
    virtual EvalInstructionSelection *create(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator)
 
188
    { return new InstructionSelection(qmlEngine, execAllocator, module, jsGenerator); }
 
189
    virtual bool jitCompileRegexps() const
 
190
    { return false; }
 
191
};
 
192
 
 
193
template<int InstrT>
 
194
ptrdiff_t InstructionSelection::addInstruction(const InstrData<InstrT> &data)
 
195
{
 
196
    Instr genericInstr;
 
197
    InstrMeta<InstrT>::setDataNoCommon(genericInstr, data);
 
198
    return addInstructionHelper(static_cast<Instr::Type>(InstrT), genericInstr);
 
199
}
 
200
 
 
201
} // namespace Moth
 
202
} // namespace QV4
 
203
 
 
204
QT_END_NAMESPACE
 
205
 
 
206
#endif // QV4ISEL_MOTH_P_H