aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-16 19:44:45 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-27 08:34:14 +0000
commit20a434faa81059fd2e969e7c372758d2e03da9e6 (patch)
tree07f41afc9663342a2ef06e8e0692cf3022950176 /src/qml/jsruntime/qv4functionobject_p.h
parent7c592625032a98f68fd6a09026e466c5fbc7bb09 (diff)
Speed up instanceof operations
Introduce a shortcut if the rhs is a functionobject with the regular function proto as prototype. Add an optimized instanceOf implementation when we already have some checks done, and inline some methods. Change-Id: Iab9b648ae7bbec749b319e883b6ae90a23875454 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject_p.h')
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index 8a2c84a8f6..b08b333411 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -77,7 +77,8 @@ DECLARE_HEAP_OBJECT(FunctionObject, Object) {
DECLARE_MARKOBJECTS(FunctionObject);
enum {
Index_ProtoConstructor = 0,
- Index_Prototype = 0
+ Index_Prototype = 0,
+ Index_HasInstance = 1,
};
bool isConstructor() const {
@@ -112,7 +113,7 @@ struct IndexedBuiltinFunction : FunctionObject {
struct ArrowFunction : FunctionObject {
enum {
- Index_Name = Index_Prototype + 1,
+ Index_Name = Index_HasInstance + 1,
Index_Length
};
void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr);
@@ -214,8 +215,12 @@ struct Q_QML_EXPORT FunctionObject: Object {
ReturnedValue getHomeObject() const;
- ReturnedValue protoProperty() const { return get(engine()->id_prototype()); }
-
+ ReturnedValue protoProperty() const {
+ return getValueByIndex(Heap::FunctionObject::Index_Prototype);
+ }
+ bool hasHasInstanceProperty() const {
+ return !internalClass()->propertyData.at(Heap::FunctionObject::Index_HasInstance).isEmpty();
+ }
QQmlSourceLocation sourceLocation() const;
};
@@ -316,6 +321,12 @@ struct BoundFunction: FunctionObject {
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
};
+inline bool FunctionObject::isBoundFunction() const
+{
+ return d()->vtable() == BoundFunction::staticVTable();
+}
+
+
}
QT_END_NAMESPACE