aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4instr_moth_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-10-29 10:28:04 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 14:06:14 +0100
commit7e69f4160ffeacb4fda1243c6f490e54ed02c655 (patch)
tree00597159341c8df402fa9c3f3cb08010313f5d12 /src/qml/compiler/qv4instr_moth_p.h
parent61be39a01b4d3348161472260efef14f8a6e7896 (diff)
Rework parameter handling for moth
Get rid of the parameter type, and only store a scope, that is an index into a SafeValue ** array. This significantly speeds up loading and saving of parameters. Change-Id: I185145f1afd0b8cea461c7ca732ada3ebe39c34c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4instr_moth_p.h')
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index f1108ff863..6eae11ae80 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -123,27 +123,26 @@ namespace QQmlJS {
namespace Moth {
struct Param {
- enum {
- ConstantType = 0,
- ArgumentType = 1,
- LocalType = 2,
- TempType = 3,
- ScopedLocalType = 4
- };
- unsigned type : 3;
- unsigned scope : 29;
+ // Params are looked up as follows:
+ // Constant: 0
+ // Temp: 1
+ // Argument: 2
+ // Local: 3
+ // Arg(outer): 4
+ // Local(outer): 5
+ // ...
+ unsigned scope;
unsigned index;
- bool isConstant() const { return type == ConstantType; }
- bool isArgument() const { return type == ArgumentType; }
- bool isLocal() const { return type == LocalType; }
- bool isTemp() const { return type == TempType; }
- bool isScopedLocal() const { return type == ScopedLocalType; }
+ bool isConstant() const { return !scope; }
+ bool isArgument() const { return scope >= 2 && !(scope &1); }
+ bool isLocal() const { return scope == 3; }
+ bool isTemp() const { return scope == 1; }
+ bool isScopedLocal() const { return scope >= 3 && (scope & 1); }
static Param createConstant(int index)
{
Param p;
- p.type = ConstantType;
p.scope = 0;
p.index = index;
return p;
@@ -152,8 +151,7 @@ struct Param {
static Param createArgument(unsigned idx, uint scope)
{
Param p;
- p.type = ArgumentType;
- p.scope = scope;
+ p.scope = 2 + 2*scope;
p.index = idx;
return p;
}
@@ -161,8 +159,7 @@ struct Param {
static Param createLocal(unsigned idx)
{
Param p;
- p.type = LocalType;
- p.scope = 0;
+ p.scope = 3;
p.index = idx;
return p;
}
@@ -170,8 +167,7 @@ struct Param {
static Param createTemp(unsigned idx)
{
Param p;
- p.type = TempType;
- p.scope = 0;
+ p.scope = 1;
p.index = idx;
return p;
}
@@ -179,14 +175,13 @@ struct Param {
static Param createScopedLocal(unsigned idx, uint scope)
{
Param p;
- p.type = ScopedLocalType;
- p.scope = scope;
+ p.scope = 3 + 2*scope;
p.index = idx;
return p;
}
inline bool operator==(const Param &other) const
- { return type == other.type && scope == other.scope && index == other.index; }
+ { return scope == other.scope && index == other.index; }
inline bool operator!=(const Param &other) const
{ return !(*this == other); }