Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4function.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
24 | ** | - | ||||||
25 | ** GNU General Public License Usage | - | ||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
35 | ** | - | ||||||
36 | ** $QT_END_LICENSE$ | - | ||||||
37 | ** | - | ||||||
38 | ****************************************************************************/ | - | ||||||
39 | - | |||||||
40 | #include "qv4function_p.h" | - | ||||||
41 | #include "qv4functionobject_p.h" | - | ||||||
42 | #include "qv4managed_p.h" | - | ||||||
43 | #include "qv4string_p.h" | - | ||||||
44 | #include "qv4value_p.h" | - | ||||||
45 | #include "qv4engine_p.h" | - | ||||||
46 | #include "qv4lookup_p.h" | - | ||||||
47 | #include <private/qv4mm_p.h> | - | ||||||
48 | #include <private/qv4identifiertable_p.h> | - | ||||||
49 | #include <assembler/MacroAssemblerCodeRef.h> | - | ||||||
50 | #include <private/qv4vme_moth_p.h> | - | ||||||
51 | #include <private/qqmlglobal_p.h> | - | ||||||
52 | - | |||||||
53 | QT_BEGIN_NAMESPACE | - | ||||||
54 | - | |||||||
55 | using namespace QV4; | - | ||||||
56 | - | |||||||
57 | ReturnedValue Function::call(const Value *thisObject, const Value *argv, int argc, const ExecutionContext *context) { | - | ||||||
58 | ExecutionEngine *engine = context->engine(); | - | ||||||
59 | CppStackFrame frame; | - | ||||||
60 | frame.init(engine, this, argv, argc); | - | ||||||
61 | frame.setupJSFrame(engine->jsStackTop, Primitive::undefinedValue(), context->d(), | - | ||||||
62 | thisObject ? *thisObject : Primitive::undefinedValue(), | - | ||||||
63 | Primitive::undefinedValue()); | - | ||||||
64 | - | |||||||
65 | frame.push(); | - | ||||||
66 | engine->jsStackTop += frame.requiredJSStackFrameSize(); | - | ||||||
67 | - | |||||||
68 | ReturnedValue result = Moth::VME::exec(&frame, engine); | - | ||||||
69 | - | |||||||
70 | frame.pop(); | - | ||||||
71 | - | |||||||
72 | return result; executed 2773696 times by 134 tests: return result; Executed by:
| 2773696 | ||||||
73 | } | - | ||||||
74 | - | |||||||
75 | Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function) | - | ||||||
76 | : compiledFunction(function) | - | ||||||
77 | , compilationUnit(unit) | - | ||||||
78 | , codeData(function->code()) | - | ||||||
79 | , jittedCode(nullptr) | - | ||||||
80 | , codeRef(nullptr) | - | ||||||
81 | , hasQmlDependencies(function->hasQmlDependencies()) | - | ||||||
82 | { | - | ||||||
83 | Scope scope(engine); | - | ||||||
84 | Scoped<InternalClass> ic(scope, engine->internalClasses(EngineBase::Class_CallContext)); | - | ||||||
85 | - | |||||||
86 | // first locals | - | ||||||
87 | const quint32_le *localsIndices = compiledFunction->localsTable(); | - | ||||||
88 | for (quint32 i = 0; i < compiledFunction->nLocals; ++i)
| 109752-3439129 | ||||||
89 | ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable); executed 109752 times by 14 tests: ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable); Executed by:
| 109752 | ||||||
90 | - | |||||||
91 | const quint32_le *formalsIndices = compiledFunction->formalsTable(); | - | ||||||
92 | for (quint32 i = 0; i < compiledFunction->nFormals; ++i)
| 1764175-3440292 | ||||||
93 | ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[formalsIndices[i]]), Attr_NotConfigurable); executed 1764265 times by 56 tests: ic = ic->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[formalsIndices[i]]), Attr_NotConfigurable); Executed by:
| 1764265 | ||||||
94 | internalClass = ic->d(); | - | ||||||
95 | - | |||||||
96 | nFormals = compiledFunction->nFormals; | - | ||||||
97 | } executed 3439949 times by 137 tests: end of block Executed by:
| 3439949 | ||||||
98 | - | |||||||
99 | Function::~Function() | - | ||||||
100 | { | - | ||||||
101 | delete codeRef; | - | ||||||
102 | } executed 3442436 times by 137 tests: end of block Executed by:
| 3442436 | ||||||
103 | - | |||||||
104 | void Function::updateInternalClass(ExecutionEngine *engine, const QList<QByteArray> ¶meters) | - | ||||||
105 | { | - | ||||||
106 | QStringList parameterNames; | - | ||||||
107 | - | |||||||
108 | // Resolve duplicate parameter names: | - | ||||||
109 | for (int i = 0, ei = parameters.count(); i != ei; ++i) {
| 10-12 | ||||||
110 | const QByteArray ¶m = parameters.at(i); | - | ||||||
111 | int duplicate = -1; | - | ||||||
112 | - | |||||||
113 | for (int j = i - 1; j >= 0; --j) {
| 2-12 | ||||||
114 | const QByteArray &prevParam = parameters.at(j); | - | ||||||
115 | if (param == prevParam) {
| 0-2 | ||||||
116 | duplicate = j; | - | ||||||
117 | break; never executed: break; | 0 | ||||||
118 | } | - | ||||||
119 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
120 | - | |||||||
121 | if (duplicate == -1) {
| 0-12 | ||||||
122 | parameterNames.append(QString::fromUtf8(param)); | - | ||||||
123 | } else { executed 12 times by 4 tests: end of block Executed by:
| 12 | ||||||
124 | const QString &dup = parameterNames[duplicate]; | - | ||||||
125 | parameterNames.append(dup); | - | ||||||
126 | parameterNames[duplicate] = | - | ||||||
127 | QString(0xfffe) + QString::number(duplicate) + dup; | - | ||||||
128 | } never executed: end of block | 0 | ||||||
129 | - | |||||||
130 | } | - | ||||||
131 | - | |||||||
132 | internalClass = engine->internalClasses(EngineBase::Class_CallContext); | - | ||||||
133 | - | |||||||
134 | // first locals | - | ||||||
135 | const quint32_le *localsIndices = compiledFunction->localsTable(); | - | ||||||
136 | for (quint32 i = 0; i < compiledFunction->nLocals; ++i)
| 0-10 | ||||||
137 | internalClass = internalClass->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable); never executed: internalClass = internalClass->addMember(engine->identifierTable->asPropertyKey(compilationUnit->runtimeStrings[localsIndices[i]]), Attr_NotConfigurable); | 0 | ||||||
138 | - | |||||||
139 | Scope scope(engine); | - | ||||||
140 | ScopedString arg(scope); | - | ||||||
141 | for (const QString ¶meterName : parameterNames) { | - | ||||||
142 | arg = engine->newIdentifier(parameterName); | - | ||||||
143 | internalClass = internalClass->addMember(arg->propertyKey(), Attr_NotConfigurable); | - | ||||||
144 | } executed 12 times by 4 tests: end of block Executed by:
| 12 | ||||||
145 | nFormals = parameters.size(); | - | ||||||
146 | } executed 10 times by 4 tests: end of block Executed by:
| 10 | ||||||
147 | - | |||||||
148 | QQmlSourceLocation Function::sourceLocation() const | - | ||||||
149 | { | - | ||||||
150 | return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column); executed 90 times by 8 tests: return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column); Executed by:
| 90 | ||||||
151 | } | - | ||||||
152 | - | |||||||
153 | QT_END_NAMESPACE | - | ||||||
Source code | Switch to Preprocessed file |