aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compiler.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-07-14 20:39:58 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-08-03 08:49:16 +0000
commitc25c95ba22ef843d09b22f9524a04585dc26f2bd (patch)
tree1da57d1b577a56a0b1c4db530ce4c6fb9b9a8a7f /src/qml/compiler/qv4compiler.cpp
parent5b620ed68909c63f3a5a892577a07f66d35c2923 (diff)
Fix endianness in constant handling
When running on a big-endian system, we need to convert the constant values into big-endian once and then it's possible to access them directly. Change-Id: I655bad7b7734e3b95e79e5f688f0b4041d0c41c4 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compiler.cpp')
-rw-r--r--src/qml/compiler/qv4compiler.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index 924f2e15e2..50ade2c6e5 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -248,8 +248,14 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorO
CompiledData::RegExp *regexpTable = reinterpret_cast<CompiledData::RegExp *>(dataPtr + unit->offsetToRegexpTable);
memcpy(regexpTable, regexps.constData(), regexps.size() * sizeof(*regexpTable));
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
ReturnedValue *constantTable = reinterpret_cast<ReturnedValue *>(dataPtr + unit->offsetToConstantTable);
memcpy(constantTable, constants.constData(), constants.size() * sizeof(ReturnedValue));
+#else
+ CompiledData::LEUInt64 *constantTable = reinterpret_cast<CompiledData::LEUInt64 *>(dataPtr + unit->offsetToConstantTable);
+ for (int i = 0; i < constants.count(); ++i)
+ constantTable[i] = constants.at(i);
+#endif
{
memcpy(dataPtr + jsClassDataOffset, jsClassData.constData(), jsClassData.size());