Commit Graph

7434 Commits

Author SHA1 Message Date
Simon Hausmann c1c526aafb Speed up stack trace generation for the JIT
It turns out that in QML it is not unusual that during early binding
evaluations due to the undefined order, the evaluation tries to look up
properties in objects that aren't initialized yet and thus exceptions are
thrown. Eeach thrown exception saves a stack trace, which is expensive to
generate when using the JIT, as it does full stack unwinding.

This patch implements a more light-weight approach by storing the instruction
pointer in the context before leaving JIT generated code.

Change-Id: I95e1cfd01179247dfc2c1df949828f474a23161b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-16 16:03:54 +02:00
Laszlo Agocs ddd9c93b08 Avoid infinite loop with distance fields disabled
createGlyphNode() and createNativeGlyphNode() kept calling each other
on GLES whenever QML_DISABLE_DISTANCEFIELD was set.

Change-Id: Ic1c2cfe0c4c7301f82cbbcce1cb512bd515b52ef
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
2013-10-16 13:12:39 +02:00
Shawn Rutledge 2f83bdbe5d Dialogs: use resources for QML and images
All the qml and image files are embedded in the QtQuick.Dialogs plugin.
If DefaultFileDialog.qml is missing from the installation directory,
loading from resources will be enabled. Otherwise, the files will be
loaded from the local path.

This is analogous to change b2e5d1acb1aca93157a6d4d0a026153134f9ad01
in Qt Quick Controls: it reduces the number of files that need to be
installed, but also preserves ease of debugging whenever the QML files
are separately installed.

Task-number: QTBUG-31565
Change-Id: Idbe6be5d818eb6a25367f2053ea52bc7ac1485bc
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
2013-10-16 10:39:38 +02:00
Albert Astals Cid 54b73b8ab5 Fix infinite loop in QQmlIncubator::forceCompletion
Without this change I'm getting this backtrace
3  0x4025b9f2 in QQmlIncubatorPrivate::incubate (this=0x18daa78, i=...) at qml/qqmlincubator.cpp:273
4  0x4025c1c2 in QQmlIncubator::forceCompletion (this=0x1527360) at qml/qqmlincubator.cpp:592
5  0x404e1626 in QQuickVisualDataModelPrivate::object (this=this@entry=0x13909f8, group=QQuickListCompositor::Default, index=index@entry=1, asynchronous=asynchronous@entry=false) at items/qquickvisualdatamodel.cpp:900
6  0x404e1f7e in QQuickVisualDataModel::item (this=<optimized out>, index=1, asynchronous=<optimized out>) at items/qquickvisualdatamodel.cpp:968
Note: This is with patched 5.0.x, change QQuickVisualDataModel to QQmlDelegateModel for >= 5.1
      and line numbers may be a bit off

What is happening:
QQmlIncubator::forceCompletion is doing
    while (Loading == status()) {
        while (Loading == status() && !d->waitingFor.isEmpty())
            static_cast<QQmlIncubatorPrivate *>(d->waitingFor.first())->incubate(i);
        if (Loading == status())
            d->incubate(i);
    }
Calling QQmlIncubatorPrivate::incubate on the first item of d->waitingFor

Then, that item is getting to QQmlIncubatorPrivate::incubate and happens that
progress is QQmlIncubatorPrivate::Completed and waitingFor is not empty,
so the only thing that QQmlIncubatorPrivate::incubate ends up doing is
calling a few calls over vmeGuard and returning, that way the inner
waitingFor items never finishe incubating and you end up in an inifite loop inside
        while (Loading == status() && !d->waitingFor.isEmpty())
            static_cast<QQmlIncubatorPrivate *>(d->waitingFor.first())->incubate(i);

This patch basically replaces this loop with a loop that does
        while (QQmlIncubator::Loading == status && !waitingFor.isEmpty())
            static_cast<QQmlIncubatorPrivate *>(waitingFor.first())->forceCompletion(i);

This way we make sure we incubate the waitingFor items of our waitingFor items

Change-Id: I4298efc7ba9d8af624bb138e64b92a40ed4c4dc9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-16 09:09:15 +02:00
Kai Koehne 29beac9aa1 Improve output of test case
Change-Id: Ib36583120ca42835534f0f8494637aeb9618f317
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
2013-10-16 08:34:32 +02:00
Kai Koehne 8c66618892 Fix segfault in autotest
Do not re-declare variable in local scope!

Change-Id: I4f66081603ce86d78965ac12368bda66d86ff0c4
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
2013-10-16 08:33:52 +02:00
Kai Koehne ff28e3519d Fix deadlocks in debugger infrastructure on Mac
Set QReadWriteLocker to recursive. This is needed e.g. to allow
_q_changeServiceState to get a read lock when called from inside
receiveMessage.

Change-Id: I287a7c7f44e94005c0458825f8f6d1877ee914dd
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
2013-10-16 08:33:18 +02:00
Lars Knoll ad7f91c59a Turn on exact garbage collection by default
Keep conservative GC as a fallback for testing
Enable all tests again that were skipped due to
GC issues.

Change-Id: I8e0fa728207bdd39a96d0acf95e27841157d8402
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-16 06:36:47 +02:00
Simon Hausmann 0c6743749f Fix cleanup handlers on Android when exceptions are thrown
When an exception is thrown and we traverse a frame that requires only cleanup
(i.e. call QV4::Scope::~Scope), control is first transferred to the generated
cleanup code. Afterwards the unwinding is resumed (on ARM) by calling
__cxa_end_cleanup, which resides in libsupc++ (libgnustl_shared).
__cxa_end_cleanup first calls __gnu_end_cleanup and then resumes the process of
stack unwinding by calling _Unwind_Resume (per specification). Given the
linking situation on Android, this will end up calling _Unwind_Resume inside
libgnustl_shared, which sidesteps our statically linked copy of the unwind
code in QtQml (libgcc.a). Therefore any further unwinding through JIT generated
frames will fail.

This patch introduces the same EABI symbol exported in libQt5Qml, which will
direct control to the correct JIT aware unwinder.

This relies on https://codereview.qt-project.org/#change,68206 in order to
ensure that libsupc++.a is gone from all link lines (not needed) and that
gnustl_shared is after libQt5Qml.

Task-Number: QTBUG-33892

Change-Id: I6ed691db3ceb287475a70b7af8cf3cd7b4ddfdd6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-16 06:36:27 +02:00
Richard Moe Gustavsen 4e45120a7b qqmlimport: avoid deadlock by scoping the usage of QWriteLocker
Change a9cf828559 refactored
QQmlImportDatabase::importPlugin() to be used for both dynamic
and static plugin loading. In the process, the scope of a
QWriteLocker protecting a call to registerTypes ended up to wide.
That caused a deadlock to occur for some static qml applications
since the lock remained active during a subsequent call to
initializeEngine.

So narrow the the scope down to be exactly as it wore before the
change. This will remove the deadlock.

Change-Id: Ibb15c953c0f693fe75dab24f0093c3bddb3f0cbb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-16 01:28:12 +02:00
Lars Knoll 473960dd61 Initialize Variable
Change-Id: I60262620eab4b653108f431a4c64a745e4312177
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 20:57:37 +02:00
Lars Knoll b538231cb2 Fix GC issues with usage of raw RegExp pointers
Properly protect them through Scoped values.

Change-Id: I5a0a1d5580d55ecff493419baa8959751a65f1d3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 20:57:37 +02:00
Lars Knoll e20253ed7a Remove debug output
The output messes up some auto tests

Change-Id: I9b9b2b4fdf023bc9953939b814872e860c84f484
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 20:57:37 +02:00
Lars Knoll ad10361aea Remove duplicated forward declaration
Change-Id: Ie3c4e7d500dc9d327aa081c8f701d88ca6d4ca40
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 20:57:37 +02:00
Tor Arne Vestbø 275514a24a Don't use constructor function to initialize providers
It complicated static linking for no good reason.

Change-Id: I8eb1548b799128bfab9451963cb80c72239b961c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 19:40:21 +02:00
Jerome Pasion e6652d8957 Doc: Renamed links to "QML Applications".
"QML Application Developer Resources" is too long and the visible text
is usually shortened to "QML Applications".

The article in qt5/qtdoc changed title to "QML Applications".

Change-Id: I301f3b4659bd87631269b912bcc36f6f00fdeb2c
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
2013-10-15 18:22:04 +02:00
Lars Knoll f82ba75a30 Make QQmlIncubatorPrivate refcounted
This fixes possible bugs and crashes where the incubator
could get deleted through GC while constructing the
component.

Change-Id: Ibe0c5d4e172f0b5505ace0c3ea0369169b8b48a5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 14:00:57 +02:00
Lars Knoll 5302fea533 Make sure the incubated object survives the statusChanged call
QQmlComponent::statusChanged() marked the incubated object
as destructable when it was done loading. This implied
that any gc call afterwards could clean it up. To fix, push
the object on the GC stack so it lives until the method returns.

Also renamed the WrapperIncubator to QQmlComponentIncubator.

Change-Id: I5a8f478a1fd65ea73ddff310392219709a935a70
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 14:00:57 +02:00
Mitch Curtis dfa234a60a Fix MSVC2010 warnings.
Change-Id: Id7a2465db4f9b1cd4d3b7ecd61538ee7110893df
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-10-15 10:34:25 +02:00
Shawn Rutledge 270125b614 QtQuick.Dialogs: on single-window platforms, don't resize the window
m_dialogWindow only needs to be set if the dialog has its own window,
because otherwise setters such as QQuickAbstractDialog::setHeight
(introduced in 37492efee0)
will result in reshaping the main application window instead of the
dialog.  Also the window decoration's translucent "veil" should
expand to fit the whole application.

Change-Id: I16fdb48c54dbc5e758dfec1f18063579ac2bbb05
Reviewed-by: Liang Qi <liang.qi@digia.com>
2013-10-15 08:08:11 +02:00
Lars Knoll 6fbf62e8e1 Fix some more issues with exact GC
Get the formal and local names of function object from the
compilation unit to avoid creating another set of strings.
Use a ScopedFunctionObject in eval()

Change-Id: I6693aec2e88818df9c160b3780db12d8df79c2fe
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 06:43:53 +02:00
Lars Knoll df267e5019 Fix GC issue with incubators
Never use multiple inheritance with Managed subclasses,
as this can easily mess up garbage collection. In this
case the vtable from the QQmlIncubator would be added
before the start of the Managed pointer. That would
not work correctly for the memory manager that casts
void pointers to Managed pointers.

Change-Id: I1c1ebc6c44bd9cb77eea49738e86ce3374c7ef80
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 06:43:34 +02:00
Lars Knoll 1be51cc3e7 inline get_element calls
Inline calls to get_element if the base is an
object with a simple array structure, and the index
is an integer number.

Implemented for 64bit only for now, saves ~25% on crypto.js

Change-Id: I3e34a6409169d90d3937f62264707d52a6c2f9f7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-14 21:59:59 +02:00
Lars Knoll 668eca2b93 Avoid creating array attributes if possible
Holes in arrays should be represented by an empty
value, not by creating/setting array attributes.

Reason is that the creation is irreversable, and slows
down execution. This speeds up crypto.js by 10%

Change-Id: I2e5472575479a5f2dbe53f59ecb8ed3aeab1be7a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-14 21:59:56 +02:00
Lars Knoll 669e6b434f Fix performance regression introduced by 6adb06
The global scope is compiled as EvalCode. Because of this
we were never using global lookups anymore, slowing down
the v8 test suite by ~20%.

Change-Id: I6c47ccf90f4d9ec3bf531bbb689d3f1511f69968
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-14 20:24:10 +02:00
Lars Knoll 27f2afddea Fix a small bug in conversion to SInt32
If the truncation from double returned out of bounds,
the code was not generating the right call to the fallback
method on 64 bit.

Change-Id: I6a126dd013c5b6373762beef0c1459fae1c26ef2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-14 20:23:57 +02:00
Mitch Curtis 77e566b6f6 Touch up QJSEngine::evaluate documentation.
Change-Id: I350ad1ccb8a6cf522787e4579292fa4ba1c8e043
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-14 16:43:51 +02:00
Erik Verbruggen 3f7f6be409 V4 JIT: fix stack size calculation on 32bit.
Registers containing outgoing parameters for calls are saved as Value
(so, 8 bytes long) instead of native register size. For 64 bit this is
the same, but not for 32 bits.

Change-Id: If1d55e9d552a301782816c9228390dc5611c6d00
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-14 16:43:06 +02:00
Erik Verbruggen f106d905df V4 disasm: fix sub sp,sp,imm
This is a special-case instruction, where the immediate needs to be
multiplied by 4.

Change-Id: I86e5ab9d39d65b8eab99fae859969896c6e5630c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-14 16:42:56 +02:00
Giulio Camuffo 403045a581 Don't leave a window current when removing it
The window may be deleted before any other window is make current,
and that would lead to memory corruption with Mesa's EGL.

Change-Id: I414b972fd517f60c28d194fa059bf7871e422872
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
2013-10-14 14:03:22 +02:00
Morten Johan Sørvig de3c837dfa Fix the QML import search.
Match the algorithm used by QML, look for the most
specific version of an import first.

Change-Id: Ibf1370af227c8154f657cc2d8a1c1d1ae28d2f39
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
2013-10-14 12:30:35 +02:00
Morten Johan Sørvig 9ca4c75da3 Make qmlimportscanner report plugin classnames.
Change-Id: Ifbe72e6dcc569c8cb311d46e4f265da348b353ea
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
2013-10-14 12:30:28 +02:00
Morten Johan Sørvig 3ac39b6088 Add classnames for QML import plugins.
Needed for static builds. qmlimportscanner will
read the "plugin" and "classname" entries.

Change-Id: I31939451366ad3e771d516ac426525c8bcdba57d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-14 12:30:11 +02:00
Lars Knoll dc46921c83 Implement >>> inline for the JIT backend
The unsigned right shift operations can use a signed int as input, unifying
the handling with the other shift operations. The only difference now is
in the type of the return value.

Change-Id: Ia9b83568951d1c1c77322d07cd734e2c37d34573
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-10-12 19:01:11 +02:00
Erik Verbruggen 41b027c399 V4 JIT: fix register allocator after change to s/uint32 usage.
Now that shifts can take a signed int32, reflect it in the check if a
binop will generate a call.

Change-Id: I3cab436bace31cdda327cf6132aa873b6c5456b1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-12 13:14:07 +02:00
Erik Verbruggen 6f886cd6a8 V4 JIT: clean-up conversion functions and add toUInt32.
Change-Id: I7ac685145fa41db2a0e02c4d15d1d287d80621f8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-12 13:14:02 +02:00
Erik Verbruggen 2fcb8cfcdf V4 ARM: fix disassembler vmov
rt is on position 12. See A8.8.345.

Change-Id: Ibf380b9bda8d2edd603857935d6c92cd89d0f104
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-12 09:22:50 +02:00
Lars Knoll 6dc9647e53 Remove some unused flags from Managed
Change-Id: I94399489823d5b0d4d40f300e1999272dc2da5c9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-12 09:22:13 +02:00
Simon Hausmann 28f67263a1 Compile signal handler expressions in the loader thread
Handle them similar to function declarations, except that we need to synthesize
the expression into a function declaration that includes the signal parameter
names. This is done quite similar to the code path in the new compiler.

Change-Id: I751081f7f1052692da6e2ed60c7f5c017372d829
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-11 22:55:08 +02:00
Simon Hausmann 774963f52f Compile JS functions as part of the QQmlCompiler run in the loader thread
...instead of extracting the function body as a string and compiling it in the
GUI thread.

Change-Id: I3c3108f6e35464b5581a2d8b5799e7285858ce4d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-11 22:55:02 +02:00
Simon Hausmann c39393e7de Compile binding expressions in the QQmlCompiler
This is done by re-using the JS code generator from the new compiler. A few bugs were
fixed on the way:

 * The index into the compiledData->runtimeFunctions array is not the same as the function
   index when they are collected (from the AST), as for example binding expressions may create
   extra V4IR::Function objects that break the 1:1 mapping. Therefore the JS code gen will return
   a mapping from incoming function index to V4IR::Module::Function (and thus runtimeFunction)
 * Binding expressions in the old backend get usually unpacked from their ExpressionStatement node.
   The reference to that node is lost, and instead of trying to preserve it, we simply synthesize it
   again. This won't be necessary anymore with the new compiler in the future.
 * Commit 1c29d63d60 ensured to always look up locals by name, and so
   we have to do the same when initializing the closures of nested functions inside binding expressions
   (in qv4codegen.cpp)
 * Had to change the Qml debugger service auto-test, which does toString() on a function that is now compiled.
   Even if we implemented FunctionPrototype::toString() to do what v8 does by extracting the string from the
   file, it wouldn't help in this test, because it feeds the input from a string instead of a file.
 * In tst_parserstress we now end up compiling all JS code, which previously was only parsed. This triggers
   some bugs in the SSA handling. Those tests are skipped and tracked in QTBUG-34047

Change-Id: I44df51085510da0fd3d99eb5f1c7d4d17bcffdcf
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-11 22:54:52 +02:00
Simon Hausmann 74a02a8380 Fix failing assertion (index != -1) when trying to re-declare a function parameter
Testcase: (covered in parserstress)

function foo(x) {
    var x = 42;
}

In variableDeclaration, the lookup for "x" with findMember will return -1, and
instead code for checking against arguments using indexOfArgument is needed.
The easiest fix is to simply use identifier(), which handles this accordingly.

Change-Id: I6a738d6196d4bff1fc987f111aebbaa83ed8f88f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-11 19:39:35 +02:00
Simon Hausmann 6adb0693a2 Fix determination of lookup mode in V4 code generator
In order to determine the type of lookup we need (name or directly in
environment members), we used Codegen::_mode, which is set to the currently
suitable mode depending on the function (parameter to defineFunction). However
that's not quite correct, the look-up mode depends on the function itself, not
where it was called from. This patch corrects that by moving the compilation
mode into the Environment itself.

This is needed by follow-up patches.

Additionally the "bool deletable" parameter to the builtin_declare_vars was
always set to false, because it used mode instead of _mode, which was never set
to Eval or QmlBinding. This will be cleaned up in a future patch.

Change-Id: I878f187945e5de091689ab5d70a0f33eb5a9e38f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-11 19:38:47 +02:00
Simon Hausmann a4449295c3 Fix crash in duplicate labelled statement check
Testcase (part of parserstress in tests/auto/qml):

outer: {
   do {
      inner: {}
   } while (false)
}

The labelled statement visitor, when hitting the outter label, would call
enterLoop(), which sets _labelledStatement back to zero. That then gets added
to the Loop object the do-while loop creates, and the duplicate labelled
statement check then for inner would unconditionally dereference
loop->labelledStatement.

In all other places where we access loop->labelledStatement we have a null
pointer check, so let's have one here as well.

Change-Id: I9d5925a2abf4db691c49c0cdec3550938ee02efa
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-10-11 19:36:53 +02:00
Lars Knoll d736b58d24 Fix possible crashes
This can (and does crash) when a gc gets triggered during the
linking stage of a compilation unit.

Change-Id: I06f1299adab68ff8e0a4755d02e246870797e7f2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-11 19:33:41 +02:00
Jan Arve Saether 8402ac0e3d Correct a small typo to QtQuick::Grid::horizontalItemAlignment
Change-Id: I09d56b69d9d958e7ad4bebd78dd66316a84a50b6
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
2013-10-11 16:01:24 +02:00
Eskil Abrahamsen Blomfeldt 4aaf5e2c20 Android: Skip tools built for target architecture
Android apps require packaging to be usable, so they need to be
built individually, not as part of the subdirs build. The build would
fail during make install due to this.

Task-number: QTBUG-34023
Change-Id: Id68f5fbdd4eeb6f130d20a0f4b831c6c24639471
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
2013-10-11 16:01:24 +02:00
Lars Knoll dfca0ef6ee Correctly set the vtbl for Boolean and NumberObject
Also accept a boolean primitive as input to
Boolean.prototype.valueOf()

Change-Id: I5b94d8d65b86e26860b9844eb4bf823577c8e924
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-11 16:01:24 +02:00
Lars Knoll e964fc3426 Fix the remaining objects against self destruction
This makes pretty much all test cases pass with exact
garbage collection.

Change-Id: Ia874e3c17c3984afb7cfe370f9bd3ad8fe46699a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-11 16:01:24 +02:00
Lars Knoll f6de6160b9 Optimise code generation for convertTypeToSInt32
Add 64 bit code patch and avoid some duplicated
calculation in 32 bit mode

Change-Id: I0e111de8ac4e733aa8802c49b4b15d785688d7ea
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-11 16:01:24 +02:00