2013-06-24 10:07:48 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
|
|
|
**
|
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
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
** 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
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
**
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3.0 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU General Public License version 3.0 requirements will be
|
|
|
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-06-11 16:58:52 +00:00
|
|
|
#include "qv4vme_moth_p.h"
|
|
|
|
#include "qv4instr_moth_p.h"
|
2014-01-24 14:07:34 +00:00
|
|
|
#include <private/qv4value_inl_p.h>
|
2013-04-15 09:50:16 +00:00
|
|
|
#include <private/qv4debugging_p.h>
|
2013-08-05 13:55:45 +00:00
|
|
|
#include <private/qv4math_p.h>
|
2013-09-05 12:49:55 +00:00
|
|
|
#include <private/qv4scopedvalue_p.h>
|
2013-10-10 09:51:42 +00:00
|
|
|
#include <private/qv4lookup_p.h>
|
2012-11-29 13:41:26 +00:00
|
|
|
#include <iostream>
|
2012-06-11 16:58:52 +00:00
|
|
|
|
2013-02-08 08:30:40 +00:00
|
|
|
#include "qv4alloca_p.h"
|
2012-12-19 10:21:06 +00:00
|
|
|
|
2012-10-23 14:06:52 +00:00
|
|
|
#ifdef DO_TRACE_INSTR
|
2012-10-24 11:45:43 +00:00
|
|
|
# define TRACE_INSTR(I) fprintf(stderr, "executing a %s\n", #I);
|
2012-12-04 09:31:31 +00:00
|
|
|
# define TRACE(n, str, ...) { char buf[4096]; snprintf(buf, 4096, str, __VA_ARGS__); fprintf(stderr, " %s : %s\n", #n, buf); }
|
2012-10-23 14:06:52 +00:00
|
|
|
#else
|
|
|
|
# define TRACE_INSTR(I)
|
|
|
|
# define TRACE(n, str, ...)
|
|
|
|
#endif // DO_TRACE_INSTR
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
using namespace QV4;
|
|
|
|
using namespace QV4::Moth;
|
2012-11-06 11:31:02 +00:00
|
|
|
|
2012-06-11 16:58:52 +00:00
|
|
|
#define MOTH_BEGIN_INSTR_COMMON(I) { \
|
|
|
|
const InstrMeta<(int)Instr::I>::DataType &instr = InstrMeta<(int)Instr::I>::data(*genericInstr); \
|
|
|
|
code += InstrMeta<(int)Instr::I>::Size; \
|
2012-10-23 14:06:52 +00:00
|
|
|
Q_UNUSED(instr); \
|
|
|
|
TRACE_INSTR(I)
|
2012-06-11 16:58:52 +00:00
|
|
|
|
|
|
|
#ifdef MOTH_THREADED_INTERPRETER
|
|
|
|
|
|
|
|
# define MOTH_BEGIN_INSTR(I) op_##I: \
|
|
|
|
MOTH_BEGIN_INSTR_COMMON(I)
|
|
|
|
|
|
|
|
# define MOTH_END_INSTR(I) } \
|
|
|
|
genericInstr = reinterpret_cast<const Instr *>(code); \
|
|
|
|
goto *genericInstr->common.code; \
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
# define MOTH_BEGIN_INSTR(I) \
|
|
|
|
case Instr::I: \
|
|
|
|
MOTH_BEGIN_INSTR_COMMON(I)
|
|
|
|
|
|
|
|
# define MOTH_END_INSTR(I) } \
|
2013-10-28 15:04:07 +00:00
|
|
|
continue;
|
2012-06-11 16:58:52 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-03-11 11:00:13 +00:00
|
|
|
#ifdef WITH_STATS
|
|
|
|
namespace {
|
|
|
|
struct VMStats {
|
|
|
|
quint64 paramIsValue;
|
|
|
|
quint64 paramIsArg;
|
|
|
|
quint64 paramIsLocal;
|
|
|
|
quint64 paramIsTemp;
|
|
|
|
quint64 paramIsScopedLocal;
|
|
|
|
|
|
|
|
VMStats()
|
|
|
|
: paramIsValue(0)
|
|
|
|
, paramIsArg(0)
|
|
|
|
, paramIsLocal(0)
|
|
|
|
, paramIsTemp(0)
|
|
|
|
, paramIsScopedLocal(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~VMStats()
|
|
|
|
{ show(); }
|
|
|
|
|
|
|
|
void show() {
|
|
|
|
fprintf(stderr, "VM stats:\n");
|
|
|
|
fprintf(stderr, " value: %lu\n", paramIsValue);
|
|
|
|
fprintf(stderr, " arg: %lu\n", paramIsArg);
|
|
|
|
fprintf(stderr, " local: %lu\n", paramIsLocal);
|
|
|
|
fprintf(stderr, " temp: %lu\n", paramIsTemp);
|
|
|
|
fprintf(stderr, " scoped local: %lu\n", paramIsScopedLocal);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static VMStats vmStats;
|
|
|
|
#define VMSTATS(what) ++vmStats.what
|
|
|
|
}
|
|
|
|
#else // !WITH_STATS
|
|
|
|
#define VMSTATS(what) {}
|
|
|
|
#endif // WITH_STATS
|
|
|
|
|
2012-11-13 11:25:23 +00:00
|
|
|
#ifdef DO_TRACE_INSTR
|
2013-10-29 09:28:04 +00:00
|
|
|
Param traceParam(const Param ¶m)
|
|
|
|
{
|
|
|
|
if (param.isConstant()) {
|
|
|
|
fprintf(stderr, " constant\n");
|
2013-01-25 18:32:30 +00:00
|
|
|
} else if (param.isArgument()) {
|
2013-03-21 19:50:55 +00:00
|
|
|
fprintf(stderr, " argument %d@%d\n", param.index, param.scope);
|
2013-01-25 18:32:30 +00:00
|
|
|
} else if (param.isLocal()) {
|
|
|
|
fprintf(stderr, " local %d\n", param.index);
|
|
|
|
} else if (param.isTemp()) {
|
|
|
|
fprintf(stderr, " temp %d\n", param.index);
|
2013-02-15 12:36:49 +00:00
|
|
|
} else if (param.isScopedLocal()) {
|
|
|
|
fprintf(stderr, " temp %d@%d\n", param.index, param.scope);
|
2012-11-13 11:25:23 +00:00
|
|
|
} else {
|
2013-01-25 18:32:30 +00:00
|
|
|
Q_ASSERT(!"INVALID");
|
2012-11-13 11:25:23 +00:00
|
|
|
}
|
2013-10-29 09:28:04 +00:00
|
|
|
return Param
|
2012-06-12 17:13:55 +00:00
|
|
|
}
|
2013-06-03 11:32:51 +00:00
|
|
|
# define VALUE(param) (*VALUEPTR(param))
|
2013-10-29 09:28:04 +00:00
|
|
|
# define VALUEPTR(param) (scopes[traceParam(param).scope] + param.index)
|
2013-01-25 18:32:30 +00:00
|
|
|
#else
|
2013-10-29 09:28:04 +00:00
|
|
|
# define VALUE(param) (*VALUEPTR(param))
|
|
|
|
# define VALUEPTR(param) (scopes[param.scope] + param.index)
|
2013-01-25 18:32:30 +00:00
|
|
|
#endif
|
2013-10-29 09:28:04 +00:00
|
|
|
|
2013-10-23 12:03:09 +00:00
|
|
|
#define STOREVALUE(param, value) { \
|
|
|
|
QV4::ReturnedValue tmp = (value); \
|
2014-02-05 15:12:16 +00:00
|
|
|
if (engine->hasException) \
|
2013-10-23 12:03:09 +00:00
|
|
|
goto catchException; \
|
|
|
|
VALUE(param) = tmp; \
|
|
|
|
}
|
|
|
|
#define CHECK_EXCEPTION \
|
2014-02-05 15:12:16 +00:00
|
|
|
if (engine->hasException) \
|
2013-10-23 12:03:09 +00:00
|
|
|
goto catchException
|
2012-06-12 17:13:55 +00:00
|
|
|
|
2014-02-06 12:22:36 +00:00
|
|
|
QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code
|
2012-06-11 16:58:52 +00:00
|
|
|
#ifdef MOTH_THREADED_INTERPRETER
|
|
|
|
, void ***storeJumpTable
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
{
|
2013-01-23 09:11:05 +00:00
|
|
|
#ifdef DO_TRACE_INSTR
|
|
|
|
qDebug("Starting VME with context=%p and code=%p", context, code);
|
|
|
|
#endif // DO_TRACE_INSTR
|
2012-06-11 16:58:52 +00:00
|
|
|
|
|
|
|
#ifdef MOTH_THREADED_INTERPRETER
|
|
|
|
if (storeJumpTable) {
|
|
|
|
#define MOTH_INSTR_ADDR(I, FMT) &&op_##I,
|
|
|
|
static void *jumpTable[] = {
|
|
|
|
FOR_EACH_MOTH_INSTR(MOTH_INSTR_ADDR)
|
|
|
|
};
|
|
|
|
#undef MOTH_INSTR_ADDR
|
|
|
|
*storeJumpTable = jumpTable;
|
2013-09-25 10:24:36 +00:00
|
|
|
return QV4::Primitive::undefinedValue().asReturnedValue();
|
2012-06-11 16:58:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-06 12:22:36 +00:00
|
|
|
QV4::Value *stack = 0;
|
|
|
|
unsigned stackSize = 0;
|
|
|
|
|
2013-10-16 10:29:47 +00:00
|
|
|
const uchar *exceptionHandler = 0;
|
|
|
|
|
2014-05-06 07:23:59 +00:00
|
|
|
context->d()->lineNumber = -1;
|
|
|
|
QV4::ExecutionEngine *engine = context->d()->engine;
|
2013-10-16 10:29:47 +00:00
|
|
|
|
|
|
|
#ifdef DO_TRACE_INSTR
|
|
|
|
qDebug("Starting VME with context=%p and code=%p", context, code);
|
|
|
|
#endif // DO_TRACE_INSTR
|
|
|
|
|
2014-05-06 07:23:59 +00:00
|
|
|
QV4::StringValue * const runtimeStrings = context->d()->compilationUnit->runtimeStrings;
|
2013-08-05 13:20:08 +00:00
|
|
|
|
2013-10-29 09:28:04 +00:00
|
|
|
// setup lookup scopes
|
|
|
|
int scopeDepth = 0;
|
|
|
|
{
|
|
|
|
QV4::ExecutionContext *scope = context;
|
|
|
|
while (scope) {
|
|
|
|
++scopeDepth;
|
2014-05-06 07:23:59 +00:00
|
|
|
scope = scope->d()->outer;
|
2013-10-29 09:28:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-24 21:55:39 +00:00
|
|
|
QV4::Value **scopes = static_cast<QV4::Value **>(alloca(sizeof(QV4::Value *)*(2 + 2*scopeDepth)));
|
2013-10-29 09:28:04 +00:00
|
|
|
{
|
2014-05-06 07:23:59 +00:00
|
|
|
scopes[0] = const_cast<QV4::Value *>(context->d()->compilationUnit->data->constants());
|
2013-10-29 09:28:04 +00:00
|
|
|
// stack gets setup in push instruction
|
|
|
|
scopes[1] = 0;
|
|
|
|
QV4::ExecutionContext *scope = context;
|
|
|
|
int i = 0;
|
|
|
|
while (scope) {
|
2014-05-06 07:23:59 +00:00
|
|
|
if (scope->d()->type >= QV4::ExecutionContext::Type_SimpleCallContext) {
|
2013-10-29 09:28:04 +00:00
|
|
|
QV4::CallContext *cc = static_cast<QV4::CallContext *>(scope);
|
2014-05-06 07:23:59 +00:00
|
|
|
scopes[2*i + 2] = cc->d()->callData->args;
|
2014-05-09 14:50:17 +00:00
|
|
|
scopes[2*i + 3] = cc->d()->locals;
|
2013-10-29 09:28:04 +00:00
|
|
|
} else {
|
|
|
|
scopes[2*i + 2] = 0;
|
|
|
|
scopes[2*i + 3] = 0;
|
|
|
|
}
|
|
|
|
++i;
|
2014-05-06 07:23:59 +00:00
|
|
|
scope = scope->d()->outer;
|
2013-10-29 09:28:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-23 12:03:09 +00:00
|
|
|
|
2012-06-11 16:58:52 +00:00
|
|
|
for (;;) {
|
|
|
|
const Instr *genericInstr = reinterpret_cast<const Instr *>(code);
|
2013-10-23 12:03:09 +00:00
|
|
|
#ifdef MOTH_THREADED_INTERPRETER
|
|
|
|
goto *genericInstr->common.code;
|
|
|
|
#else
|
2012-06-11 16:58:52 +00:00
|
|
|
switch (genericInstr->common.instructionType) {
|
|
|
|
#endif
|
|
|
|
|
2013-10-29 07:17:54 +00:00
|
|
|
MOTH_BEGIN_INSTR(Move)
|
2013-01-25 18:32:30 +00:00
|
|
|
VALUE(instr.result) = VALUE(instr.source);
|
2013-10-29 07:17:54 +00:00
|
|
|
MOTH_END_INSTR(Move)
|
2012-06-12 17:13:55 +00:00
|
|
|
|
2014-02-06 12:19:27 +00:00
|
|
|
MOTH_BEGIN_INSTR(MoveConst)
|
|
|
|
VALUE(instr.result) = instr.source;
|
|
|
|
MOTH_END_INSTR(MoveConst)
|
|
|
|
|
2013-09-01 13:45:53 +00:00
|
|
|
MOTH_BEGIN_INSTR(SwapTemps)
|
|
|
|
qSwap(VALUE(instr.left), VALUE(instr.right));
|
|
|
|
MOTH_END_INSTR(MoveTemp)
|
|
|
|
|
2013-08-19 09:57:03 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadRuntimeString)
|
2013-08-16 14:35:05 +00:00
|
|
|
// TRACE(value, "%s", instr.value.toString(context)->toQString().toUtf8().constData());
|
2013-09-25 13:24:50 +00:00
|
|
|
VALUE(instr.result) = runtimeStrings[instr.stringId].asReturnedValue();
|
2013-08-19 09:57:03 +00:00
|
|
|
MOTH_END_INSTR(LoadRuntimeString)
|
2013-08-16 14:35:05 +00:00
|
|
|
|
2013-08-16 14:40:21 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadRegExp)
|
|
|
|
// TRACE(value, "%s", instr.value.toString(context)->toQString().toUtf8().constData());
|
2014-05-06 07:23:59 +00:00
|
|
|
VALUE(instr.result) = context->d()->compilationUnit->runtimeRegularExpressions[instr.regExpId];
|
2013-08-16 14:40:21 +00:00
|
|
|
MOTH_END_INSTR(LoadRegExp)
|
|
|
|
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadClosure)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::closure(context, instr.value));
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_END_INSTR(LoadClosure)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(LoadName)
|
2013-09-15 13:46:36 +00:00
|
|
|
TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData());
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::getActivationProperty(context, runtimeStrings[instr.name]));
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_END_INSTR(LoadName)
|
|
|
|
|
2013-10-10 09:51:42 +00:00
|
|
|
MOTH_BEGIN_INSTR(GetGlobalLookup)
|
|
|
|
TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData());
|
2014-05-06 07:23:59 +00:00
|
|
|
QV4::Lookup *l = context->d()->lookups + instr.index;
|
2013-10-10 09:51:42 +00:00
|
|
|
STOREVALUE(instr.result, l->globalGetter(l, context));
|
|
|
|
MOTH_END_INSTR(GetGlobalLookup)
|
|
|
|
|
2012-10-24 11:45:43 +00:00
|
|
|
MOTH_BEGIN_INSTR(StoreName)
|
2013-09-15 13:46:36 +00:00
|
|
|
TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData());
|
2014-03-10 18:58:05 +00:00
|
|
|
Runtime::setActivationProperty(context, runtimeStrings[instr.name], VALUEPTR(instr.source));
|
2013-10-23 12:03:09 +00:00
|
|
|
CHECK_EXCEPTION;
|
2012-10-24 11:45:43 +00:00
|
|
|
MOTH_END_INSTR(StoreName)
|
|
|
|
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadElement)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::getElement(context, VALUEPTR(instr.base), VALUEPTR(instr.index)));
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_END_INSTR(LoadElement)
|
|
|
|
|
2014-01-31 13:58:14 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadElementLookup)
|
2014-05-06 07:23:59 +00:00
|
|
|
QV4::Lookup *l = context->d()->lookups + instr.lookup;
|
2014-01-31 13:58:14 +00:00
|
|
|
STOREVALUE(instr.result, l->indexedGetter(l, VALUEPTR(instr.base), VALUEPTR(instr.index)));
|
|
|
|
MOTH_END_INSTR(LoadElementLookup)
|
|
|
|
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_BEGIN_INSTR(StoreElement)
|
2014-03-10 18:58:05 +00:00
|
|
|
Runtime::setElement(context, VALUEPTR(instr.base), VALUEPTR(instr.index), VALUEPTR(instr.source));
|
2013-10-23 12:03:09 +00:00
|
|
|
CHECK_EXCEPTION;
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_END_INSTR(StoreElement)
|
|
|
|
|
2014-01-31 13:58:14 +00:00
|
|
|
MOTH_BEGIN_INSTR(StoreElementLookup)
|
2014-05-06 07:23:59 +00:00
|
|
|
QV4::Lookup *l = context->d()->lookups + instr.lookup;
|
2014-01-31 13:58:14 +00:00
|
|
|
l->indexedSetter(l, VALUEPTR(instr.base), VALUEPTR(instr.index), VALUEPTR(instr.source));
|
|
|
|
CHECK_EXCEPTION;
|
|
|
|
MOTH_END_INSTR(StoreElementLookup)
|
|
|
|
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadProperty)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::getProperty(context, VALUEPTR(instr.base), runtimeStrings[instr.name]));
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_END_INSTR(LoadProperty)
|
|
|
|
|
2013-10-10 09:51:42 +00:00
|
|
|
MOTH_BEGIN_INSTR(GetLookup)
|
2014-05-06 07:23:59 +00:00
|
|
|
QV4::Lookup *l = context->d()->lookups + instr.index;
|
2013-10-10 09:51:42 +00:00
|
|
|
STOREVALUE(instr.result, l->getter(l, VALUEPTR(instr.base)));
|
|
|
|
MOTH_END_INSTR(GetLookup)
|
|
|
|
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_BEGIN_INSTR(StoreProperty)
|
2014-03-10 18:58:05 +00:00
|
|
|
Runtime::setProperty(context, VALUEPTR(instr.base), runtimeStrings[instr.name], VALUEPTR(instr.source));
|
2013-10-23 12:03:09 +00:00
|
|
|
CHECK_EXCEPTION;
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_END_INSTR(StoreProperty)
|
|
|
|
|
2013-10-10 09:51:42 +00:00
|
|
|
MOTH_BEGIN_INSTR(SetLookup)
|
2014-05-06 07:23:59 +00:00
|
|
|
QV4::Lookup *l = context->d()->lookups + instr.index;
|
2013-10-10 09:51:42 +00:00
|
|
|
l->setter(l, VALUEPTR(instr.base), VALUEPTR(instr.source));
|
|
|
|
CHECK_EXCEPTION;
|
|
|
|
MOTH_END_INSTR(SetLookup)
|
|
|
|
|
2013-10-28 14:18:31 +00:00
|
|
|
MOTH_BEGIN_INSTR(StoreQObjectProperty)
|
2014-03-10 18:58:05 +00:00
|
|
|
Runtime::setQmlQObjectProperty(context, VALUEPTR(instr.base), instr.propertyIndex, VALUEPTR(instr.source));
|
2013-10-28 14:18:31 +00:00
|
|
|
CHECK_EXCEPTION;
|
|
|
|
MOTH_END_INSTR(StoreQObjectProperty)
|
|
|
|
|
2013-10-24 12:51:02 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadQObjectProperty)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::getQmlQObjectProperty(context, VALUEPTR(instr.base), instr.propertyIndex, instr.captureRequired));
|
2013-10-24 12:51:02 +00:00
|
|
|
MOTH_END_INSTR(LoadQObjectProperty)
|
|
|
|
|
2013-11-14 23:06:18 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadAttachedQObjectProperty)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::getQmlAttachedProperty(context, instr.attachedPropertiesId, instr.propertyIndex));
|
2013-11-14 23:06:18 +00:00
|
|
|
MOTH_END_INSTR(LoadAttachedQObjectProperty)
|
|
|
|
|
2014-07-23 17:43:38 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadSingletonQObjectProperty)
|
|
|
|
STOREVALUE(instr.result, Runtime::getQmlSingletonQObjectProperty(context, VALUEPTR(instr.base), instr.propertyIndex, instr.captureRequired));
|
|
|
|
MOTH_END_INSTR(LoadSingletonQObjectProperty)
|
|
|
|
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_BEGIN_INSTR(Push)
|
2012-11-06 11:31:02 +00:00
|
|
|
TRACE(inline, "stack size: %u", instr.value);
|
2012-12-04 12:40:18 +00:00
|
|
|
stackSize = instr.value;
|
2014-05-06 07:23:59 +00:00
|
|
|
stack = context->engine()->stackPush(stackSize);
|
2014-02-06 13:57:09 +00:00
|
|
|
#ifndef QT_NO_DEBUG
|
2014-01-24 21:55:39 +00:00
|
|
|
memset(stack, 0, stackSize * sizeof(QV4::Value));
|
2014-02-06 13:57:09 +00:00
|
|
|
#endif
|
2013-10-29 09:28:04 +00:00
|
|
|
scopes[1] = stack;
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_END_INSTR(Push)
|
|
|
|
|
2012-10-24 15:04:29 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallValue)
|
2013-09-15 13:46:36 +00:00
|
|
|
#if 0 //def DO_TRACE_INSTR
|
2014-05-06 07:23:59 +00:00
|
|
|
if (Debugging::Debugger *debugger = context->engine()->debugger) {
|
2013-04-19 11:03:42 +00:00
|
|
|
if (QV4::FunctionObject *o = (VALUE(instr.dest)).asFunctionObject()) {
|
2012-11-29 13:35:18 +00:00
|
|
|
if (Debugging::FunctionDebugInfo *info = debugger->debugInfo(o)) {
|
|
|
|
QString n = debugger->name(o);
|
|
|
|
std::cerr << "*** Call to \"" << (n.isNull() ? "<no name>" : qPrintable(n)) << "\" defined @" << info->startLine << ":" << info->startColumn << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // DO_TRACE_INSTR
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-09-05 12:49:55 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
2013-09-15 13:46:36 +00:00
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
2013-09-05 12:49:55 +00:00
|
|
|
callData->argc = instr.argc;
|
2013-09-25 10:24:36 +00:00
|
|
|
callData->thisObject = QV4::Primitive::undefinedValue();
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::callValue(context, VALUEPTR(instr.dest), callData));
|
2012-10-24 15:04:29 +00:00
|
|
|
MOTH_END_INSTR(CallValue)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CallProperty)
|
2013-09-15 13:46:36 +00:00
|
|
|
TRACE(property name, "%s, args=%u, argc=%u, this=%s", qPrintable(runtimeStrings[instr.name]->toQString()), instr.callData, instr.argc, (VALUE(instr.base)).toString(context)->toQString().toUtf8().constData());
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-09-05 12:49:55 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
2013-09-15 13:46:36 +00:00
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
2013-09-05 12:49:55 +00:00
|
|
|
callData->argc = instr.argc;
|
|
|
|
callData->thisObject = VALUE(instr.base);
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::callProperty(context, runtimeStrings[instr.name], callData));
|
2012-10-24 15:04:29 +00:00
|
|
|
MOTH_END_INSTR(CallProperty)
|
2012-06-12 17:13:55 +00:00
|
|
|
|
2013-10-10 09:51:42 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallPropertyLookup)
|
|
|
|
TRACE(property name, "%s, args=%u, argc=%u, this=%s", qPrintable(runtimeStrings[instr.name]->toQString()), instr.callData, instr.argc, (VALUE(instr.base)).toString(context)->toQString().toUtf8().constData());
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-10-10 09:51:42 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
|
|
|
callData->argc = instr.argc;
|
|
|
|
callData->thisObject = VALUE(instr.base);
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::callPropertyLookup(context, instr.lookupIndex, callData));
|
2013-10-10 09:51:42 +00:00
|
|
|
MOTH_END_INSTR(CallPropertyLookup)
|
|
|
|
|
2013-01-27 21:39:01 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallElement)
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-09-05 12:49:55 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
2013-09-15 13:46:36 +00:00
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
2013-09-05 12:49:55 +00:00
|
|
|
callData->argc = instr.argc;
|
|
|
|
callData->thisObject = VALUE(instr.base);
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::callElement(context, VALUEPTR(instr.index), callData));
|
2013-02-15 12:36:49 +00:00
|
|
|
MOTH_END_INSTR(CallElement)
|
2013-01-27 21:39:01 +00:00
|
|
|
|
2013-01-23 12:21:09 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallActivationProperty)
|
2013-06-11 09:43:55 +00:00
|
|
|
TRACE(args, "starting at %d, length %d", instr.args, instr.argc);
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-09-05 12:49:55 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
2013-09-15 13:46:36 +00:00
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
2013-09-05 12:49:55 +00:00
|
|
|
callData->argc = instr.argc;
|
2013-09-25 10:24:36 +00:00
|
|
|
callData->thisObject = QV4::Primitive::undefinedValue();
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::callActivationProperty(context, runtimeStrings[instr.name], callData));
|
2013-01-23 12:21:09 +00:00
|
|
|
MOTH_END_INSTR(CallActivationProperty)
|
|
|
|
|
2013-10-10 09:51:42 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallGlobalLookup)
|
|
|
|
TRACE(args, "starting at %d, length %d", instr.args, instr.argc);
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-10-10 09:51:42 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
|
|
|
callData->argc = instr.argc;
|
|
|
|
callData->thisObject = QV4::Primitive::undefinedValue();
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::callGlobalLookup(context, instr.index, callData));
|
2013-10-10 09:51:42 +00:00
|
|
|
MOTH_END_INSTR(CallGlobalLookup)
|
|
|
|
|
2013-10-23 12:03:09 +00:00
|
|
|
MOTH_BEGIN_INSTR(SetExceptionHandler)
|
|
|
|
exceptionHandler = instr.offset ? ((uchar *)&instr.offset) + instr.offset : 0;
|
|
|
|
MOTH_END_INSTR(SetExceptionHandler)
|
|
|
|
|
2013-01-27 08:59:37 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinThrow)
|
2014-03-10 18:58:05 +00:00
|
|
|
Runtime::throwException(context, VALUEPTR(instr.arg));
|
2013-10-23 12:03:09 +00:00
|
|
|
CHECK_EXCEPTION;
|
2013-01-27 08:59:37 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinThrow)
|
|
|
|
|
2013-10-23 12:03:09 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinUnwindException)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::unwindException(context));
|
2013-10-23 12:03:09 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinUnwindException)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinPushCatchScope)
|
2014-03-10 18:58:05 +00:00
|
|
|
context = Runtime::pushCatchScope(context, runtimeStrings[instr.name]);
|
2013-10-23 12:03:09 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinPushCatchScope)
|
|
|
|
|
2013-01-27 08:59:37 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinPushScope)
|
2014-03-10 18:58:05 +00:00
|
|
|
context = Runtime::pushWithScope(VALUEPTR(instr.arg), context);
|
2013-01-27 08:59:37 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinPushScope)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinPopScope)
|
2014-03-10 18:58:05 +00:00
|
|
|
context = Runtime::popScope(context);
|
2013-01-27 08:59:37 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinPopScope)
|
2012-10-25 08:08:22 +00:00
|
|
|
|
2013-01-23 09:11:05 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinForeachIteratorObject)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::foreachIterator(context, VALUEPTR(instr.arg)));
|
2013-01-23 09:11:05 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinForeachIteratorObject)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinForeachNextPropertyName)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::foreachNextPropertyName(VALUEPTR(instr.arg)));
|
2013-01-23 09:11:05 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinForeachNextPropertyName)
|
|
|
|
|
2012-11-12 13:31:05 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinDeleteMember)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::deleteMember(context, VALUEPTR(instr.base), runtimeStrings[instr.member]));
|
2012-11-12 13:31:05 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinDeleteMember)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinDeleteSubscript)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::deleteElement(context, VALUEPTR(instr.base), VALUEPTR(instr.index)));
|
2012-11-12 13:31:05 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinDeleteSubscript)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinDeleteName)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::deleteName(context, runtimeStrings[instr.name]));
|
2012-11-12 13:31:05 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinDeleteName)
|
|
|
|
|
2012-12-18 09:59:26 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinTypeofMember)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::typeofMember(context, VALUEPTR(instr.base), runtimeStrings[instr.member]));
|
2012-12-18 09:59:26 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinTypeofMember)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinTypeofSubscript)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::typeofElement(context, VALUEPTR(instr.base), VALUEPTR(instr.index)));
|
2012-12-18 09:59:26 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinTypeofSubscript)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinTypeofName)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::typeofName(context, runtimeStrings[instr.name]));
|
2012-12-18 09:59:26 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinTypeofName)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinTypeofValue)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::typeofValue(context, VALUEPTR(instr.value)));
|
2012-12-18 09:59:26 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinTypeofValue)
|
|
|
|
|
2012-11-27 11:17:19 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinDeclareVar)
|
2014-03-10 18:58:05 +00:00
|
|
|
Runtime::declareVar(context, instr.isDeletable, runtimeStrings[instr.varName]);
|
2013-01-16 14:49:42 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinDeclareVar)
|
2012-11-27 11:17:19 +00:00
|
|
|
|
2013-03-01 15:47:07 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinDefineArray)
|
2013-03-04 08:32:16 +00:00
|
|
|
Q_ASSERT(instr.args + instr.argc <= stackSize);
|
2014-01-24 21:55:39 +00:00
|
|
|
QV4::Value *args = stack + instr.args;
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::arrayLiteral(context, args, instr.argc));
|
2013-03-01 15:47:07 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinDefineArray)
|
2013-01-24 11:53:47 +00:00
|
|
|
|
2013-04-23 05:31:02 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinDefineObjectLiteral)
|
2014-01-24 21:55:39 +00:00
|
|
|
QV4::Value *args = stack + instr.args;
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::objectLiteral(context, args, instr.internalClassId, instr.arrayValueCount, instr.arrayGetterSetterCountAndFlags));
|
2013-04-23 05:31:02 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinDefineObjectLiteral)
|
|
|
|
|
2013-08-16 10:54:30 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinSetupArgumentsObject)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::setupArgumentsObject(context));
|
2013-08-16 10:54:30 +00:00
|
|
|
MOTH_END_INSTR(CallBuiltinSetupArgumentsObject)
|
|
|
|
|
2013-11-02 20:10:13 +00:00
|
|
|
MOTH_BEGIN_INSTR(CallBuiltinConvertThisToObject)
|
2014-03-10 18:58:05 +00:00
|
|
|
Runtime::convertThisToObject(context);
|
2013-11-02 20:10:13 +00:00
|
|
|
CHECK_EXCEPTION;
|
|
|
|
MOTH_END_INSTR(CallBuiltinConvertThisToObject)
|
|
|
|
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_BEGIN_INSTR(CreateValue)
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-09-05 12:49:55 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
2013-09-15 13:46:36 +00:00
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
2013-09-05 12:49:55 +00:00
|
|
|
callData->argc = instr.argc;
|
2013-09-25 10:24:36 +00:00
|
|
|
callData->thisObject = QV4::Primitive::undefinedValue();
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::constructValue(context, VALUEPTR(instr.func), callData));
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_END_INSTR(CreateValue)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(CreateProperty)
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-09-05 12:49:55 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
2013-09-15 13:46:36 +00:00
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
2013-09-05 12:49:55 +00:00
|
|
|
callData->argc = instr.argc;
|
2013-11-13 10:45:51 +00:00
|
|
|
callData->thisObject = VALUE(instr.base);
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::constructProperty(context, runtimeStrings[instr.name], callData));
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_END_INSTR(CreateProperty)
|
|
|
|
|
2013-11-13 10:45:51 +00:00
|
|
|
MOTH_BEGIN_INSTR(ConstructPropertyLookup)
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-11-13 10:45:51 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
|
|
|
callData->argc = instr.argc;
|
|
|
|
callData->thisObject = VALUE(instr.base);
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::constructPropertyLookup(context, instr.index, callData));
|
2013-11-13 10:45:51 +00:00
|
|
|
MOTH_END_INSTR(ConstructPropertyLookup)
|
|
|
|
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_BEGIN_INSTR(CreateActivationProperty)
|
2013-09-15 13:46:36 +00:00
|
|
|
TRACE(inline, "property name = %s, args = %d, argc = %d", runtimeStrings[instr.name]->toQString().toUtf8().constData(), instr.args, instr.argc);
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-09-05 12:49:55 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
2013-09-15 13:46:36 +00:00
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
2013-09-05 12:49:55 +00:00
|
|
|
callData->argc = instr.argc;
|
2013-09-25 10:24:36 +00:00
|
|
|
callData->thisObject = QV4::Primitive::undefinedValue();
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::constructActivationProperty(context, runtimeStrings[instr.name], callData));
|
2012-11-06 11:54:20 +00:00
|
|
|
MOTH_END_INSTR(CreateActivationProperty)
|
|
|
|
|
2013-10-10 09:51:42 +00:00
|
|
|
MOTH_BEGIN_INSTR(ConstructGlobalLookup)
|
|
|
|
TRACE(inline, "property name = %s, args = %d, argc = %d", runtimeStrings[instr.name]->toQString().toUtf8().constData(), instr.args, instr.argc);
|
2014-01-24 21:55:39 +00:00
|
|
|
Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
|
2013-10-10 09:51:42 +00:00
|
|
|
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
|
|
|
|
callData->tag = QV4::Value::Integer_Type;
|
|
|
|
callData->argc = instr.argc;
|
|
|
|
callData->thisObject = QV4::Primitive::undefinedValue();
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::constructGlobalLookup(context, instr.index, callData));
|
2013-10-10 09:51:42 +00:00
|
|
|
MOTH_END_INSTR(ConstructGlobalLookup)
|
|
|
|
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_BEGIN_INSTR(Jump)
|
2012-06-12 17:26:29 +00:00
|
|
|
code = ((uchar *)&instr.offset) + instr.offset;
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_END_INSTR(Jump)
|
|
|
|
|
2014-02-06 14:05:35 +00:00
|
|
|
MOTH_BEGIN_INSTR(JumpEq)
|
|
|
|
bool cond = VALUEPTR(instr.condition)->toBoolean();
|
2013-01-25 18:32:30 +00:00
|
|
|
TRACE(condition, "%s", cond ? "TRUE" : "FALSE");
|
|
|
|
if (cond)
|
2012-06-12 17:26:29 +00:00
|
|
|
code = ((uchar *)&instr.offset) + instr.offset;
|
2014-02-06 14:05:35 +00:00
|
|
|
MOTH_END_INSTR(JumpEq)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(JumpNe)
|
|
|
|
bool cond = VALUEPTR(instr.condition)->toBoolean();
|
|
|
|
TRACE(condition, "%s", cond ? "TRUE" : "FALSE");
|
|
|
|
if (!cond)
|
|
|
|
code = ((uchar *)&instr.offset) + instr.offset;
|
|
|
|
MOTH_END_INSTR(JumpNe)
|
2012-06-12 17:13:55 +00:00
|
|
|
|
2013-10-29 11:53:05 +00:00
|
|
|
MOTH_BEGIN_INSTR(UNot)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::uNot(VALUEPTR(instr.source)));
|
2013-10-29 11:53:05 +00:00
|
|
|
MOTH_END_INSTR(UNot)
|
|
|
|
|
2013-10-29 15:06:43 +00:00
|
|
|
MOTH_BEGIN_INSTR(UNotBool)
|
|
|
|
bool b = VALUE(instr.source).booleanValue();
|
|
|
|
VALUE(instr.result) = QV4::Encode(!b);
|
|
|
|
MOTH_END_INSTR(UNotBool)
|
|
|
|
|
2013-10-29 11:53:05 +00:00
|
|
|
MOTH_BEGIN_INSTR(UPlus)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::uPlus(VALUEPTR(instr.source)));
|
2013-10-29 11:53:05 +00:00
|
|
|
MOTH_END_INSTR(UPlus)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(UMinus)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::uMinus(VALUEPTR(instr.source)));
|
2013-10-29 11:53:05 +00:00
|
|
|
MOTH_END_INSTR(UMinus)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(UCompl)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::complement(VALUEPTR(instr.source)));
|
2013-10-29 11:53:05 +00:00
|
|
|
MOTH_END_INSTR(UCompl)
|
|
|
|
|
2013-10-29 15:06:43 +00:00
|
|
|
MOTH_BEGIN_INSTR(UComplInt)
|
|
|
|
VALUE(instr.result) = QV4::Encode((int)~VALUE(instr.source).integerValue());
|
|
|
|
MOTH_END_INSTR(UComplInt)
|
|
|
|
|
2013-10-29 11:53:05 +00:00
|
|
|
MOTH_BEGIN_INSTR(Increment)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::increment(VALUEPTR(instr.source)));
|
2013-10-29 11:53:05 +00:00
|
|
|
MOTH_END_INSTR(Increment)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(Decrement)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::decrement(VALUEPTR(instr.source)));
|
2013-10-29 11:53:05 +00:00
|
|
|
MOTH_END_INSTR(Decrement)
|
2012-11-06 11:54:20 +00:00
|
|
|
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_BEGIN_INSTR(Binop)
|
2013-09-11 09:28:27 +00:00
|
|
|
STOREVALUE(instr.result, instr.alu(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_END_INSTR(Binop)
|
|
|
|
|
2013-10-29 14:28:17 +00:00
|
|
|
MOTH_BEGIN_INSTR(Add)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::add(context, VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
|
2013-10-29 14:28:17 +00:00
|
|
|
MOTH_END_INSTR(Add)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(BitAnd)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::bitAnd(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
|
2013-10-29 14:28:17 +00:00
|
|
|
MOTH_END_INSTR(BitAnd)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(BitOr)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::bitOr(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
|
2013-10-29 14:28:17 +00:00
|
|
|
MOTH_END_INSTR(BitOr)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(BitXor)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::bitXor(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
|
2013-10-29 14:28:17 +00:00
|
|
|
MOTH_END_INSTR(BitXor)
|
|
|
|
|
2014-02-06 13:56:32 +00:00
|
|
|
MOTH_BEGIN_INSTR(Shr)
|
|
|
|
STOREVALUE(instr.result, QV4::Encode((int)(VALUEPTR(instr.lhs)->toInt32() >> (VALUEPTR(instr.rhs)->toInt32() & 0x1f))));
|
|
|
|
MOTH_END_INSTR(Shr)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(Shl)
|
|
|
|
STOREVALUE(instr.result, QV4::Encode((int)(VALUEPTR(instr.lhs)->toInt32() << (VALUEPTR(instr.rhs)->toInt32() & 0x1f))));
|
|
|
|
MOTH_END_INSTR(Shl)
|
|
|
|
|
2013-10-29 15:06:43 +00:00
|
|
|
MOTH_BEGIN_INSTR(BitAndConst)
|
|
|
|
int lhs = VALUEPTR(instr.lhs)->toInt32();
|
|
|
|
STOREVALUE(instr.result, QV4::Encode((int)(lhs & instr.rhs)));
|
|
|
|
MOTH_END_INSTR(BitAnd)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(BitOrConst)
|
|
|
|
int lhs = VALUEPTR(instr.lhs)->toInt32();
|
|
|
|
STOREVALUE(instr.result, QV4::Encode((int)(lhs | instr.rhs)));
|
|
|
|
MOTH_END_INSTR(BitOr)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(BitXorConst)
|
|
|
|
int lhs = VALUEPTR(instr.lhs)->toInt32();
|
|
|
|
STOREVALUE(instr.result, QV4::Encode((int)(lhs ^ instr.rhs)));
|
|
|
|
MOTH_END_INSTR(BitXor)
|
|
|
|
|
2014-02-06 13:56:32 +00:00
|
|
|
MOTH_BEGIN_INSTR(ShrConst)
|
|
|
|
STOREVALUE(instr.result, QV4::Encode((int)(VALUEPTR(instr.lhs)->toInt32() >> instr.rhs)));
|
|
|
|
MOTH_END_INSTR(ShrConst)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(ShlConst)
|
|
|
|
STOREVALUE(instr.result, QV4::Encode((int)(VALUEPTR(instr.lhs)->toInt32() << instr.rhs)));
|
|
|
|
MOTH_END_INSTR(ShlConst)
|
|
|
|
|
2013-10-29 14:28:17 +00:00
|
|
|
MOTH_BEGIN_INSTR(Mul)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::mul(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
|
2013-10-29 14:28:17 +00:00
|
|
|
MOTH_END_INSTR(Mul)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(Sub)
|
2014-03-10 18:58:05 +00:00
|
|
|
STOREVALUE(instr.result, Runtime::sub(VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
|
2013-10-29 14:28:17 +00:00
|
|
|
MOTH_END_INSTR(Sub)
|
|
|
|
|
2013-08-05 21:41:42 +00:00
|
|
|
MOTH_BEGIN_INSTR(BinopContext)
|
2013-09-11 09:28:27 +00:00
|
|
|
STOREVALUE(instr.result, instr.alu(context, VALUEPTR(instr.lhs), VALUEPTR(instr.rhs)));
|
2013-08-05 21:41:42 +00:00
|
|
|
MOTH_END_INSTR(BinopContext)
|
|
|
|
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_BEGIN_INSTR(Ret)
|
2014-05-06 07:23:59 +00:00
|
|
|
context->engine()->stackPop(stackSize);
|
2012-12-04 09:31:31 +00:00
|
|
|
// TRACE(Ret, "returning value %s", result.toString(context)->toQString().toUtf8().constData());
|
2013-09-27 14:15:38 +00:00
|
|
|
return VALUE(instr.result).asReturnedValue();
|
2012-06-12 17:13:55 +00:00
|
|
|
MOTH_END_INSTR(Ret)
|
2012-06-11 16:58:52 +00:00
|
|
|
|
2014-02-05 13:38:03 +00:00
|
|
|
MOTH_BEGIN_INSTR(Debug)
|
2014-05-06 07:23:59 +00:00
|
|
|
context->d()->lineNumber = instr.lineNumber;
|
|
|
|
QV4::Debugging::Debugger *debugger = context->engine()->debugger;
|
2014-03-03 13:20:54 +00:00
|
|
|
if (debugger && debugger->pauseAtNextOpportunity())
|
2014-03-03 13:41:31 +00:00
|
|
|
debugger->maybeBreakAtInstruction();
|
|
|
|
MOTH_END_INSTR(Debug)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(Line)
|
2014-05-06 07:23:59 +00:00
|
|
|
context->d()->lineNumber = instr.lineNumber;
|
2014-02-05 13:38:03 +00:00
|
|
|
MOTH_END_INSTR(Debug)
|
|
|
|
|
2012-10-24 11:45:43 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadThis)
|
2014-05-06 07:23:59 +00:00
|
|
|
VALUE(instr.result) = context->d()->callData->thisObject;
|
2012-10-24 11:45:43 +00:00
|
|
|
MOTH_END_INSTR(LoadThis)
|
2012-10-23 14:06:52 +00:00
|
|
|
|
2013-11-02 17:48:18 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadQmlIdArray)
|
2014-03-10 18:58:05 +00:00
|
|
|
VALUE(instr.result) = Runtime::getQmlIdArray(static_cast<QV4::NoThrowContext*>(context));
|
2013-11-02 17:48:18 +00:00
|
|
|
MOTH_END_INSTR(LoadQmlIdArray)
|
2013-10-24 12:51:02 +00:00
|
|
|
|
2013-10-29 10:59:54 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadQmlImportedScripts)
|
2014-03-10 18:58:05 +00:00
|
|
|
VALUE(instr.result) = Runtime::getQmlImportedScripts(static_cast<QV4::NoThrowContext*>(context));
|
2013-10-29 10:59:54 +00:00
|
|
|
MOTH_END_INSTR(LoadQmlImportedScripts)
|
2013-10-28 16:02:54 +00:00
|
|
|
|
2013-10-24 12:51:02 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadQmlContextObject)
|
2014-03-10 18:58:05 +00:00
|
|
|
VALUE(instr.result) = Runtime::getQmlContextObject(static_cast<QV4::NoThrowContext*>(context));
|
2013-10-24 12:51:02 +00:00
|
|
|
MOTH_END_INSTR(LoadContextObject)
|
|
|
|
|
|
|
|
MOTH_BEGIN_INSTR(LoadQmlScopeObject)
|
2014-03-10 18:58:05 +00:00
|
|
|
VALUE(instr.result) = Runtime::getQmlScopeObject(static_cast<QV4::NoThrowContext*>(context));
|
2013-10-24 12:51:02 +00:00
|
|
|
MOTH_END_INSTR(LoadScopeObject)
|
2013-10-23 14:24:58 +00:00
|
|
|
|
2013-11-02 21:46:25 +00:00
|
|
|
MOTH_BEGIN_INSTR(LoadQmlSingleton)
|
2014-03-10 18:58:05 +00:00
|
|
|
VALUE(instr.result) = Runtime::getQmlSingleton(static_cast<QV4::NoThrowContext*>(context), runtimeStrings[instr.name]);
|
2013-11-02 21:46:25 +00:00
|
|
|
MOTH_END_INSTR(LoadQmlSingleton)
|
|
|
|
|
2012-06-11 16:58:52 +00:00
|
|
|
#ifdef MOTH_THREADED_INTERPRETER
|
|
|
|
// nothing to do
|
|
|
|
#else
|
|
|
|
default:
|
|
|
|
qFatal("QQmlJS::Moth::VME: Internal error - unknown instruction %d", genericInstr->common.instructionType);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-10-23 12:03:09 +00:00
|
|
|
Q_ASSERT(false);
|
|
|
|
catchException:
|
2014-05-06 07:23:59 +00:00
|
|
|
Q_ASSERT(context->engine()->hasException);
|
2013-10-23 12:03:09 +00:00
|
|
|
if (!exceptionHandler) {
|
2014-05-06 07:23:59 +00:00
|
|
|
context->engine()->stackPop(stackSize);
|
2013-10-23 12:03:09 +00:00
|
|
|
return QV4::Encode::undefined();
|
|
|
|
}
|
|
|
|
code = exceptionHandler;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-11 16:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MOTH_THREADED_INTERPRETER
|
|
|
|
void **VME::instructionJumpTable()
|
|
|
|
{
|
|
|
|
static void **jumpTable = 0;
|
|
|
|
if (!jumpTable) {
|
Implement JavaScript exceptions using C++ exceptions
Instead of registering catch handlers with setjmp and throwing JS exceptions
with longjmp, they are now thrown and caught as C++ exceptions. This allows for
tight interoperability between C++ and JS in the future and allows for clear
semantics with regards to cleaning up memory in the engine when throwing
exceptions. (destructors are guaranteed to be called, unlike with
setjmp/longjmp).
The recent unwind table additions allow for the exceptions to be thrown through
JIT generated code.
Catching the exception is done by re-using the existing IR semantics where the
beginning of a try block is marked by registering an exception handler.
Execution after the registration continues conditionally, based on the return
value of builtin_create_exception_handler. A return value of is 0 the try
block(s) are executed. If an exception is thrown during that time, execution
resumes at the point where builtin_create_exception_handler returns, but with a
return value of 1. If an exception is thrown within the catch handler, the
execution resumes again at the same point, but the inCatch IR variable will
guide execution straight to the finally block(s), which calls
delete_exception_handler.
In the JIT as well as the interpreter this is implemented by entering a C++
code section that contains a C++ try {} catch {} block, in which the calling
function is called again and continues right at the next instruction (or the
interpreter loop is recursively entered). An exception will throw us out of
that scope and back into the try {} catch {} wrapper, which can call again
into the calling function.
The IR guarantees that delete_exception_handler is always called, regardless of
how the try or catch blocks are terminated. That is where in the JIT and
interpreter we return from the nested function call and return back into the
original stack frame, effectively unregistering the catch handler.
Further cleanups with regards to the naming and the exception handler stack
will come in subsequent patches, this is merely the minimal patch set to
change to the new mechanism.
This patch set breaks ARM until ARM exception handler tables are implemented.
The interpreter changes are based on a patchset from Erik
from https://codereview.qt-project.org/#change,45750
Change-Id: I543f2bd37b2186f7e48ffcab177d57b5ce932a0c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-03-01 16:04:21 +00:00
|
|
|
const uchar *code = 0;
|
2014-02-06 12:22:36 +00:00
|
|
|
VME().run(0, code, &jumpTable);
|
2012-06-11 16:58:52 +00:00
|
|
|
}
|
|
|
|
return jumpTable;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-09-11 10:46:20 +00:00
|
|
|
QV4::ReturnedValue VME::exec(QV4::ExecutionContext *ctxt, const uchar *code)
|
2012-06-12 17:13:55 +00:00
|
|
|
{
|
|
|
|
VME vme;
|
2014-05-06 07:23:59 +00:00
|
|
|
QV4::Debugging::Debugger *debugger = ctxt->engine()->debugger;
|
2013-10-16 10:29:47 +00:00
|
|
|
if (debugger)
|
|
|
|
debugger->enteringFunction();
|
|
|
|
QV4::ReturnedValue retVal = vme.run(ctxt, code);
|
|
|
|
if (debugger)
|
|
|
|
debugger->leavingFunction(retVal);
|
|
|
|
return retVal;
|
2012-06-12 17:13:55 +00:00
|
|
|
}
|