From ffe0f153f9c084170a249ffddd4c9ea7339572e3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 22 Jan 2015 09:38:22 +0100 Subject: [PATCH] QML: Fix MSVC 2013/64bit warnings. compiler\qv4ssa.cpp(687) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data compiler\qv4ssa.cpp(950) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data compiler\qv4ssa.cpp(1117) : warning C4267: 'return' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(1120) : warning C4267: 'return' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(1148) : warning C4267: 'initializing' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(1266) : warning C4267: 'initializing' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(1622) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data compiler\qv4ssa.cpp(2246) : warning C4267: 'initializing' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(4289) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data compiler\qv4ssa.cpp(4351) : warning C4267: 'initializing' : conversion from 'size_t' to 'unsigned int', possible loss of data jit\qv4regalloc.cpp(1383) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data jit\qv4regalloc.cpp(1769) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jit\qv4regalloc.cpp(1814) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jsruntime\qv4mm.cpp(496) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jsruntime\qv4mm.cpp(503) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jsruntime\qv4mm.cpp(506) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jsruntime\qv4regexp.cpp(60) : warning C4267: 'return' : conversion from 'size_t' to 'uint', possible loss of data jsruntime\qv4typedarray.cpp(85) : warning C4309: '=' : truncation of constant value Change-Id: I0b04e1a9d379c068fb3efe90a9db8b592061e448 Reviewed-by: Erik Verbruggen Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4ssa.cpp | 31 +++++++++++++++++-------------- src/qml/jit/qv4regalloc.cpp | 11 +++++++---- src/qml/jsruntime/qv4mm.cpp | 6 +++--- src/qml/jsruntime/qv4regexp.cpp | 2 +- src/qml/jsruntime/qv4typedarray.cpp | 2 +- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index 924a5d8..85da241 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -684,7 +684,7 @@ public: return; for (size_t i = 0, ei = idom.size(); i != ei; ++i) { if (idom[i] == dominator) { - BasicBlock *bb = function->basicBlock(i); + BasicBlock *bb = function->basicBlock(int(i)); if (!bb->isRemoved()) siblings.insert(bb); } @@ -946,8 +946,9 @@ public: for (int i = 0; i < function->tempCount; ++i) _defsites[i].init(function); nonLocals.resize(function->tempCount); - A_orig.resize(function->basicBlockCount()); - for (int i = 0, ei = A_orig.size(); i != ei; ++i) + const size_t ei = function->basicBlockCount(); + A_orig.resize(ei); + for (size_t i = 0; i != ei; ++i) A_orig[i].reserve(8); foreach (BasicBlock *bb, function->basicBlocks()) { @@ -1114,10 +1115,10 @@ public: } unsigned statementCount() const - { return _usesPerStatement.size(); } + { return unsigned(_usesPerStatement.size()); } unsigned tempCount() const - { return _defUses.size(); } + { return unsigned(_defUses.size()); } const Temp &temp(int idx) const { return _defUses[idx].temp; } @@ -1144,8 +1145,9 @@ public: std::vector defs() const { std::vector res; - res.reserve(_defUses.size()); - for (unsigned i = 0, ei = _defUses.size(); i != ei; ++i) { + const size_t ei = _defUses.size(); + res.reserve(ei); + for (size_t i = 0; i != ei; ++i) { const DefUse &du = _defUses.at(i); if (du.isValid()) res.push_back(&du.temp); @@ -1263,7 +1265,7 @@ public: qout << endl; } qout << "Uses per statement:" << endl; - for (unsigned i = 0, ei = _usesPerStatement.size(); i != ei; ++i) { + for (size_t i = 0, ei = _usesPerStatement.size(); i != ei; ++i) { qout << " " << i << ":"; foreach (const Temp &t, _usesPerStatement[i]) qout << ' ' << t.index; @@ -1618,8 +1620,9 @@ void convertToSSA(IR::Function *function, const DominatorTree &df, DefUses &defU // Prepare for phi node insertion: std::vector > A_phi; - A_phi.resize(function->basicBlockCount()); - for (int i = 0, ei = A_phi.size(); i != ei; ++i) + const size_t ei = function->basicBlockCount(); + A_phi.resize(ei); + for (size_t i = 0; i != ei; ++i) A_phi[i].assign(function->tempCount, false); std::vector W; @@ -2243,8 +2246,8 @@ public: } PropagateTempTypes propagator(_defUses); - for (unsigned i = 0, ei = _tempTypes.size(); i != ei; ++i) { - const Temp &temp = _defUses.temp(i); + for (size_t i = 0, ei = _tempTypes.size(); i != ei; ++i) { + const Temp &temp = _defUses.temp(int(i)); if (temp.kind == Temp::Invalid) continue; const DiscoveredType &tempType = _tempTypes[i]; @@ -4286,7 +4289,7 @@ public: } IRPrinter printer(&qout); - for (int i = 0, ei = _liveIn.size(); i != ei; ++i) { + for (size_t i = 0, ei = _liveIn.size(); i != ei; ++i) { qout << "L" << i <<" live-in: "; QList live = QList::fromSet(_liveIn.at(i)); if (live.isEmpty()) @@ -4348,7 +4351,7 @@ private: _sortedIntervals->add(<i); } //### TODO: use DefUses from the optimizer, because it already has all this information - for (unsigned i = 0, ei = collector.inputs.size(); i != ei; ++i) { + for (size_t i = 0, ei = collector.inputs.size(); i != ei; ++i) { Temp *opd = collector.inputs[i]; interval(opd).addRange(start(bb), usePosition(s)); live.insert(*opd); diff --git a/src/qml/jit/qv4regalloc.cpp b/src/qml/jit/qv4regalloc.cpp index 64cbdf9..cd85e7d 100644 --- a/src/qml/jit/qv4regalloc.cpp +++ b/src/qml/jit/qv4regalloc.cpp @@ -1380,7 +1380,7 @@ LifeTimeInterval *RegisterAllocator::cloneFixedInterval(int reg, bool isFP, cons // saved registers. void RegisterAllocator::prepareRanges() { - LifeTimeInterval ltiWithCalls = createFixedInterval(_info->calls().size()); + LifeTimeInterval ltiWithCalls = createFixedInterval(int(_info->calls().size())); foreach (int callPosition, _info->calls()) ltiWithCalls.addRange(callPosition, callPosition); @@ -1765,9 +1765,12 @@ int RegisterAllocator::nextIntersection(const LifeTimeInterval ¤t, /// Find the first use after the start position for the given temp. int RegisterAllocator::nextUse(const Temp &t, int startPosition) const { + typedef std::vector::const_iterator ConstIt; + const std::vector &usePositions = _info->uses(t); - for (int i = 0, ei = usePositions.size(); i != ei; ++i) { //### FIXME: use an iterator - const int usePos = usePositions.at(i).pos; + const ConstIt cend = usePositions.end(); + for (ConstIt it = usePositions.begin(); it != cend; ++it) { + const int usePos = it->pos; if (usePos >= startPosition) return usePos; } @@ -1811,7 +1814,7 @@ void RegisterAllocator::split(LifeTimeInterval ¤t, int beforePosition, int lastUse = firstPosition; int nextUse = -1; const std::vector &usePositions = _info->uses(current.temp()); - for (int i = 0, ei = usePositions.size(); i != ei; ++i) { + for (size_t i = 0, ei = usePositions.size(); i != ei; ++i) { const Use &usePosition = usePositions.at(i); const int usePos = usePosition.pos; if (lastUse < usePos && usePos < beforePosition) { diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp index 66b291d..0dbf422 100644 --- a/src/qml/jsruntime/qv4mm.cpp +++ b/src/qml/jsruntime/qv4mm.cpp @@ -493,17 +493,17 @@ void MemoryManager::runGC() mark(); sweep(); } else { - int totalMem = getAllocatedMem(); + const size_t totalMem = getAllocatedMem(); QTime t; t.start(); mark(); int markTime = t.elapsed(); t.restart(); - int usedBefore = getUsedMem(); + const size_t usedBefore = getUsedMem(); int chunksBefore = m_d->heapChunks.size(); sweep(); - int usedAfter = getUsedMem(); + const size_t usedAfter = getUsedMem(); int sweepTime = t.elapsed(); qDebug() << "========== GC =========="; diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index cff15bd..5311dd8 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -57,7 +57,7 @@ uint RegExp::match(const QString &string, int start, uint *matchOffsets) #if ENABLE(YARR_JIT) if (!jitCode().isFallBack() && jitCode().has16BitCode()) - return jitCode().execute(s.characters16(), start, s.length(), (int*)matchOffsets).start; + return uint(jitCode().execute(s.characters16(), start, s.length(), (int*)matchOffsets).start); #endif return JSC::Yarr::interpret(byteCode().get(), s.characters16(), string.length(), start, matchOffsets); diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index 2277d37..ed18174 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -82,7 +82,7 @@ void UInt8ClampedArrayWrite(ExecutionEngine *e, char *data, int index, ValueRef return; } if (d >= 255) { - data[index] = 255; + data[index] = (unsigned char)(255); return; } double f = floor(d); -- 2.7.4