Commit Graph

320 Commits

Author SHA1 Message Date
Lars Knoll cae7975a03 Move the internalClass field from Heap::Object to Heap::Base
And do not store the vtable in Heap::Base anymore. This change
makes the internal class the main distinguishing feature
of all garbage collected objects.

It also saves one pointer on all Objects. No measurable
impact on runtime performance.

Change-Id: I040a28b7581b993f1886b5219e279173dfa567e8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-19 06:23:26 +00:00
Lars Knoll 70a49fe042 Add ICs for String, MemberData and ArrayData
Change-Id: I43ddcb4842e501cbea8a950ab6ffa2d906014efd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-19 06:23:16 +00:00
Lars Knoll 931239579d Move the list of default internal classes into EngineBase
And store them in an enumerated array. This will simplify
upcoming changes.

Change-Id: I82eac03b9f6264843ae625e36e150464fe08be9d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-19 06:23:13 +00:00
Lars Knoll fa4f49169a Move a few more members from ExecutionEngine to EngineBase
Change-Id: I5d1e0d2251e04cc871f9c298849aafac17f23fbf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-05-19 06:23:07 +00:00
Tasuku Suzuki 85eaae8b4c Fix build without features.qml-interpreter
Change-Id: I5f9c00541c27377e8310d32bf045c2860eeffcb4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-04-21 09:24:17 +00:00
Simon Hausmann a295dae1bc Fix value type encoding constant usage when cross-compiling
Our two value encodings use different masks for the upper 4 bytes.
Depending on the target architecture we must use different values when
generating code that uses these masks.

This patch replaces the #ifdef'ed ValueTypeInternal_* enum values with
two C++11 scoped enums that allows for the co-existence of both
throughout the code base as well as selective use in the code
generators.

Change-Id: I380c8c28b84df2874cca521b78bfe7f9388ed228
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-30 08:40:39 +00:00
Simon Hausmann 4db21fe60e Complete transition to standard layout classes for JIT access
Move the Runtime function pointer array into EngineBase so that
we can eliminate the last use of qOffsetOf.

For improved cache locality the memory manager point is now also
located in the EngineBase.

Change-Id: I0b3cf44c726aa4fb8db1206cc414a56c2f522a84
Task-number: QTBUG-58666
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-21 10:38:02 +00:00
Simon Hausmann 7efa1e60d2 Fix running of 32-bit JIT code generated on 64-bit hosts
The offsets of members encoded in JIT generated code differ between
32-bit and 64-bit architectures. This patch moves some of the
ExecutionEngine members into a separate standard-layout EngineBase class
(in line with the same class in commit
2a554434a5 and subject to merging). By
ensuring that the members are stored at pointer intervals, we can
translate from host pointer size to target when generating the code.

Task-number: QTBUG-58666
Change-Id: I1c38a7da059826848b80fd9972ed073214501386
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-17 08:34:57 +00:00
Ionut Alexandrescu bf1bd3abc9 Add a javascript push method binding to QQmlListProperty
Create a PropertyList prototype, and add the push method to
QQmlListProperty that call the append function if it has been defined.

Added a unit test and updated the documentation.

Change-Id: I2647766e98b60bf0546f6d6ed1422a616e0d3a07
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-02-21 12:30:30 +00:00
Simon Hausmann 8b7d48d99c Make the JIT ISelFactory a template
That way qmldevtools can - in the future - instantiate that also for the
cross-compilation targets.

Change-Id: If15b195f24e54226dc4f2fd9f0ad6874f44cb5af
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-01-31 18:30:10 +00:00
Kimmo Ollila a92950743f Add fixes for INTEGRITY
Full definitions of types are needed in static_casts.

Change-Id: I028ffc40a76cdb16cb297a181b3d9dfe9d09c945
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-01-31 13:39:59 +00:00
Liang Qi 60300fda46 Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
	.qmake.conf

Change-Id: I9d87ed86e95b5901a86cc3aa65d7ac39b0b708c2
2017-01-14 22:17:32 +01:00
Lars Knoll d2eaf438ac Get rid of the GCBlocker
It's a hack we needed when we still had a conservative GC, but
it is not required anymore. The only thing we still need is the
protection against running the GC recursively.

Change-Id: I55cd51d4929c828db5b61b38e781467c5bf77314
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-12-28 14:49:59 +00:00
Liang Qi 0e80d28aa5 Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
	src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
	src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
	src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
	src/qml/qml/qqmlimport.cpp
	src/quick/items/context2d/qquickcontext2dtexture_p.h
	tools/qmleasing/splineeditor.h

Change-Id: I8f6630fcac243824350986c8e9f4bd6483bf20b5
2016-12-14 19:01:23 +01:00
Lars Knoll 4dd13bb4c3 Get rid of SimpleScriptFunction
Now that the code paths are very similar, we can simply to the
check whether to do a fast or slow function call in
ScriptFunction::call/contruct. To make this fast, cache the
result of the required check in QV4::Function

Change-Id: I03085ca2beb83b1721b60b0d7b2ab4c9266d1e48
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-12-11 17:00:29 +00:00
Lars Knoll deec039008 Refactor the calling code for (Simple)ScriptFunction
Factor the common code out into separate methods that can
later on be reused by the QQmlJavaScriptExpression.

Also ensure a CallContext is safe to use with a 0
FunctionObject.

Change-Id: I1181a8e320b8c931d9df5b2c91bc143d8587fb60
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-12-09 08:31:01 +00:00
Lars Knoll b4ccdf004a Change ExecutionContext::getFunctionObject() to getFunction()
And return a QV4::Function from now on. This simplifies code in
other places and provides all the info required for stack traces
and debugging.

Change-Id: I512a8ac3932268d8cfc60675e75c4661d1f16fd8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-12-06 13:01:44 +00:00
Lars Knoll 8a6383775a Start cleaning up the QmlContextWrapper
The class should get merged with the QV4::QmlContext class.
Simplify the cleanup by moving both classes into a common
file.

Change-Id: I0074da79701d5f41eb51681b70fcde85bfd45fc1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-12-04 08:31:49 +00:00
Lars Knoll 46941afcc1 Cleanup Value::isObject/objectValue usages
Try to avoid calling both as objectValue() already
checks isObject().

Change-Id: I1d770d4d9dabed4ea4cc3e322b8fdc5a64f5bd2b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-11-29 20:00:29 +00:00
Lars Knoll 5d35573a62 Clean up Value::isString()/stringValue() combinations
It's enough to just call stringValue(), as that already
does the isString() check.

Change-Id: I7be0e643a7975c0704b4c9c43b337deb8db9fce0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-11-29 20:00:18 +00:00
Liang Qi f04c2c40fd Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
	src/qml/jsruntime/qv4variantobject.cpp
	src/qml/types/qquickworkerscript.cpp
	src/quick/scenegraph/util/qsgdefaultpainternode_p.h
	tools/qmljs/qmljs.cpp

Change-Id: I876242714ec8c046238d8fd673a5ace2455b2b59
2016-10-18 08:33:26 +02:00
Lars Knoll 11e0e5574a Make the Moth interpreter configurable
Change-Id: I2b784820c4e39a7932f81bfee9ce78e01a2e96b5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-10-10 14:11:44 +00:00
Erik Verbruggen 64afa01c32 QML: Introduce destroy() on Base subclasses
This removes the destructors of subclasses of Base, making them nearly
trivial.

Change-Id: Ia6f7d467e87899b5ad37b8709a8f633a51689d59
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-10-05 13:15:18 +00:00
Erik Verbruggen a166367bd8 QML: Move the ScarceResourceData from VariantObject onto the heap
So now VariantObject is nearly a trivial struct.

Change-Id: Ifc54c04d9686c03e12066c5287823dd3b1315d2a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-10-05 10:51:29 +00:00
Liang Qi ead7aea128 Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
	src/qml/jsruntime/qv4qobjectwrapper.cpp

Change-Id: I1a125b2334532ec5de4af39c0d6628890f4d0587
2016-10-01 22:27:26 +02:00
Erik Verbruggen b80fa8e7d5 QML: Make all context objects trivial
This change also adds a check to the d() calls for Managed, verifies
that the object has been initialized. This is only done for debug
builds.

To prevent other code from tripping the check, a number of other classes
are either marked as trivial, or do initialization in the constructors.
Because of template function changes in them memory manager (those now
call init() instead of in-place new), String has an extra parameter
to force it to temporarily use an old/unmodified template function.

Change-Id: I8c35161ce7680835d830638b6d21498c5129b02b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-09-30 14:14:31 +00:00
Anton Kudryavtsev 372082dd8e Qml jsruntime: replace 'foreach' with 'range for'
Change-Id: Ieb99b73037bc5b07caf62121d51a17c3025df97c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2016-09-16 19:35:02 +00:00
Anton Kudryavtsev 358fb253ea Replace QStringLiteral with QL1S in QStringBuilder
Saves some text size.

Change-Id: Ib521959784071a79462cf7962657d8158cf130a2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-24 08:13:32 +00:00
Liang Qi 7e609f6d10 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	src/qml/compiler/qqmltypecompiler.cpp
	src/qml/compiler/qv4isel_moth.cpp
	src/qml/compiler/qv4ssa_p.h
	src/qml/qml/qqmlobjectcreator.cpp

Change-Id: I8bb7fe773d657f908f20ee5e72c2b9bd643f6260
2016-08-17 10:57:38 +02:00
Liang Qi d54d28981c Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/qml/compiler/qv4isel_moth.cpp
	src/qml/compiler/qv4ssa_p.h
	tests/benchmarks/qml/qqmlimage/qqmlimage.pro
	tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp

Change-Id: Iad11ce7fdf0c6d200fdebc16a94081bd8069a87a
2016-08-13 00:41:58 +02:00
Erik Verbruggen 6e687e8571 V4: Handle QTime->DateObject conversion better
By specification, date conversion functions for dates before the epoch
are not DST corrected. We converted QTime to a QDateTime where we set
the date part to Jan. 1, 1970, and then convert that to msecs since the
epoch UTC. For places on Earth where they had DST on that day (e.g.
Hobart in Australia), strange things happen: conversion from a QTime to
DateObject will use DST (because it's after the epoch in local time),
but conversions from DateObject to QTime won't use the DST because it's
before the epoch (in UTC).

Now as everyone knows, a 24-hour clock time has no meaning without a
date, only "elapsed time" has. But users still expect to be able to pass
QTime to QML/JS. So, we do the conversion on day 0 of month 0 of year 0,
and all of it in local time. This gives a stable conversion in both
directions, and the values in both C++ and QML/JS are the same for any
timezone (with or without DST) on this planet.

Task-number: QTBUG-54378
Change-Id: I892e16a93f015e92d311c6cae3ae7768b7373f6a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2016-08-10 17:17:15 +00:00
Christian Strømme 35597f3014 Fix char conversions in QML
This is a partial revert of 90b06e2773, as it had unwanted side
effects. The original intention was to make assignment from char to
string possible, or more specifically, we wanted a solution where a
QChar could be assigned to a QString, as a character and not a string
representation of its value. While this behavior is desirable for
QChar, we most likely want the opposite for the regular character types.

Task-number: QTBUG-49232
Change-Id: I82d5f72b900fe984c4db1478fd52a9eb69ad2ee6
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-09 11:24:19 +00:00
Christian Kandeler 3e5152be41 QJSValue: Adapt to introduction of QMetaType::Nullptr
[ChangeLog][QtQml][Important Behavior Changes] A JS null value converted
to a QVariant now has type QMetaType::Nullptr rather than
QMetaType::VoidStar.

Change-Id: I91a64e444ada0f1884fe807f9973348ba1a878ff
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-08-08 12:45:38 +00:00
Ulf Hermann 91deafdcc8 Remove some unused members on -no-qml-debug
It's debatable if the uglification is worth the overhead of a few
pointers.

Change-Id: I63b55b2043b8752a94d4b862c3892915135a72b7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-07-28 15:09:43 +00:00
Ulf Hermann a7c7b26653 V4: Make ExecutionEngine's debugger and profiler private
This will allow us to #define them away on -no-qml-debug, saving two
pointers per engine.

Change-Id: I400cffd32cd7f55ff0e68565734b6002b9f901d5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-07-28 15:09:33 +00:00
Ulf Hermann c685165038 Qml: Create profiler adapters in the plugins
This way QtQml doesn't need to know the ctors.

Change-Id: Ie74049092b5eb9837537591c0cf37ad1487e4066
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-07-28 11:03:22 +00:00
Anton Kudryavtsev c03d9c49d3 Qml: replace QStringLiteral with QL1S
... or with QL1C in such cases:

- if there is overloaded function
- in QStringBuilder expressions

Saves ~1.5 KB in text size.
Build config: ubuntu 16.04 x64, gcc 5.3

Change-Id: Icc0789f1c244ce20a3182494b0c7f35c9d77e41d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2016-07-05 15:22:08 +00:00
Erik Verbruggen 702c4247d7 V4: Pass scope around as parameters inside the runtime.
The implementation of many (or all) runtime functions consist of first
creating a QV4::Scope, which saves and restores the JS stack pointer.
It also prevents tail-calls because of that restoring behavior. In many
cases it suffices to do that at the entry-point of the runtime.

The return value of a JS function call is now also stored in the scope.
Previously, all return values were stored in a ScopedValue, got loaded
on return, and immediately stored in another ScopedValue in the caller.
This resulted in a lot of stores, where now there is only one store
needed, and no extra ScopedValue for every function.

Change-Id: I13d80fc0ce72c5702ef1536d41d12f710c5914fa
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-06-22 11:07:05 +00:00
Liang Qi 4d2f743baa Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp

Change-Id: I26d6435a29cac3840bb567ade5149c2562a94bf9
2016-06-13 19:06:06 +02:00
Liang Qi 0932a59971 Merge remote-tracking branch 'origin/5.6' into 5.7
Part of 0e053528 was reverted in the merge, about lastTimestamp. It
will be applied later in separate commit.

qmltest::shadersource-dynamic-sourceobject::test_endresult() was
blacklisted on linux.

Conflicts:
	.qmake.conf
	tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
	tests/auto/qmltest/BLACKLIST
	tests/auto/qmltest/qmltest.pro

Task-number: QTBUG-53590
Task-number: QTBUG-53971
Change-Id: I48af90b49a3c7b29de16f4178a04807f8bc05130
2016-06-10 10:06:39 +02:00
Erik Verbruggen dbf7efde1e V4: Mirror jsAlloc behavior at stack allocation.
Allocating from the JS stack will zero out the memory, and thus indicate
to valgrind that memory is not uninitialized. By first marking the whole
stack as uninitialized and only then allocating 2 entries, the behavior
for those two entries will now match the allocation behavior. This
fixes a false positive when using valgrind.

Change-Id: Icdb5279e1cfbfe6b5c385cc42c556edf721fa74b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2016-05-27 10:04:59 +00:00
Liang Qi 8ae479a8ea Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	src/qml/jsruntime/qv4engine_p.h
	src/qml/jsruntime/qv4runtime_p.h
	src/qml/qml/qqmldelayedcallqueue.cpp
	src/qml/qml/qqmlvaluetypewrapper.cpp
	src/qml/qml/qqmlvmemetaobject.cpp
	src/qml/qml/v8/qv8engine_p.h
	tests/auto/quick/qquicktext/tst_qquicktext.cpp

Change-Id: I3f0608c7beb88088cbbef4d0db59920f56deaea9
2016-05-24 14:00:39 +02:00
Erik Verbruggen 607320ca9f V4: allow inlining of ExecutionEngine::{qml,js}Engine()
All other changes are just to be able to include qv8engine_p.h in
qv4engine_p.h

Change-Id: I71ba2ec42cdc20d5c7d97a74b99b4d1ada1a5ed8
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-05-20 13:44:13 +00:00
Liang Qi 63ec33e79c Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp
	src/qml/jsruntime/qv4engine.cpp
	src/qml/jsruntime/qv4engine_p.h

Change-Id: I89ffccd699bee675732758d039e22224b275d60d
2016-05-19 20:41:34 +02:00
Simon Hausmann 72515ebe5a Fix crashes when incubating objects asynchronously with initial properties
This is a regression from commit 94e337fa95 where
we accidentally ended up not having a calling QML context set anymore when
initializing the properties on newly incubated objects as provided by the
caller. The QML context is necessary as for example when we set a URL property,
the URL can be relative and it will be resolved to the base url of the context
when written, such as in in QQmlPropertyPrivate::write.

Change-Id: I1d896381fc92f653a7d76f4d82174bca48828f5e
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-05-18 10:08:30 +00:00
Erik Verbruggen 74f75a3a12 V4: Limit call depth by count, not by checking the native stack.
Getting the native stack size can be really expensive. For example, on
Linux/x86_64 (Ubuntu 15.04), it is at least 200,000 instructions for a
single-threaded application. With more threads (like qmlscene) it typically
ends up around 1M(!) instructions. Worse, it is called twice in the
ExecutionEngine constructor.

So, now we limit the depth of JavaScript calls to a fixed number, 1234 by
default. This can be changed by setting the environment variable
QV4_MAX_CALL_DEPTH to the desired depth.

Change-Id: Ic13c8efb2769e64fbc73deee6f6fa39d7c0b7af5
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-05-11 11:11:34 +00:00
Andy Nichols 60da655dff Merge remote-tracking branch 'origin/5.7' into dev
Change-Id: I57b06e2e98beb010a56dd0593d93e078ecf76eea
2016-04-05 12:11:13 +02:00
Erik Verbruggen 7d51248284 V4: Allow some more functions to be inlined.
Change-Id: If9d1f87fd7cf0b12d2827c4574109234be7e8ab8
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2016-03-31 11:00:50 +00:00
Nobuaki Sukegawa 3b7e2a69f7 Convert QByteArray in C++ type to ArrayBuffer in QML and vice-versa
Change-Id: Ie4e29a443a17826a3ce4d1e1912bd35dc497ac78
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-03-05 08:26:29 +00:00
Jani Heikkinen 45bd04ba73 Updated license headers
From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/

Updated license headers to use new LGPL header instead of LGPL21 one
(in those files which will be under LGPL v3)

Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-01-19 14:53:18 +00:00