aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language/evaluatorscriptclass.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-04-24 11:50:33 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-04-26 13:24:01 +0000
commit589021d6eb5d7330d12d0b2efe76dff77f10b0b6 (patch)
treea42f86d847f12f821ce155e13f1af8525c942301 /src/lib/corelib/language/evaluatorscriptclass.cpp
parent1a440ba0708414843280c2f3e5d65b9f169acb51 (diff)
Merge caches with same key in Evaluator
Reduce hash lookups and memory footprint. ========== Performance data for Resolving ========== Old instruction count: 2465977485 New instruction count: 2457362647 Relative change: -1 % Old peak memory usage: 21248960 Bytes New peak memory usage: 21237680 Bytes Relative change: -1 % ========== Performance data for Rule Execution ========== Old instruction count: 4898426038 New instruction count: 4857983226 Relative change: -1 % Old peak memory usage: 27604240 Bytes New peak memory usage: 27593424 Bytes Relative change: -1 % ========== Performance data for Null Build ========== Old instruction count: 4509789474 New instruction count: 4490616946 Relative change: -1 % Old peak memory usage: 30680456 Bytes New peak memory usage: 30670784 Bytes Relative change: -1 % Change-Id: Ie613447cf9da4bc3d2bfdab42c9a9b5ace643540 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib/language/evaluatorscriptclass.cpp')
-rw-r--r--src/lib/corelib/language/evaluatorscriptclass.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index c68a195bc..50aa23707 100644
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -101,15 +101,6 @@ public:
}
private:
- QScriptValue importScope(Evaluator *evaluator, const FileContextConstPtr &file)
- {
- try {
- return evaluator->importScope(file);
- } catch (const ErrorInfo &e) {
- return evaluator->engine()->currentContext()->throwError(e.toString());
- }
- }
-
void setupConvenienceProperty(const QString &conveniencePropertyName, QScriptValue *extraScope,
const QScriptValue &scriptValue)
{
@@ -162,6 +153,8 @@ private:
for (int i = 0; i < value->alternatives().count(); ++i) {
const JSSourceValue::Alternative *alternative = 0;
alternative = &value->alternatives().at(i);
+ const Evaluator::FileContextScopes fileCtxScopes
+ = data->evaluator->fileContextScopes(value->file());
if (!conditionScopeItem) {
// We have to differentiate between module instances and normal items here.
//
@@ -194,14 +187,14 @@ private:
? data->item->scope() : data->item;
conditionScope = data->evaluator->scriptValue(conditionScopeItem);
QBS_ASSERT(conditionScope.isObject(), return);
- conditionFileScope = data->evaluator->fileScope(value->file());
+ conditionFileScope = fileCtxScopes.fileScope;
}
scriptContext->pushScope(conditionFileScope);
pushItemScopes(conditionScopeItem);
if (alternative->value->definingItem())
pushItemScopes(alternative->value->definingItem());
scriptContext->pushScope(conditionScope);
- const QScriptValue theImportScope = importScope(data->evaluator, value->file());
+ const QScriptValue &theImportScope = fileCtxScopes.importScope;
if (theImportScope.isError()) {
scriptContext->popScope();
scriptContext->popScope();
@@ -275,7 +268,9 @@ private:
setupConvenienceProperty(QLatin1String("original"), &extraScope, originalValue);
}
- pushScope(data->evaluator->fileScope(value->file()));
+ const Evaluator::FileContextScopes fileCtxScopes
+ = data->evaluator->fileContextScopes(value->file());
+ pushScope(fileCtxScopes.fileScope);
pushItemScopes(data->item);
if (itemOfProperty && itemOfProperty->type() != ItemType::ModuleInstance) {
// Own properties of module instances must not have the instance itself in the scope.
@@ -284,7 +279,7 @@ private:
if (value->definingItem())
pushItemScopes(value->definingItem());
pushScope(extraScope);
- const QScriptValue theImportScope = importScope(data->evaluator, value->file());
+ const QScriptValue &theImportScope = fileCtxScopes.importScope;
if (theImportScope.isError()) {
*result = theImportScope;
} else {