diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-10-09 10:03:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-04-11 12:27:37 +0000 |
commit | db4a2fb7631391495eb4d92db9576272a3c2ec97 (patch) | |
tree | b2536e53f52c3b1a2fea83be8a415a6f73f5ef70 /src | |
parent | 3a3703f298534fce8e2be5fc1f03d84fd32c1b73 (diff) |
Convert comparison methods to the new runtime syntax
Change-Id: Iad4dadddefca2d6322d4f778272b75d64e1a746f
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qv4ssa.cpp | 16 | ||||
-rw-r--r-- | src/qml/jit/qv4assembler_p.h | 5 | ||||
-rw-r--r-- | src/qml/jit/qv4isel_masm.cpp | 14 | ||||
-rw-r--r-- | src/qml/jit/qv4unop.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsapi/qjsvalue.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 28 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime_p.h | 22 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtimeapi_p.h | 30 |
8 files changed, 67 insertions, 54 deletions
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index f021e1f760..6965d839ab 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -3748,42 +3748,42 @@ bool tryOptimizingComparison(Expr *&expr) switch (b->op) { case OpGt: - leftConst->value = Runtime::compareGreaterThan(l, r); + leftConst->value = Runtime::method_compareGreaterThan(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpLt: - leftConst->value = Runtime::compareLessThan(l, r); + leftConst->value = Runtime::method_compareLessThan(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpGe: - leftConst->value = Runtime::compareGreaterEqual(l, r); + leftConst->value = Runtime::method_compareGreaterEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpLe: - leftConst->value = Runtime::compareLessEqual(l, r); + leftConst->value = Runtime::method_compareLessEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpStrictEqual: - leftConst->value = Runtime::compareStrictEqual(l, r); + leftConst->value = Runtime::method_compareStrictEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpEqual: - leftConst->value = Runtime::compareEqual(l, r); + leftConst->value = Runtime::method_compareEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpStrictNotEqual: - leftConst->value = Runtime::compareStrictNotEqual(l, r); + leftConst->value = Runtime::method_compareStrictNotEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; case OpNotEqual: - leftConst->value = Runtime::compareNotEqual(l, r); + leftConst->value = Runtime::method_compareNotEqual(l, r); leftConst->type = BoolType; expr = leftConst; return true; diff --git a/src/qml/jit/qv4assembler_p.h b/src/qml/jit/qv4assembler_p.h index 957e8fc444..b11b76f3be 100644 --- a/src/qml/jit/qv4assembler_p.h +++ b/src/qml/jit/qv4assembler_p.h @@ -63,6 +63,8 @@ #include <config.h> #include <wtf/Vector.h> +#include <climits> + #if ENABLE(ASSEMBLER) #include <assembler/MacroAssembler.h> @@ -107,7 +109,8 @@ struct LookupCall { struct RuntimeCall { JSC::MacroAssembler::Address addr; - inline RuntimeCall(uint offset); + inline RuntimeCall(uint offset = INT_MIN); + bool isValid() const { return addr.offset >= 0; } }; template <typename T> diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index f9bec119d1..e864a79daf 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -982,9 +982,9 @@ void InstructionSelection::swapValues(IR::Expr *source, IR::Expr *target) } #define setOp(op, opName, operation) \ - do { op = operation; opName = isel_stringIfy(operation); } while (0) + do { op = RuntimeCall(qOffsetOf(QV4::Runtime, operation)); opName = "Runtime::" isel_stringIfy(operation); } while (0) #define setOpContext(op, opName, operation) \ - do { opContext = operation; opName = isel_stringIfy(operation); } while (0) + do { opContext = RuntimeCall(qOffsetOf(QV4::Runtime, operation)); opName = "Runtime::" isel_stringIfy(operation); } while (0) void InstructionSelection::unop(IR::AluOp oper, IR::Expr *source, IR::Expr *target) { @@ -1455,8 +1455,8 @@ void InstructionSelection::visitCJump(IR::CJump *s) return; } - Runtime::CompareOperation op = 0; - Runtime::CompareOperationContext opContext = 0; + RuntimeCall op; + RuntimeCall opContext; const char *opName = 0; switch (b->op) { default: Q_UNREACHABLE(); Q_ASSERT(!"todo"); break; @@ -1477,7 +1477,7 @@ void InstructionSelection::visitCJump(IR::CJump *s) // if (true === true) ..... // Of course, after folding the CJUMP to a JUMP, dead-code (dead-basic-block) // elimination (which isn't there either) would remove the whole else block. - if (opContext) + if (opContext.isValid()) _as->generateFunctionCallImp(Assembler::ReturnValueRegister, opName, opContext, Assembler::EngineRegister, Assembler::PointerToValue(b->left), @@ -1801,7 +1801,7 @@ void InstructionSelection::visitCJumpStrict(IR::Binop *binop, IR::BasicBlock *tr IR::Expr *left = binop->left; IR::Expr *right = binop->right; - _as->generateFunctionCallImp(Assembler::ReturnValueRegister, "Runtime::compareStrictEqual", Runtime::compareStrictEqual, + generateRuntimeCall(Assembler::ReturnValueRegister, compareStrictEqual, Assembler::PointerToValue(left), Assembler::PointerToValue(right)); _as->generateCJumpOnCompare(binop->op == IR::OpStrictEqual ? Assembler::NotEqual : Assembler::Equal, Assembler::ReturnValueRegister, Assembler::TrustedImm32(0), @@ -1955,7 +1955,7 @@ void InstructionSelection::visitCJumpEqual(IR::Binop *binop, IR::BasicBlock *tru IR::Expr *left = binop->left; IR::Expr *right = binop->right; - _as->generateFunctionCallImp(Assembler::ReturnValueRegister, "Runtime::compareEqual", Runtime::compareEqual, + generateRuntimeCall(Assembler::ReturnValueRegister, compareEqual, Assembler::PointerToValue(left), Assembler::PointerToValue(right)); _as->generateCJumpOnCompare(binop->op == IR::OpEqual ? Assembler::NotEqual : Assembler::Equal, Assembler::ReturnValueRegister, Assembler::TrustedImm32(0), diff --git a/src/qml/jit/qv4unop.cpp b/src/qml/jit/qv4unop.cpp index 618f3b2796..6a32069ac4 100644 --- a/src/qml/jit/qv4unop.cpp +++ b/src/qml/jit/qv4unop.cpp @@ -51,7 +51,7 @@ using namespace JIT; void Unop::generate(IR::Expr *source, IR::Expr *target) { - RuntimeCall call(-1); + RuntimeCall call; const char *name = 0; switch (op) { case IR::OpNot: @@ -70,7 +70,7 @@ void Unop::generate(IR::Expr *source, IR::Expr *target) Q_UNREACHABLE(); } // switch - Q_ASSERT(call.addr.offset >= 0); + Q_ASSERT(call.isValid()); _as->generateFunctionCallImp(target, name, call, Assembler::PointerToValue(source)); } diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index e369842252..edb23d94db 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -938,7 +938,7 @@ bool QJSValue::equals(const QJSValue& other) const if (!ov) return other.equals(*this); - return Runtime::compareEqual(*v, *ov); + return Runtime::method_compareEqual(*v, *ov); } /*! diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 4c1be4a65d..7dae2cad32 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -742,9 +742,9 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y) double dx = RuntimeHelpers::toNumber(x); return dx == y.asDouble(); } else if (x.isBoolean()) { - return Runtime::compareEqual(Primitive::fromDouble((double) x.booleanValue()), y); + return Runtime::method_compareEqual(Primitive::fromDouble((double) x.booleanValue()), y); } else if (y.isBoolean()) { - return Runtime::compareEqual(x, Primitive::fromDouble((double) y.booleanValue())); + return Runtime::method_compareEqual(x, Primitive::fromDouble((double) y.booleanValue())); } else { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); @@ -752,11 +752,11 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y) if ((x.isNumber() || x.isString()) && y.isObject()) { Scope scope(y.objectValue()->engine()); ScopedValue py(scope, RuntimeHelpers::toPrimitive(y, PREFERREDTYPE_HINT)); - return Runtime::compareEqual(x, py); + return Runtime::method_compareEqual(x, py); } else if (x.isObject() && (y.isNumber() || y.isString())) { Scope scope(x.objectValue()->engine()); ScopedValue px(scope, RuntimeHelpers::toPrimitive(x, PREFERREDTYPE_HINT)); - return Runtime::compareEqual(px, y); + return Runtime::method_compareEqual(px, y); } #endif } @@ -779,7 +779,7 @@ Bool RuntimeHelpers::strictEqual(const Value &x, const Value &y) return false; } -QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareGreaterThan(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -803,7 +803,7 @@ QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareGreaterThan(pl, pr); + return Runtime::method_compareGreaterThan(pl, pr); #endif } @@ -812,7 +812,7 @@ QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) return dl > dr; } -QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareLessThan(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -836,7 +836,7 @@ QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareLessThan(pl, pr); + return Runtime::method_compareLessThan(pl, pr); #endif } @@ -845,7 +845,7 @@ QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) return dl < dr; } -QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareGreaterEqual(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -869,7 +869,7 @@ QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareGreaterEqual(pl, pr); + return Runtime::method_compareGreaterEqual(pl, pr); #endif } @@ -878,7 +878,7 @@ QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) return dl >= dr; } -QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareLessEqual(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -902,7 +902,7 @@ QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareLessEqual(pl, pr); + return Runtime::method_compareLessEqual(pl, pr); #endif } @@ -912,7 +912,7 @@ QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) } #ifndef V4_BOOTSTRAP -Bool Runtime::compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right) +Bool Runtime::method_compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); @@ -921,7 +921,7 @@ Bool Runtime::compareInstanceof(ExecutionEngine *engine, const Value &left, cons return v->booleanValue(); } -uint Runtime::compareIn(ExecutionEngine *engine, const Value &left, const Value &right) +uint Runtime::method_compareIn(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 12b9a11a38..d9a9f0b780 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -313,7 +313,7 @@ inline ReturnedValue Runtime::greaterThan(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareGreaterThan(left, right); + bool r = method_compareGreaterThan(left, right); return Encode(r); } @@ -321,7 +321,7 @@ inline ReturnedValue Runtime::lessThan(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareLessThan(left, right); + bool r = method_compareLessThan(left, right); return Encode(r); } @@ -329,7 +329,7 @@ inline ReturnedValue Runtime::greaterEqual(const Value &left, const Value &right { TRACE2(left, right); - bool r = Runtime::compareGreaterEqual(left, right); + bool r = method_compareGreaterEqual(left, right); return Encode(r); } @@ -337,11 +337,11 @@ inline ReturnedValue Runtime::lessEqual(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareLessEqual(left, right); + bool r = method_compareLessEqual(left, right); return Encode(r); } -inline Bool Runtime::compareEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -363,7 +363,7 @@ inline ReturnedValue Runtime::equal(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareEqual(left, right); + bool r = method_compareEqual(left, right); return Encode(r); } @@ -371,7 +371,7 @@ inline ReturnedValue Runtime::notEqual(const Value &left, const Value &right) { TRACE2(left, right); - bool r = !Runtime::compareEqual(left, right); + bool r = !method_compareEqual(left, right); return Encode(r); } @@ -391,21 +391,21 @@ inline ReturnedValue Runtime::strictNotEqual(const Value &left, const Value &rig return Encode(r); } -inline Bool Runtime::compareNotEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareNotEqual(const Value &left, const Value &right) { TRACE2(left, right); - return !Runtime::compareEqual(left, right); + return !Runtime::method_compareEqual(left, right); } -inline Bool Runtime::compareStrictEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareStrictEqual(const Value &left, const Value &right) { TRACE2(left, right); return RuntimeHelpers::strictEqual(left, right); } -inline Bool Runtime::compareStrictNotEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareStrictNotEqual(const Value &left, const Value &right) { TRACE2(left, right); diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h index 8f5a010107..e17b1803d8 100644 --- a/src/qml/jsruntime/qv4runtimeapi_p.h +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -106,6 +106,16 @@ struct Q_QML_PRIVATE_EXPORT Runtime { , INIT_RUNTIME_METHOD(complement) , INIT_RUNTIME_METHOD(increment) , INIT_RUNTIME_METHOD(decrement) + , INIT_RUNTIME_METHOD(compareGreaterThan) + , INIT_RUNTIME_METHOD(compareLessThan) + , INIT_RUNTIME_METHOD(compareGreaterEqual) + , INIT_RUNTIME_METHOD(compareLessEqual) + , INIT_RUNTIME_METHOD(compareEqual) + , INIT_RUNTIME_METHOD(compareNotEqual) + , INIT_RUNTIME_METHOD(compareStrictEqual) + , INIT_RUNTIME_METHOD(compareStrictNotEqual) + , INIT_RUNTIME_METHOD(compareInstanceof) + , INIT_RUNTIME_METHOD(compareIn) , INIT_RUNTIME_METHOD(toBoolean) , INIT_RUNTIME_METHOD(toDouble) , INIT_RUNTIME_METHOD(toInt) @@ -227,18 +237,18 @@ struct Q_QML_PRIVATE_EXPORT Runtime { // comparisons typedef Bool (*CompareOperation)(const Value &left, const Value &right); - static Bool compareGreaterThan(const Value &l, const Value &r); - static Bool compareLessThan(const Value &l, const Value &r); - static Bool compareGreaterEqual(const Value &l, const Value &r); - static Bool compareLessEqual(const Value &l, const Value &r); - static Bool compareEqual(const Value &left, const Value &right); - static Bool compareNotEqual(const Value &left, const Value &right); - static Bool compareStrictEqual(const Value &left, const Value &right); - static Bool compareStrictNotEqual(const Value &left, const Value &right); + RUNTIME_METHOD(Bool, compareGreaterThan, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareLessThan, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareGreaterEqual, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareLessEqual, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareNotEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareStrictEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareStrictNotEqual, (const Value &left, const Value &right)); typedef Bool (*CompareOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right); - static Bool compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right); - static Bool compareIn(ExecutionEngine *engine, const Value &left, const Value &right); + RUNTIME_METHOD(Bool, compareInstanceof, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareIn, (ExecutionEngine *engine, const Value &left, const Value &right)); // conversions RUNTIME_METHOD(Bool, toBoolean, (const Value &value)); |