Fix crashes with MSVC on x86
authorSimon Hausmann <simon.hausmann@digia.com>
Wed, 26 Jun 2013 10:41:21 +0000 (12:41 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 26 Jun 2013 13:45:55 +0000 (15:45 +0200)
When returning a struct like QV4::Value from a function, the compiler can
either place the return value into the stack by expecting the caller
to provide a hidden first argument (pointer to where to store the value)
or pass it in eax:edx. The choice of which approach to pick depends on
whether the type is known at function declaration time. In this case we
had a mismatch where qv4serialize.cpp had a function that returned a value
and it is implemented by calling another function that would return the value.
QV4::Value was forward-declared, and so when compiling the function, the
compiler would assume that the caller provided an invisible first argument
for return value storage. The caller (in qquickworkerscript.cpp) however
had fully visibility of QV4::Value at call time and therefore assumed that
the value is returned in eax:edx. This mismatch caused naturally all sorts
of funny crashes.

The approach chosen is to eliminate any forward declarations of QV4::Value
and instead include the definition where appropriate.

Change-Id: I33303d86964239d3be30d1096806c605cddb7bbc
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
12 files changed:
src/qml/qml/qqmlbinding_p.h
src/qml/qml/v4/moth/qv4vme_moth_p.h
src/qml/qml/v4/qv4context_p.h
src/qml/qml/v4/qv4engine_p.h
src/qml/qml/v4/qv4function_p.h
src/qml/qml/v4/qv4functionobject_p.h
src/qml/qml/v4/qv4global_p.h
src/qml/qml/v4/qv4jsir_p.h
src/qml/qml/v4/qv4object_p.h
src/qml/qml/v4/qv4objectiterator_p.h
src/qml/qml/v4/qv4serialize_p.h
src/qml/qml/v8/qv8engine_p.h

index 7b2f84d..ea703e8 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
-namespace QV4 {
-struct Value;
-}
-
 class QQmlContext;
 class Q_QML_PRIVATE_EXPORT QQmlBinding : public QQmlJavaScriptExpression,
                                          public QQmlAbstractExpression,
index 49cb1f7..5969250 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
-namespace QV4 {
-    struct Value;
-}
-
 namespace QQmlJS {
 namespace Moth {
 
index 3125a63..cf4446d 100644 (file)
@@ -48,7 +48,6 @@ QT_BEGIN_NAMESPACE
 
 namespace QV4 {
 
-struct Value;
 struct Object;
 struct ExecutionEngine;
 struct DeclarativeEnvironment;
index bb44d94..2109acf 100644 (file)
@@ -64,7 +64,6 @@ class Debugger;
 
 namespace QV4 {
 
-struct Value;
 struct Function;
 struct Object;
 struct BooleanObject;
index 65f36bc..4dd0533 100644 (file)
 
 #include <config.h>
 #include <assembler/MacroAssemblerCodeRef.h>
+#include "qv4value_def_p.h"
 
 QT_BEGIN_NAMESPACE
 
 namespace QV4 {
 
-struct Value;
 struct String;
 struct Function;
 struct Object;
index 6d328f1..b72b02e 100644 (file)
@@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE
 
 namespace QV4 {
 
-struct Value;
 struct Function;
 struct Object;
 struct BooleanObject;
index acee20b..1960a57 100644 (file)
@@ -82,7 +82,6 @@ struct FunctionObject;
 struct ErrorObject;
 struct ArgumentsObject;
 struct Managed;
-struct Value;
 struct Lookup;
 struct ExecutionEngine;
 struct QObjectWrapper;
index 4f4cb31..aaebdd7 100644 (file)
@@ -72,7 +72,6 @@ class QQmlType;
 
 namespace QV4 {
 struct ExecutionContext;
-struct Value;
 }
 
 namespace QQmlJS {
index 35d14c4..c0850a0 100644 (file)
@@ -64,7 +64,6 @@ QT_BEGIN_NAMESPACE
 
 namespace QV4 {
 
-struct Value;
 struct Function;
 struct Lookup;
 struct Object;
index 70bc052..9543939 100644 (file)
@@ -54,7 +54,6 @@ struct ArrayObject;
 struct PropertyAttributes;
 struct ExecutionContext;
 struct Property;
-struct Value;
 struct String;
 struct InternalClass;
 
index a1a5ec5..5a04c9d 100644 (file)
 //
 
 #include <QtCore/qbytearray.h>
+#include <private/qv4value_p.h>
 
 QT_BEGIN_NAMESPACE
 
 class QV8Engine;
 
 namespace QV4 {
-struct Value;
 
 class Serialize {
 public:
index 61db8a7..04eacfc 100644 (file)
@@ -78,7 +78,6 @@ QT_BEGIN_NAMESPACE
 namespace QV4 {
     struct ArrayObject;
     struct ExecutionEngine;
-    struct Value;
 }
 
 // Uncomment the following line to enable global handle debugging.  When enabled, all the persistent