aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/memory')
-rw-r--r--src/qml/memory/qv4mm_p.h61
1 files changed, 52 insertions, 9 deletions
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index c01866ff11..6b6b502b95 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -37,6 +37,7 @@
#include <private/qv4global_p.h>
#include <private/qv4value_p.h>
#include <private/qv4scopedvalue_p.h>
+#include <private/qv4object_p.h>
//#define DETAILED_MM_STATS
@@ -91,6 +92,57 @@ public:
return static_cast<typename ManagedType::Data *>(o);
}
+ template <typename ManagedType, typename Arg1>
+ typename ManagedType::Data *allocWithStringData(std::size_t unmanagedSize, Arg1 arg1)
+ {
+ Scope scope(engine());
+ Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data), unmanagedSize));
+ (void)new (t->d()) typename ManagedType::Data(this, arg1);
+ return t->d();
+ }
+
+ template <typename ObjectType>
+ typename ObjectType::Data *allocObject(InternalClass *ic, Object *prototype)
+ {
+ Scope scope(engine());
+ const int size = (sizeof(typename ObjectType::Data) + (sizeof(Value) - 1)) & ~(sizeof(Value) - 1);
+ Scoped<ObjectType> t(scope, allocManaged<ObjectType>(size + ic->size*sizeof(Value)));
+ t->d()->internalClass = ic;
+ t->d()->prototype = prototype->d();
+ t->d()->inlineMemberSize = ic->size;
+ t->d()->inlineMemberOffset = size/sizeof(Value);
+ (void)new (t->d()) typename ObjectType::Data();
+ return t->d();
+ }
+
+ template <typename ObjectType, typename Arg1>
+ typename ObjectType::Data *allocObject(InternalClass *ic, Object *prototype, Arg1 arg1)
+ {
+ Scope scope(engine());
+ const int size = (sizeof(typename ObjectType::Data) + (sizeof(Value) - 1)) & ~(sizeof(Value) - 1);
+ Scoped<ObjectType> t(scope, allocManaged<ObjectType>(size + ic->size*sizeof(Value)));
+ t->d()->internalClass = ic;
+ t->d()->prototype = prototype->d();
+ t->d()->inlineMemberSize = ic->size;
+ t->d()->inlineMemberOffset = size/sizeof(Value);
+ (void)new (t->d()) typename ObjectType::Data(arg1);
+ return t->d();
+ }
+
+ template <typename ObjectType, typename Arg1, typename Arg2>
+ typename ObjectType::Data *allocObject(InternalClass *ic, Object *prototype, Arg1 arg1, Arg2 arg2)
+ {
+ Scope scope(engine());
+ const int size = (sizeof(typename ObjectType::Data) + (sizeof(Value) - 1)) & ~(sizeof(Value) - 1);
+ Scoped<ObjectType> t(scope, allocManaged<ObjectType>(size + ic->size*sizeof(Value)));
+ t->d()->internalClass = ic;
+ t->d()->prototype = prototype->d();
+ t->d()->inlineMemberSize = ic->size;
+ t->d()->inlineMemberOffset = size/sizeof(Value);
+ (void)new (t->d()) typename ObjectType::Data(arg1, arg2);
+ return t->d();
+ }
+
template <typename ManagedType>
typename ManagedType::Data *alloc()
{
@@ -109,15 +161,6 @@ public:
return t->d();
}
- template <typename ManagedType, typename Arg1>
- typename ManagedType::Data *allocWithStringData(std::size_t unmanagedSize, Arg1 arg1)
- {
- Scope scope(engine());
- Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data), unmanagedSize));
- (void)new (t->d()) typename ManagedType::Data(this, arg1);
- return t->d();
- }
-
template <typename ManagedType, typename Arg1, typename Arg2>
typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2)
{