From ae6f850ab50bfe07625df4f810c7bf975c224877 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 7 Nov 2018 10:38:09 +0100 Subject: Generate lookups into the global object more aggressively Since change 9333ea8649838d7e0400b0e94c8cbd4fa5d216b0, we lookup properties in the QML context object before the global object to have proper scoping rules for QML. Unfortunately this lead to a performance regression when using global properties such as Math in imported script files, as the lookup would always go through the qml context first. This can be fixed, as we know that the global object is frozen in qml mode, and the standard names of properties in the global object are illegal to use in QML. So simply check for those names in the code generator and create lookups into the global object for those. Change-Id: I4b2089178c9e5f9440abdfd834cf7d92c3c0e2c3 Fixes: QTBUG-71591 Reviewed-by: Erik Verbruggen --- src/qml/compiler/qv4codegen_p.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/qml/compiler/qv4codegen_p.h') diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index e6e7d2e9fb..7630a1f71d 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -708,6 +708,11 @@ public: return *_returnLabel; } + void setGlobalNames(const QSet& globalNames) { + m_globalNames = globalNames; + } + + protected: friend class ScanFunctions; friend struct ControlFlow; @@ -730,6 +735,7 @@ protected: bool inFormalParameterList = false; bool functionEndsWithReturn = false; bool _tailCallsAreAllowed = true; + QSet m_globalNames; ControlFlow *controlFlow = nullptr; -- cgit v1.2.3