From f3561037c9892c9c467f618ce3000567a4924363 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 3 Jul 2017 16:23:35 +0200 Subject: Limit the amount of escaping variables Calculate more exactly which variables can be referenced from an inner context, and convert all the non escaping ones to temporaries on the stack. Change-Id: I0e33e85b0f6f426ef2812b8ecccee1870492b7b5 Reviewed-by: Erik Verbruggen --- src/qml/compiler/qv4compilerscanfunctions.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp') diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index 2a217fbb99..b59beb0315 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -305,6 +305,13 @@ void ScanFunctions::endVisit(FunctionDeclaration *) leaveEnvironment(); } +bool ScanFunctions::visit(TryStatement *) +{ + // ### should limit to catch(), as try{} finally{} should be ok without + _context->hasTry = true; + return true; +} + bool ScanFunctions::visit(WithStatement *ast) { if (_context->isStrict) { @@ -312,6 +319,7 @@ bool ScanFunctions::visit(WithStatement *ast) return false; } + _context->hasWith = true; return true; } @@ -436,6 +444,11 @@ void ScanFunctions::calcEscapingVariables() c = c->parent; } } + Context *c = inner->parent; + while (c) { + c->hasDirectEval |= inner->hasDirectEval; + c = c->parent; + } } static const bool showEscapingVars = qEnvironmentVariableIsSet("QV4_SHOW_ESCAPING_VARS"); -- cgit v1.2.3