aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-16 16:30:15 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-08-25 11:59:18 +0000
commit34280d266fe4bed0274b260c0091d50908acd087 (patch)
treec7a757587a33119c293b1c909d228f38f4179347 /src
parent69a1018c9737751c2cc7daae2c03882dc81bd104 (diff)
Cleanup object construction instructions
Remove the unused Create/Construct instructions, and rename the single remaining one to 'Construct'. Change-Id: I10163a15681156f37e34d21a05d195d3c22adcff Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4codegen.cpp6
-rw-r--r--src/qml/compiler/qv4instr_moth.cpp20
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h40
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp59
-rw-r--r--src/qml/jsruntime/qv4runtimeapi_p.h6
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp38
6 files changed, 13 insertions, 156 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 5a7c12d0a2..0b8091d70e 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1483,12 +1483,12 @@ bool Codegen::visit(NewExpression *ast)
Reference base = expression(ast->expression);
if (hasError)
return false;
- //### Maybe create a CreateValueA that takes an accumulator?
+ //### Maybe create a ConstructA that takes an accumulator?
base = base.storeOnStack();
auto calldata = pushArgs(0);
- Instruction::CreateValue create;
+ Instruction::Construct create;
create.func = base.stackSlot();
create.callData = calldata;
bytecodeGenerator->addInstruction(create);
@@ -1512,7 +1512,7 @@ bool Codegen::visit(NewMemberExpression *ast)
if (hasError)
return false;
- Instruction::CreateValue create;
+ Instruction::Construct create;
create.func = base.stackSlot();
create.callData = calldata;
bytecodeGenerator->addInstruction(create);
diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp
index f3da508266..a6d0691db7 100644
--- a/src/qml/compiler/qv4instr_moth.cpp
+++ b/src/qml/compiler/qv4instr_moth.cpp
@@ -358,25 +358,9 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals)
MOTH_BEGIN_INSTR(ConvertThisToObject)
MOTH_END_INSTR(ConvertThisToObject)
- MOTH_BEGIN_INSTR(CreateValue)
+ MOTH_BEGIN_INSTR(Construct)
d << "new" << instr.func.dump(nFormals) << "(" << instr.callData.dump(nFormals) << ")";
- MOTH_END_INSTR(CreateValue)
-
- MOTH_BEGIN_INSTR(CreateProperty)
- d << "new" << instr.name << "(" << instr.callData.dump(nFormals) << instr.argc << ")";
- MOTH_END_INSTR(CreateProperty)
-
- MOTH_BEGIN_INSTR(ConstructPropertyLookup)
- d << "new" << instr.index << "(" << instr.callData.dump(nFormals) << instr.argc << ")";
- MOTH_END_INSTR(ConstructPropertyLookup)
-
- MOTH_BEGIN_INSTR(CreateName)
- d << "new" << instr.name << "(" << instr.callData.dump(nFormals) << instr.argc << ")";
- MOTH_END_INSTR(CreateName)
-
- MOTH_BEGIN_INSTR(ConstructGlobalLookup)
- d << "new" << instr.index << "(" << instr.callData.dump(nFormals) << instr.argc << ")";
- MOTH_END_INSTR(ConstructGlobalLookup)
+ MOTH_END_INSTR(Construct)
MOTH_BEGIN_INSTR(Jump)
d << absoluteInstructionOffset(start, instr);
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index c7e999e2e1..3d004d10e9 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -132,11 +132,7 @@ QT_BEGIN_NAMESPACE
F(CreateMappedArgumentsObject, createMappedArgumentsObject) \
F(CreateUnmappedArgumentsObject, createUnmappedArgumentsObject) \
F(ConvertThisToObject, convertThisToObject) \
- F(CreateValue, createValue) \
- F(CreateProperty, createProperty) \
- F(ConstructPropertyLookup, constructPropertyLookup) \
- F(CreateName, createName) \
- F(ConstructGlobalLookup, constructGlobalLookup) \
+ F(Construct, construct) \
F(Jump, jump) \
F(JumpEq, jumpEq) \
F(JumpNe, jumpNe) \
@@ -531,37 +527,11 @@ union Instr
struct instr_convertThisToObject {
MOTH_INSTR_HEADER
};
- struct instr_createValue {
+ struct instr_construct {
MOTH_INSTR_HEADER
StackSlot callData;
StackSlot func;
};
- struct instr_createProperty {
- MOTH_INSTR_HEADER
- int name;
- int argc;
- StackSlot callData;
- StackSlot base;
- };
- struct instr_constructPropertyLookup {
- MOTH_INSTR_HEADER
- int index;
- int argc;
- StackSlot callData;
- StackSlot base;
- };
- struct instr_createName {
- MOTH_INSTR_HEADER
- int name;
- int argc;
- StackSlot callData;
- };
- struct instr_constructGlobalLookup {
- MOTH_INSTR_HEADER
- int index;
- int argc;
- StackSlot callData;
- };
struct instr_jump {
MOTH_INSTR_HEADER
ptrdiff_t offset;
@@ -802,11 +772,7 @@ union Instr
instr_createMappedArgumentsObject createMappedArgumentsObject;
instr_createUnmappedArgumentsObject createUnmappedArgumentsObject;
instr_convertThisToObject convertThisToObject;
- instr_createValue createValue;
- instr_createProperty createProperty;
- instr_constructPropertyLookup constructPropertyLookup;
- instr_createName createName;
- instr_constructGlobalLookup constructGlobalLookup;
+ instr_construct construct;
instr_jump jump;
instr_jumpEq jumpEq;
instr_jumpNe jumpNe;
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 8a630b451c..a1d480160f 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1126,36 +1126,7 @@ ReturnedValue Runtime::method_callValue(ExecutionEngine *engine, const Value &fu
}
-ReturnedValue Runtime::method_constructGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData)
-{
- Scope scope(engine);
- Q_ASSERT(callData->thisObject.isUndefined());
-
- Lookup *l = engine->currentStackFrame->v4Function->compilationUnit->runtimeLookups + index;
- ScopedObject f(scope, l->globalGetter(l, engine));
- if (f)
- return f->construct(callData);
-
- return engine->throwTypeError();
-}
-
-
-ReturnedValue Runtime::method_constructName(ExecutionEngine *engine, int nameIndex, CallData *callData)
-{
- Scope scope(engine);
- ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- ScopedValue func(scope, static_cast<ExecutionContext &>(engine->currentStackFrame->jsFrame->context).getProperty(name));
- if (scope.engine->hasException)
- return Encode::undefined();
-
- Object *f = func->as<Object>();
- if (!f)
- return engine->throwTypeError();
-
- return f->construct(callData);
-}
-
-ReturnedValue Runtime::method_constructValue(ExecutionEngine *engine, const Value &func, CallData *callData)
+ReturnedValue Runtime::method_construct(ExecutionEngine *engine, const Value &func, CallData *callData)
{
const Object *f = func.as<Object>();
if (!f)
@@ -1164,34 +1135,6 @@ ReturnedValue Runtime::method_constructValue(ExecutionEngine *engine, const Valu
return f->construct(callData);
}
-ReturnedValue Runtime::method_constructProperty(ExecutionEngine *engine, int nameIndex, CallData *callData)
-{
- Scope scope(engine);
- ScopedObject thisObject(scope, callData->thisObject.toObject(engine));
- ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- if (scope.engine->hasException)
- return Encode::undefined();
-
- ScopedObject f(scope, thisObject->get(name));
- if (f)
- return f->construct(callData);
-
- return engine->throwTypeError();
-}
-
-ReturnedValue Runtime::method_constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData)
-{
- Lookup *l = engine->currentStackFrame->v4Function->compilationUnit->runtimeLookups + index;
- Value v;
- v = l->getter(l, engine, callData->thisObject);
- Object *o = v.objectValue();
- if (Q_LIKELY(o))
- return o->construct(callData);
-
- return engine->throwTypeError();
-}
-
-
void Runtime::method_throwException(ExecutionEngine *engine, const Value &value)
{
if (!value.isEmpty())
diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h
index e7f9a04434..d8e1b4f443 100644
--- a/src/qml/jsruntime/qv4runtimeapi_p.h
+++ b/src/qml/jsruntime/qv4runtimeapi_p.h
@@ -100,11 +100,7 @@ struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> {
F(ReturnedValue, callValue, (ExecutionEngine *engine, const Value &func, CallData *callData)) \
\
/* construct */ \
- F(ReturnedValue, constructGlobalLookup, (ExecutionEngine *engine, uint index, CallData *callData)) \
- F(ReturnedValue, constructName, (ExecutionEngine *engine, int nameIndex, CallData *callData)) \
- F(ReturnedValue, constructProperty, (ExecutionEngine *engine, int nameIndex, CallData *callData)) \
- F(ReturnedValue, constructPropertyLookup, (ExecutionEngine *engine, uint index, CallData *callData)) \
- F(ReturnedValue, constructValue, (ExecutionEngine *engine, const Value &func, CallData *callData)) \
+ F(ReturnedValue, construct, (ExecutionEngine *engine, const Value &func, CallData *callData)) \
\
/* load & store */ \
F(void, storeNameStrict, (ExecutionEngine *engine, int nameIndex, const Value &value)) \
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index d8d900f2bd..6d20fcc426 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -874,42 +874,10 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat
CHECK_EXCEPTION;
MOTH_END_INSTR(ConvertThisToObject)
- MOTH_BEGIN_INSTR(CreateValue)
+ MOTH_BEGIN_INSTR(Construct)
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData.stackSlot());
- STORE_ACCUMULATOR(Runtime::method_constructValue(engine, STACK_VALUE(instr.func), callData));
- MOTH_END_INSTR(CreateValue)
-
- MOTH_BEGIN_INSTR(CreateProperty)
- QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData.stackSlot());
- callData->tag = quint32(Value::ValueTypeInternal::Integer);
- callData->argc = instr.argc;
- callData->thisObject = STACK_VALUE(instr.base);
- STORE_ACCUMULATOR(Runtime::method_constructProperty(engine, instr.name, callData));
- MOTH_END_INSTR(CreateProperty)
-
- MOTH_BEGIN_INSTR(ConstructPropertyLookup)
- QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData.stackSlot());
- callData->tag = quint32(Value::ValueTypeInternal::Integer);
- callData->argc = instr.argc;
- callData->thisObject = STACK_VALUE(instr.base);
- STORE_ACCUMULATOR(Runtime::method_constructPropertyLookup(engine, instr.index, callData));
- MOTH_END_INSTR(ConstructPropertyLookup)
-
- MOTH_BEGIN_INSTR(CreateName)
- QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData.stackSlot());
- callData->tag = quint32(Value::ValueTypeInternal::Integer);
- callData->argc = instr.argc;
- callData->thisObject = QV4::Primitive::undefinedValue();
- STORE_ACCUMULATOR(Runtime::method_constructName(engine, instr.name, callData));
- MOTH_END_INSTR(CreateName)
-
- MOTH_BEGIN_INSTR(ConstructGlobalLookup)
- QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData.stackSlot());
- callData->tag = quint32(Value::ValueTypeInternal::Integer);
- callData->argc = instr.argc;
- callData->thisObject = QV4::Primitive::undefinedValue();
- STORE_ACCUMULATOR(Runtime::method_constructGlobalLookup(engine, instr.index, callData));
- MOTH_END_INSTR(ConstructGlobalLookup)
+ STORE_ACCUMULATOR(Runtime::method_construct(engine, STACK_VALUE(instr.func), callData));
+ MOTH_END_INSTR(Construct)
MOTH_BEGIN_INSTR(Jump)
code = reinterpret_cast<const uchar *>(&instr.offset) + instr.offset;