From 20a434faa81059fd2e969e7c372758d2e03da9e6 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 16 Sep 2018 19:44:45 +0200 Subject: 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 --- src/qml/jsruntime/qv4object_p.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/qml/jsruntime/qv4object_p.h') diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 7ac9888a88..6753ebfcd4 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -191,9 +191,14 @@ struct Q_QML_EXPORT Object: Managed { return getValueAccessor(thisObject, v, attrs); } ReturnedValue getValue(const Value &v, PropertyAttributes attrs) const { - Scope scope(this->engine()); - ScopedValue t(scope, const_cast(this)); - return getValue(t, v, attrs); + return getValue(*this, v, attrs); + } + ReturnedValue getValueByIndex(uint propertyIndex) const { + PropertyAttributes attrs = internalClass()->propertyData.at(propertyIndex); + const Value *v = propertyData(propertyIndex); + if (!attrs.isAccessor()) + return v->asReturnedValue(); + return getValueAccessor(*this, *v, attrs); } static ReturnedValue getValueAccessor(const Value &thisObject, const Value &v, PropertyAttributes attrs); @@ -382,6 +387,9 @@ protected: static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); static qint64 virtualGetLength(const Managed *m); static ReturnedValue virtualInstanceOf(const Object *typeObject, const Value &var); +public: + // qv4runtime uses this directly + static ReturnedValue checkedInstanceOf(ExecutionEngine *engine, const FunctionObject *typeObject, const Value &var); private: bool internalDefineOwnProperty(ExecutionEngine *engine, uint index, const InternalClassEntry *memberEntry, const Property *p, PropertyAttributes attrs); -- cgit v1.2.3