Stabilize tst_qqmlprofilerservice

Change-Id: Ia381d51561f1c183ec7f2e3fcfe49810bfbfcc61
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Don't delete scene-graph atlas manager if it hasn't been created yet

QSGContext::invalidate() is called from the QSGContext destructor,
but the atlas manager is only created if QSGContext::initialize()
is called, which may not always happen.

The result was a bunch of "QCoreApplication::postEvent: Unexpected
null receiver" messages during testing.

Change-Id: I11a294d48c06d687a9f82cf1ce825063cda8ecf6
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
V4 IR: fix type inference.

When a phi-node couldn't be fully typed (e.g., when one of the temps
was not yet typed), VarType was assumed. When a circular dependency
between two phi-nodes occurred, like with a condition inside a loop,
then depending on the ordering of the work-list, the two phi-nodes
could start oscillating between VarType and the correct type.

The fix is to check if one of the temps is not fully typed, and if so,
assume whatever we currently have as the result and have the statement
re-scheduled. Full typing will occur when the temp with the missing
type information is typed.

Change-Id: I950d81fe7fa8272cb37f7eea5b88092d1eb4817e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Always call callCompleted in QQmlDataBlob::tryDone

We need this since it could happen that in QQmlComponentPrivate::loadUrl we did
  QQmlTypeData *data = QQmlEnginePrivate::get(engine)->typeLoader.getType(url, loaderMode);
and got a sync QQmlTypeData even if we asked for async, and thus the async loader was never notified
when it finished and we were never loaded.

Situation in which this can happen is:
 * ListView with an async Loader as delegate
 * Loader loads two items A and B, while A is a B
 * Item 0 of the ListView triggers an async loading of A that triggers the sync loading of B
 * Item 1 of the ListView triggers an async loading of B
 * Since B is already being loaded (though in sync), we just add ourselves to the people that want to be notified
 * sync loading of B is done and QQmlDataBlob::tryDone does not call the callbacks because it's sync
 * Item 1 is never finished loading

Change-Id: I52a0979a1d3cfcfe73a71196bf24f491d6cf8e9a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Don't create a ValueRef to a temporary

Change-Id: I6d7fbcee594298517b880e4b0fac9df1f9e54d61
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Fix ObjectIterator API to be GC safe

Change-Id: I3a9c48d53d8dbadcb9b32c00fcef1f89447c4b8c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Remove more uses of Value

Change-Id: I889e760f75b485a28e1f2a2c26b2337ae9bfafac
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Remove some more uses of QV4::Value

All remaining uses should be GC safe now.

Change-Id: I05c962de6ab896f108f70caa1bf937a24e67bfe1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Use SafeValue instead of Value in ScopedValue methods

Change-Id: Ie463efe600d498ce77d4b9e8b48abcfd61c1ab78
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Cleanup API of Safe<T>

Don't have an implicit cast operator to Returned<T>
anymore, and return a T* from the operator->()

Change-Id: If4165071b986bfc84a157560d94d39c2dcfbc9e1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Change exception handling API

This patch changes the exception handling API in the engine slightly, encapsulating
any use of direct throw statements and catch blocks with concrete types. In the future
we need to be able to change the way these are implemented, in order to ensure that
the correct stack unwinding code is triggered for throw and re-throw.

This patch separates the C++ exception object thrown from the V4 exception
(that includes value, throwing context pointer) and stores the latter inside
the engine.

In order for that to compile, ExecutionEngine::StackTrace and StackFrame had to
move into the QV4 namespace directly.

In addition the syntax for catching exceptions changes from

try {
    ...
} catch (QV4::Exception &ex) {
    ex.accept(context);
    QV4::ScopedValue exceptionValue(scope, ex.value());
}

to

try {
    ...
} catch (...) {
    QV4::ScopedValue exception(scope, context->catchException());
}

Context::catchException() checks if there's a "current" exception in the engine,
and if not assumes that we caught an unrelated exception and consequently re-throws.

partiallyUnwind() is also gone and replaced with rethrowException(), in order to
encapsulate the re-throw.

Lastly, in the future nesting try/catch blocks isn't going to be possible due to
limitations in the common C++ ABI with regards to foreign exceptions.

Change-Id: Ic81c75b057a2147e3176d8e0b4d326c14278b47d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>