aboutsummaryrefslogtreecommitdiffstats
path: root/qv4mm.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-01-02 22:09:31 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2013-01-03 12:20:10 +0100
commit18d493f9a3f873532eaa197665db60638c415cff (patch)
treef35ee9bd456a92d96b9090cba5faef7b3302d4d3 /qv4mm.h
parentb46c04669f32a360eb839ca3ec17e769a7494825 (diff)
Move the mark and inUse bits into the Managed class
This simplifies the memory manager further, and removes some book-keeping overhead. Change-Id: I969c092cee822f7f0ab89e09d76b5c68c6bd50d2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'qv4mm.h')
-rw-r--r--qv4mm.h52
1 files changed, 6 insertions, 46 deletions
diff --git a/qv4mm.h b/qv4mm.h
index 5995984971..cefb97b01d 100644
--- a/qv4mm.h
+++ b/qv4mm.h
@@ -39,6 +39,8 @@
namespace QQmlJS {
namespace VM {
+class Managed;
+
class MemoryManager
{
MemoryManager(const MemoryManager &);
@@ -79,19 +81,8 @@ public:
inline Managed *allocManaged(std::size_t size)
{
size = align(size);
- MMObject *o = alloc(size);
- Managed *ptr = reinterpret_cast<Managed *>(&o->data);
- ptr->mm = this;
- return ptr;
- }
-
- inline void deallocManaged(Managed *m)
- {
- if (!m)
- return;
-
- assert(m->mm == this);
- dealloc(toObject(m));
+ Managed *o = alloc(size);
+ return o;
}
bool isGCBlocked() const;
@@ -105,42 +96,11 @@ public:
void dumpStats() const;
protected:
- struct MMObject;
-#if CPU(X86_64) // 64bit and x86:
- struct MMInfo {
- std::size_t inUse : 1;
- std::size_t markBit : 1;
- std::size_t size : 62;
- MMObject *next;
- };
- struct MMObject {
- MMInfo info;
- std::size_t data;
- };
-#elif CPU(X86) // for 32bits:
- struct MMInfo {
- std::size_t inUse : 1;
- std::size_t markBit : 1;
- std::size_t size : 30;
- struct MMObject *next;
- };
- struct MMObject {
- MMInfo info;
- std::size_t data;
- };
-#endif
-
-protected:
- static inline MMObject *toObject(void *ptr) { return reinterpret_cast<MMObject *>(reinterpret_cast<char *>(ptr) - sizeof(MMInfo)); }
-
/// expects size to be aligned
// TODO: try to inline
- MMObject *alloc(std::size_t size);
-
- // TODO: try to inline
- void dealloc(MMObject *ptr);
+ Managed *alloc(std::size_t size);
- void scribble(MMObject *obj, int c) const;
+ void scribble(Managed *obj, int c, int size) const;
void collectRootsOnStack(QVector<VM::Object *> &roots) const;