aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-01-14 12:00:56 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-01-16 12:46:52 +0100
commit291aea14636a0e779d874a01630524facb1397dd (patch)
tree044ff4131a9b3f5a3edb00e6a807d0609c04a182 /src/qml/jsruntime
parent39f1e0d66dc434e764731fbfed29c8fd98d217aa (diff)
parent88e87647c3b7d651dba2c8e61f945d47ecdd02c4 (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: .qmake.conf src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4debugging.cpp src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4functionobject_p.h src/qml/jsruntime/qv4qobjectwrapper.cpp src/quick/scenegraph/shaders/visualization.frag tests/auto/qml/qjsengine/tst_qjsengine.cpp Change-Id: I492e8546c278f80a300a2129e9a29d861e144a30
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4context.cpp16
-rw-r--r--src/qml/jsruntime/qv4context_p.h14
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4debugging.cpp18
-rw-r--r--src/qml/jsruntime/qv4engine.cpp15
-rw-r--r--src/qml/jsruntime/qv4global_p.h4
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp14
7 files changed, 60 insertions, 23 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 85bcadd8d2..40c02ef4ee 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -475,3 +475,19 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Heap::Object **
ScopedValue n(scope, name);
return engine()->throwReferenceError(n);
}
+
+Heap::FunctionObject *ExecutionContext::getFunctionObject() const
+{
+ Scope scope(d()->engine);
+ ScopedContext it(scope, this->d());
+ for (; it; it = it->d()->parent) {
+ if (const CallContext *callCtx = it->asCallContext())
+ return callCtx->d()->function;
+ else if (it->asCatchContext() || it->asWithContext())
+ continue; // look in the parent context for a FunctionObject
+ else
+ break;
+ }
+
+ return 0;
+}
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index ea2d266146..48319c7444 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -154,6 +154,10 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
inline CallContext *asCallContext();
inline const CallContext *asCallContext() const;
+ inline const CatchContext *asCatchContext() const;
+ inline const WithContext *asWithContext() const;
+
+ Heap::FunctionObject *getFunctionObject() const;
static void markObjects(Heap::Base *m, ExecutionEngine *e);
};
@@ -202,6 +206,16 @@ inline const CallContext *ExecutionContext::asCallContext() const
return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast<const CallContext *>(this) : 0;
}
+inline const CatchContext *ExecutionContext::asCatchContext() const
+{
+ return d()->type == Heap::ExecutionContext::Type_CatchContext ? static_cast<const CatchContext *>(this) : 0;
+}
+
+inline const WithContext *ExecutionContext::asWithContext() const
+{
+ return d()->type == Heap::ExecutionContext::Type_WithContext ? static_cast<const WithContext *>(this) : 0;
+}
+
/* Function *f, int argc */
#define requiredMemoryForExecutionContect(f, argc) \
((sizeof(CallContext::Data) + 7) & ~7) + sizeof(Value) * (f->varCount() + qMax((uint)argc, f->formalParameterCount())) + sizeof(CallData)
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 7f79de3035..4379e3ff94 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -482,6 +482,8 @@ static inline double ParseString(const QString &s)
QDateTime dt = QDateTime::fromString(s, Qt::TextDate);
if (!dt.isValid())
dt = QDateTime::fromString(s, Qt::ISODate);
+ if (!dt.isValid())
+ dt = QDateTime::fromString(s, Qt::RFC2822Date);
if (!dt.isValid()) {
QStringList formats;
formats << QStringLiteral("M/d/yyyy")
diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp
index 9361fa1a23..01ee9585c3 100644
--- a/src/qml/jsruntime/qv4debugging.cpp
+++ b/src/qml/jsruntime/qv4debugging.cpp
@@ -523,7 +523,6 @@ void Debugger::maybeBreakAtInstruction()
return;
QMutexLocker locker(&m_lock);
- int lineNumber = engine()->currentContext()->lineNumber;
if (m_gatherSources) {
m_gatherSources->run();
@@ -547,8 +546,12 @@ void Debugger::maybeBreakAtInstruction()
if (m_pauseRequested) { // Serve debugging requests from the agent
m_pauseRequested = false;
pauseAndWait(PauseRequest);
- } else if (m_haveBreakPoints && reallyHitTheBreakPoint(getFunction()->sourceFile(), lineNumber)) {
- pauseAndWait(BreakPoint);
+ } else if (m_haveBreakPoints) {
+ if (Function *f = getFunction()) {
+ const int lineNumber = engine()->currentContext()->lineNumber;
+ if (reallyHitTheBreakPoint(f->sourceFile(), lineNumber))
+ pauseAndWait(BreakPoint);
+ }
}
}
@@ -594,12 +597,11 @@ Function *Debugger::getFunction() const
{
Scope scope(m_engine);
ScopedContext context(scope, m_engine->currentContext());
- if (CallContext *callCtx = context->asCallContext())
- return callCtx->d()->function->function;
- else {
- Q_ASSERT(context->d()->type == QV4::Heap::ExecutionContext::Type_GlobalContext);
+ ScopedFunctionObject function(scope, context->getFunctionObject());
+ if (function)
+ return function->function();
+ else
return context->d()->engine->globalCode;
- }
}
void Debugger::pauseAndWait(PauseReason reason)
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 4f8f329e2b..a51ea36351 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -762,21 +762,21 @@ QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const
QVector<StackFrame> stack;
ScopedContext c(scope, currentContext());
+ ScopedFunctionObject function(scope);
while (c && frameLimit) {
- CallContext *callCtx = c->asCallContext();
- if (callCtx && callCtx->d()->function) {
+ function = c->getFunctionObject();
+ if (function) {
StackFrame frame;
- ScopedFunctionObject function(scope, callCtx->d()->function);
- if (function->function())
- frame.source = function->function()->sourceFile();
+ if (const Function *f = function->function())
+ frame.source = f->sourceFile();
name = function->name();
frame.function = name->toQString();
frame.line = -1;
frame.column = -1;
- if (callCtx->d()->function->function)
+ if (function->function())
// line numbers can be negative for places where you can't set a real breakpoint
- frame.line = qAbs(callCtx->d()->lineNumber);
+ frame.line = qAbs(c->d()->lineNumber);
stack.append(frame);
--frameLimit;
@@ -791,7 +791,6 @@ QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const
frame.line = rootContext()->lineNumber;
frame.column = -1;
-
stack.append(frame);
}
return stack;
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index 61cd53cd61..687ff19be4 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -69,9 +69,9 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); }
//
// NOTE: This should match the logic in qv4targetplatform_p.h!
-#if defined(Q_PROCESSOR_X86) && (defined(Q_OS_WINDOWS) || defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_FREEBSD))
+#if defined(Q_PROCESSOR_X86) && (defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_FREEBSD))
#define V4_ENABLE_JIT
-#elif defined(Q_PROCESSOR_X86_64) && (defined(Q_OS_WINDOWS) || defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_FREEBSD))
+#elif defined(Q_PROCESSOR_X86_64) && (defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_FREEBSD))
#define V4_ENABLE_JIT
#elif defined(Q_PROCESSOR_ARM_32)
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 7ec66dd0e5..1248991789 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -814,13 +814,17 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
f->call(callData);
if (scope.hasException()) {
+ QQmlError error = v4->catchExceptionAsQmlError();
+ if (error.description().isEmpty()) {
+ QV4::ScopedString name(scope, f->name());
+ error.setDescription(QString::fromLatin1("Unknown exception occurred during evaluation of connected function: %1").arg(name->toQString()));
+ }
if (QQmlEngine *qmlEngine = v4->qmlEngine()) {
- QQmlError error = v4->catchExceptionAsQmlError();
- if (error.description().isEmpty()) {
- QV4::ScopedString name(scope, f->name());
- error.setDescription(QString(QLatin1String("Unknown exception occurred during evaluation of connected function: %1")).arg(name->toQString()));
- }
QQmlEnginePrivate::get(qmlEngine)->warning(error);
+ } else {
+ QMessageLogger(error.url().toString().toLatin1().constData(),
+ error.line(), 0).warning().noquote()
+ << error.toString();
}
}
}