diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-07-14 20:39:58 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-08-03 08:49:16 +0000 |
commit | c25c95ba22ef843d09b22f9524a04585dc26f2bd (patch) | |
tree | 1da57d1b577a56a0b1c4db530ce4c6fb9b9a8a7f /src/qml/compiler/qv4compileddata.cpp | |
parent | 5b620ed68909c63f3a5a892577a07f66d35c2923 (diff) | |
download | qtdeclarative-c25c95ba22ef843d09b22f9524a04585dc26f2bd.tar.gz |
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/qv4compileddata.cpp')
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 121b5907db..b060d72448 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -161,6 +161,16 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) } } +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + Value *bigEndianConstants = new Value[data->constantTableSize]; + const LEUInt64 *littleEndianConstants = data->constants(); + for (uint i = 0; i < data->constantTableSize; ++i) + bigEndianConstants[i] = Value::fromReturnedValue(littleEndianConstants[i]); + constants = bigEndianConstants; +#else + constants = reinterpret_cast<const Value*>(data->constants()); +#endif + linkBackendToEngine(engine); if (data->indexOfRootFunction != -1) @@ -203,6 +213,9 @@ void CompilationUnit::unlink() runtimeClasses = 0; qDeleteAll(runtimeFunctions); runtimeFunctions.clear(); +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + delete [] constants; +#endif } void CompilationUnit::markObjects(QV4::ExecutionEngine *e) |