diff options
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp | 3 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h | 2 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 6 | ||||
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 18 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 54 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4enginebase_p.h | 29 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4sequenceobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 18 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 16 |
14 files changed, 80 insertions, 80 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index 76d5315004..0097fed0d6 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE QV4::Heap::CallContext *QV4DataCollector::findContext(int frame) { - QV4::EngineBase::StackFrame *f = engine()->currentStackFrame; + QV4::CppStackFrame *f = engine()->currentStackFrame; while (f && frame) { --frame; f = f->parent; @@ -99,7 +99,6 @@ int QV4DataCollector::encodeScopeType(QV4::Heap::ExecutionContext::ContextType s return 4; case QV4::Heap::ExecutionContext::Type_WithContext: return 2; - case QV4::Heap::ExecutionContext::Type_SimpleCallContext: case QV4::Heap::ExecutionContext::Type_CallContext: return 1; case QV4::Heap::ExecutionContext::Type_QmlContext: diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h index b2200c47fc..42f4534015 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.h @@ -150,7 +150,7 @@ private: void runJobUnpaused(); QV4::ExecutionEngine *m_engine; - QV4::EngineBase::StackFrame *m_currentFrame = 0; + QV4::CppStackFrame *m_currentFrame = 0; QMutex m_lock; QWaitCondition m_runningCondition; State m_state; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp index 09ed9ac98c..316fd87dd4 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debuggeragent.cpp @@ -79,7 +79,7 @@ void QV4DebuggerAgent::debuggerPaused(QV4Debugger *debugger, QV4Debugger::PauseR case QV4Debugger::PauseRequest: case QV4Debugger::BreakPointHit: { event.insert(QStringLiteral("event"), QStringLiteral("break")); - QV4::EngineBase::StackFrame *frame = debugger->engine()->currentStackFrame; + QV4::CppStackFrame *frame = debugger->engine()->currentStackFrame; if (!frame) break; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 45af1f44a5..625095b340 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -67,7 +67,7 @@ void JavaScriptJob::run() QObject scopeObject; if (frameNr > 0) { - QV4::EngineBase::StackFrame *f = engine->currentStackFrame; + QV4::CppStackFrame *f = engine->currentStackFrame; for (int i = 0; i < frameNr; ++i) f = f->parent; ctx = static_cast<QV4::ExecutionContext *>(&f->jsFrame->context); diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 32c67b3986..167083155c 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -229,7 +229,7 @@ private: QV4::ExecutionEngine *m_engine; QQmlNativeDebugServiceImpl *m_service; - QV4::EngineBase::StackFrame *m_currentFrame = 0; + QV4::CppStackFrame *m_currentFrame = 0; Speed m_stepping; bool m_pauseRequested; bool m_runningJob; @@ -332,7 +332,7 @@ void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &a int limit = arguments.value(QLatin1String("limit")).toInt(0); QJsonArray frameArray; - QV4::EngineBase::StackFrame *f= m_engine->currentStackFrame; + QV4::CppStackFrame *f= m_engine->currentStackFrame; for (int i = 0; i < limit && f; ++i) { QV4::Function *function = f->v4Function; @@ -677,7 +677,7 @@ void NativeDebugger::pauseAndWait() event.insert(QStringLiteral("event"), QStringLiteral("break")); event.insert(QStringLiteral("language"), QStringLiteral("js")); - if (QV4::EngineBase::StackFrame *frame = m_engine->currentStackFrame) { + if (QV4::CppStackFrame *frame = m_engine->currentStackFrame) { QV4::Function *function = frame->v4Function; event.insert(QStringLiteral("file"), function->sourceFile()); int line = frame->line; diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index eee9d05d52..4fb34a677f 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -1795,7 +1795,7 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast, bytecodeGenerator = &bytecode; // allocate the js stack frame (Context & js Function & accumulator) - bytecodeGenerator->newRegisterArray(sizeof(EngineBase::JSStackFrame)/sizeof(Value)); + bytecodeGenerator->newRegisterArray(sizeof(JSStackFrame)/sizeof(Value)); int returnAddress = bytecodeGenerator->newRegister(); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index d10d1d0413..8de733c26a 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -534,12 +534,6 @@ InternalClass *ExecutionEngine::newClass(const InternalClass &other) return new (classPool) InternalClass(other); } -Heap::ExecutionContext *ExecutionEngine::pushGlobalContext() -{ - setCurrentContext(rootContext()->d()); - return currentContext()->d(); -} - InternalClass *ExecutionEngine::newInternalClass(const VTable *vtable, Object *prototype) { return internalClasses[EngineBase::Class_Empty]->changeVTable(vtable)->changePrototype(prototype ? prototype->d() : 0); @@ -797,23 +791,27 @@ QQmlContextData *ExecutionEngine::callingQmlContext() const return ctx->qml()->context->contextData(); } -QString EngineBase::StackFrame::source() const +QString CppStackFrame::source() const { return v4Function->sourceFile(); } -QString EngineBase::StackFrame::function() const +QString CppStackFrame::function() const { return v4Function->name()->toQString(); } +ReturnedValue CppStackFrame::thisObject() const { + return jsFrame->stack[-(int)v4Function->nFormals - 1].asReturnedValue(); +} + StackTrace ExecutionEngine::stackTrace(int frameLimit) const { Scope scope(const_cast<ExecutionEngine *>(this)); ScopedString name(scope); StackTrace stack; - StackFrame *f = currentStackFrame; + CppStackFrame *f = currentStackFrame; while (f && frameLimit) { QV4::StackFrame frame; frame.source = f->source(); @@ -868,7 +866,7 @@ QUrl ExecutionEngine::resolvedUrl(const QString &file) return src; QUrl base; - StackFrame *f = currentStackFrame; + CppStackFrame *f = currentStackFrame; while (f) { if (f->v4Function) { base.setUrl(f->v4Function->sourceFile()); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 3fc79fd67d..3c3e6e048f 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -87,6 +87,46 @@ struct CompilationUnit; struct InternalClass; struct InternalClassPool; +struct JSStackFrame { + enum Offsets { + JSFunction = 0, + Context = 1, + Accumulator = 2 + }; + // callData is directly before this + union { + Value jsFunction; + Value stack[1]; + }; + Value context; + Value accumulator; // ### + // registers follow +}; + +struct Q_QML_EXPORT CppStackFrame { + CppStackFrame *parent; + Function *v4Function; + JSStackFrame *jsFrame; + int line = -1; + int column = -1; + + QString source() const; + QString function() const; + inline QV4::ExecutionContext *context() const { + return static_cast<ExecutionContext *>(&jsFrame->context); + } + + inline QV4::Heap::CallContext *callContext() const { + Heap::ExecutionContext *ctx = static_cast<ExecutionContext &>(jsFrame->context).d();\ + while (ctx->type != Heap::ExecutionContext::Type_CallContext) + ctx = ctx->outer; + return static_cast<Heap::CallContext *>(ctx); + } + ReturnedValue thisObject() const; +}; + + + struct Q_QML_EXPORT ExecutionEngine : public EngineBase { private: @@ -354,7 +394,6 @@ public: void setProfiler(Profiling::Profiler *profiler); #endif // QT_NO_QML_DEBUGGER - Heap::ExecutionContext *pushGlobalContext(); void setCurrentContext(Heap::ExecutionContext *context); ExecutionContext *currentContext() const { return static_cast<ExecutionContext *>(¤tStackFrame->jsFrame->context); @@ -524,19 +563,6 @@ inline bool ExecutionEngine::checkStackLimits() return false; } -inline QV4::ExecutionContext *EngineBase::StackFrame::context() const -{ - return static_cast<ExecutionContext *>(&jsFrame->context); -} - -inline QV4::Heap::CallContext *EngineBase::StackFrame::callContext() const -{ - Heap::ExecutionContext *ctx = static_cast<ExecutionContext &>(jsFrame->context).d();\ - while (ctx->type != Heap::ExecutionContext::Type_CallContext) - ctx = ctx->outer; - return static_cast<Heap::CallContext *>(ctx); -} - } // namespace QV4 QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4enginebase_p.h b/src/qml/jsruntime/qv4enginebase_p.h index fa07fb6566..00049392af 100644 --- a/src/qml/jsruntime/qv4enginebase_p.h +++ b/src/qml/jsruntime/qv4enginebase_p.h @@ -57,39 +57,16 @@ QT_BEGIN_NAMESPACE namespace QV4 { +struct CppStackFrame; + // Base class for the execution engine #if defined(Q_CC_MSVC) || defined(Q_CC_GNU) #pragma pack(push, 1) #endif struct Q_QML_EXPORT EngineBase { - struct JSStackFrame { - enum Offsets { - JSFunction = 0, - Context = 1, - Accumulator = 2 - }; - // callData is directly before this - Value jsFunction; - Value context; - Value accumulator; // ### - // registers follow - }; - - struct StackFrame { - StackFrame *parent; - Function *v4Function; - JSStackFrame *jsFrame; - int line = -1; - int column = -1; - - QString source() const; - QString function() const; - QV4::ExecutionContext *context() const; - QV4::Heap::CallContext *callContext() const; - }; - StackFrame *currentStackFrame = 0; + CppStackFrame *currentStackFrame = 0; Value *jsStackTop = 0; quint8 hasException = false; diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 6c24367b67..f8886cb47f 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -343,7 +343,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const return Encode::undefined(); ExecutionEngine *v4 = engine(); - bool isStrict = v4->currentContext()->d()->v4Function->isStrict(); + bool isStrict = v4->currentStackFrame->v4Function->isStrict(); Scope scope(v4); ScopedContext ctx(scope, v4->currentContext()); diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 26b15838f3..b21f23c34e 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -373,7 +373,7 @@ struct ScopedCallData { struct ScopedStackFrame { Scope &scope; - EngineBase::StackFrame frame; + CppStackFrame frame; ScopedStackFrame(Scope &scope, Heap::ExecutionContext *context) : scope(scope) @@ -381,7 +381,7 @@ struct ScopedStackFrame { frame.parent = scope.engine->currentStackFrame; if (!context) return; - frame.jsFrame = reinterpret_cast<EngineBase::JSStackFrame *>(scope.alloc(sizeof(EngineBase::JSStackFrame)/sizeof(Value))); + frame.jsFrame = reinterpret_cast<JSStackFrame *>(scope.alloc(sizeof(JSStackFrame)/sizeof(Value))); frame.jsFrame->context = context; frame.v4Function = frame.parent ? frame.parent->v4Function : 0; scope.engine->currentStackFrame = &frame; diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 08c64aaa27..10043be917 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -66,7 +66,7 @@ static void generateWarning(QV4::ExecutionEngine *v4, const QString& description QQmlError retn; retn.setDescription(description); - QV4::EngineBase::StackFrame *stackFrame = v4->currentStackFrame; + QV4::CppStackFrame *stackFrame = v4->currentStackFrame; retn.setLine(stackFrame->line); retn.setUrl(QUrl(stackFrame->source())); diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 7655f898c3..13f22368ca 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -236,7 +236,7 @@ int qt_v4DebuggerHook(const char *json) return -NoSuchCommand; // Failure. } -Q_NEVER_INLINE static void qt_v4CheckForBreak(QV4::EngineBase::StackFrame *frame) +Q_NEVER_INLINE static void qt_v4CheckForBreak(QV4::CppStackFrame *frame) { if (!qt_v4IsStepping && !qt_v4Breakpoints.size()) return; @@ -362,7 +362,7 @@ static struct InstrCount { if (engine->hasException) \ goto catchException -static inline QV4::Heap::ExecutionContext *getScope(EngineBase::JSStackFrame *frame, int level) +static inline QV4::Heap::ExecutionContext *getScope(JSStackFrame *frame, int level) { QV4::Heap::ExecutionContext *scope = static_cast<ExecutionContext &>(frame->context).d(); while (level > 0) { @@ -373,7 +373,7 @@ static inline QV4::Heap::ExecutionContext *getScope(EngineBase::JSStackFrame *fr return scope; } -static inline ReturnedValue loadScopedLocal(EngineBase::StackFrame &frame, int index, int scope) +static inline ReturnedValue loadScopedLocal(CppStackFrame &frame, int index, int scope) { auto ctxt = getScope(frame.jsFrame, scope); Q_ASSERT(ctxt->type == QV4::Heap::ExecutionContext::Type_CallContext); @@ -381,7 +381,7 @@ static inline ReturnedValue loadScopedLocal(EngineBase::StackFrame &frame, int i return cc->locals[index].asReturnedValue(); } -static inline void storeScopedLocal(ExecutionEngine *engine, EngineBase::StackFrame &frame, int index, int scope, +static inline void storeScopedLocal(ExecutionEngine *engine, CppStackFrame &frame, int index, int scope, const QV4::Value &value) { auto ctxt = getScope(frame.jsFrame, scope); @@ -391,7 +391,7 @@ static inline void storeScopedLocal(ExecutionEngine *engine, EngineBase::StackFr QV4::WriteBarrier::write(engine, cc, cc->locals.values + index, value); } -static inline ReturnedValue loadScopedArg(EngineBase::StackFrame &frame, int index, int scope) +static inline ReturnedValue loadScopedArg(CppStackFrame &frame, int index, int scope) { auto ctxt = getScope(frame.jsFrame, scope); Q_ASSERT(ctxt->type == QV4::Heap::ExecutionContext::Type_CallContext); @@ -399,7 +399,7 @@ static inline ReturnedValue loadScopedArg(EngineBase::StackFrame &frame, int ind return cc->callData->args[index].asReturnedValue(); } -static inline void storeScopedArg(ExecutionEngine *engine, EngineBase::StackFrame &frame, int index, int scope, +static inline void storeScopedArg(ExecutionEngine *engine, CppStackFrame &frame, int index, int scope, const QV4::Value &value) { auto ctxt = getScope(frame.jsFrame, scope); @@ -434,7 +434,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat for (int i = callData->argc; i < (int)function->nFormals; ++i) callData->args[i] = Encode::undefined(); - EngineBase::StackFrame frame; + CppStackFrame frame; frame.parent = engine->currentStackFrame; frame.v4Function = function; engine->currentStackFrame = &frame; @@ -442,8 +442,8 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat QV4::Value *stack = nullptr; const uchar *exceptionHandler = 0; - stack = engine->jsAlloca(function->compiledFunction->nRegisters + sizeof(EngineBase::JSStackFrame)/sizeof(QV4::Value)); - frame.jsFrame = reinterpret_cast<EngineBase::JSStackFrame *>(stack); + stack = engine->jsAlloca(function->compiledFunction->nRegisters + sizeof(JSStackFrame)/sizeof(QV4::Value)); + frame.jsFrame = reinterpret_cast<JSStackFrame *>(stack); frame.jsFrame->context = context; if (jsFunction) frame.jsFrame->jsFunction = *jsFunction; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index a3874e4e65..56188a4b7d 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1339,7 +1339,7 @@ void Heap::QQmlBindingFunction::init(const QV4::FunctionObject *originalFunction QQmlSourceLocation QQmlBindingFunction::currentLocation() const { - QV4::EngineBase::StackFrame *frame = engine()->currentStackFrame; + QV4::CppStackFrame *frame = engine()->currentStackFrame; return QQmlSourceLocation(frame->source(), frame->line, 0); } @@ -1547,7 +1547,7 @@ static ReturnedValue writeToConsole(const BuiltinFunction *b, CallData *callData if (!loggingCategory) loggingCategory = v4->qmlEngine() ? &qmlLoggingCategory : &jsLoggingCategory; - QV4::EngineBase::StackFrame *frame = v4->currentStackFrame; + QV4::CppStackFrame *frame = v4->currentStackFrame; const QByteArray baSource = frame->source().toUtf8(); const QByteArray baFunction = frame->function().toUtf8(); QMessageLogger logger(baSource.constData(), frame->line, baFunction.constData(), loggingCategory->categoryName()); @@ -1601,7 +1601,7 @@ ReturnedValue ConsoleObject::method_profile(const BuiltinFunction *b, CallData * QV4::Scope scope(b); QV4::ExecutionEngine *v4 = scope.engine; - QV4::EngineBase::StackFrame *frame = v4->currentStackFrame; + QV4::CppStackFrame *frame = v4->currentStackFrame; const QByteArray baSource = frame->source().toUtf8(); const QByteArray baFunction = frame->function().toUtf8(); QMessageLogger logger(baSource.constData(), frame->line, baFunction.constData()); @@ -1621,7 +1621,7 @@ ReturnedValue ConsoleObject::method_profileEnd(const BuiltinFunction *b, CallDat QV4::Scope scope(b); QV4::ExecutionEngine *v4 = scope.engine; - QV4::EngineBase::StackFrame *frame = v4->currentStackFrame; + QV4::CppStackFrame *frame = v4->currentStackFrame; const QByteArray baSource = frame->source().toUtf8(); const QByteArray baFunction = frame->function().toUtf8(); QMessageLogger logger(baSource.constData(), frame->line, baFunction.constData()); @@ -1678,7 +1678,7 @@ ReturnedValue ConsoleObject::method_count(const BuiltinFunction *b, CallData *ca QV4::ExecutionEngine *v4 = scope.engine; QV8Engine *v8engine = scope.engine->v8Engine; - QV4::EngineBase::StackFrame *frame = v4->currentStackFrame; + QV4::CppStackFrame *frame = v4->currentStackFrame; QString scriptName = frame->source(); @@ -1702,7 +1702,7 @@ ReturnedValue ConsoleObject::method_trace(const BuiltinFunction *b, CallData *ca QString stack = jsStack(v4); - QV4::EngineBase::StackFrame *frame = v4->currentStackFrame; + QV4::CppStackFrame *frame = v4->currentStackFrame; QMessageLogger(frame->source().toUtf8().constData(), frame->line, frame->function().toUtf8().constData()) .debug("%s", qPrintable(stack)); @@ -1734,7 +1734,7 @@ ReturnedValue ConsoleObject::method_assert(const BuiltinFunction *b, CallData *c QString stack = jsStack(v4); - QV4::EngineBase::StackFrame *frame = v4->currentStackFrame; + QV4::CppStackFrame *frame = v4->currentStackFrame; QMessageLogger(frame->source().toUtf8().constData(), frame->line, frame->function().toUtf8().constData()) .critical("%s\n%s",qPrintable(message), qPrintable(stack)); @@ -1908,7 +1908,7 @@ ReturnedValue GlobalExtensions::method_qsTr(const BuiltinFunction *b, CallData * int length = lastDot - (lastSlash + 1); context = (lastSlash > -1) ? path.mid(lastSlash + 1, (length > -1) ? length : -1) : QString(); } else { - ExecutionEngine::StackFrame *frame = scope.engine->currentStackFrame; + CppStackFrame *frame = scope.engine->currentStackFrame; // The first non-empty source URL in the call stack determines the translation context. while (frame && context.isEmpty()) { if (CompiledData::CompilationUnit *unit = frame->v4Function->compilationUnit) { |