aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-13 22:42:48 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-08-18 10:06:43 +0000
commitb5d89b3e539399e692fc056e3e03e09038adb6d8 (patch)
treef37146fe95c945cd4a7c56a6e67d545ea381fdda /src
parentaf5adb9e32713edb7196f761bcabd19f35722c57 (diff)
Remove the Load/StoreScopedArgument instructions
They are not used anymore. Change-Id: I0cb3754899a30d5f88279ff31296fd73edf90a9a Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4codegen.cpp23
-rw-r--r--src/qml/compiler/qv4codegen_p.h7
-rw-r--r--src/qml/compiler/qv4instr_moth.cpp20
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h20
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp28
5 files changed, 15 insertions, 83 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index b8a6b4c974..9e075fbe6f 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1239,7 +1239,6 @@ bool Codegen::visit(DeleteExpression *ast)
if (!expr.stackSlotIsLocalOrArgument)
break;
// fall through
- case Reference::ScopedArgument:
case Reference::ScopedLocal:
// Trying to delete a function argument might throw.
if (_context->isStrict) {
@@ -1367,7 +1366,8 @@ Codegen::Reference Codegen::referenceForName(const QString &name, bool isLhs)
const int argIdx = c->findArgument(name);
if (argIdx != -1) {
if (c->argumentsCanEscape || c->usesArgumentsObject == Context::ArgumentsObjectUsed) {
- return Reference::fromScopedArgument(this, argIdx, scope);
+ int idx = argIdx + c->locals.size();
+ return Reference::fromScopedLocal(this, idx, scope);
} else {
Q_ASSERT(scope == 0);
return Reference::fromArgument(this, argIdx);
@@ -1985,7 +1985,7 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
if (showCode) {
qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
<< "register count" << _context->registerCount;
- QV4::Moth::dumpBytecode(_context->code, _context->arguments.size());
+ QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size());
qDebug();
}
@@ -2760,7 +2760,6 @@ Codegen::Reference &Codegen::Reference::operator =(const Reference &other)
theStackSlot = other.theStackSlot;
break;
case ScopedLocal:
- case ScopedArgument:
index = other.index;
scope = other.scope;
break;
@@ -2812,7 +2811,6 @@ bool Codegen::Reference::operator==(const Codegen::Reference &other) const
case StackSlot:
return theStackSlot == other.theStackSlot;
case ScopedLocal:
- case ScopedArgument:
return index == other.index && scope == other.scope;
case Name:
return unqualifiedNameIndex == other.unqualifiedNameIndex;
@@ -2936,7 +2934,6 @@ bool Codegen::Reference::storeWipesAccumulator() const
return false;
case StackSlot:
case ScopedLocal:
- case ScopedArgument:
return false;
case Name:
case Member:
@@ -2964,13 +2961,6 @@ void Codegen::Reference::storeAccumulator() const
codegen->bytecodeGenerator->addInstruction(store);
return;
}
- case ScopedArgument: {
- Instruction::StoreScopedArgument store;
- store.index = index;
- store.scope = scope;
- codegen->bytecodeGenerator->addInstruction(store);
- return;
- }
case Name: {
Context *c = codegen->currentContext();
if (c->isStrict) {
@@ -3073,13 +3063,6 @@ void Codegen::Reference::loadInAccumulator() const
codegen->bytecodeGenerator->addInstruction(load);
return;
}
- case ScopedArgument: {
- Instruction::LoadScopedArgument load;
- load.index = index;
- load.scope = scope;
- codegen->bytecodeGenerator->addInstruction(load);
- return;
- }
case Name:
if (codegen->useFastLookups && global) {
Instruction::LoadGlobalLookup load;
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h
index 0d63854ed1..8d0fe7f056 100644
--- a/src/qml/compiler/qv4codegen_p.h
+++ b/src/qml/compiler/qv4codegen_p.h
@@ -163,7 +163,6 @@ public:
Accumulator,
StackSlot,
ScopedLocal,
- ScopedArgument,
Name,
Member,
Subscript,
@@ -229,12 +228,6 @@ public:
r.scope = scope;
return r;
}
- static Reference fromScopedArgument(Codegen *cg, int index, int scope) {
- Reference r(cg, ScopedArgument);
- r.index = index;
- r.scope = scope;
- return r;
- }
static Reference fromName(Codegen *cg, const QString &name) {
Reference r(cg, Name);
r.unqualifiedNameIndex = cg->registerString(name);
diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp
index 4691815bf0..95cbfc07bf 100644
--- a/src/qml/compiler/qv4instr_moth.cpp
+++ b/src/qml/compiler/qv4instr_moth.cpp
@@ -109,7 +109,7 @@ void dumpConstantTable(const Value *constants, uint count)
<< toString(constants[i].asReturnedValue()).toUtf8().constData() << "\n";
}
-void dumpBytecode(const char *code, int len, int nFormals)
+void dumpBytecode(const char *code, int len, int nLocals, int nFormals)
{
const char *start = code;
const char *end = code + len;
@@ -154,21 +154,19 @@ void dumpBytecode(const char *code, int len, int nFormals)
MOTH_END_INSTR(MoveConst)
MOTH_BEGIN_INSTR(LoadScopedLocal)
- d << "l" << instr.index << "@" << instr.scope;
+ if (instr.index < nLocals)
+ d << "l" << instr.index << "@" << instr.scope;
+ else
+ d << "a" << (instr.index - nLocals) << "@" << instr.scope;
MOTH_END_INSTR(LoadScopedLocal)
MOTH_BEGIN_INSTR(StoreScopedLocal)
- d << ", " << "l" << instr.index << "@" << instr.scope;
+ if (instr.index < nLocals)
+ d << ", " << "l" << instr.index << "@" << instr.scope;
+ else
+ d << ", " << "a" << (instr.index - nLocals) << "@" << instr.scope;
MOTH_END_INSTR(StoreScopedLocal)
- MOTH_BEGIN_INSTR(LoadScopedArgument)
- d << "a" << instr.index << "@" << instr.scope;
- MOTH_END_INSTR(LoadScopedArgument)
-
- MOTH_BEGIN_INSTR(StoreScopedArgument)
- d << "a" << instr.index << "@" << instr.scope;
- MOTH_END_INSTR(StoreScopedArgument)
-
MOTH_BEGIN_INSTR(LoadRuntimeString)
d << instr.stringId;
MOTH_END_INSTR(LoadRuntimeString)
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index 770f3be7a8..d972f64ba4 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -83,8 +83,6 @@ QT_BEGIN_NAMESPACE
F(MoveReg, moveReg) \
F(LoadScopedLocal, loadScopedLocal) \
F(StoreScopedLocal, storeScopedLocal) \
- F(LoadScopedArgument, loadScopedArgument) \
- F(StoreScopedArgument, storeScopedArgument) \
F(LoadRuntimeString, loadRuntimeString) \
F(LoadRegExp, loadRegExp) \
F(LoadClosure, loadClosure) \
@@ -236,9 +234,9 @@ inline bool operator!=(const StackSlot &l, const StackSlot &r) { return l.stackS
// When making changes to the instructions, make sure to bump QV4_DATA_STRUCTURE_VERSION in qv4compileddata_p.h
void dumpConstantTable(const Value *constants, uint count);
-void dumpBytecode(const char *bytecode, int len, int nFormals);
-inline void dumpBytecode(const QByteArray &bytecode, int nFormals) {
- dumpBytecode(bytecode.constData(), bytecode.length(), nFormals);
+void dumpBytecode(const char *bytecode, int len, int nLocals, int nFormals);
+inline void dumpBytecode(const QByteArray &bytecode, int nLocals, int nFormals) {
+ dumpBytecode(bytecode.constData(), bytecode.length(), nLocals, nFormals);
}
union Instr
@@ -314,16 +312,6 @@ union Instr
int scope;
int index;
};
- struct instr_loadScopedArgument {
- MOTH_INSTR_HEADER
- int scope;
- int index;
- };
- struct instr_storeScopedArgument {
- MOTH_INSTR_HEADER
- int scope;
- int index;
- };
struct instr_loadRuntimeString {
MOTH_INSTR_HEADER
int stringId;
@@ -739,8 +727,6 @@ union Instr
instr_moveReg moveReg;
instr_loadScopedLocal loadScopedLocal;
instr_storeScopedLocal storeScopedLocal;
- instr_loadScopedArgument loadScopedArgument;
- instr_storeScopedArgument storeScopedArgument;
instr_loadRuntimeString loadRuntimeString;
instr_loadRegExp loadRegExp;
instr_loadClosure loadClosure;
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 20b38823f9..2e2986ec47 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -392,25 +392,6 @@ static inline void storeScopedLocal(ExecutionEngine *engine, CppStackFrame &fram
QV4::WriteBarrier::write(engine, cc, cc->locals.values + index, value);
}
-static inline ReturnedValue loadScopedArg(CppStackFrame &frame, int index, int scope)
-{
- auto ctxt = getScope(frame.jsFrame, scope);
- Q_ASSERT(ctxt->type == QV4::Heap::ExecutionContext::Type_CallContext);
- auto cc = static_cast<Heap::CallContext *>(ctxt);
- return cc->args()[index].asReturnedValue();
-}
-
-static inline void storeScopedArg(ExecutionEngine *engine, CppStackFrame &frame, int index, int scope,
- const QV4::Value &value)
-{
- Q_UNUSED(engine);
- auto ctxt = getScope(frame.jsFrame, scope);
- Q_ASSERT(ctxt->type == QV4::Heap::ExecutionContext::Type_CallContext);
- auto cc = static_cast<Heap::CallContext *>(ctxt);
-
- cc->setArg(index, value);
-}
-
static inline const QV4::Value &constant(Function *function, int index)
{
return function->compilationUnit->constants[index];
@@ -514,15 +495,6 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat
storeScopedLocal(engine, frame, instr.index, instr.scope, accumulator);
MOTH_END_INSTR(StoreScopedLocal)
- MOTH_BEGIN_INSTR(LoadScopedArgument)
- accumulator = loadScopedArg(frame, instr.index, instr.scope);
- MOTH_END_INSTR(LoadScopedArgument)
-
- MOTH_BEGIN_INSTR(StoreScopedArgument)
- CHECK_EXCEPTION;
- storeScopedArg(engine, frame, instr.index, instr.scope, accumulator);
- MOTH_END_INSTR(StoreScopedArgument)
-
MOTH_BEGIN_INSTR(LoadRuntimeString)
accumulator = function->compilationUnit->runtimeStrings[instr.stringId];
MOTH_END_INSTR(LoadRuntimeString)