Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4stackframe_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2018 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 | #ifndef QV4STACKFRAME_H | - | ||||||
40 | #define QV4STACKFRAME_H | - | ||||||
41 | - | |||||||
42 | #include <private/qv4context_p.h> | - | ||||||
43 | #include <private/qv4enginebase_p.h> | - | ||||||
44 | #ifndef V4_BOOTSTRAP | - | ||||||
45 | #include <private/qv4function_p.h> | - | ||||||
46 | #endif | - | ||||||
47 | - | |||||||
48 | QT_BEGIN_NAMESPACE | - | ||||||
49 | - | |||||||
50 | namespace QV4 { | - | ||||||
51 | - | |||||||
52 | struct CallData | - | ||||||
53 | { | - | ||||||
54 | enum Offsets { | - | ||||||
55 | Function = 0, | - | ||||||
56 | Context = 1, | - | ||||||
57 | Accumulator = 2, | - | ||||||
58 | This = 3, | - | ||||||
59 | NewTarget = 4, | - | ||||||
60 | Argc = 5 | - | ||||||
61 | }; | - | ||||||
62 | - | |||||||
63 | Value function; | - | ||||||
64 | Value context; | - | ||||||
65 | Value accumulator; | - | ||||||
66 | Value thisObject; | - | ||||||
67 | Value newTarget; | - | ||||||
68 | Value _argc; | - | ||||||
69 | - | |||||||
70 | int argc() const { | - | ||||||
71 | Q_ASSERT(_argc.isInteger()); | - | ||||||
72 | return _argc.int_32(); executed 2207750 times by 130 tests: return _argc.int_32(); Executed by:
| 2207750 | ||||||
73 | } | - | ||||||
74 | - | |||||||
75 | void setArgc(int argc) { | - | ||||||
76 | Q_ASSERT(argc >= 0); | - | ||||||
77 | _argc.setInt_32(argc); | - | ||||||
78 | } executed 19862422 times by 135 tests: end of block Executed by:
| 19862422 | ||||||
79 | - | |||||||
80 | inline ReturnedValue argument(int i) const { | - | ||||||
81 | return i < argc() ? args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); never executed: return i < argc() ? args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); | 0 | ||||||
82 | } | - | ||||||
83 | - | |||||||
84 | Value args[1]; | - | ||||||
85 | - | |||||||
86 | static Q_DECL_CONSTEXPR int HeaderSize() { return offsetof(CallData, args) / sizeof(QV4::Value); } | - | ||||||
87 | }; | - | ||||||
88 | - | |||||||
89 | Q_STATIC_ASSERT(std::is_standard_layout<CallData>::value); | - | ||||||
90 | Q_STATIC_ASSERT(offsetof(CallData, thisObject) == CallData::This*sizeof(Value)); | - | ||||||
91 | Q_STATIC_ASSERT(offsetof(CallData, args) == 6*sizeof(Value)); | - | ||||||
92 | - | |||||||
93 | struct Q_QML_EXPORT CppStackFrame { | - | ||||||
94 | EngineBase *engine; | - | ||||||
95 | Value *savedStackTop; | - | ||||||
96 | CppStackFrame *parent; | - | ||||||
97 | Function *v4Function; | - | ||||||
98 | CallData *jsFrame; | - | ||||||
99 | const Value *originalArguments; | - | ||||||
100 | int originalArgumentsCount; | - | ||||||
101 | int instructionPointer; | - | ||||||
102 | const char *yield; | - | ||||||
103 | const char *unwindHandler; | - | ||||||
104 | const char *unwindLabel; | - | ||||||
105 | int unwindLevel; | - | ||||||
106 | - | |||||||
107 | void init(EngineBase *engine, Function *v4Function, const Value *argv, int argc) { | - | ||||||
108 | this->engine = engine; | - | ||||||
109 | - | |||||||
110 | this->v4Function = v4Function; | - | ||||||
111 | originalArguments = argv; | - | ||||||
112 | originalArgumentsCount = argc; | - | ||||||
113 | instructionPointer = 0; | - | ||||||
114 | yield = nullptr; | - | ||||||
115 | unwindHandler = nullptr; | - | ||||||
116 | unwindLabel = nullptr; | - | ||||||
117 | unwindLevel = 0; | - | ||||||
118 | } executed 17775220 times by 135 tests: end of block Executed by:
| 17775220 | ||||||
119 | - | |||||||
120 | void push() { | - | ||||||
121 | parent = engine->currentStackFrame; | - | ||||||
122 | engine->currentStackFrame = this; | - | ||||||
123 | savedStackTop = engine->jsStackTop; | - | ||||||
124 | } executed 17779491 times by 135 tests: end of block Executed by:
| 17779491 | ||||||
125 | - | |||||||
126 | void pop() { | - | ||||||
127 | engine->currentStackFrame = parent; | - | ||||||
128 | engine->jsStackTop = savedStackTop; | - | ||||||
129 | } executed 17723791 times by 135 tests: end of block Executed by:
| 17723791 | ||||||
130 | - | |||||||
131 | #ifndef V4_BOOTSTRAP | - | ||||||
132 | static uint requiredJSStackFrameSize(uint nRegisters) { | - | ||||||
133 | return CallData::HeaderSize() + nRegisters; | - | ||||||
134 | } | - | ||||||
135 | static uint requiredJSStackFrameSize(Function *v4Function) { | - | ||||||
136 | return CallData::HeaderSize() + v4Function->compiledFunction->nRegisters; | - | ||||||
137 | } | - | ||||||
138 | uint requiredJSStackFrameSize() const { | - | ||||||
139 | return requiredJSStackFrameSize(v4Function); | - | ||||||
140 | } | - | ||||||
141 | void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope, | - | ||||||
142 | const Value &thisObject, const Value &newTarget = Primitive::undefinedValue()) { | - | ||||||
143 | setupJSFrame(stackSpace, function, scope, thisObject, newTarget, | - | ||||||
144 | v4Function->nFormals, v4Function->compiledFunction->nRegisters); | - | ||||||
145 | } | - | ||||||
146 | void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope, | - | ||||||
147 | const Value &thisObject, const Value &newTarget, uint nFormals, uint nRegisters) | - | ||||||
148 | { | - | ||||||
149 | jsFrame = reinterpret_cast<CallData *>(stackSpace); | - | ||||||
150 | jsFrame->function = function; | - | ||||||
151 | jsFrame->context = scope->asReturnedValue(); | - | ||||||
152 | jsFrame->accumulator = Encode::undefined(); | - | ||||||
153 | jsFrame->thisObject = thisObject; | - | ||||||
154 | jsFrame->newTarget = newTarget; | - | ||||||
155 | - | |||||||
156 | uint argc = uint(originalArgumentsCount); | - | ||||||
157 | if (argc > nFormals) | - | ||||||
158 | argc = nFormals; | - | ||||||
159 | jsFrame->setArgc(argc); | - | ||||||
160 | - | |||||||
161 | memcpy(jsFrame->args, originalArguments, argc*sizeof(Value)); | - | ||||||
162 | const Value *end = jsFrame->args + nRegisters; | - | ||||||
163 | for (Value *v = jsFrame->args + argc; v < end; ++v) | - | ||||||
164 | *v = Encode::undefined(); | - | ||||||
165 | } | - | ||||||
166 | #endif | - | ||||||
167 | - | |||||||
168 | QString source() const; | - | ||||||
169 | QString function() const; | - | ||||||
170 | inline QV4::ExecutionContext *context() const { | - | ||||||
171 | return static_cast<ExecutionContext *>(&jsFrame->context); executed 8691557 times by 29 tests: return static_cast<ExecutionContext *>(&jsFrame->context); Executed by:
| 8691557 | ||||||
172 | } | - | ||||||
173 | int lineNumber() const; | - | ||||||
174 | - | |||||||
175 | inline QV4::Heap::CallContext *callContext() const { | - | ||||||
176 | Heap::ExecutionContext *ctx = static_cast<ExecutionContext &>(jsFrame->context).d();\ | - | ||||||
177 | while (ctx->type != Heap::ExecutionContext::Type_CallContext)
| 0 | ||||||
178 | ctx = ctx->outer; never executed: ctx = ctx->outer; | 0 | ||||||
179 | return static_cast<Heap::CallContext *>(ctx); never executed: return static_cast<Heap::CallContext *>(ctx); | 0 | ||||||
180 | } | - | ||||||
181 | ReturnedValue thisObject() const; | - | ||||||
182 | }; | - | ||||||
183 | - | |||||||
184 | } | - | ||||||
185 | - | |||||||
186 | QT_END_NAMESPACE | - | ||||||
187 | - | |||||||
188 | #endif | - | ||||||
Source code | Switch to Preprocessed file |