aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4value_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-08-18 10:29:10 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-08-18 10:29:47 +0200
commiteb30e3d7ee81c48cea720e7ecd2ed45647bc70ee (patch)
tree810e8ad0642434eeb4043c3a06c82217314300e1 /src/qml/jsruntime/qv4value_p.h
parent9c9fca5e27bd91da1ea07bebd7569049493c5ccf (diff)
parent521ace713d8e5230d47f3da8cd941699ca085af2 (diff)
Merge remote-tracking branch 'origin/5.5' into 5.6
Conflicts: src/qml/debugger/qv4debugservice.cpp src/qml/jsruntime/qv4value_inl_p.h src/qml/jsruntime/qv4value_p.h src/qml/memory/qv4mm.cpp src/qml/memory/qv4mm_p.h src/qml/qml/qqmlnotifier_p.h src/qml/qml/qqmlproperty.cpp src/quick/items/qquickflickable.cpp src/quick/items/qquicktextedit.cpp tests/auto/quick/qquickwindow/BLACKLIST The extra changes in qqmlbinding.cpp are ported from changes to qqmlproperty.cpp that occurred in parallel with writeBinding() being moved to qqmlbinding.cpp. Change-Id: I16d1920abf448c29a01822256f52153651a56356
Diffstat (limited to 'src/qml/jsruntime/qv4value_p.h')
-rw-r--r--src/qml/jsruntime/qv4value_p.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index c0420a38db..6305e6dfbb 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -39,6 +39,14 @@
#include "qv4global_p.h"
#include <private/qv4heap_p.h>
+/* We cannot rely on QT_POINTER_SIZE to be set correctly on host builds. In qmldevtools the Value objects
+ are only used to store primitives, never object pointers. So we can use the 64-bit encoding. */
+#ifdef V4_BOOTSTRAP
+#define QV4_USE_64_BIT_VALUE_ENCODING
+#elif QT_POINTER_SIZE == 8
+#define QV4_USE_64_BIT_VALUE_ENCODING
+#endif
+
QT_BEGIN_NAMESPACE
namespace QV4 {
@@ -94,10 +102,10 @@ struct Q_QML_PRIVATE_EXPORT Value
Q_ALWAYS_INLINE quint32 value() const { return _val >> 32; }
#endif
-#if QT_POINTER_SIZE == 8
+#ifdef QV4_USE_64_BIT_VALUE_ENCODING
Q_ALWAYS_INLINE Heap::Base *m() const { Heap::Base *b; memcpy(&b, &_val, 8); return b; }
Q_ALWAYS_INLINE void setM(Heap::Base *b) { memcpy(&_val, &b, 8); }
-#else // QT_POINTER_SIZE == 4
+#else // !QV4_USE_64_BIT_VALUE_ENCODING
Q_ALWAYS_INLINE Heap::Base *m() const { Heap::Base *b; quint32 v = value(); memcpy(&b, &v, 4); return b; }
Q_ALWAYS_INLINE void setM(Heap::Base *b) { quint32 v; memcpy(&v, &b, 4); setValue(v); }
#endif
@@ -106,7 +114,7 @@ struct Q_QML_PRIVATE_EXPORT Value
Q_ALWAYS_INLINE void setInt_32(int i) { quint32 u; memcpy(&u, &i, 4); setValue(u); }
Q_ALWAYS_INLINE uint uint_32() const { return value(); }
-#if QT_POINTER_SIZE == 4
+#ifndef QV4_USE_64_BIT_VALUE_ENCODING
enum Masks {
SilentNaNBit = 0x00040000,
NaN_Mask = 0x7ff80000,
@@ -186,7 +194,7 @@ struct Q_QML_PRIVATE_EXPORT Value
inline bool isUndefined() const { return tag() == Undefined_Type; }
inline bool isNull() const { return tag() == _Null_Type; }
inline bool isBoolean() const { return tag ()== _Boolean_Type; }
-#if QT_POINTER_SIZE == 8
+#ifdef QV4_USE_64_BIT_VALUE_ENCODING
inline bool isInteger() const { return (_val >> IsNumber_Shift) == 1; }
inline bool isDouble() const { return (_val >> IsDouble_Shift); }
inline bool isNumber() const { return (_val >> IsNumber_Shift); }
@@ -219,7 +227,7 @@ struct Q_QML_PRIVATE_EXPORT Value
Q_ASSERT(isDouble());
double d;
quint64 v = _val;
-#if QT_POINTER_SIZE == 8
+#ifdef QV4_USE_64_BIT_VALUE_ENCODING
v ^= NaNEncodeMask;
#endif
memcpy(&d, &v, 8);
@@ -227,7 +235,7 @@ struct Q_QML_PRIVATE_EXPORT Value
}
Q_ALWAYS_INLINE void setDouble(double d) {
memcpy(&_val, &d, 8);
-#if QT_POINTER_SIZE == 8
+#ifdef QV4_USE_64_BIT_VALUE_ENCODING
_val ^= NaNEncodeMask;
#endif
Q_ASSERT(isDouble());
@@ -287,7 +295,7 @@ struct Q_QML_PRIVATE_EXPORT Value
Value v;
v.setRawValue(0);
v.setM(m);
-#if QT_POINTER_SIZE == 4
+#ifndef QV4_USE_64_BIT_VALUE_ENCODING
v.setTag(Managed_Type);
#endif
return v;
@@ -368,7 +376,7 @@ struct Q_QML_PRIVATE_EXPORT Value
}
Value &operator=(Heap::Base *o) {
setM(o);
-#if QT_POINTER_SIZE == 4
+#ifndef QV4_USE_64_BIT_VALUE_ENCODING
setTag(Managed_Type);
#endif
return *this;
@@ -413,7 +421,7 @@ inline double Value::toNumber() const
#ifndef V4_BOOTSTRAP
inline uint Value::asArrayIndex() const
{
-#if QT_POINTER_SIZE == 8
+#ifdef QV4_USE_64_BIT_VALUE_ENCODING
if (!isNumber())
return UINT_MAX;
if (isInteger())
@@ -461,7 +469,7 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value
inline Primitive Primitive::undefinedValue()
{
Primitive v;
-#if QT_POINTER_SIZE == 8
+#ifdef QV4_USE_64_BIT_VALUE_ENCODING
v.setRawValue(quint64(Undefined_Type) << Tag_Shift);
#else
v.setRawValue(0);
@@ -481,7 +489,7 @@ inline Primitive Primitive::emptyValue()
inline Primitive Primitive::nullValue()
{
Primitive v;
-#if QT_POINTER_SIZE == 8
+#ifndef QV4_USE_64_BIT_VALUE_ENCODING
v.setRawValue(quint64(_Null_Type) << Tag_Shift);
#else
v.setTagValue(_Null_Type, 0);