aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4mm.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-03 12:40:07 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-11 13:01:44 +0200
commit1986cf68d09fcd6cb586286bb21d8d9b7d405ce8 (patch)
tree4dc50920eeb124a893253eec7afe911747960020 /src/qml/jsruntime/qv4mm.cpp
parent87063772e329a8423d92a4eb8a8c29cff2fd9d18 (diff)
Create a stack for JS values and use it in the interpreter
First step towards being able to do an exact GC. Create a stack for JS Values that is separate from the C++ stack. Use the stack for generated methods (masm and moth). Change-Id: I80ac0e5b5d86439dda5e9ea2b21fa0c57d8aef22 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4mm.cpp')
-rw-r--r--src/qml/jsruntime/qv4mm.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp
index 095d27e1c0..874c349c42 100644
--- a/src/qml/jsruntime/qv4mm.cpp
+++ b/src/qml/jsruntime/qv4mm.cpp
@@ -293,6 +293,7 @@ void MemoryManager::mark()
#endif // COMPILER
collectFromStack();
+ collectFromJSStack();
// Preserve QObject ownership rules within JavaScript: A parent with c++ ownership
// keeps all of its children alive in JavaScript.
@@ -602,4 +603,16 @@ void MemoryManager::collectFromStack() const
}
}
+void MemoryManager::collectFromJSStack() const
+{
+ Value *v = engine()->jsStackBase;
+ Value *top = engine()->jsStackTop;
+ while (v < top) {
+ Managed *m = v->asManaged();
+ if (m && m->inUse)
+ // Skip pointers to already freed objects, they are bogus as well
+ m->mark();
+ ++v;
+ }
+}
QT_END_NAMESPACE