Commit Graph

9820 Commits

Author SHA1 Message Date
Simon Hausmann 9d7b27f5bf Clean up JS .import/.pragma directive scanning
There's a scanner in QQmlJS::Lexer::scanDirectives that can parse those, so
let's get rid of extra parser that operates on a string. Instead this way we
can do the scanning all in one shot, avoid detaching a copy of the source code
string and (most importantly) bring the parser closer to the copy in Qt
Creator, which uses the directives approach to extract imports and pragma.

Change-Id: Iff6eb8d91a45d8a70f383f953115692be48259de
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
2015-01-08 22:08:19 +01:00
Lars Knoll bede2a3ac7 Remove qv8engine usage in the contextwrapper
Change-Id: Iaf807add5d971e96cac57e38e13385e901f9c930
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-08 12:34:36 +01:00
Lars Knoll 3e054a80dd Get rid of QV8Engine::toString
Change-Id: Ib51fa09ae251c1b7b8878ecdf920016f8fcc0067
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-08 12:34:32 +01:00
Lars Knoll 486965a12e Remove v8engine pointer from QQmlV4Function
Change-Id: I68ddd79b8866ef9b8628a2eab1118d3ee3d72759
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-08 12:34:25 +01:00
Lars Knoll bb29bebc8a Get rid of more uses of QV8Engine
Change-Id: I763728b1685e8e68bcf815dda4dd8e5757f59dd2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-08 12:34:22 +01:00
Lars Knoll 1a86ccd527 Reduce v8engine dependency for the list model
Change-Id: Ib9e39a886c918a8f6ee1477465895739f90e1a0a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-08 12:34:20 +01:00
Lars Knoll b5c6b78ee4 Further reduce v8engine dependencies
Change-Id: I9f50f5ed1928de0c389c9646b308b431b51dae37
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-08 12:34:17 +01:00
Lars Knoll 2828ee37e2 The property() calls in the proeprty cache only require a QJSEngine now
Change-Id: Ic4a944b4f1dd02ad2f0284acad5f3135068f66df
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-08 12:34:14 +01:00
J-P Nurmi 5cb8ca29c3 Allow importing protected modules with different major versions
This allows QtQuick.Controls 1.x and 2.x imports to co-exist even
if they are two different plugins with the same module directive.

Change-Id: Idee302439e3c2fd6813ba2f41b69144fbae7902c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-08 11:12:56 +01:00
Albert Astals Cid bf10bf0331 Make waitForRendering without item fail instead of crash
Change-Id: Icd276ed19087c2a1cde8c626347c696efb21ceb3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-08 10:55:40 +01:00
Robin Burchell c3b6a64136 QV4: Lower time spent in indirections and allocations.
Change data type for defsUntyped from QList -> QVector & reserve space when
creating the list. Drops ~250ms off a pretty morbid QML testcase, most, but not
all of which was spent in allocations.

Change-Id: I2ed8c62e7d41ab353a0194da268a2b430f079474
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-07 21:35:58 +01:00
Robin Burchell ba690fb738 V4 IR: Change data type used in RemoveSharedExpressions pass.
Profiling the loading of a pretty morbidly large QML file consistently showed
that this was quite slow, around 1300ms in removeSharedExpressions, of which a
good >600-700ms (I didn't count exactly, but it was a very large amount) was
down to allocating and freeing QHash nodes.

As we don't require removals, leaving insertion and lookup as the only two
remaining options, a sorted vector becomes a viable alternative (credit to João
Abecasis for the idea).

An additional benefit of this change is that the two hash lookups are now
compressed into a single 'hash' lookup (via the lower_bound call) instead of
separately using contains() / insert().

Measuring the exact saving is difficult, but it looks like this saves between
700-1000ms off the runtime RemoveSharedExpressions. After this patch, malloc and
free are dominating the optimizer run, instead of any particular method.

Change-Id: I6c0bb8495eac4dd3613ba0274e8802d7bd609460
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-07 21:35:54 +01:00
Simon Hausmann 05fd01c14a Fix property access and method invocation on value types that use inheritance
For gadgets/value types we use moc's static_metacall, which doesn't call the
parent class implementation. Therefore before placing a static metacall we
must resolve the indicies and find the right meta-object.

Change-Id: I258e3d9ecfc704498c68772dc42b16134a3bfd83
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
2015-01-07 15:34:19 +01:00
J-P Nurmi 353e43cb6d Unify QQmlDirParser version parsing and error reporting
Add a parseVersion() helper function to avoid duplicating
the same version parsing logic three times.

Change-Id: I4e5b6a8c86ee3a26c4eb91c660a81176ac0346cf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
2015-01-07 14:44:05 +01:00
Laszlo Agocs fae16f9d2f Prevent windows outside the gui thread in rendercontrol example
In the multithreaded case we attempted to create QWindows outside
the gui thread on platforms where QOffscreenSurface is backed by
the hidden QWindow in the absence of a better solution. This has
to be avoided. Therefore, pass a suitable surface from the gui
thread instead.

This will avoid "Attempting to create QWindow-based QOffscreenSurface
outside the gui thread." type of warnings when running on OS X with
--threaded.

Change-Id: Ie3ebeeeaa9e6bdf83e763e40213e2940fbfde667
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-01-07 13:21:00 +01:00
Robin Burchell 5352f67ffa qmltime: Correct module name in error message.
Change-Id: Icccad866bdbaf53bf2cb3f1aff30ecd9ff6d06a5
Reviewed-by: Michael Brasser <michael.brasser@live.com>
2015-01-06 22:26:59 +01:00
Jocelyn Turcotte a832461468 Fix the vertex ordering of merged triangle strips
Culling and gl_FrontFacing depend on the vertex order matching the
value set through glFrontFace. To match the default counter-clockwise
order we need to preserve the parity of triangles relatively to the
start of the indices argument of glDrawElements, but we break this
parity because of the degenerate triangles between merged strips.

Fix the issue by skipping the first degenerate triangle, the parity
of following strips will be preserved since they are then separated
by two triangles.

This fixes a regression of
tests/manual/scenegraph_lancelot/data/shaders/culling/culling_1.qml
triggered by 38cab579a0.

Change-Id: Iefa7eaab68112d31be9d8646bd288eb000528cd5
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
2015-01-06 18:26:21 +01:00
Gunnar Sletta a371bac3fb Reuse the memory we use for vertex uploads.
Every batch would have its own buffer with its own memory
and the original idea was that it would stabilize so that
the same batch would be used over and over, so the memory
allocatd for each batch's buffer would be reused. In practice
batches get discarded and recycled in somewhat arbitrary
order so we always end up reallocating.

Instead, use a single buffer for all uploads. This saves us several
reallocations per frame, and also prevents pooling of several
potentially large allocated blocks inside the renderer.

The exception is when using visualization or for drivers
which have broken index buffer support (nouveau only currently),
where we keep the existing behavior as the buffer data is
needed during rendering and visualization.

Change-Id: Id29095e00128ec1ee6d4ac3caa8f2c17cc7bbd27
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-01-06 17:18:27 +01:00
hjk ba455b8e1c Some minimal changes to make qmlpuppet compile again
Access to QJSEnginePrivate::createCache and the previous
signature of QQmlPropertyCache::invalidate is used.

Change-Id: Ie2578eee33ee4ebb2cdc4574d8d1cb7c8209868e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
2015-01-06 10:55:33 +01:00
Gunnar Sletta d8a09da9a4 Remove bogus assert.
It is perfectly valid to reparent nodes to a parent
that is part of an existing hierarchy.

Change-Id: Icf2dbe6030d399047e7ebe735e3096d1a8cd8c0e
Task-number: QTBUG-43278
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-01-05 15:26:39 +01:00
Gunnar Sletta 01cb25953d Traverse children correctly when reparenting.
Since the children are being removed from the parent, using
nextSibling on the child won't work. We need to extract the
first child from the parent until there are no more children
left.

Change-Id: Ifca5f2760e2b1c7ba56c198623c5dc9d82c7560f
Task-number: QTBUG-42530
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-01-05 15:26:38 +01:00
Albert Astals Cid c7ab634fc7 Add propertyName to error
May help a bit to the reader, even if the line is already there
sometimes it can be confusing if it is a default property like data

Change-Id: I5cb8e8833c78a784ad4f5541d094840477e8f350
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-05 12:02:21 +01:00
Oleg Shparber 2fe82c505d Use QV4::ScopedObject typedef instead of actual type
Change-Id: I0b68c534ea513a7c230b12114f6b42b069f9864b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-03 23:29:57 +01:00
Oleg Shparber 4a9ed3de7d Use QV4::ScopedArrayObject typedef instead of actual type
Change-Id: I975536745ac6c264aca074f84d223fbec7682d3d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-03 23:29:51 +01:00
Oleg Shparber 21d481c209 Use QV4::ScopedContext typedef instead of actual type
Change-Id: I71c6c9cf030e347fbc5e4073e9ca338a9ce95999
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:29:48 +01:00
Oleg Shparber 2fadffdc46 Use QV4::ScopedFunctionObject typedef instead of actual type
Change-Id: I6b4effaa5bef992b4ae9402eea7fe655bc7b18f0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:29:41 +01:00
Oleg Shparber 29c0102adb Use QV4::ScopedString typedef instead of actual type
Change-Id: I64ecbf6cea463387a70e909ecc5f9165d22a7b0f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:29:09 +01:00
Thiago Macieira d0db6dc2b7 Fix build: include <qdatastream.h> before using QDataStream
Change-Id: I779e0cd705f664368b47763d4367b9dc377c1770
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:11:29 +01:00
Lars Knoll 46e028bb45 Remove unused variable
Change-Id: I399e66822f52e35d122d3a20bb8de20206e5864d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:11:12 +01:00
Lars Knoll 1443b0566e Add a direct accessor to retrieve the JS engine from the ExecutionEngine
Change-Id: I2617143e39f354657e12541f3796a583e9934118
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:11:06 +01:00
Lars Knoll 3d11162fba Reduce v8engine dependency in the type wrapper
Change-Id: I3a50aa3c0929c14ad856463635bf2fb2188f5c9f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:11:01 +01:00
Lars Knoll 545338b21c Reduce v8engine dependency in qv4include
Change-Id: Idc50e7ed9e0de5c8742688c8493c2124075450ee
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:10:55 +01:00
Lars Knoll b9b12af83f Remove v8engine dependency in fromVariant conversions
Change-Id: I3427129dc7a0e68c8fa0b61f353835e2bee179a0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:10:50 +01:00
Lars Knoll 2056538fea Remove v8engine dependency in toVariant conversions
Change-Id: I0f2f77c9cc268a0c5ca3ffe0cd66fc98bb1964b3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 21:10:43 +01:00
Nobuaki Sukegawa 96178192c4 Do not cause SegFault when importing empty javascript
Change-Id: I31f6571e73b5dd74bf3ade5cadc2daa02475b5cb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-02 15:31:11 +01:00
Simon Hausmann 2b5fb18562 Enable gadget wrapping for custom value types
[ChangeLog][QtQml] Custom C++ value types annotated with Q_GADGET are now fully
accessible in the QML and QJSEngine JavaScript environment.

QJSEngine::toScriptValue can be used for injection and fromScriptValue to
extraction. The QML "built-in" gadget wrappers for QPoint and the gui types are
not exposed this way, toScriptValue(point) will still return an opaque QVariant
wrapper. We could expose the core types right away, but then we would be
lacking an API to enable use of the Gui types that are registered in QtQuick.

It would be better to make the core types in qtbase gadgets and thus enable
them without the need for hooks and init functions to be called by the user.

Task-number: QTBUG-29769
Change-Id: I8179cd599bdc1209ff61cfdbdda419cb400296bb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-01-02 15:06:46 +01:00
Lars Knoll 9a2701c1c3 Remove v8engine dependency from qv4serialize.*
Change-Id: I5b4c1247286bf18c96df3b68b7bae9feefbbdbc9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-01 21:36:48 +01:00
Lars Knoll 05b5f4bc16 Don't store a v8engine pointer in qqmllistwrapper
Change-Id: I21b055deb74aafff8b2ee1cdce776e06f154dcaa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-01 21:36:44 +01:00
Lars Knoll 032619e115 Remove unused enum value
Change-Id: I1e1a34a974cea129fcf4513c0a163254d6c114cd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-01 21:36:41 +01:00
Lars Knoll 645d9e9632 Fix constructions of QJSEngine objects
The private class is not empty anymore, so calling the wrong
constructor would lead to memory corruption

Change-Id: I6d477fc63bba46be733273f548397c2a50ef2bf4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-01 21:36:36 +01:00
Oleg Shparber 07d714f3ca Make QV4::Value::isNaN() inline
Change-Id: Ia80d3b150822ec9b3965c981d58660567ca73ec1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-31 09:20:50 +01:00
Robin Burchell 132cdfa69c QV4::InternalClass: reserve space for transitions.
Profiling of allocations shows that this is one of the most frequent allocators.

Change-Id: Iae0350c61bfe37381577642b9a93064377f45c1d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-12-31 05:07:08 +01:00
Simon Hausmann efc3cc717a Make QQmlPropertyCache available in QJSEngine
The QQmlEngine has two containers for property caches, one for QML types and
one for all-purpose meta-objects. The latter is rather useful and now being
moved to QJSEngine to be available there.

Change-Id: Ieab65c400b8a2e410e5f9eee6d603162dbb864d9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-12-29 14:39:22 +01:00
Simon Hausmann 65953304a2 Prepare for QQmlPropertyCache to become available in QJSEngine
The cache is seemingly tied to QQmlEngine, but it isn't. A lot of
times a QQmlEngine parameter is unnecessarily dragged around and the
engine member is option as well as it turns out.

Change-Id: Iffd2a5046e9785249689ebfcbc8a0ad509f76aea
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-29 13:57:28 +01:00
Konstantin Ritt 802a996693 Fix build on MinGW
- alloca() needs malloc.h
- crtdbg.h couldn't be found on MinGW

Change-Id: Ibbf91a58d39ef1e2572baae3c409393acf7aa5df
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-12-28 18:46:59 +01:00
Simon Hausmann b7bcde88a3 Removed usage of QQmlValueType in QQmlValueTypeWrapper
QQmlValueType doesn't have anything really necessary :). Some code it has, but
that was only called from the wrapper, so it was moved there. This also reduces
one level of memory allocation for the wrapper.

In theory the allocation for the JavaScript wrapper could be changed to be the
size of the wrapper _plus_ the size needed for the gadget. However in
anticipation of wanting to be able to move objects, we can't do that as we
can't memmove() gadgets around - they might contain pointers to memory areas
within.

Change-Id: Icb5a6f5513e3b2c87f6639f6f7b1fb572af08137
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-12-28 18:39:51 +01:00
Oleg Shparber 7dd5895854 Make QV4::CallData::argument() method constant
Change-Id: Id2640f6a0c08069764baeac606a25fdb53b23419
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-27 09:40:45 +01:00
Tasuku Suzuki f8beab1d73 support XMLHttpRequest sync mode
[ChangeLog][QtQml][XMLHttpRequest] Supported synchronous requests

Change-Id: Ia38fcf97f212a14657bb519240d8406368a72390
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-26 04:39:46 +01:00
Simon Hausmann d641008d04 Prepare method invocation in QObject bindings for gadget support
In order to support calling invokable methods in gadgets from JavaScript, the
wrapper code needs to be able to operate on gadgets and not only QObject
pointers. The minimal abstraction for that - QQmlGadgetOrObject - is passed
through the relevant invocation methods in the wrapper for that.

Change-Id: I94f939c942241f49dce4d32d05bf24822b2d331b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-12-23 14:51:17 +01:00
Simon Hausmann c9adc7661a Move methodParameterTypes and methodReturnType helper functions
These can extract the type information from either a property cache (through
QQmlData from a QObject) or (fallback) from a QMetaObject.  The difference
between a QMetaObject and a QQmlPropertyCache is what QQmlMetaObject abstracts
and therefore we can move the functions there.  This is in preparation for
gadget support and also avoids the repeated QQmlData::get() dance but allows
the re-use of a QQmlMetaObject instance in the future to do that dance only
once.

Change-Id: Ibff6ce498d09fabc97e0801653edc5b1ff446c6a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-12-23 14:51:04 +01:00