aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-30 21:53:03 +0200
committerLars Knoll <lars.knoll@qt.io>2017-09-01 12:30:49 +0000
commit6df6f642ea382169533a0ad106be270b6d4b7d58 (patch)
tree143401796a060f2e9aef61f9e5bf9a5ffa34a73b /src/qml/compiler/qv4codegen.cpp
parentcc7a858698063649f9770a89949354e2b58ae288 (diff)
Move CallContext construction into a interpreter instruction
This will allow us to further cut down on function call overhead. To make this work, introduce a proper distinction between EvalCode and GlobalCode and use the correct compilation mode in all places. Change-Id: I070621142159b7416026347c9239200c5ed7a56b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 52f88905c5..deda792cc6 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -1949,7 +1949,7 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
_module->functions.append(_context);
_context->functionIndex = _module->functions.count() - 1;
- _context->hasDirectEval |= _context->compilationMode == EvalCode || _module->debugMode; // Conditional breakpoints are like eval in the function
+ _context->hasDirectEval |= (_context->compilationMode == EvalCode || _context->compilationMode == GlobalCode || _module->debugMode); // Conditional breakpoints are like eval in the function
// ### still needed?
_context->maxNumberOfArguments = qMax(_context->maxNumberOfArguments, (int)QV4::Global::ReservedArgumentCount);
@@ -1963,7 +1963,7 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
bytecodeGenerator->newRegisterArray(sizeof(CallData)/sizeof(Value) - 1 + _context->arguments.size());
int returnAddress = -1;
- bool _requiresReturnValue = (_context->compilationMode == QmlBinding || _context->compilationMode == EvalCode);
+ bool _requiresReturnValue = (_context->compilationMode == QmlBinding || _context->compilationMode == EvalCode || _context->compilationMode == GlobalCode);
qSwap(requiresReturnValue, _requiresReturnValue);
if (requiresReturnValue)
returnAddress = bytecodeGenerator->newRegister();
@@ -1974,6 +1974,11 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
bool allVarsEscape = _context->hasWith || _context->hasTry || _context->hasDirectEval;
+ if (!_context->canUseSimpleCall() && _context->compilationMode != GlobalCode && (_context->compilationMode != EvalCode || _context->isStrict)) {
+ Instruction::CreateCallContext createContext;
+ bytecodeGenerator->addInstruction(createContext);
+ }
+
// variables in global code are properties of the global context object, not locals as with other functions.
if (_context->compilationMode == FunctionCode || _context->compilationMode == QmlBinding) {
for (Context::MemberMap::iterator it = _context->members.begin(), end = _context->members.end(); it != end; ++it) {