From b80fa8e7d59c2824de067ab4d488d865a6e69d94 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 8 Sep 2016 11:07:26 +0200 Subject: QML: Make all context objects trivial This change also adds a check to the d() calls for Managed, verifies that the object has been initialized. This is only done for debug builds. To prevent other code from tripping the check, a number of other classes are either marked as trivial, or do initialization in the constructors. Because of template function changes in them memory manager (those now call init() instead of in-place new), String has an extra parameter to force it to temporarily use an old/unmodified template function. Change-Id: I8c35161ce7680835d830638b6d21498c5129b02b Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/qml/jsruntime/qv4functionobject.cpp') diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index df9f92b259..e160dd8a36 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -527,9 +527,7 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData ScopedObject proto(scope, f->protoForConstructor()); callData->thisObject = v4->newObject(ic, proto); - CallContext::Data ctx(v4); - ctx.mm_data = 0; - ctx.setVtable(CallContext::staticVTable()); + CallContext::Data ctx = CallContext::Data::createOnStack(v4); ctx.strictMode = f->strictMode(); ctx.callData = callData; ctx.function = f->d(); @@ -568,9 +566,7 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal Scoped f(scope, static_cast(that)); - CallContext::Data ctx(v4); - ctx.mm_data = 0; - ctx.setVtable(CallContext::staticVTable()); + CallContext::Data ctx = CallContext::Data::createOnStack(v4); ctx.strictMode = f->strictMode(); ctx.callData = callData; ctx.function = f->d(); @@ -626,9 +622,7 @@ void BuiltinFunction::call(const Managed *that, Scope &scope, CallData *callData ExecutionContextSaver ctxSaver(scope); - CallContext::Data ctx(v4); - ctx.mm_data = 0; - ctx.setVtable(CallContext::staticVTable()); + CallContext::Data ctx = CallContext::Data::createOnStack(v4); ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? ctx.callData = callData; v4->pushContext(&ctx); @@ -649,9 +643,7 @@ void IndexedBuiltinFunction::call(const Managed *that, Scope &scope, CallData *c ExecutionContextSaver ctxSaver(scope); - CallContext::Data ctx(v4); - ctx.mm_data = 0; - ctx.setVtable(CallContext::staticVTable()); + CallContext::Data ctx = CallContext::Data::createOnStack(v4); ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? ctx.callData = callData; v4->pushContext(&ctx); -- cgit v1.2.3