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/qv4functionobject_p.h | |
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/qv4functionobject_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index f5a9376b9e..e58b83e2c3 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -69,13 +69,13 @@ struct Q_QML_PRIVATE_EXPORT FunctionObject : Object { Index_ProtoConstructor = 0 }; - FunctionObject(QV4::ExecutionContext *scope, QV4::String *name, bool createProto = false); - FunctionObject(QV4::ExecutionContext *scope, QV4::Function *function, bool createProto = false); - FunctionObject(QV4::ExecutionContext *scope, const QString &name = QString(), bool createProto = false); - FunctionObject(ExecutionContext *scope, const QString &name = QString(), bool createProto = false); - FunctionObject(QV4::ExecutionContext *scope, const ReturnedValue name); - FunctionObject(ExecutionContext *scope, const ReturnedValue name); - FunctionObject(); + void init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto = false); + void init(QV4::ExecutionContext *scope, QV4::Function *function, bool createProto = false); + void init(QV4::ExecutionContext *scope, const QString &name = QString(), bool createProto = false); + void init(ExecutionContext *scope, const QString &name = QString(), bool createProto = false); + void init(QV4::ExecutionContext *scope, const ReturnedValue name); + void init(ExecutionContext *scope, const ReturnedValue name); + void init(); void destroy(); unsigned int formalParameterCount() { return function ? function->nFormals : 0; } @@ -87,20 +87,20 @@ struct Q_QML_PRIVATE_EXPORT FunctionObject : Object { }; struct FunctionCtor : FunctionObject { - FunctionCtor(QV4::ExecutionContext *scope); + void init(QV4::ExecutionContext *scope); }; struct FunctionPrototype : FunctionObject { - FunctionPrototype(); + void init(); }; struct Q_QML_EXPORT BuiltinFunction : FunctionObject { - BuiltinFunction(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(QV4::CallContext *)); + void init(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(QV4::CallContext *)); ReturnedValue (*code)(QV4::CallContext *); }; struct IndexedBuiltinFunction : FunctionObject { - inline IndexedBuiltinFunction(QV4::ExecutionContext *scope, uint index, ReturnedValue (*code)(QV4::CallContext *ctx, uint index)); + inline void init(QV4::ExecutionContext *scope, uint index, ReturnedValue (*code)(QV4::CallContext *ctx, uint index)); ReturnedValue (*code)(QV4::CallContext *, uint index); uint index; }; @@ -110,15 +110,15 @@ struct SimpleScriptFunction : FunctionObject { Index_Name = FunctionObject::Index_Prototype + 1, Index_Length }; - SimpleScriptFunction(QV4::ExecutionContext *scope, Function *function, bool createProto); + void init(QV4::ExecutionContext *scope, Function *function, bool createProto); }; struct ScriptFunction : SimpleScriptFunction { - ScriptFunction(QV4::ExecutionContext *scope, Function *function); + void init(QV4::ExecutionContext *scope, Function *function); }; struct BoundFunction : FunctionObject { - BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionObject *target, const Value &boundThis, QV4::MemberData *boundArgs); + void init(QV4::ExecutionContext *scope, QV4::FunctionObject *target, const Value &boundThis, QV4::MemberData *boundArgs); Pointer<FunctionObject> target; Value boundThis; Pointer<MemberData> boundArgs; @@ -216,12 +216,12 @@ struct IndexedBuiltinFunction: FunctionObject static void call(const Managed *that, Scope &scope, CallData *callData); }; -Heap::IndexedBuiltinFunction::IndexedBuiltinFunction(QV4::ExecutionContext *scope, uint index, - ReturnedValue (*code)(QV4::CallContext *ctx, uint index)) - : Heap::FunctionObject(scope), - code(code) - , index(index) +void Heap::IndexedBuiltinFunction::init(QV4::ExecutionContext *scope, uint index, + ReturnedValue (*code)(QV4::CallContext *ctx, uint index)) { + Heap::FunctionObject::init(scope); + this->index = index; + this->code = code; } |