17#include <private/qintrusivelist_p.h>
18#include <private/qqmldelayedcallqueue_p.h>
19#include <private/qqmlrefcount_p.h>
20#include <private/qv4compileddata_p.h>
21#include <private/qv4context_p.h>
22#include <private/qv4enginebase_p.h>
23#include <private/qv4executablecompilationunit_p.h>
24#include <private/qv4function_p.h>
25#include <private/qv4global_p.h>
26#include <private/qv4stacklimits_p.h>
28#include <QtCore/qelapsedtimer.h>
29#include <QtCore/qmutex.h>
30#include <QtCore/qprocessordetection.h>
31#include <QtCore/qset.h>
34class BumpPointerAllocator;
38#define V4_DEFINE_EXTENSION(dataclass, datafunction) \
39 static inline dataclass *datafunction(QV4::ExecutionEngine *engine) \
41 static int extensionId = -1; \
42 if (extensionId == -1) { \
43 QV4::ExecutionEngine::registrationMutex()->lock(); \
44 if (extensionId == -1) \
45 extensionId = QV4::ExecutionEngine::registerExtension(); \
46 QV4::ExecutionEngine::registrationMutex()->unlock(); \
48 dataclass *rv = (dataclass *)engine->extensionData(extensionId); \
50 rv = new dataclass(engine); \
51 engine->setExtensionData(extensionId, rv); \
59#if QT_CONFIG(qml_network)
69namespace QV4 {
struct QObjectMethod; }
98 : callData(callData), retVal(retVal),
e(
e)
120namespace CompiledData {
121struct CompilationUnit;
137 friend struct ExecutionContextSaver;
139 friend struct Heap::ExecutionContext;
143 AotByteCode = 1 << 0,
147 Aot = AotByteCode | AotNative,
148 Qmlc = QmlcRead | QmlcWrite,
149 Enabled = Aot | Qmlc,
166 jsStackTop =
ptr + nValues;
295 return reinterpret_cast<FunctionObject *
>(jsObjects + UrlSearchParams_Ctor);
349#if QT_CONFIG(qml_network)
515#if QT_CONFIG(qml_jit)
516 const bool m_canAllocateExecutableMemory;
524#if !QT_CONFIG(qml_debug)
534 void setDebugger(Debugging::Debugger *
debugger);
535 void setProfiler(Profiling::Profiler *profiler);
541 template<
typename StackFrame = CppStackFrame>
552 Heap::Object *newObject();
558 Heap::Object *newStringObject(
const String *
string);
559 Heap::Object *newSymbolObject(
const Symbol *symbol);
560 Heap::Object *newNumberObject(
double value);
561 Heap::Object *newBooleanObject(
bool b);
571 Heap::DateObject *newDateObject(
double dateTime);
578 Heap::RegExpObject *newRegExpObject(
RegExp *re);
579#if QT_CONFIG(regularexpression)
583 Heap::UrlObject *newUrlObject();
584 Heap::UrlObject *newUrlObject(
const QUrl &
url);
585 Heap::UrlSearchParamsObject *newUrlSearchParamsObject();
587 Heap::Object *newErrorObject(
const Value &
value);
599 Heap::PromiseObject *newPromiseObject();
605 Heap::Object *newForInIteratorObject(
Object *
o);
606 Heap::Object *newSetIteratorObject(
Object *
o);
607 Heap::Object *newMapIteratorObject(
Object *
o);
608 Heap::Object *newArrayIteratorObject(
Object *
o);
612 Heap::ExecutionContext *outer =
ctx->outer;
614 if (
ctx->type != Heap::ExecutionContext::Type_QmlContext && !outer)
617 while (outer && outer->type != Heap::ExecutionContext::Type_GlobalContext) {
623 if (
ctx->type != Heap::ExecutionContext::Type_QmlContext)
630 QObject *qmlScopeObject()
const;
634 StackTrace stackTrace(
int frameLimit = -1)
const;
639 void initRootContext();
676 int maxJSStackSize()
const;
677 int maxGCStackSize()
const;
679 bool checkStackLimits();
680 int safeForAllocLength(
qint64 len64);
684#if QT_CONFIG(qml_jit)
685 if (!m_canAllocateExecutableMemory)
688 return f->kind != Function::AotCompiled
690 &&
f->interpreterCallCount >= s_jitCallCountThreshold;
700 void initQmlGlobalObject();
701 void initializeGlobal();
702 void createQtObject();
710#if QT_CONFIG(qml_xml_http_request)
711 void *xmlHttpRequestData()
const {
return m_xmlHttpRequestData; }
719 void startTimer(
const QString &timerName);
720 qint64 stopTimer(
const QString &timerName,
bool *wasRunning);
729 static QMutex *registrationMutex();
730 static int registerExtension();
732 void setExtensionData(
int, Deletable *);
735 if (
index < m_extensionData.size())
736 return m_extensionData[
index];
741 double localTZA = 0.0;
760 DiskCacheOptions diskCacheOptions()
const;
775 template<
typename Value>
778 if (
v->isUndefined())
797 static void initializeStaticMembers();
799 bool inStack(
const void *current)
const
801#if Q_STACK_GROWTH_DIRECTION > 0
802 return current < cppStackLimit && current >= cppStackBase;
804 return current > cppStackLimit && current <= cppStackBase;
808 bool hasCppStackOverflow()
810 if (s_maxCallDepth >= 0)
811 return callDepth >= s_maxCallDepth;
819 cppStackBase = stack.
base;
824 bool hasJsStackOverflow()
const
826 return jsStackTop > jsStackLimit;
829 bool hasStackOverflow()
831 return hasJsStackOverflow() || hasCppStackOverflow();
834 static int s_maxCallDepth;
835 static int s_jitCallCountThreshold;
836 static int s_maxJSStackSize;
837 static int s_maxGCStackSize;
839#if QT_CONFIG(qml_debug)
848#if QT_CONFIG(qml_xml_http_request)
849 void *m_xmlHttpRequestData;
863 mutable QMutex moduleMutex;
873#define CHECK_STACK_LIMITS(v4) \
874 if (v4->checkStackLimits()) \
875 return Encode::undefined(); \
876 ExecutionEngineCallDepthRecorder _executionEngineCallDepthRecorder(v4);
878template<
int Frames = 1>
885 if (ExecutionEngine::s_maxCallDepth >= 0)
891 if (ExecutionEngine::s_maxCallDepth >= 0)
897 return ee->hasCppStackOverflow();
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
The QIntrusiveList class is a template class that provides a list of objects using static storage.
The QJSEngine class provides an environment for evaluating JavaScript code.
The QJSPrimitiveValue class operates on primitive types in JavaScript semantics.
The QNetworkAccessManager class allows the application to send network requests and receive replies.
The QQmlEngine class provides an environment for instantiating QML components.
The QQmlError class encapsulates a QML error.
QV4::ExecutionEngine * v4engine() const
QV4::ReturnedValue operator[](int idx) const
void setReturnValue(QV4::ReturnedValue rv)
\inmodule QtCore \reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
\inmodule QtCore \reentrant
ScarceResourceData(const QMetaType type, const void *data)
ScarceResourceData()=default
Combined button and popup list for selecting options.
\qmltype Particle \inqmlmodule QtQuick.Particles
StackProperties stackProperties()
const void * currentStackPointer()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
static ControlElement< T > * ptr(QWidget *widget)
GLenum GLsizei GLsizei GLint * values
[15]
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLsizei GLenum GLenum * types
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
QQmlContext * qmlContext(const QObject *obj)
static QUrl resolvedUrl(const QUrl &url, const QQmlRefPointer< QQmlContextData > &context)
#define QStringLiteral(str)
static DebuggerProgram debugger
#define QML_NEARLY_ALWAYS_INLINE
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols, V4ObjectSet *visitedObjects)
ReturnedValue throwTypeError(const FunctionObject *b, const QV4::Value *, const QV4::Value *, int)
QUrl url("example.com")
[constructor-url-reference]
An empty marker type to signify the JavaScript null value. \inmodule QtQml.
An empty marker type to signify the JavaScript Undefined type and its single value....
static constexpr ReturnedValue undefined()
~ExecutionEngineCallDepthRecorder()
ExecutionEngineCallDepthRecorder(ExecutionEngine *e)
QQmlRefPointer< ExecutableCompilationUnit > compiled
String * id_sticky() const
Symbol * symbol_isConcatSpreadable() const
FunctionObject * promiseCtor() const
FunctionObject * getSymbolSpecies() const
WTF::PageAllocation * gcStack
Symbol * symbol_split() const
Object * typeErrorPrototype() const
String * id_unicode() const
ExecutionContext * rootContext() const
Q_DECLARE_FLAGS(DiskCacheOptions, DiskCache)
String * id_byteLength() const
Symbol * symbol_iterator() const
String * id_flags() const
StackTrace exceptionStackTrace
WTF::PageAllocation * jsStack
Object * iteratorPrototype() const
FunctionObject * objectCtor() const
FunctionObject * urlSearchParamsCtor() const
FunctionObject * regExpCtor() const
QIntrusiveList< ScarceResourceData, &ScarceResourceData::node > scarceResources
QV4::Debugging::Debugger * debugger() const
String * id_arguments() const
String * id_uintMax() const
Symbol * symbol_toPrimitive() const
FunctionObject * booleanCtor() const
String * id_callee() const
Object * urlPrototype() const
Object * dataViewPrototype() const
QQmlDelayedCallQueue * delayedCallQueue()
ReturnedValue throwRangeError(const Value &value)
Object * stringPrototype() const
FunctionObject * dateCtor() const
String * id_length() const
Object * signalHandlerPrototype() const
void setProfiler(Profiling::Profiler *)
Object * arrayPrototype() const
String * id_constructor() const
String * id_global() const
static int maxCallDepth()
FunctionObject * evalErrorCtor() const
String * id_multiline() const
String * id_ignoreCase() const
Object * weakSetPrototype() const
String * id_string() const
Symbol * symbol_replace() const
Object * stringIteratorPrototype() const
String * id_buffer() const
String * id_value() const
FunctionObject * typedArrayCtors
@ IntrinsicTypedArrayProto
@ IntrinsicTypedArray_Ctor
Object * variantPrototype() const
String * id_destroy() const
Object * weakMapPrototype() const
String * id_writable() const
Deletable * extensionData(int index) const
String * id_toString() const
Object * mapIteratorPrototype() const
String * id_prototype() const
Object * numberPrototype() const
String * id_lastIndex() const
String * id_false() const
FunctionObject * urlCtor() const
QML_NEARLY_ALWAYS_INLINE Value * jsAlloca(int nValues)
QIntrusiveList< ExecutableCompilationUnit, &ExecutableCompilationUnit::nextCompilationUnit > compilationUnits
String * id_caller() const
String * id_byteOffset() const
String * id___proto__() const
FunctionObject * typeErrorCtor() const
String * id_toLocaleString() const
FunctionObject * referenceErrorCtor() const
Object * rangeErrorPrototype() const
ExecutableAllocator * executableAllocator
Object * setPrototype() const
Object * valueTypeWrapperPrototype() const
Symbol * symbol_toStringTag() const
FunctionObject * arrayBufferCtor() const
Object * forInIteratorPrototype() const
String * id_index() const
String * id_undefined() const
String * id_default() const
Symbol * symbol_revokableProxy() const
String * id_boolean() const
ExecutionContext * scriptContext() const
Object * uRIErrorPrototype() const
String * id_enumerable() const
Object * datePrototype() const
EvalFunction * evalFunction() const
FunctionObject * functionCtor() const
FunctionObject * syntaxErrorCtor() const
String * id_empty() const
WTF::BumpPointerAllocator * bumperPointerAllocator
String * id_input() const
ExecutableAllocator * regExpAllocator
Object * intrinsicTypedArrayPrototype() const
static void setMaxCallDepth(int maxCallDepth)
Object * objectPrototype() const
String * id_number() const
Symbol * symbol_hasInstance() const
FunctionObject * errorCtor() const
Symbol * symbol_species() const
FunctionObject * symbolCtor() const
QJSEngine * jsEngine() const
Object * syntaxErrorPrototype() const
RegExpCache * regExpCache
Object * sharedArrayBufferPrototype() const
static QJSPrimitiveValue createPrimitive(const Value &v)
FunctionObject * mapCtor() const
Object * booleanPrototype() const
Object * setIteratorPrototype() const
void setDebugger(Debugging::Debugger *)
@ Symbol_isConcatSpreadable
Object * symbolPrototype() const
Object * functionPrototype() const
FunctionObject * uRIErrorCtor() const
FunctionObject * generatorFunctionCtor() const
String * id_object() const
Object * urlSearchParamsPrototype() const
bool canJIT(Function *f=nullptr)
QQmlEngine * qmlEngine() const
void setScriptContext(ReturnedValue c)
String * id_throw() const
FunctionObject * arrayCtor() const
Object * promisePrototype() const
String * id_symbol() const
FunctionObject * setCtor() const
Object * arrayProtoValues() const
Symbol * symbol_match() const
String * id_configurable() const
static Heap::ExecutionContext * qmlContext(Heap::ExecutionContext *ctx)
Object * arrayIteratorPrototype() const
FunctionObject * thrower() const
Object * sequencePrototype() const
Object * arrayBufferPrototype() const
FunctionObject * intrinsicTypedArrayCtor() const
FunctionObject * rangeErrorCtor() const
FunctionObject * dataViewCtor() const
Object * typedArrayPrototype
String * id_source() const
String * id_return() const
Object * propertyListPrototype() const
Object * evalErrorPrototype() const
String * id_valueOf() const
Object * regExpPrototype() const
Symbol * symbol_unscopables() const
FunctionObject * weakSetCtor() const
FunctionObject * weakMapCtor() const
FunctionObject * stringCtor() const
MultiplyWrappedQObjectMap * m_multiplyWrappedQObjects
FunctionObject * numberCtor() const
FunctionObject * sharedArrayBufferCtor() const
Object * mapPrototype() const
Object * errorPrototype() const
QV4::Profiling::Profiler * profiler() const
Symbol * symbol_search() const
FunctionObject * getStackFunction() const
ExecutionContext * currentContext() const
Object * generatorPrototype() const
Object * referenceErrorPrototype() const
String * id_function() const
constexpr ReturnedValue asReturnedValue() const
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent