diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-23 14:23:51 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-23 14:02:08 +0000 |
commit | 9d1a907345d6a04178b93389803e2d17f090953a (patch) | |
tree | 076a4f347964e2cd001ee70cb996a63fe4ef6780 /src | |
parent | 3813b6205b3519fc3372d0e6a8073d2fb82a6145 (diff) | |
download | qtscript-9d1a907345d6a04178b93389803e2d17f090953a.tar.gz |
Fix QtScript on 64-bit systems with gcc 8
Similar to commit 92836d052efb6d8073136e8507083f93fb60bb80 in
qtdeclarative, we must use memcpy to do a bit-wise conversion from the
JSCell *m_ptr to an intptr_t for JSValue tag operations.
This fixes the referenced task and all the failing auto-tests.
The most visible result was that
if ((jsvalue.immediateValue() & 0xffff000000000000ll) == 0xffff000000000000ll)
return static_cast<int32_t>(jsvalue.immediateValue());
was "optimized" to "return 0", breaking QScriptValue::toNumber() for
integer encoded values.
[ChangeLog][QtScript] Fix incorrect script evaluations on 64-bit systems
with gcc 8.
Change-Id: I525b6b66d0e3c5163ad7e338fd0e866cdf620dad
Task-number: QTBUG-68367
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h index 501ab5e..7584c52 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h @@ -773,22 +773,30 @@ namespace JSC { // JSValue member functions. inline EncodedJSValue JSValue::encode(JSValue value) { - return reinterpret_cast<EncodedJSValue>(value.m_ptr); + EncodedJSValue r; + memcpy(&r, &value.m_ptr, sizeof(r)); + return r; } inline JSValue JSValue::decode(EncodedJSValue ptr) { - return JSValue(reinterpret_cast<JSCell*>(ptr)); + JSCell *cellPtr; + memcpy(&cellPtr, &ptr, sizeof(cellPtr)); + return JSValue(cellPtr); } inline JSValue JSValue::makeImmediate(intptr_t value) { - return JSValue(reinterpret_cast<JSCell*>(value)); + JSCell *cellPtr; + memcpy(&cellPtr, &value, sizeof(cellPtr)); + return JSValue(cellPtr); } inline intptr_t JSValue::immediateValue() { - return reinterpret_cast<intptr_t>(m_ptr); + intptr_t v; + memcpy(&v, &m_ptr, sizeof(v)); + return v; } // 0x0 can never occur naturally because it has a tag of 00, indicating a pointer value, but a payload of 0x0, which is in the (invalid) zero page. |