aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-08-16 12:54:30 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-17 09:26:30 +0200
commit3cfc7e0c026faf70eff8e180a2df3a01b34491c0 (patch)
treedcac9d9a70e1664452647f5c165cb2f7a5692692 /src/qml/compiler/qv4codegen.cpp
parent51e7447481a472ef542e7c6e7b669574ba366a9d (diff)
Move arguments object creation into the generated code
So far we've been creating the arguments object at runtime in initCallContext(). It's much more efficient to simply add arguments as a local variable in qv4codegen if it's being used and initialize it through a builtin method. Change-Id: I6913f3565adf3aa1917adae8dceef9f50ecf1722 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index e0c77cfa94..8c751246db 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1820,11 +1820,14 @@ V4IR::Function *Codegen::defineFunction(const QString &name, AST::Node *ast,
V4IR::BasicBlock *exitBlock = function->newBasicBlock(groupStartBlock(), V4IR::Function::DontInsertBlock);
V4IR::BasicBlock *throwBlock = function->newBasicBlock(groupStartBlock());
function->hasDirectEval = _env->hasDirectEval;
- function->usesArgumentsObject = (_env->usesArgumentsObject == Environment::ArgumentsObjectUsed);
+ function->usesArgumentsObject = _env->parent && (_env->usesArgumentsObject == Environment::ArgumentsObjectUsed);
function->maxNumberOfArguments = _env->maxNumberOfArguments;
function->isStrict = _env->isStrict;
function->isNamedExpression = _env->isNamedFunctionExpression;
+ if (function->usesArgumentsObject)
+ _env->enter("arguments", Environment::VariableDeclaration);
+
// variables in global code are properties of the global context object, not locals as with other functions.
if (_mode == FunctionCode) {
unsigned t = 0;
@@ -1897,6 +1900,11 @@ V4IR::Function *Codegen::defineFunction(const QString &name, AST::Node *ast,
}
}
}
+ if (_function->usesArgumentsObject) {
+ move(_block->NAME("arguments", ast->firstSourceLocation().startLine, ast->firstSourceLocation().startColumn),
+ _block->CALL(_block->NAME(V4IR::Name::builtin_setup_argument_object,
+ ast->firstSourceLocation().startLine, ast->firstSourceLocation().startColumn), 0));
+ }
sourceElements(body);