Generate correct code when calling values
__qmljs_call_value was still using a pointer to a Value. In addition, qcv4isel_masm.cpp was using a wrong order of the arguments. Change-Id: I0414aa732ae8074420e4f11525f5b04712cc1bab Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
parent
951990255e
commit
f5b98f6386
|
@ -229,7 +229,7 @@ void __qmljs_llvm_call_activation_property(Context *context, Value *result, Stri
|
|||
void __qmljs_llvm_call_value(Context *context, Value *result, const Value *thisObject, const Value *func, Value *args, int argc)
|
||||
{
|
||||
Value that = thisObject ? *thisObject : Value::undefinedValue();
|
||||
*result = __qmljs_call_value(context, that, func, args, argc);
|
||||
*result = __qmljs_call_value(context, that, *func, args, argc);
|
||||
}
|
||||
|
||||
void __qmljs_llvm_construct_activation_property(Context *context, Value *result, String *name, Value *args, int argc)
|
||||
|
|
|
@ -133,7 +133,7 @@ void VME::operator()(QQmlJS::VM::Context *context, const uchar *code
|
|||
|
||||
MOTH_BEGIN_INSTR(Call)
|
||||
VM::Value *args = stack.data() + instr.args;
|
||||
tempRegister = __qmljs_call_value(context, VM::Value::undefinedValue(), &tempRegister, args, instr.argc);
|
||||
tempRegister = __qmljs_call_value(context, VM::Value::undefinedValue(), tempRegister, args, instr.argc);
|
||||
MOTH_END_INSTR(Call)
|
||||
|
||||
MOTH_BEGIN_INSTR(Jump)
|
||||
|
|
|
@ -809,14 +809,14 @@ Value __qmljs_object_default_value(Context *ctx, const Value object, int typeHin
|
|||
|
||||
Value conv = oo->getProperty(ctx, meth1);
|
||||
if (!conv.isUndefined() && conv.isFunctionObject()) {
|
||||
Value r = __qmljs_call_value(ctx, object, &conv, 0, 0);
|
||||
Value r = __qmljs_call_value(ctx, object, conv, 0, 0);
|
||||
if (r.isPrimitive())
|
||||
return r;
|
||||
}
|
||||
|
||||
conv = oo->getProperty(ctx, meth2);
|
||||
if (!conv.isUndefined() && conv.isFunctionObject()) {
|
||||
Value r = __qmljs_call_value(ctx, object, &conv, 0, 0);
|
||||
Value r = __qmljs_call_value(ctx, object, conv, 0, 0);
|
||||
if (r.isPrimitive())
|
||||
return r;
|
||||
}
|
||||
|
@ -1074,7 +1074,7 @@ Value __qmljs_call_activation_property(Context *context, String *name, Value *ar
|
|||
context->throwReferenceError(Value::fromString(name));
|
||||
return Value::undefinedValue();
|
||||
}
|
||||
Value result = __qmljs_call_value(context, Value::undefinedValue(), func, args, argc);
|
||||
Value result = __qmljs_call_value(context, Value::undefinedValue(), *func, args, argc);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1111,10 +1111,10 @@ Value __qmljs_call_property(Context *context, const Value base, String *name, Va
|
|||
return result;
|
||||
}
|
||||
|
||||
Value __qmljs_call_value(Context *context, const Value thisObject, const Value *func, Value *args, int argc)
|
||||
Value __qmljs_call_value(Context *context, const Value thisObject, const Value func, Value *args, int argc)
|
||||
{
|
||||
Value result;
|
||||
if (FunctionObject *f = func->asFunctionObject()) {
|
||||
if (FunctionObject *f = func.asFunctionObject()) {
|
||||
Context k;
|
||||
Context *ctx = f->needsActivation ? context->engine->newContext() : &k;
|
||||
const Value *that = thisObject.isUndefined() ? 0 : &thisObject;
|
||||
|
|
|
@ -93,7 +93,7 @@ extern "C" {
|
|||
// context
|
||||
Value __qmljs_call_activation_property(Context *, String *name, Value *args, int argc);
|
||||
Value __qmljs_call_property(Context *context, const Value base, String *name, Value *args, int argc);
|
||||
Value __qmljs_call_value(Context *context, const Value thisObject, const Value *func, Value *args, int argc);
|
||||
Value __qmljs_call_value(Context *context, const Value thisObject, const Value func, Value *args, int argc);
|
||||
|
||||
Value __qmljs_construct_activation_property(Context *, String *name, Value *args, int argc);
|
||||
Value __qmljs_construct_property(Context *context, const Value base, String *name, Value *args, int argc);
|
||||
|
|
|
@ -53,7 +53,7 @@ bool ArrayElementLessThan::operator()(const Value &v1, const Value &v2) const
|
|||
return true;
|
||||
if (!m_comparefn.isUndefined()) {
|
||||
Value args[] = { v1, v2 };
|
||||
Value result = __qmljs_call_value(m_context, Value::undefinedValue(), &m_comparefn, args, 2);
|
||||
Value result = __qmljs_call_value(m_context, Value::undefinedValue(), m_comparefn, args, 2);
|
||||
return result.toNumber(m_context) <= 0;
|
||||
}
|
||||
return v1.toString(m_context)->toQString() < v2.toString(m_context)->toQString();
|
||||
|
|
|
@ -1548,7 +1548,7 @@ void ArrayPrototype::method_every(Context *ctx)
|
|||
args[0] = v;
|
||||
args[1] = Value::fromDouble(k);
|
||||
args[2] = ctx->thisObject;
|
||||
Value r = __qmljs_call_value(ctx, thisArg, &callback, args, 3);
|
||||
Value r = __qmljs_call_value(ctx, thisArg, callback, args, 3);
|
||||
ok = __qmljs_to_boolean(r, ctx);
|
||||
}
|
||||
ctx->result = Value::fromBoolean(ok);
|
||||
|
@ -1577,7 +1577,7 @@ void ArrayPrototype::method_some(Context *ctx)
|
|||
args[0] = v;
|
||||
args[1] = Value::fromDouble(k);
|
||||
args[2] = ctx->thisObject;
|
||||
Value r = __qmljs_call_value(ctx, thisArg, &callback, args, 3);
|
||||
Value r = __qmljs_call_value(ctx, thisArg, callback, args, 3);
|
||||
ok = __qmljs_to_boolean(r, ctx);
|
||||
}
|
||||
ctx->result = Value::fromBoolean(ok);
|
||||
|
@ -1606,7 +1606,7 @@ void ArrayPrototype::method_forEach(Context *ctx)
|
|||
args[0] = v;
|
||||
args[1] = Value::fromDouble(k);
|
||||
args[2] = ctx->thisObject;
|
||||
Value r = __qmljs_call_value(ctx, thisArg, &callback, args, 3);
|
||||
Value r = __qmljs_call_value(ctx, thisArg, callback, args, 3);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1633,7 +1633,7 @@ void ArrayPrototype::method_map(Context *ctx)
|
|||
args[0] = v;
|
||||
args[1] = Value::fromDouble(k);
|
||||
args[2] = ctx->thisObject;
|
||||
Value r = __qmljs_call_value(ctx, thisArg, &callback, args, 3);
|
||||
Value r = __qmljs_call_value(ctx, thisArg, callback, args, 3);
|
||||
a->value.assign(k, r);
|
||||
}
|
||||
ctx->result = Value::fromObject(a);
|
||||
|
@ -1661,7 +1661,7 @@ void ArrayPrototype::method_filter(Context *ctx)
|
|||
args[0] = v;
|
||||
args[1] = Value::fromDouble(k);
|
||||
args[2] = ctx->thisObject;
|
||||
Value r = __qmljs_call_value(ctx, thisArg, &callback, args, 3);
|
||||
Value r = __qmljs_call_value(ctx, thisArg, callback, args, 3);
|
||||
if (__qmljs_to_boolean(r, ctx)) {
|
||||
const uint index = a->value.size();
|
||||
a->value.resize(index + 1);
|
||||
|
@ -1697,7 +1697,7 @@ void ArrayPrototype::method_reduce(Context *ctx)
|
|||
args[1] = v;
|
||||
args[2] = Value::fromDouble(k);
|
||||
args[3] = ctx->thisObject;
|
||||
Value r = __qmljs_call_value(ctx, Value::undefinedValue(), &callback, args, 4);
|
||||
Value r = __qmljs_call_value(ctx, Value::undefinedValue(), callback, args, 4);
|
||||
acc = r;
|
||||
}
|
||||
ctx->result = acc;
|
||||
|
@ -1728,7 +1728,7 @@ void ArrayPrototype::method_reduceRight(Context *ctx)
|
|||
args[1] = v;
|
||||
args[2] = Value::fromDouble(k);
|
||||
args[3] = ctx->thisObject;
|
||||
Value r = __qmljs_call_value(ctx, Value::undefinedValue(), &callback, args, 4);
|
||||
Value r = __qmljs_call_value(ctx, Value::undefinedValue(), callback, args, 4);
|
||||
acc = r;
|
||||
}
|
||||
ctx->result = acc;
|
||||
|
@ -1798,7 +1798,7 @@ void FunctionPrototype::method_apply(Context *ctx)
|
|||
return;
|
||||
}
|
||||
|
||||
ctx->result = __qmljs_call_value(ctx, thisObject, &ctx->thisObject, args.data(), args.size());
|
||||
ctx->result = __qmljs_call_value(ctx, thisObject, ctx->thisObject, args.data(), args.size());
|
||||
} else {
|
||||
ctx->throwTypeError();
|
||||
}
|
||||
|
@ -1812,7 +1812,7 @@ void FunctionPrototype::method_call(Context *ctx)
|
|||
QVector<Value> args(ctx->argumentCount ? ctx->argumentCount - 1 : 0);
|
||||
if (ctx->argumentCount)
|
||||
qCopy(ctx->arguments + 1, ctx->arguments + ctx->argumentCount, args.begin());
|
||||
ctx->result = __qmljs_call_value(ctx, thisArg, &ctx->thisObject, args.data(), args.size());
|
||||
ctx->result = __qmljs_call_value(ctx, thisArg, ctx->thisObject, args.data(), args.size());
|
||||
} else {
|
||||
ctx->throwTypeError();
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ void InstructionSelection::callValue(IR::Call *call, IR::Temp *result)
|
|||
|
||||
int argc = prepareVariableArguments(call->args);
|
||||
IR::Temp* thisObject = 0;
|
||||
generateFunctionCall2(result, __qmljs_call_value, ContextRegister, baseTemp, thisObject, baseAddressForCallArguments(), TrustedImm32(argc));
|
||||
generateFunctionCall2(result, __qmljs_call_value, ContextRegister, thisObject, baseTemp, baseAddressForCallArguments(), TrustedImm32(argc));
|
||||
checkExceptions();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue