aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4managed_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-08-21 17:31:22 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-02 17:27:36 +0200
commit6f472680ebecb3a4d700eedcf62cb423b05c4fd1 (patch)
treebc732911a9c353dbac232ebda5a94468e3e261fe /src/qml/jsruntime/qv4managed_p.h
parentda2f24d8e5c32fe4ed45dcb89aa357465f85fc1e (diff)
change calling convention for JS function calls
This allows faster pass through of the data if we have nested calls. Also make sure we always reserve at least QV4::Global::ReservedArgumentCount Values on the stack to avoid stack corruption. Change-Id: I42976460f1ef11a333d4adda70fba8daac66acf3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4managed_p.h')
-rw-r--r--src/qml/jsruntime/qv4managed_p.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 227cd4bdb0..b77b1cd638 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -74,10 +74,30 @@ struct GCDeletable
bool lastCall;
};
+struct CallData
+{
+ Value thisObject;
+ Value *args;
+ int argc;
+};
+
+#ifdef QT_NO_DEBUG
+#define CALLDATA(argc_) \
+ QV4::CallData d; \
+ d.argc = argc_; \
+ d.args = (QV4::Value *)alloca(qMax((int)(argc_), (int)QV4::Global::ReservedArgumentCount)*sizeof(QV4::Value))
+#else
+#define CALLDATA(argc_) \
+ QV4::CallData d; \
+ d.argc = argc_; \
+ d.args = (QV4::Value *)alloca(qMax((int)(argc_), (int)QV4::Global::ReservedArgumentCount)*sizeof(QV4::Value)); \
+ for (int iii = 0; iii < qMax((int)(argc_), (int)QV4::Global::ReservedArgumentCount); ++iii) d.args[iii] = QV4::Value::undefinedValue()
+#endif
+
struct ManagedVTable
{
- Value (*call)(Managed *, const Value &thisObject, Value *args, int argc);
- Value (*construct)(Managed *, Value *args, int argc);
+ Value (*call)(Managed *, const CallData &data);
+ Value (*construct)(Managed *, const CallData &data);
void (*markObjects)(Managed *);
void (*destroy)(Managed *);
void (*collectDeletables)(Managed *, GCDeletable **deletable);
@@ -237,8 +257,8 @@ public:
inline bool hasInstance(const Value &v) {
return vtbl->hasInstance(this, v);
}
- Value construct(Value *args, int argc);
- Value call(const Value &thisObject, Value *args, int argc);
+ Value construct(const CallData &d);
+ Value call(const CallData &d);
Value get(String *name, bool *hasProperty = 0);
Value getIndexed(uint index, bool *hasProperty = 0);
void put(String *name, const Value &value)
@@ -266,8 +286,8 @@ public:
static void destroy(Managed *that) { that->_data = 0; }
static bool hasInstance(Managed *that, const Value &value);
- static Value construct(Managed *m, Value *, int);
- static Value call(Managed *m, const Value &, Value *, int);
+ static Value construct(Managed *m, const CallData &d);
+ static Value call(Managed *m, const CallData &);
static void getLookup(Managed *m, Lookup *, Value *);
static void setLookup(Managed *m, Lookup *l, const Value &v);
static bool isEqualTo(Managed *m, Managed *other);