From eec7ea703caf37db4ae1801f5ea016fd3cf8b221 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 13 Feb 2013 22:13:53 +0100 Subject: [PATCH] Convert post inc/dev operators to new calling convention Change-Id: Idbfa6852d308337076a1aa18cdeb43460fb5bed6 Reviewed-by: Simon Hausmann --- src/v4/moth/qv4vme_moth.cpp | 16 ++-- src/v4/qmljs_runtime.cpp | 100 +++++++++++++------------ src/v4/qmljs_runtime.h | 179 ++++++++++++++++++++++---------------------- src/v4/qv4codegen.cpp | 4 +- src/v4/qv4isel_masm.cpp | 32 +++++--- 5 files changed, 172 insertions(+), 159 deletions(-) diff --git a/src/v4/moth/qv4vme_moth.cpp b/src/v4/moth/qv4vme_moth.cpp index 880f2f3..0dbaee6 100644 --- a/src/v4/moth/qv4vme_moth.cpp +++ b/src/v4/moth/qv4vme_moth.cpp @@ -328,35 +328,35 @@ VM::Value VME::operator()(QQmlJS::VM::ExecutionContext *context, const uchar *co MOTH_END_INSTR(CallBuiltinTypeofValue) MOTH_BEGIN_INSTR(CallBuiltinPostIncMember) - VALUE(instr.result) = __qmljs_builtin_post_increment_member(VALUE(instr.base), instr.member, context); + __qmljs_builtin_post_increment_member(context, VALUEPTR(instr.result), VALUEPTR(instr.base), instr.member); MOTH_END_INSTR(CallBuiltinTypeofMember) MOTH_BEGIN_INSTR(CallBuiltinPostIncSubscript) - VALUE(instr.result) = __qmljs_builtin_post_increment_element(VALUE(instr.base), VALUE(instr.index), context); + __qmljs_builtin_post_increment_element(context, VALUEPTR(instr.result), VALUEPTR(instr.base), VALUEPTR(instr.index)); MOTH_END_INSTR(CallBuiltinTypeofSubscript) MOTH_BEGIN_INSTR(CallBuiltinPostIncName) - VALUE(instr.result) = __qmljs_builtin_post_increment_name(instr.name, context); + __qmljs_builtin_post_increment_name(context, VALUEPTR(instr.result), instr.name); MOTH_END_INSTR(CallBuiltinTypeofName) MOTH_BEGIN_INSTR(CallBuiltinPostIncValue) - VALUE(instr.result) = __qmljs_builtin_post_increment(VALUEPTR(instr.value), context); + __qmljs_builtin_post_increment(context, VALUEPTR(instr.result), VALUEPTR(instr.value)); MOTH_END_INSTR(CallBuiltinTypeofValue) MOTH_BEGIN_INSTR(CallBuiltinPostDecMember) - VALUE(instr.result) = __qmljs_builtin_post_decrement_member(VALUE(instr.base), instr.member, context); + __qmljs_builtin_post_decrement_member(context, VALUEPTR(instr.result), VALUEPTR(instr.base), instr.member); MOTH_END_INSTR(CallBuiltinTypeofMember) MOTH_BEGIN_INSTR(CallBuiltinPostDecSubscript) - VALUE(instr.result) = __qmljs_builtin_post_decrement_element(VALUE(instr.base), VALUE(instr.index), context); + __qmljs_builtin_post_decrement_element(context, VALUEPTR(instr.result), VALUEPTR(instr.base), VALUEPTR(instr.index)); MOTH_END_INSTR(CallBuiltinTypeofSubscript) MOTH_BEGIN_INSTR(CallBuiltinPostDecName) - VALUE(instr.result) = __qmljs_builtin_post_decrement_name(instr.name, context); + __qmljs_builtin_post_decrement_name(context, VALUEPTR(instr.result), instr.name); MOTH_END_INSTR(CallBuiltinTypeofName) MOTH_BEGIN_INSTR(CallBuiltinPostDecValue) - VALUE(instr.result) = __qmljs_builtin_post_decrement(VALUEPTR(instr.value), context); + __qmljs_builtin_post_decrement(context, VALUEPTR(instr.result), VALUEPTR(instr.value)); MOTH_END_INSTR(CallBuiltinTypeofValue) MOTH_BEGIN_INSTR(CallBuiltinDeclareVar) diff --git a/src/v4/qmljs_runtime.cpp b/src/v4/qmljs_runtime.cpp index 200388f..b00d340 100644 --- a/src/v4/qmljs_runtime.cpp +++ b/src/v4/qmljs_runtime.cpp @@ -1041,160 +1041,164 @@ Value __qmljs_builtin_typeof_element(Value base, Value index, ExecutionContext * return __qmljs_builtin_typeof(obj.objectValue()->__get__(context, name), context); } -Value __qmljs_builtin_post_increment(Value *val, ExecutionContext *ctx) +void __qmljs_builtin_post_increment(ExecutionContext *ctx, Value *result, Value *val) { if (val->isInteger() && val->integerValue() < INT_MAX) { - Value retval = *val; + if (result) + *result = *val; val->int_32 += 1; - return retval; + return; } double d = __qmljs_to_number(*val, ctx); *val = Value::fromDouble(d + 1); - return Value::fromDouble(d); + if (result) + *result = Value::fromDouble(d); } -Value __qmljs_builtin_post_increment_name(String *name, ExecutionContext *context) +void __qmljs_builtin_post_increment_name(ExecutionContext *context, Value *result, String *name) { Value v = context->getProperty(name); - Value retval; if (v.isInteger() && v.integerValue() < INT_MAX) { - retval = v; + if (result) + *result = v; v.int_32 += 1; } else { double d = __qmljs_to_number(v, context); - retval = Value::fromDouble(d); + if (result) + *result = Value::fromDouble(d); v = Value::fromDouble(d + 1); } context->setProperty(name, v); - return retval; } -Value __qmljs_builtin_post_increment_member(Value base, String *name, ExecutionContext *context) +void __qmljs_builtin_post_increment_member(ExecutionContext *context, Value *result, const Value *base, String *name) { - Object *o = __qmljs_to_object(base, context).objectValue(); + Object *o = __qmljs_to_object(*base, context).objectValue(); Value v = o->__get__(context, name); - Value retval; if (v.isInteger() && v.integerValue() < INT_MAX) { - retval = v; + if (result) + *result = v; v.int_32 += 1; } else { double d = __qmljs_to_number(v, context); - retval = Value::fromDouble(d); + if (result) + *result = Value::fromDouble(d); v = Value::fromDouble(d + 1); } o->__put__(context, name, v); - return retval; } -Value __qmljs_builtin_post_increment_element(Value base, Value index, ExecutionContext *context) +void __qmljs_builtin_post_increment_element(ExecutionContext *context, Value *result, const Value *base, const Value *index) { - Object *o = __qmljs_to_object(base, context).objectValue(); + Object *o = __qmljs_to_object(*base, context).objectValue(); - uint idx = index.asArrayIndex(); + uint idx = index->asArrayIndex(); if (idx == UINT_MAX) { - String *s = index.toString(context); - return __qmljs_builtin_post_increment_member(base, s, context); + String *s = index->toString(context); + return __qmljs_builtin_post_increment_member(context, result, base, s); } Value v = o->__get__(context, idx); - Value retval; if (v.isInteger() && v.integerValue() < INT_MAX) { - retval = v; + if (result) + *result = v; v.int_32 += 1; } else { double d = __qmljs_to_number(v, context); - retval = Value::fromDouble(d); + if (result) + *result = Value::fromDouble(d); v = Value::fromDouble(d + 1); } o->__put__(context, idx, v); - return retval; } -Value __qmljs_builtin_post_decrement(Value *val, ExecutionContext *ctx) +void __qmljs_builtin_post_decrement(ExecutionContext *ctx, Value *result, Value *val) { if (val->isInteger() && val->integerValue() > INT_MIN) { - Value retval = *val; + if (result) + *result = *val; val->int_32 -= 1; - return retval; + return; } double d = __qmljs_to_number(*val, ctx); *val = Value::fromDouble(d - 1); - return Value::fromDouble(d); + if (result) + *result = Value::fromDouble(d); } -Value __qmljs_builtin_post_decrement_name(String *name, ExecutionContext *context) +void __qmljs_builtin_post_decrement_name(ExecutionContext *context, Value *result, String *name) { Value v = context->getProperty(name); - Value retval; if (v.isInteger() && v.integerValue() > INT_MIN) { - retval = v; + if (result) + *result = v; v.int_32 -= 1; } else { double d = __qmljs_to_number(v, context); - retval = Value::fromDouble(d); + if (result) + *result = Value::fromDouble(d); v = Value::fromDouble(d - 1); } context->setProperty(name, v); - return retval; } -Value __qmljs_builtin_post_decrement_member(Value base, String *name, ExecutionContext *context) +void __qmljs_builtin_post_decrement_member(ExecutionContext *context, Value *result, const Value *base, String *name) { - Object *o = __qmljs_to_object(base, context).objectValue(); + Object *o = __qmljs_to_object(*base, context).objectValue(); Value v = o->__get__(context, name); - Value retval; if (v.isInteger() && v.integerValue() > INT_MIN) { - retval = v; + if (result) + *result = v; v.int_32 -= 1; } else { double d = __qmljs_to_number(v, context); - retval = Value::fromDouble(d); + if (result) + *result = Value::fromDouble(d); v = Value::fromDouble(d - 1); } o->__put__(context, name, v); - return retval; } -Value __qmljs_builtin_post_decrement_element(Value base, Value index, ExecutionContext *context) +void __qmljs_builtin_post_decrement_element(ExecutionContext *context, Value *result, const Value *base, const Value *index) { - Object *o = __qmljs_to_object(base, context).objectValue(); + Object *o = __qmljs_to_object(*base, context).objectValue(); - uint idx = index.asArrayIndex(); + uint idx = index->asArrayIndex(); if (idx == UINT_MAX) { - String *s = index.toString(context); - return __qmljs_builtin_post_decrement_member(base, s, context); + String *s = index->toString(context); + return __qmljs_builtin_post_decrement_member(context, result, base, s); } Value v = o->__get__(context, idx); - Value retval; if (v.isInteger() && v.integerValue() > INT_MIN) { - retval = v; + if (result) + *result = v; v.int_32 -= 1; } else { double d = __qmljs_to_number(v, context); - retval = Value::fromDouble(d); + if (result) + *result = Value::fromDouble(d); v = Value::fromDouble(d - 1); } o->__put__(context, idx, v); - return retval; } void __qmljs_builtin_throw(Value val, ExecutionContext *context) diff --git a/src/v4/qmljs_runtime.h b/src/v4/qmljs_runtime.h index f47c6e6..7dcba81 100644 --- a/src/v4/qmljs_runtime.h +++ b/src/v4/qmljs_runtime.h @@ -106,15 +106,15 @@ Value __qmljs_builtin_typeof_name(String *name, ExecutionContext *context); Value __qmljs_builtin_typeof_member(Value base, String *name, ExecutionContext *context); Value __qmljs_builtin_typeof_element(Value base, Value index, ExecutionContext *context); -Value __qmljs_builtin_post_increment(Value *val, ExecutionContext *ctx); -Value __qmljs_builtin_post_increment_name(String *name, ExecutionContext *context); -Value __qmljs_builtin_post_increment_member(Value base, String *name, ExecutionContext *context); -Value __qmljs_builtin_post_increment_element(Value base, Value index, ExecutionContext *context); +void __qmljs_builtin_post_increment(ExecutionContext *ctx, Value *result, Value *val); +void __qmljs_builtin_post_increment_name(ExecutionContext *context, Value *result, String *name); +void __qmljs_builtin_post_increment_member(ExecutionContext *context, Value *result, const Value *base, String *name); +void __qmljs_builtin_post_increment_element(ExecutionContext *context, Value *result, const Value *base, const Value *index); -Value __qmljs_builtin_post_decrement(Value *val, ExecutionContext *ctx); -Value __qmljs_builtin_post_decrement_name(String *name, ExecutionContext *context); -Value __qmljs_builtin_post_decrement_member(Value base, String *name, ExecutionContext *context); -Value __qmljs_builtin_post_decrement_element(Value base, Value index, ExecutionContext *context); +void __qmljs_builtin_post_decrement(ExecutionContext *ctx, Value *result, Value *val); +void __qmljs_builtin_post_decrement_name(ExecutionContext *context, Value *result, String *name); +void __qmljs_builtin_post_decrement_member(ExecutionContext *context, Value *result, const Value *base, String *name); +void __qmljs_builtin_post_decrement_element(ExecutionContext *context, Value *result, const Value *base, const Value *index); void __qmljs_builtin_throw(Value val, ExecutionContext *context); void __qmljs_builtin_rethrow(ExecutionContext *context); @@ -285,16 +285,17 @@ void __qmljs_inplace_shl_member(ExecutionContext *ctx, const Value *base, String void __qmljs_inplace_shr_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs); void __qmljs_inplace_ushr_member(ExecutionContext *ctx, const Value *base, String *name, const Value *rhs); -Bool __qmljs_cmp_gt(Value left, Value right, ExecutionContext *ctx); -Bool __qmljs_cmp_lt(Value left, Value right, ExecutionContext *ctx); -Bool __qmljs_cmp_ge(Value left, Value right, ExecutionContext *ctx); -Bool __qmljs_cmp_le(Value left, Value right, ExecutionContext *ctx); -Bool __qmljs_cmp_eq(Value left, Value right, ExecutionContext *ctx); -Bool __qmljs_cmp_ne(Value left, Value right, ExecutionContext *ctx); -Bool __qmljs_cmp_se(Value left, Value right, ExecutionContext *ctx); -Bool __qmljs_cmp_sne(Value left, Value right, ExecutionContext *ctx); -Bool __qmljs_cmp_instanceof(Value left, Value right, ExecutionContext *ctx); -Bool __qmljs_cmp_in(Value left, Value right, ExecutionContext *ctx); +typedef Bool (*CmpOp)(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_le(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_eq(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_ne(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_se(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_sne(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_instanceof(ExecutionContext *ctx, const Value *left, const Value *right); +Bool __qmljs_cmp_in(ExecutionContext *ctx, const Value *left, const Value *right); // type conversion and testing inline Value __qmljs_to_primitive(Value value, ExecutionContext *ctx, int typeHint) @@ -690,42 +691,42 @@ inline void __qmljs_gt(ExecutionContext *ctx, Value *result, const Value *left, { TRACE2(left, right); - *result = Value::fromBoolean(__qmljs_cmp_gt(*left, *right, ctx)); + *result = Value::fromBoolean(__qmljs_cmp_gt(ctx, left, right)); } inline void __qmljs_lt(ExecutionContext *ctx, Value *result, const Value *left, const Value *right) { TRACE2(left, right); - *result = Value::fromBoolean(__qmljs_cmp_lt(*left, *right, ctx)); + *result = Value::fromBoolean(__qmljs_cmp_lt(ctx, left, right)); } inline void __qmljs_ge(ExecutionContext *ctx, Value *result, const Value *left, const Value *right) { TRACE2(left, right); - *result = Value::fromBoolean(__qmljs_cmp_ge(*left, *right, ctx)); + *result = Value::fromBoolean(__qmljs_cmp_ge(ctx, left, right)); } inline void __qmljs_le(ExecutionContext *ctx, Value *result, const Value *left, const Value *right) { TRACE2(left, right); - *result = Value::fromBoolean(__qmljs_cmp_le(*left, *right, ctx)); + *result = Value::fromBoolean(__qmljs_cmp_le(ctx, left, right)); } inline void __qmljs_eq(ExecutionContext *ctx, Value *result, const Value *left, const Value *right) { TRACE2(left, right); - *result = Value::fromBoolean(__qmljs_cmp_eq(*left, *right, ctx)); + *result = Value::fromBoolean(__qmljs_cmp_eq(ctx, left, right)); } inline void __qmljs_ne(ExecutionContext *ctx, Value *result, const Value *left, const Value *right) { TRACE2(left, right); - *result = Value::fromBoolean(!__qmljs_cmp_eq(*left, *right, ctx)); + *result = Value::fromBoolean(!__qmljs_cmp_eq(ctx, left, right)); } inline void __qmljs_se(ExecutionContext *, Value *result, const Value *left, const Value *right) @@ -744,137 +745,137 @@ inline void __qmljs_sne(ExecutionContext *, Value *result, const Value *left, co *result = Value::fromBoolean(r); } -inline Bool __qmljs_cmp_gt(Value left, Value right, ExecutionContext *ctx) +inline Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value *left, const Value *right) { TRACE2(left, right); - left = __qmljs_to_primitive(left, ctx, NUMBER_HINT); - right = __qmljs_to_primitive(right, ctx, NUMBER_HINT); + Value l = __qmljs_to_primitive(*left, ctx, NUMBER_HINT); + Value r = __qmljs_to_primitive(*right, ctx, NUMBER_HINT); - if (Value::integerCompatible(left, right)) - return left.integerValue() > right.integerValue(); - if (Value::bothDouble(left, right)) { - return left.doubleValue() > right.doubleValue(); - } else if (left.isString() && right.isString()) { - return __qmljs_string_compare(ctx, right.stringValue(), left.stringValue()); + if (Value::integerCompatible(l, r)) + return l.integerValue() > r.integerValue(); + if (Value::bothDouble(l, r)) { + return l.doubleValue() > r.doubleValue(); + } else if (l.isString() && r.isString()) { + return __qmljs_string_compare(ctx, r.stringValue(), l.stringValue()); } else { - double l = __qmljs_to_number(left, ctx); - double r = __qmljs_to_number(right, ctx); - return l > r; + double dl = __qmljs_to_number(l, ctx); + double dr = __qmljs_to_number(r, ctx); + return dl > dr; } } -inline Bool __qmljs_cmp_lt(Value left, Value right, ExecutionContext *ctx) +inline Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value *left, const Value *right) { TRACE2(left, right); - left = __qmljs_to_primitive(left, ctx, NUMBER_HINT); - right = __qmljs_to_primitive(right, ctx, NUMBER_HINT); + Value l = __qmljs_to_primitive(*left, ctx, NUMBER_HINT); + Value r = __qmljs_to_primitive(*right, ctx, NUMBER_HINT); - if (Value::integerCompatible(left, right)) - return left.integerValue() < right.integerValue(); - if (Value::bothDouble(left, right)) { - return left.doubleValue() < right.doubleValue(); - } else if (left.isString() && right.isString()) { - return __qmljs_string_compare(ctx, left.stringValue(), right.stringValue()); + if (Value::integerCompatible(l, r)) + return l.integerValue() < r.integerValue(); + if (Value::bothDouble(l, r)) { + return l.doubleValue() < r.doubleValue(); + } else if (l.isString() && r.isString()) { + return __qmljs_string_compare(ctx, l.stringValue(), r.stringValue()); } else { - double l = __qmljs_to_number(left, ctx); - double r = __qmljs_to_number(right, ctx); - return l < r; + double dl = __qmljs_to_number(l, ctx); + double dr = __qmljs_to_number(r, ctx); + return dl < dr; } } -inline Bool __qmljs_cmp_ge(Value left, Value right, ExecutionContext *ctx) +inline Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value *left, const Value *right) { TRACE2(left, right); - left = __qmljs_to_primitive(left, ctx, NUMBER_HINT); - right = __qmljs_to_primitive(right, ctx, NUMBER_HINT); + Value l = __qmljs_to_primitive(*left, ctx, NUMBER_HINT); + Value r = __qmljs_to_primitive(*right, ctx, NUMBER_HINT); - if (Value::integerCompatible(left, right)) - return left.integerValue() >= right.integerValue(); - if (Value::bothDouble(left, right)) { - return left.doubleValue() >= right.doubleValue(); - } else if (left.isString() && right.isString()) { - return !__qmljs_string_compare(ctx, left.stringValue(), right.stringValue()); + if (Value::integerCompatible(l, r)) + return l.integerValue() >= r.integerValue(); + if (Value::bothDouble(l, r)) { + return l.doubleValue() >= r.doubleValue(); + } else if (l.isString() && r.isString()) { + return !__qmljs_string_compare(ctx, l.stringValue(), r.stringValue()); } else { - double l = __qmljs_to_number(left, ctx); - double r = __qmljs_to_number(right, ctx); - return l >= r; + double dl = __qmljs_to_number(l, ctx); + double dr = __qmljs_to_number(r, ctx); + return dl >= dr; } } -inline Bool __qmljs_cmp_le(Value left, Value right, ExecutionContext *ctx) +inline Bool __qmljs_cmp_le(ExecutionContext *ctx, const Value *left, const Value *right) { TRACE2(left, right); - left = __qmljs_to_primitive(left, ctx, NUMBER_HINT); - right = __qmljs_to_primitive(right, ctx, NUMBER_HINT); + Value l = __qmljs_to_primitive(*left, ctx, NUMBER_HINT); + Value r = __qmljs_to_primitive(*right, ctx, NUMBER_HINT); - if (Value::integerCompatible(left, right)) - return left.integerValue() <= right.integerValue(); - if (Value::bothDouble(left, right)) { - return left.doubleValue() <= right.doubleValue(); - } else if (left.isString() && right.isString()) { - return !__qmljs_string_compare(ctx, right.stringValue(), left.stringValue()); + if (Value::integerCompatible(l, r)) + return l.integerValue() <= r.integerValue(); + if (Value::bothDouble(l, r)) { + return l.doubleValue() <= r.doubleValue(); + } else if (l.isString() && r.isString()) { + return !__qmljs_string_compare(ctx, r.stringValue(), l.stringValue()); } else { - double l = __qmljs_to_number(left, ctx); - double r = __qmljs_to_number(right, ctx); - return l <= r; + double dl = __qmljs_to_number(l, ctx); + double dr = __qmljs_to_number(r, ctx); + return dl <= dr; } } -inline Bool __qmljs_cmp_eq(Value left, Value right, ExecutionContext *ctx) +inline Bool __qmljs_cmp_eq(ExecutionContext *ctx, const Value *left, const Value *right) { TRACE2(left, right); // need to test for doubles first as NaN != NaN - if (Value::bothDouble(left, right)) - return left.doubleValue() == right.doubleValue(); - if (left.val == right.val) + if (Value::bothDouble(*left, *right)) + return left->doubleValue() == right->doubleValue(); + if (left->val == right->val) return true; - if (left.isString() && right.isString()) - return __qmljs_string_equal(left.stringValue(), right.stringValue()); + if (left->isString() && right->isString()) + return __qmljs_string_equal(left->stringValue(), right->stringValue()); - return __qmljs_equal(left, right, ctx); + return __qmljs_equal(*left, *right, ctx); } -inline Bool __qmljs_cmp_ne(Value left, Value right, ExecutionContext *ctx) +inline Bool __qmljs_cmp_ne(ExecutionContext *ctx, const Value *left, const Value *right) { TRACE2(left, right); - return !__qmljs_cmp_eq(left, right, ctx); + return !__qmljs_cmp_eq(ctx, left, right); } -inline Bool __qmljs_cmp_se(Value left, Value right, ExecutionContext *) +inline Bool __qmljs_cmp_se(ExecutionContext *, const Value *left, const Value *right) { TRACE2(left, right); - return __qmljs_strict_equal(left, right); + return __qmljs_strict_equal(*left, *right); } -inline Bool __qmljs_cmp_sne(Value left, Value right, ExecutionContext *) +inline Bool __qmljs_cmp_sne(ExecutionContext *, const Value *left, const Value *right) { TRACE2(left, right); - return ! __qmljs_strict_equal(left, right); + return ! __qmljs_strict_equal(*left, *right); } -inline Bool __qmljs_cmp_instanceof(Value left, Value right, ExecutionContext *ctx) +inline Bool __qmljs_cmp_instanceof(ExecutionContext *ctx, const Value *left, const Value *right) { TRACE2(left, right); Value v; - __qmljs_instanceof(ctx, &v, &left, &right); + __qmljs_instanceof(ctx, &v, left, right); return v.booleanValue(); } -inline uint __qmljs_cmp_in(Value left, Value right, ExecutionContext *ctx) +inline uint __qmljs_cmp_in(ExecutionContext *ctx, const Value *left, const Value *right) { TRACE2(left, right); Value v; - __qmljs_in(ctx, &v, &left, &right); + __qmljs_in(ctx, &v, left, right); return v.booleanValue(); } diff --git a/src/v4/qv4codegen.cpp b/src/v4/qv4codegen.cpp index d82f1b1..4ad7b69 100644 --- a/src/v4/qv4codegen.cpp +++ b/src/v4/qv4codegen.cpp @@ -695,8 +695,8 @@ IR::Expr *Codegen::binop(IR::AluOp op, IR::Expr *left, IR::Expr *right) right = _block->TEMP(t); } - assert(left->asTemp() || left->asConst()); - assert(right->asTemp() || right->asConst()); + assert(left->asTemp()); + assert(right->asTemp()); return _block->BINOP(op, left, right); } diff --git a/src/v4/qv4isel_masm.cpp b/src/v4/qv4isel_masm.cpp index 1378b3d..6cc798a 100644 --- a/src/v4/qv4isel_masm.cpp +++ b/src/v4/qv4isel_masm.cpp @@ -520,42 +520,50 @@ void InstructionSelection::callBuiltinDeleteValue(IR::Temp *result) void InstructionSelection::callBuiltinPostIncrementMember(IR::Temp *base, const QString &name, IR::Temp *result) { - generateFunctionCall(result, __qmljs_builtin_post_increment_member, base, identifier(name), Assembler::ContextRegister); + generateFunctionCall(Assembler::Void, __qmljs_builtin_post_increment_member, Assembler::ContextRegister, + Assembler::PointerToValue(result), Assembler::PointerToValue(base), identifier(name)); } void InstructionSelection::callBuiltinPostIncrementSubscript(IR::Temp *base, IR::Temp *index, IR::Temp *result) { - generateFunctionCall(result, __qmljs_builtin_post_increment_element, base, index, Assembler::ContextRegister); + generateFunctionCall(Assembler::Void, __qmljs_builtin_post_increment_element, Assembler::ContextRegister, + Assembler::PointerToValue(result), Assembler::PointerToValue(base), Assembler::PointerToValue(index)); } void InstructionSelection::callBuiltinPostIncrementName(const QString &name, IR::Temp *result) { - generateFunctionCall(result, __qmljs_builtin_post_increment_name, identifier(name), Assembler::ContextRegister); + generateFunctionCall(Assembler::Void, __qmljs_builtin_post_increment_name, Assembler::ContextRegister, + Assembler::PointerToValue(result), identifier(name)); } void InstructionSelection::callBuiltinPostIncrementValue(IR::Temp *value, IR::Temp *result) { - generateFunctionCall(result, __qmljs_builtin_post_increment, Assembler::PointerToValue(value), Assembler::ContextRegister); + generateFunctionCall(Assembler::Void, __qmljs_builtin_post_increment, Assembler::ContextRegister, + Assembler::PointerToValue(result), Assembler::PointerToValue(value)); } void InstructionSelection::callBuiltinPostDecrementMember(IR::Temp *base, const QString &name, IR::Temp *result) { - generateFunctionCall(result, __qmljs_builtin_post_decrement_member, base, identifier(name), Assembler::ContextRegister); + generateFunctionCall(Assembler::Void, __qmljs_builtin_post_decrement_member, Assembler::ContextRegister, + Assembler::PointerToValue(result), Assembler::PointerToValue(base), identifier(name)); } void InstructionSelection::callBuiltinPostDecrementSubscript(IR::Temp *base, IR::Temp *index, IR::Temp *result) { - generateFunctionCall(result, __qmljs_builtin_post_decrement_element, base, index, Assembler::ContextRegister); + generateFunctionCall(Assembler::Void, __qmljs_builtin_post_decrement_element, Assembler::ContextRegister, + Assembler::PointerToValue(result), Assembler::PointerToValue(base), Assembler::PointerToValue(index)); } void InstructionSelection::callBuiltinPostDecrementName(const QString &name, IR::Temp *result) { - generateFunctionCall(result, __qmljs_builtin_post_decrement_name, identifier(name), Assembler::ContextRegister); + generateFunctionCall(Assembler::Void, __qmljs_builtin_post_decrement_name, Assembler::ContextRegister, + Assembler::PointerToValue(result), identifier(name)); } void InstructionSelection::callBuiltinPostDecrementValue(IR::Temp *value, IR::Temp *result) { - generateFunctionCall(result, __qmljs_builtin_post_decrement, Assembler::PointerToValue(value), Assembler::ContextRegister); + generateFunctionCall(Assembler::Void, __qmljs_builtin_post_decrement, Assembler::ContextRegister, + Assembler::PointerToValue(result), Assembler::PointerToValue(value)); } void InstructionSelection::callBuiltinThrow(IR::Temp *arg) @@ -927,9 +935,8 @@ void InstructionSelection::visitCJump(IR::CJump *s) _as->jumpToBlock(_block, s->iffalse); return; } else if (IR::Binop *b = s->cond->asBinop()) { - if ((b->left->asTemp() || b->left->asConst()) && - (b->right->asTemp() || b->right->asConst())) { - Bool (*op)(const Value, const Value, ExecutionContext *ctx) = 0; + if (b->left->asTemp() && b->right->asTemp()) { + VM::CmpOp op = 0; const char *opName = 0; switch (b->op) { default: Q_UNREACHABLE(); assert(!"todo"); break; @@ -945,7 +952,8 @@ void InstructionSelection::visitCJump(IR::CJump *s) case IR::OpIn: setOp(op, opName, __qmljs_cmp_in); break; } // switch - _as->generateFunctionCallImp(Assembler::ReturnValueRegister, opName, op, b->left, b->right, Assembler::ContextRegister); + _as->generateFunctionCallImp(Assembler::ReturnValueRegister, opName, op, Assembler::ContextRegister, + Assembler::PointerToValue(b->left->asTemp()), Assembler::PointerToValue(b->right->asTemp())); Assembler::Jump target = _as->branch32(Assembler::NotEqual, Assembler::ReturnValueRegister, Assembler::TrustedImm32(0)); _as->addPatch(s->iftrue, target); -- 2.7.4