diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2016-09-09 15:37:57 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-06 11:44:08 +0000 |
commit | 3b14e2ffdd8eb4b7f7f4508768b75f2acc399370 (patch) | |
tree | 7943f293bf2d0d376d5dc620448bab1a2b58027d /src/qml/jsruntime/qv4errorobject.cpp | |
parent | 1b90dc4482d001512f09a5785d4cbd8030879d82 (diff) |
QML: Make Heap::Object and all subclasses trivial
GCC6 might dead-store-eliminate out our secret write to Base::mmdata,
because it expects all memory content to be "undefined" before
constructor calls. Clang might take the same approach if the constructor
of Heap::Object is removed.
By making these structs trivial, it also makes them memcpy-able.
Change-Id: I055b2ad28311b997fbe059849ebda4d5894eaa9b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4errorobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4errorobject.cpp | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index bb5d32cbd7..597ded6ae1 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -67,8 +67,9 @@ using namespace QV4; -Heap::ErrorObject::ErrorObject() +void Heap::ErrorObject::init() { + Object::init(); stackTrace = nullptr; Scope scope(internalClass->engine); @@ -83,8 +84,9 @@ Heap::ErrorObject::ErrorObject() *propertyData(QV4::ErrorObject::Index_LineNumber) = Encode::undefined(); } -Heap::ErrorObject::ErrorObject(const Value &message, ErrorType t) +void Heap::ErrorObject::init(const Value &message, ErrorType t) { + Object::init(); errorType = t; Scope scope(internalClass->engine); @@ -103,8 +105,9 @@ Heap::ErrorObject::ErrorObject(const Value &message, ErrorType t) *propertyData(QV4::ErrorObject::Index_Message) = message; } -Heap::ErrorObject::ErrorObject(const Value &message, const QString &fileName, int line, int column, ErrorObject::ErrorType t) +void Heap::ErrorObject::init(const Value &message, const QString &fileName, int line, int column, ErrorObject::ErrorType t) { + Object::init(); errorType = t; Scope scope(internalClass->engine); @@ -183,44 +186,44 @@ DEFINE_OBJECT_VTABLE(ErrorObject); DEFINE_OBJECT_VTABLE(SyntaxErrorObject); -Heap::SyntaxErrorObject::SyntaxErrorObject(const Value &msg) - : Heap::ErrorObject(msg, SyntaxError) +void Heap::SyntaxErrorObject::init(const Value &msg) { + Heap::ErrorObject::init(msg, SyntaxError); } -Heap::SyntaxErrorObject::SyntaxErrorObject(const Value &msg, const QString &fileName, int lineNumber, int columnNumber) - : Heap::ErrorObject(msg, fileName, lineNumber, columnNumber, SyntaxError) +void Heap::SyntaxErrorObject::init(const Value &msg, const QString &fileName, int lineNumber, int columnNumber) { + Heap::ErrorObject::init(msg, fileName, lineNumber, columnNumber, SyntaxError); } -Heap::EvalErrorObject::EvalErrorObject(const Value &message) - : Heap::ErrorObject(message, EvalError) +void Heap::EvalErrorObject::init(const Value &message) { + Heap::ErrorObject::init(message, EvalError); } -Heap::RangeErrorObject::RangeErrorObject(const Value &message) - : Heap::ErrorObject(message, RangeError) +void Heap::RangeErrorObject::init(const Value &message) { + Heap::ErrorObject::init(message, RangeError); } -Heap::ReferenceErrorObject::ReferenceErrorObject(const Value &message) - : Heap::ErrorObject(message, ReferenceError) +void Heap::ReferenceErrorObject::init(const Value &message) { + Heap::ErrorObject::init(message, ReferenceError); } -Heap::ReferenceErrorObject::ReferenceErrorObject(const Value &msg, const QString &fileName, int lineNumber, int columnNumber) - : Heap::ErrorObject(msg, fileName, lineNumber, columnNumber, ReferenceError) +void Heap::ReferenceErrorObject::init(const Value &msg, const QString &fileName, int lineNumber, int columnNumber) { + Heap::ErrorObject::init(msg, fileName, lineNumber, columnNumber, ReferenceError); } -Heap::TypeErrorObject::TypeErrorObject(const Value &message) - : Heap::ErrorObject(message, TypeError) +void Heap::TypeErrorObject::init(const Value &message) { + Heap::ErrorObject::init(message, TypeError); } -Heap::URIErrorObject::URIErrorObject(const Value &message) - : Heap::ErrorObject(message, URIError) +void Heap::URIErrorObject::init(const Value &message) { + Heap::ErrorObject::init(message, URIError); } DEFINE_OBJECT_VTABLE(ErrorCtor); @@ -231,14 +234,14 @@ DEFINE_OBJECT_VTABLE(SyntaxErrorCtor); DEFINE_OBJECT_VTABLE(TypeErrorCtor); DEFINE_OBJECT_VTABLE(URIErrorCtor); -Heap::ErrorCtor::ErrorCtor(QV4::ExecutionContext *scope) - : Heap::FunctionObject(scope, QStringLiteral("Error")) +void Heap::ErrorCtor::init(QV4::ExecutionContext *scope) { + Heap::FunctionObject::init(scope, QStringLiteral("Error")); } -Heap::ErrorCtor::ErrorCtor(QV4::ExecutionContext *scope, const QString &name) - : Heap::FunctionObject(scope, name) +void Heap::ErrorCtor::init(QV4::ExecutionContext *scope, const QString &name) { + Heap::FunctionObject::init(scope, name); } void ErrorCtor::construct(const Managed *, Scope &scope, CallData *callData) @@ -252,9 +255,9 @@ void ErrorCtor::call(const Managed *that, Scope &scope, CallData *callData) static_cast<const Object *>(that)->construct(scope, callData); } -Heap::EvalErrorCtor::EvalErrorCtor(QV4::ExecutionContext *scope) - : Heap::ErrorCtor(scope, QStringLiteral("EvalError")) +void Heap::EvalErrorCtor::init(QV4::ExecutionContext *scope) { + Heap::ErrorCtor::init(scope, QStringLiteral("EvalError")); } void EvalErrorCtor::construct(const Managed *, Scope &scope, CallData *callData) @@ -263,9 +266,9 @@ void EvalErrorCtor::construct(const Managed *, Scope &scope, CallData *callData) scope.result = ErrorObject::create<EvalErrorObject>(scope.engine, v); } -Heap::RangeErrorCtor::RangeErrorCtor(QV4::ExecutionContext *scope) - : Heap::ErrorCtor(scope, QStringLiteral("RangeError")) +void Heap::RangeErrorCtor::init(QV4::ExecutionContext *scope) { + Heap::ErrorCtor::init(scope, QStringLiteral("RangeError")); } void RangeErrorCtor::construct(const Managed *, Scope &scope, CallData *callData) @@ -274,9 +277,9 @@ void RangeErrorCtor::construct(const Managed *, Scope &scope, CallData *callData scope.result = ErrorObject::create<RangeErrorObject>(scope.engine, v); } -Heap::ReferenceErrorCtor::ReferenceErrorCtor(QV4::ExecutionContext *scope) - : Heap::ErrorCtor(scope, QStringLiteral("ReferenceError")) +void Heap::ReferenceErrorCtor::init(QV4::ExecutionContext *scope) { + Heap::ErrorCtor::init(scope, QStringLiteral("ReferenceError")); } void ReferenceErrorCtor::construct(const Managed *, Scope &scope, CallData *callData) @@ -285,9 +288,9 @@ void ReferenceErrorCtor::construct(const Managed *, Scope &scope, CallData *call scope.result = ErrorObject::create<ReferenceErrorObject>(scope.engine, v); } -Heap::SyntaxErrorCtor::SyntaxErrorCtor(QV4::ExecutionContext *scope) - : Heap::ErrorCtor(scope, QStringLiteral("SyntaxError")) +void Heap::SyntaxErrorCtor::init(QV4::ExecutionContext *scope) { + Heap::ErrorCtor::init(scope, QStringLiteral("SyntaxError")); } void SyntaxErrorCtor::construct(const Managed *, Scope &scope, CallData *callData) @@ -296,9 +299,9 @@ void SyntaxErrorCtor::construct(const Managed *, Scope &scope, CallData *callDat scope.result = ErrorObject::create<SyntaxErrorObject>(scope.engine, v); } -Heap::TypeErrorCtor::TypeErrorCtor(QV4::ExecutionContext *scope) - : Heap::ErrorCtor(scope, QStringLiteral("TypeError")) +void Heap::TypeErrorCtor::init(QV4::ExecutionContext *scope) { + Heap::ErrorCtor::init(scope, QStringLiteral("TypeError")); } void TypeErrorCtor::construct(const Managed *, Scope &scope, CallData *callData) @@ -307,9 +310,9 @@ void TypeErrorCtor::construct(const Managed *, Scope &scope, CallData *callData) scope.result = ErrorObject::create<TypeErrorObject>(scope.engine, v); } -Heap::URIErrorCtor::URIErrorCtor(QV4::ExecutionContext *scope) - : Heap::ErrorCtor(scope, QStringLiteral("URIError")) +void Heap::URIErrorCtor::init(QV4::ExecutionContext *scope) { + Heap::ErrorCtor::init(scope, QStringLiteral("URIError")); } void URIErrorCtor::construct(const Managed *, Scope &scope, CallData *callData) |