2013-06-24 10:07:48 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-06-24 10:07:48 +00:00
|
|
|
**
|
2013-06-24 11:50:51 +00:00
|
|
|
** This file is part of the QtQml module of the Qt Toolkit.
|
2013-06-24 10:07:48 +00:00
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
2013-06-24 10:07:48 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 11:55:39 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-19 09:38:36 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-06-24 10:07:48 +00:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2016-01-19 09:38:36 +00:00
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 3 requirements
|
|
|
|
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
2013-06-24 10:07:48 +00:00
|
|
|
**
|
2016-01-19 09:38:36 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 2.0 or (at your option) the GNU General
|
|
|
|
** Public license version 3 or any later version approved by the KDE Free
|
|
|
|
** Qt Foundation. The licenses are as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
|
|
|
** https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-06-24 10:07:48 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-12-16 12:44:14 +00:00
|
|
|
#include <QtCore/QDebug>
|
|
|
|
#include <QtCore/QBuffer>
|
2013-03-05 11:49:35 +00:00
|
|
|
#include "qv4jsir_p.h"
|
2012-11-19 13:59:53 +00:00
|
|
|
#include "qv4isel_p.h"
|
2012-12-11 09:03:40 +00:00
|
|
|
#include "qv4isel_util_p.h"
|
2015-02-14 21:46:41 +00:00
|
|
|
#include <private/qv4value_p.h>
|
2014-03-12 15:55:06 +00:00
|
|
|
#ifndef V4_BOOTSTRAP
|
2013-10-24 12:51:02 +00:00
|
|
|
#include <private/qqmlpropertycache_p.h>
|
2014-03-12 15:55:06 +00:00
|
|
|
#endif
|
2012-12-11 09:03:40 +00:00
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
using namespace QV4;
|
|
|
|
using namespace QV4::IR;
|
2012-11-19 13:59:53 +00:00
|
|
|
|
2013-09-01 11:11:00 +00:00
|
|
|
EvalInstructionSelection::EvalInstructionSelection(QV4::ExecutableAllocator *execAllocator, Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator)
|
|
|
|
: useFastLookups(true)
|
2014-08-22 10:11:40 +00:00
|
|
|
, useTypeInference(true)
|
2013-08-17 18:48:56 +00:00
|
|
|
, executableAllocator(execAllocator)
|
2013-09-01 11:11:00 +00:00
|
|
|
, irModule(module)
|
2012-12-11 09:03:40 +00:00
|
|
|
{
|
2013-09-01 11:11:00 +00:00
|
|
|
if (!jsGenerator) {
|
|
|
|
jsGenerator = new QV4::Compiler::JSUnitGenerator(module);
|
|
|
|
ownJSGenerator.reset(jsGenerator);
|
|
|
|
}
|
|
|
|
this->jsGenerator = jsGenerator;
|
2014-03-12 15:55:06 +00:00
|
|
|
#ifndef V4_BOOTSTRAP
|
2014-03-18 08:20:45 +00:00
|
|
|
Q_ASSERT(execAllocator);
|
2014-03-12 15:55:06 +00:00
|
|
|
#endif
|
2014-03-18 08:20:45 +00:00
|
|
|
Q_ASSERT(module);
|
2012-12-11 09:03:40 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 13:59:53 +00:00
|
|
|
EvalInstructionSelection::~EvalInstructionSelection()
|
|
|
|
{}
|
|
|
|
|
2012-11-20 12:41:49 +00:00
|
|
|
EvalISelFactory::~EvalISelFactory()
|
2012-11-19 13:59:53 +00:00
|
|
|
{}
|
2012-12-11 09:03:40 +00:00
|
|
|
|
2014-10-04 15:18:15 +00:00
|
|
|
QQmlRefPointer<CompiledData::CompilationUnit> EvalInstructionSelection::compile(bool generateUnitData)
|
2012-12-11 09:03:40 +00:00
|
|
|
{
|
2013-09-11 09:26:32 +00:00
|
|
|
for (int i = 0; i < irModule->functions.size(); ++i)
|
|
|
|
run(i);
|
2012-12-13 11:09:04 +00:00
|
|
|
|
2014-10-04 15:18:15 +00:00
|
|
|
QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = backendCompileStep();
|
2014-03-04 15:15:26 +00:00
|
|
|
if (generateUnitData)
|
2013-08-06 14:41:28 +00:00
|
|
|
unit->data = jsGenerator->generateUnit();
|
|
|
|
return unit;
|
2012-12-13 11:09:04 +00:00
|
|
|
}
|
2013-01-13 21:17:26 +00:00
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
void IRDecoder::visitMove(IR::Move *s)
|
2013-01-13 21:17:26 +00:00
|
|
|
{
|
2014-02-14 12:58:40 +00:00
|
|
|
if (IR::Name *n = s->target->asName()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
if (s->source->asTemp() || s->source->asConst() || s->source->asArgLocal()) {
|
2013-09-26 12:49:44 +00:00
|
|
|
setActivationProperty(s->source, *n->id);
|
|
|
|
return;
|
|
|
|
}
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
} else if (s->target->asTemp() || s->target->asArgLocal()) {
|
2014-02-14 12:58:40 +00:00
|
|
|
if (IR::Name *n = s->source->asName()) {
|
2016-01-18 15:01:29 +00:00
|
|
|
if (n->id && *n->id == QLatin1String("this")) // TODO: `this' should be a builtin.
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
loadThisObject(s->target);
|
2015-06-18 11:12:31 +00:00
|
|
|
else if (n->builtin == IR::Name::builtin_qml_context)
|
|
|
|
loadQmlContext(s->target);
|
2014-02-14 12:58:40 +00:00
|
|
|
else if (n->builtin == IR::Name::builtin_qml_imported_scripts_object)
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
loadQmlImportedScripts(s->target);
|
2013-11-02 21:46:25 +00:00
|
|
|
else if (n->qmlSingleton)
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
loadQmlSingleton(*n->id, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
else
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
getActivationProperty(n, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Const *c = s->source->asConst()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
loadConst(c, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
} else if (s->source->asTemp() || s->source->asArgLocal()) {
|
2013-09-26 12:49:44 +00:00
|
|
|
if (s->swap)
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
swapValues(s->source, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
else
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
copyValue(s->source, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::String *str = s->source->asString()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
loadString(*str->value, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::RegExp *re = s->source->asRegExp()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
loadRegexp(re, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Closure *clos = s->source->asClosure()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
initClosure(clos, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::New *ctor = s->source->asNew()) {
|
2013-09-26 12:49:44 +00:00
|
|
|
if (Name *func = ctor->base->asName()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
constructActivationProperty(func, ctor->args, s->target);
|
2013-01-13 21:17:26 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Member *member = ctor->base->asMember()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
constructProperty(member->base, *member->name, ctor->args, s->target);
|
2013-05-02 13:40:35 +00:00
|
|
|
return;
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
} else if (ctor->base->asTemp() || ctor->base->asArgLocal()) {
|
|
|
|
constructValue(ctor->base, ctor->args, s->target);
|
2013-06-10 14:32:48 +00:00
|
|
|
return;
|
2013-01-13 21:17:26 +00:00
|
|
|
}
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Member *m = s->source->asMember()) {
|
2013-11-02 17:48:18 +00:00
|
|
|
if (m->property) {
|
2014-03-12 15:55:06 +00:00
|
|
|
#ifdef V4_BOOTSTRAP
|
|
|
|
Q_UNIMPLEMENTED();
|
|
|
|
#else
|
2013-11-02 19:35:33 +00:00
|
|
|
bool captureRequired = true;
|
2013-12-05 13:53:58 +00:00
|
|
|
|
2015-06-22 14:33:40 +00:00
|
|
|
Q_ASSERT(m->kind != IR::Member::MemberOfEnum && m->kind != IR::Member::MemberOfIdObjectsArray);
|
|
|
|
const int attachedPropertiesId = m->attachedPropertiesId;
|
2014-07-23 17:43:38 +00:00
|
|
|
const bool isSingletonProperty = m->kind == IR::Member::MemberOfSingletonObject;
|
2013-12-05 13:53:58 +00:00
|
|
|
|
|
|
|
if (_function && attachedPropertiesId == 0 && !m->property->isConstant()) {
|
2014-02-14 12:58:40 +00:00
|
|
|
if (m->kind == IR::Member::MemberOfQmlContextObject) {
|
2013-12-05 13:53:58 +00:00
|
|
|
_function->contextObjectPropertyDependencies.insert(m->property->coreIndex, m->property->notifyIndex);
|
2013-12-04 15:30:54 +00:00
|
|
|
captureRequired = false;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (m->kind == IR::Member::MemberOfQmlScopeObject) {
|
2013-12-05 13:53:58 +00:00
|
|
|
_function->scopeObjectPropertyDependencies.insert(m->property->coreIndex, m->property->notifyIndex);
|
2013-12-04 15:30:54 +00:00
|
|
|
captureRequired = false;
|
|
|
|
}
|
2013-11-02 19:35:33 +00:00
|
|
|
}
|
2015-06-22 05:46:32 +00:00
|
|
|
if (m->kind == IR::Member::MemberOfQmlScopeObject || m->kind == IR::Member::MemberOfQmlContextObject) {
|
2016-04-12 12:52:23 +00:00
|
|
|
getQmlContextProperty(m->base, (IR::Member::MemberKind)m->kind, m->property,
|
|
|
|
m->property->coreIndex, s->target);
|
2015-06-19 12:18:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-04-12 12:52:23 +00:00
|
|
|
getQObjectProperty(m->base, m->property, captureRequired, isSingletonProperty, attachedPropertiesId, s->target);
|
2014-03-12 15:55:06 +00:00
|
|
|
#endif // V4_BOOTSTRAP
|
2013-10-24 12:51:02 +00:00
|
|
|
return;
|
2015-06-22 14:33:40 +00:00
|
|
|
} else if (m->kind == IR::Member::MemberOfIdObjectsArray) {
|
2016-04-12 12:52:23 +00:00
|
|
|
getQmlContextProperty(m->base, (IR::Member::MemberKind)m->kind, nullptr, m->idIndex, s->target);
|
2015-06-22 14:33:40 +00:00
|
|
|
return;
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
} else if (m->base->asTemp() || m->base->asConst() || m->base->asArgLocal()) {
|
|
|
|
getProperty(m->base, *m->name, s->target);
|
2013-01-13 21:17:26 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Subscript *ss = s->source->asSubscript()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
getElement(ss->base, ss->index, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Unop *u = s->source->asUnop()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
unop(u->op, u->expr, s->target);
|
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Binop *b = s->source->asBinop()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
binop(b->op, b->left, b->right, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Call *c = s->source->asCall()) {
|
2013-09-26 12:49:44 +00:00
|
|
|
if (c->base->asName()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
callBuiltin(c, s->target);
|
2013-01-13 21:17:26 +00:00
|
|
|
return;
|
2013-09-26 12:49:44 +00:00
|
|
|
} else if (Member *member = c->base->asMember()) {
|
2015-06-19 12:18:13 +00:00
|
|
|
#ifndef V4_BOOTSTRAP
|
2015-06-22 14:33:40 +00:00
|
|
|
Q_ASSERT(member->kind != IR::Member::MemberOfIdObjectsArray);
|
2015-06-22 05:46:32 +00:00
|
|
|
if (member->kind == IR::Member::MemberOfQmlScopeObject || member->kind == IR::Member::MemberOfQmlContextObject) {
|
2015-06-19 12:18:13 +00:00
|
|
|
callQmlContextProperty(member->base, (IR::Member::MemberKind)member->kind, member->property->coreIndex, c->args, s->target);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
callProperty(member->base, *member->name, c->args, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
|
|
|
} else if (Subscript *ss = c->base->asSubscript()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
callSubscript(ss->base, ss->index, c->args, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
2015-01-13 15:59:22 +00:00
|
|
|
} else if (c->base->asTemp() || c->base->asArgLocal() || c->base->asConst()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
callValue(c->base, c->args, s->target);
|
2013-01-13 21:17:26 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Convert *c = s->source->asConvert()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
Q_ASSERT(c->expr->asTemp() || c->expr->asArgLocal());
|
|
|
|
convertType(c->expr, s->target);
|
2013-09-26 12:49:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Member *m = s->target->asMember()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
if (m->base->asTemp() || m->base->asConst() || m->base->asArgLocal()) {
|
|
|
|
if (s->source->asTemp() || s->source->asConst() || s->source->asArgLocal()) {
|
2014-02-14 12:58:40 +00:00
|
|
|
Q_ASSERT(m->kind != IR::Member::MemberOfEnum);
|
2015-06-22 14:33:40 +00:00
|
|
|
Q_ASSERT(m->kind != IR::Member::MemberOfIdObjectsArray);
|
|
|
|
const int attachedPropertiesId = m->attachedPropertiesId;
|
2013-12-05 13:53:58 +00:00
|
|
|
if (m->property && attachedPropertiesId == 0) {
|
2014-03-12 15:55:06 +00:00
|
|
|
#ifdef V4_BOOTSTRAP
|
|
|
|
Q_UNIMPLEMENTED();
|
|
|
|
#else
|
2015-06-22 05:46:32 +00:00
|
|
|
if (m->kind == IR::Member::MemberOfQmlScopeObject || m->kind == IR::Member::MemberOfQmlContextObject) {
|
2015-06-19 12:18:13 +00:00
|
|
|
setQmlContextProperty(s->source, m->base, (IR::Member::MemberKind)m->kind, m->property->coreIndex);
|
|
|
|
return;
|
|
|
|
}
|
2013-10-28 14:18:31 +00:00
|
|
|
setQObjectProperty(s->source, m->base, m->property->coreIndex);
|
2014-03-12 15:55:06 +00:00
|
|
|
#endif
|
2013-10-28 14:18:31 +00:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
setProperty(s->source, m->base, *m->name);
|
|
|
|
return;
|
|
|
|
}
|
2013-01-13 21:17:26 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Subscript *ss = s->target->asSubscript()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
if (s->source->asTemp() || s->source->asConst() || s->source->asArgLocal()) {
|
2013-09-26 12:49:44 +00:00
|
|
|
setElement(s->source, ss->base, ss->index);
|
|
|
|
return;
|
|
|
|
}
|
2013-01-13 21:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// For anything else...:
|
|
|
|
Q_UNIMPLEMENTED();
|
2014-12-16 12:44:14 +00:00
|
|
|
QBuffer buf;
|
|
|
|
buf.open(QIODevice::WriteOnly);
|
|
|
|
QTextStream qout(&buf);
|
2014-04-16 11:22:28 +00:00
|
|
|
IRPrinter(&qout).print(s);
|
2013-01-13 21:17:26 +00:00
|
|
|
qout << endl;
|
2014-12-16 12:44:14 +00:00
|
|
|
qDebug("%s", buf.data().constData());
|
2014-03-18 08:20:45 +00:00
|
|
|
Q_ASSERT(!"TODO");
|
2013-01-13 21:17:26 +00:00
|
|
|
}
|
|
|
|
|
2013-06-12 11:30:28 +00:00
|
|
|
IRDecoder::~IRDecoder()
|
2013-01-13 21:17:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
void IRDecoder::visitExp(IR::Exp *s)
|
2013-01-13 21:17:26 +00:00
|
|
|
{
|
2014-02-14 12:58:40 +00:00
|
|
|
if (IR::Call *c = s->expr->asCall()) {
|
2013-01-13 21:17:26 +00:00
|
|
|
// These are calls where the result is ignored.
|
|
|
|
if (c->base->asName()) {
|
2013-01-16 14:49:42 +00:00
|
|
|
callBuiltin(c, 0);
|
2014-05-09 11:10:16 +00:00
|
|
|
} else if (c->base->asTemp() || c->base->asArgLocal() || c->base->asConst()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
callValue(c->base, c->args, 0);
|
2013-01-23 09:22:52 +00:00
|
|
|
} else if (Member *member = c->base->asMember()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
Q_ASSERT(member->base->asTemp() || member->base->asArgLocal());
|
2015-06-19 12:18:13 +00:00
|
|
|
#ifndef V4_BOOTSTRAP
|
2015-06-22 14:33:40 +00:00
|
|
|
Q_ASSERT(member->kind != IR::Member::MemberOfIdObjectsArray);
|
2015-06-22 05:46:32 +00:00
|
|
|
if (member->kind == IR::Member::MemberOfQmlScopeObject || member->kind == IR::Member::MemberOfQmlContextObject) {
|
2015-06-19 12:18:13 +00:00
|
|
|
callQmlContextProperty(member->base, (IR::Member::MemberKind)member->kind, member->property->coreIndex, c->args, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
callProperty(member->base, *member->name, c->args, 0);
|
2013-01-27 21:39:01 +00:00
|
|
|
} else if (Subscript *s = c->base->asSubscript()) {
|
2013-12-02 15:33:58 +00:00
|
|
|
callSubscript(s->base, s->index, c->args, 0);
|
2013-01-13 21:17:26 +00:00
|
|
|
} else {
|
2014-05-09 11:10:16 +00:00
|
|
|
Q_UNREACHABLE();
|
2013-01-13 21:17:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2014-05-09 11:10:16 +00:00
|
|
|
Q_UNREACHABLE();
|
2013-01-13 21:17:26 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-16 14:49:42 +00:00
|
|
|
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
void IRDecoder::callBuiltin(IR::Call *call, Expr *result)
|
2013-01-16 14:49:42 +00:00
|
|
|
{
|
2014-02-14 12:58:40 +00:00
|
|
|
IR::Name *baseName = call->base->asName();
|
2014-03-18 08:20:45 +00:00
|
|
|
Q_ASSERT(baseName != 0);
|
2013-01-16 14:49:42 +00:00
|
|
|
|
|
|
|
switch (baseName->builtin) {
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_invalid:
|
2013-01-16 15:29:28 +00:00
|
|
|
callBuiltinInvalid(baseName, call->args, result);
|
2013-01-16 14:49:42 +00:00
|
|
|
return;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_typeof: {
|
2015-10-27 11:21:00 +00:00
|
|
|
if (IR::Member *member = call->args->expr->asMember()) {
|
|
|
|
#ifndef V4_BOOTSTRAP
|
|
|
|
Q_ASSERT(member->kind != IR::Member::MemberOfIdObjectsArray);
|
|
|
|
if (member->kind == IR::Member::MemberOfQmlScopeObject || member->kind == IR::Member::MemberOfQmlContextObject) {
|
|
|
|
callBuiltinTypeofQmlContextProperty(member->base,
|
|
|
|
IR::Member::MemberKind(member->kind),
|
|
|
|
member->property->coreIndex, result);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
callBuiltinTypeofMember(member->base, *member->name, result);
|
2013-01-16 14:49:42 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Subscript *ss = call->args->expr->asSubscript()) {
|
2013-08-23 12:40:33 +00:00
|
|
|
callBuiltinTypeofSubscript(ss->base, ss->index, result);
|
2013-01-16 14:49:42 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Name *n = call->args->expr->asName()) {
|
2013-01-16 14:49:42 +00:00
|
|
|
callBuiltinTypeofName(*n->id, result);
|
|
|
|
return;
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
} else if (call->args->expr->asTemp() ||
|
|
|
|
call->args->expr->asConst() ||
|
|
|
|
call->args->expr->asArgLocal()) {
|
2013-08-23 12:40:33 +00:00
|
|
|
callBuiltinTypeofValue(call->args->expr, result);
|
2013-01-16 14:49:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_delete: {
|
|
|
|
if (IR::Member *m = call->args->expr->asMember()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
callBuiltinDeleteMember(m->base, *m->name, result);
|
2013-01-16 14:49:42 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Subscript *ss = call->args->expr->asSubscript()) {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
callBuiltinDeleteSubscript(ss->base, ss->index, result);
|
2013-01-16 14:49:42 +00:00
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
} else if (IR::Name *n = call->args->expr->asName()) {
|
2013-01-16 14:49:42 +00:00
|
|
|
callBuiltinDeleteName(*n->id, result);
|
|
|
|
return;
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
} else if (call->args->expr->asTemp() ||
|
|
|
|
call->args->expr->asArgLocal()) {
|
2013-01-16 14:49:42 +00:00
|
|
|
// TODO: should throw in strict mode
|
|
|
|
callBuiltinDeleteValue(result);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_throw: {
|
|
|
|
IR::Expr *arg = call->args->expr;
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
Q_ASSERT(arg->asTemp() || arg->asConst() || arg->asArgLocal());
|
2013-05-27 12:19:35 +00:00
|
|
|
callBuiltinThrow(arg);
|
2013-01-16 14:49:42 +00:00
|
|
|
} return;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_rethrow: {
|
2013-10-18 13:42:17 +00:00
|
|
|
callBuiltinReThrow();
|
|
|
|
} return;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_unwind_exception: {
|
2013-10-21 15:07:45 +00:00
|
|
|
callBuiltinUnwindException(result);
|
|
|
|
} return;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_push_catch_scope: {
|
|
|
|
IR::String *s = call->args->expr->asString();
|
2013-10-18 13:42:17 +00:00
|
|
|
Q_ASSERT(s);
|
|
|
|
callBuiltinPushCatchScope(*s->value);
|
|
|
|
} return;
|
2013-01-16 14:49:42 +00:00
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_foreach_iterator_object: {
|
2014-03-18 08:12:42 +00:00
|
|
|
IR::Expr *arg = call->args->expr;
|
2014-03-18 08:20:45 +00:00
|
|
|
Q_ASSERT(arg != 0);
|
2013-01-16 14:49:42 +00:00
|
|
|
callBuiltinForeachIteratorObject(arg, result);
|
|
|
|
} return;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_foreach_next_property_name: {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
IR::Expr *arg = call->args->expr;
|
2014-03-18 08:20:45 +00:00
|
|
|
Q_ASSERT(arg != 0);
|
2013-01-16 14:49:42 +00:00
|
|
|
callBuiltinForeachNextPropertyname(arg, result);
|
|
|
|
} return;
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_push_with_scope: {
|
V4: Split arguments/locals from temps.
There are a couple of reasons to split the temporaries off from the
arguments and locals:
Temporaries are invisible, and changes to them cannot be observed.
On the other hand, arguments and locals are visible, and writes to them
can be seen from other places (nested functions), or by using the
arguments array. So, in practice these correspond to memory locations.
(One could argue that if neither nested functions, nor eval(), nor
arguments[] is used, the loads/stores are invisible too. But that's an
optimization, and changing locals/arguments to temporaries can be done
in a separate pass.)
Because of the "volatile" nature of arguments and locals, their usage
cannot be optimized. All optimizations (SSA construction, register
allocation, copy elimination, etc.) work on temporaries. Being able to
easily ignore all non-temporaries has the benefit that optimizations can
be faster.
Previously, Temps were not uniquely numbered: argument 1, local 1, and
temporary 1 all had the same number and were distinguishable by their
type. So, for any mapping from Temp to something else, a QHash was used.
Now that Temps only hold proper temporaries, the indexes do uniquely
identify them. Add to that the fact that after transforming to SSA form
all temporaries are renumbered starting from 0 and without any holes in
the numbering, many of those datastructures can be changed to simple
vectors. That change gives a noticeable performance improvement.
One implication of this change is that a number of functions that took
a Temp as their argument, now need to take Temp-or-ArgLocal, so Expr.
However, it turns out that there are very few places where that applies,
as many of those places also need to take constants or names. However,
explicitly separating memory loads/stores for arguments/locals from
temporaries adds the benefit that it's now easier to do a peep-hole
optimizer for those load/store operations in the future: when a load is
directly preceded by a store, it can be eliminated if the value is
still available in a temporary.
Change-Id: I4114006b076795d9ea9fe3649cdb3b9d7b7508f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-30 13:38:01 +00:00
|
|
|
if (call->args->expr->asTemp() || call->args->expr->asArgLocal())
|
|
|
|
callBuiltinPushWithScope(call->args->expr);
|
|
|
|
else
|
|
|
|
Q_UNIMPLEMENTED();
|
2013-01-16 14:49:42 +00:00
|
|
|
} return;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_pop_scope:
|
2013-01-24 11:13:47 +00:00
|
|
|
callBuiltinPopScope();
|
2013-01-16 14:49:42 +00:00
|
|
|
return;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_declare_vars: {
|
2013-01-16 14:49:42 +00:00
|
|
|
if (!call->args)
|
|
|
|
return;
|
2014-02-14 12:58:40 +00:00
|
|
|
IR::Const *deletable = call->args->expr->asConst();
|
2014-03-18 08:20:45 +00:00
|
|
|
Q_ASSERT(deletable->type == IR::BoolType);
|
2014-02-14 12:58:40 +00:00
|
|
|
for (IR::ExprList *it = call->args->next; it; it = it->next) {
|
|
|
|
IR::Name *arg = it->expr->asName();
|
2014-03-18 08:20:45 +00:00
|
|
|
Q_ASSERT(arg != 0);
|
2013-01-16 14:49:42 +00:00
|
|
|
callBuiltinDeclareVar(deletable->value != 0, *arg->id);
|
|
|
|
}
|
|
|
|
} return;
|
|
|
|
|
2014-02-15 01:16:43 +00:00
|
|
|
case IR::Name::builtin_define_array:
|
|
|
|
callBuiltinDefineArray(result, call->args);
|
|
|
|
return;
|
2013-01-16 14:49:42 +00:00
|
|
|
|
2014-02-15 01:16:43 +00:00
|
|
|
case IR::Name::builtin_define_object_literal: {
|
2014-02-14 12:58:40 +00:00
|
|
|
IR::ExprList *args = call->args;
|
2014-02-15 01:16:43 +00:00
|
|
|
const int keyValuePairsCount = args->expr->asConst()->value;
|
2013-01-16 14:49:42 +00:00
|
|
|
args = args->next;
|
|
|
|
|
2014-02-15 01:16:43 +00:00
|
|
|
IR::ExprList *keyValuePairs = args;
|
|
|
|
for (int i = 0; i < keyValuePairsCount; ++i) {
|
|
|
|
args = args->next; // name
|
|
|
|
bool isData = args->expr->asConst()->value;
|
|
|
|
args = args->next; // isData flag
|
|
|
|
args = args->next; // value or getter
|
|
|
|
if (!isData)
|
|
|
|
args = args->next; // setter
|
|
|
|
}
|
2013-01-16 14:49:42 +00:00
|
|
|
|
2014-02-15 01:16:43 +00:00
|
|
|
IR::ExprList *arrayEntries = args;
|
2014-02-15 03:39:33 +00:00
|
|
|
bool needSparseArray = false;
|
|
|
|
for (IR::ExprList *it = arrayEntries; it; it = it->next) {
|
|
|
|
uint index = it->expr->asConst()->value;
|
|
|
|
if (index > 16) {
|
|
|
|
needSparseArray = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
it = it->next;
|
|
|
|
bool isData = it->expr->asConst()->value;
|
|
|
|
it = it->next;
|
|
|
|
if (!isData)
|
|
|
|
it = it->next;
|
|
|
|
}
|
2013-01-24 11:53:47 +00:00
|
|
|
|
2014-02-15 03:39:33 +00:00
|
|
|
callBuiltinDefineObjectLiteral(result, keyValuePairsCount, keyValuePairs, arrayEntries, needSparseArray);
|
2014-02-15 01:16:43 +00:00
|
|
|
} return;
|
2013-04-23 05:31:02 +00:00
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_setup_argument_object:
|
2013-08-16 10:54:30 +00:00
|
|
|
callBuiltinSetupArgumentObject(result);
|
|
|
|
return;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
case IR::Name::builtin_convert_this_to_object:
|
2013-11-02 20:10:13 +00:00
|
|
|
callBuiltinConvertThisToObject();
|
|
|
|
return;
|
|
|
|
|
2013-01-16 14:49:42 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_UNIMPLEMENTED();
|
2014-12-16 12:44:14 +00:00
|
|
|
QBuffer buf;
|
|
|
|
buf.open(QIODevice::WriteOnly);
|
|
|
|
QTextStream qout(&buf);
|
2014-04-16 11:22:28 +00:00
|
|
|
IRPrinter(&qout).print(call); qout << endl;
|
2014-12-16 12:44:14 +00:00
|
|
|
qDebug("%s", buf.data().constData());
|
2013-01-16 14:49:42 +00:00
|
|
|
Q_UNREACHABLE();
|
|
|
|
}
|