aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4scopedvalue_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2014-12-17 21:07:05 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-12-19 16:30:16 +0100
commit45f77a6bfc05b97e6312a379c63840243b5815f3 (patch)
treec581f59d704c4af1a69a36f7c3bb404d36fc6e90 /src/qml/jsruntime/qv4scopedvalue_p.h
parentb50278bda4df94550bfbe5663ddebcd4b0f9734f (diff)
Cleanup code that modifies the JS stack
Change-Id: Ic043e256c3df984bb06c9a16b86573b0173b19a1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4scopedvalue_p.h')
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index 461d499694..6805fc80be 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -82,11 +82,12 @@ struct Scope {
}
Value *alloc(int nValues) {
- Value *ptr = engine->jsStackTop;
- engine->jsStackTop += nValues;
#ifndef QT_NO_DEBUG
size += nValues;
#endif
+ Value *ptr = engine->jsStackTop;
+ engine->jsStackTop = ptr + nValues;
+ memset(ptr, 0, nValues*sizeof(Value));
return ptr;
}
@@ -111,6 +112,7 @@ struct ScopedValue
ScopedValue(const Scope &scope)
{
ptr = scope.engine->jsStackTop++;
+ ptr->val = 0;
#ifndef QT_NO_DEBUG
++scope.size;
#endif
@@ -372,14 +374,9 @@ struct ScopedCallData {
ScopedCallData(Scope &scope, int argc = 0)
{
int size = qMax(argc, (int)QV4::Global::ReservedArgumentCount) + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value);
- ptr = reinterpret_cast<CallData *>(scope.engine->stackPush(size));
+ ptr = reinterpret_cast<CallData *>(scope.alloc(size));
ptr->tag = QV4::Value::Integer_Type;
ptr->argc = argc;
-#ifndef QT_NO_DEBUG
- scope.size += size;
- for (int ii = 0; ii < qMax(argc, (int)QV4::Global::ReservedArgumentCount); ++ii)
- ptr->args[ii] = QV4::Primitive::undefinedValue();
-#endif
}
CallData *operator->() {