Commit Graph

427 Commits

Author SHA1 Message Date
Lars Knoll 589f8a90fa Separate the stack used for GC from the regular JS stack
This is required to be able to implement concurrent or
incremental garbage collection.

Change-Id: Ib3c5eee3779ca2ee08a57cd3961dbcb0537bbb54
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-04-07 06:06:17 +00:00
Lars Knoll 1e63f7c483 Cleanups
* Only call ExecutionEngine::markObjects() on a full GC, it doesn't do
anything in the incrementall case anyway.
* Move the marking of child objects into it's own method for clarity
* Move collection of gray items down to happen directly before we drain
the mark stack

Change-Id: I41067e17d483067bd1c4d60da22c5628482dae78
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-04-07 06:06:14 +00:00
Lars Knoll a410cb6901 Remove assertObjectBelongsToEngine method
It's only used during mark() calls, where we can be reasonably
safe that the assertion holds. But mark() needs to change and
become independent of the execution engine for concurrent collection,
so remove the assert as a preparation.

Change-Id: I52266af719afd76048d73efdcfcf96c0abc8843f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-04-07 06:06:10 +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 24d0266ee4 Merge remote-tracking branch 'origin/5.9' into HEAD
Conflicts:
	src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp
	src/qml/jit/qv4assembler.cpp
	src/qml/jit/qv4assembler_p.h
	src/qml/jit/qv4isel_masm.cpp
	src/qml/jsruntime/qv4context.cpp
	src/qml/jsruntime/qv4context_p.h
	src/qml/jsruntime/qv4engine.cpp
	src/qml/jsruntime/qv4vme_moth.cpp
	src/qml/memory/qv4mmdefs_p.h

Change-Id: I9966750b7cd9106b78e4c4779f12b95a481cca40
2017-03-23 14:43:46 +01: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
Lars Knoll e772081db1 Incremental garbage collection
Add an incremental mode to the garbage collector, that will
get used for many collections. This should significantly
reduce average stop times for GC.

Make sure that manual calls to gc() still do a full collection,
to ensure consistency and keep tests that rely on gc() working.

Change-Id: I87b13529377b7639ce993dbd99e85ff0a555acd8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:59:23 +00:00
Lars Knoll 2a554434a5 Implement a real write barrier
Implement a Steel write barrier for our objects. The barrier is
interesting as it can also be used for incremental GC runs by
simply turning the barrier on and leaving old objects marked as
black.

Change-Id: I0b273974d94a990dee3cd9298089b8b202c75bf2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:59:20 +00:00
Lars Knoll d7aa952e14 Make writes to ArrayData write-barrier safe
Change-Id: I2e46100fe72fd83b36b3195130eefce5289d1627
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:58:49 +00:00
Lars Knoll 91714e004e Make all write operations to Pointer<> types go through a set() method
The new set() method also taked an ExecutionEngine pointer. This makes
it trivial to now add a write barrier for those operations.

Change-Id: I321eccfe6fb279cc240b5c84910e6854f71759f6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:58:34 +00:00
Lars Knoll 3a0bb11d73 Separate SimpleCallData and CallData
SimpleCallData doesn't need any loca variables, so
move it into a separate CallData Heap object. This
also allows getting rid of the manual markObjects()
implementation for CallContext.

Change-Id: I9014eb2f815d3e2fe63a951a9d126c38e8aaa0a3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:58:17 +00:00
Lars Knoll 10c1e40533 Unify mark handling for MemberData and ArrayData
Introduce a ValueArray class, that defines an array of
Values at the end of a Heap Object.

Change-Id: I00efbf6f5839a6687dd5bc5fc037ec8f06e0936e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-03-09 08:58:15 +00:00
Liang Qi afec9016d0 Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I92b13a9c1727644d63e125c1e6f1fdac72720ad7
2017-02-28 13:04:17 +01: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
Robin Burchell dd31156c6c NumberObject: Copy parseInt and parseFloat from the global object
Per the spec, these use the same FunctionObject as the global object.

Implements:
    20.1.2.12
    20.1.2.13

For es6 test/built-ins/Number, we go from:
    === Summary ===
     - Ran 490 tests
     - Passed 412 tests (84.1%)
     - Failed 78 tests (15.9%)

to:
    === Summary ===
     - Ran 490 tests
     - Passed 416 tests (84.9%)
     - Failed 74 tests (15.1%)

Change-Id: I7e6f84ef81a429a4bce4895663ad6dc10f389f86
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-02-03 15:10:29 +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
Maurice Kalinowski 9e980750c6 WinRT: Enable JIT for x86/x64 target platforms
This only works for Windows 10 and later.

Setting the "Code Generation" capability in the manifest, WinRT
applications can use JIT for Windows 10 Desktop. Update the Allocator
in regards to this and also update the VirtualProtectFromApp section.

When the engine gets initialized, check for marking an area as
executable. If it fails, fallback to interpreter mode.

This does not affect ARM platforms, as we do not have calling
conventions yet. It is implicitly disabled as V4_ENABLE_JIT is not
defined.

[ChangeLog][WinRT] Enable JIT for x86/x64 targets on Windows 10 and
later.

Change-Id: Ie05add5263f71387c5ce98456b9bec86c6c07ceb
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-01-16 10:33:06 +00:00
Mathias Hasselmann a29c621659 Print warning if JIT is disabled
The wiki will provide information on how to work around the issue.

Change-Id: I4409f5b4af0668ab28197adb8766898124e8cec8
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-01-14 19:05:36 +00:00
Thiago Macieira 65fa1b4c08 Remove prohibited uses of underscore + capital letter
All identifiers starting with an underscore and a capital letter are
reserved to the compiler and must never be used by the user code. Try to
find a better name or, in the worst case, move the underscore to the
last position in these identifiers.

See commit cf63c63d558227fdbef09699c261560e7474f5ea in qtbase for a case
of such an identifier causing a build breakage when the compiler began
treating it specially (it was _Nullable).

Change-Id: I1d0f78915b5942aab07cffff140f9f39c29f0fdf
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2016-01-08 00:09:50 +00:00
Sérgio Martins 49f9797d2a Fix a couple of container detachments
Change-Id: I0def20d858de7721771702907b7a431b5fb90a1f
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2016-01-05 16:36:02 +00:00
Friedemann Kleint 8848abe69f QML: Sanitize reading environment variables.
Where possible, use qEnvironmentVariableIsSet()/
qEnvironmentVariableIsEmpty() instead of checking on the
return value of qgetenv().
Where the value is required, add a check using one of
qEnvironmentVariableIsSet()/Empty().

Change-Id: Ia8b7534e6f5165bd8a6b4e63ccc139c42dd03056
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2015-10-22 12:40:18 +00:00
Ulf Hermann 5c64391fb4 Only set V4 debugger when service is enabled
Otherwise different debug services could steal each other's debugers.

Change-Id: Ic0a50333d21c7d20a7124240ea598f8446400ae3
Reviewed-by: hjk <hjk@theqtcompany.com>
2015-10-15 17:11:50 +00:00
hjk 23f3fcbabc QmlDebug: Split QV4::Debugging::Debugger
... into a pure interface and a QV4::Debugging::V4Debugger implementation.

This is in preparation of a second implementation of this interface
to be used with 'native mixed' debugging.

Change-Id: I3078dcfe4bdee392a2d13ef43a55ca993e7b88d8
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
2015-10-14 13:38:07 +00:00
Lars Knoll 6565e78610 Reduce memory consumption of signal handlers
Move the connect/disconnect methods for signal handlers into
their prototype, so that we don't need to define them per instance
anymore.

Change-Id: Iac1e6d1dd7bce86730dbb6c51e2c3f79713641f7
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-25 08:40:03 +00:00
Lars Knoll c72f973a35 Speed up creation of Array literals
Gives around 10% speedup on the v8 splay benchmark.

Change-Id: I47f64e7b73bde59ac3bdd2c94fc199ecfbbf290e
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-25 08:38:56 +00:00
Lars Knoll ff347ccb09 Fixes to Error objects
Move the name and message property into the prototype as
per JS spec. Only define the message property in the
object itself if the value used for construction is not
undefined.

In addition, clean up creation of the objects and centralize
it in a few template methods.

Change-Id: I014017b710575b30bf4e0b0228111878f5c73b9a
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-22 08:20:18 +00:00
Lars Knoll 13edffa303 Move remaining objects to new constructor syntax
Also disable the old way of constructing objects.

Change-Id: Ib4e69087cd563ae1481da116d6caf97876239798
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-22 08:20:13 +00:00
Lars Knoll 2a8de9d8d8 Convert FunctionObjects to new allocation syntax
Change-Id: I269c20abdc7f9eb0d71a2d2d485d622b65405762
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-22 08:20:09 +00:00
Lars Knoll b3cdc48914 Simplify new construction scheme
Declare the default prototype and internal class
in the class itself.

Change-Id: I08c2b42aa61a886580061336ae60cef8dedc0f03
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-22 08:20:07 +00:00
Lars Knoll 6190b10d1c move error objects over to new construction scheme
Change-Id: I533c7bf90d49aee10b5661fd15a98e013b1169bd
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-22 08:20:04 +00:00
Lars Knoll d7e535e99b Convert variant object and ObjectProto
Change-Id: I5ee3b453b74f5832997aca68d04979302f9afac5
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-22 08:20:01 +00:00
Lars Knoll 9420eb5c4e Use the new construction scheme for RegExpObjects
Gives around 10% speed improvement on the v8 regexp
benchmark.

Change-Id: Iad37bcbc79ccbfb92f65852b660364c919862a75
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-22 08:19:59 +00:00
Lars Knoll 17a0c271e0 Move more objects over to the new allocation scheme
Change-Id: I0241efe10d115f8e4a646f840e47e220eb6cfc18
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-22 08:19:56 +00:00
Lars Knoll 833c99db20 Inline property data into the object
Append the part of the objects property data that is
known ad instantiation time to the object itself and
by that avoid creating a separate MemberData. Saves
some memory and should speed up object creation.

Currently implemented only for Object and ArrayObject.

Change-Id: I7693bf2f3a28fb718522398ebb94ac115e021fa4
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-22 08:19:53 +00:00
Lars Knoll fb52dab6b4 Further cleanups
Reduce usage of ScopedContext.

Change-Id: I84a6a7478065de3398fd0b21596ca1308e78ceb3
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-15 19:12:40 +00:00
Lars Knoll f3efdebc34 Fix typo
Change-Id: I9bfc96096ec5e2c8bd4d3c5bad13fc78ae657962
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-15 07:37:28 +00:00
Lars Knoll 830376c962 Rename currentExecutionContext to currentContext
Now that the other method is gone, let's use
the shorter currentContext

Change-Id: I2a6fb3b77f83a1ffdf314ad29081e303d17030ed
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-15 07:37:26 +00:00
Lars Knoll 0e6195a85c Cleanup usage of ExecutionEngine::currentContext
Change-Id: Ic79d6da162375928ec25871cd0341daeab6483d2
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-15 07:37:22 +00:00
Lars Knoll 3a8d6123d1 Store the stack of executioncontext's on the JS stack
This saves one pointer per allocated execution context.
Now every execution context that is pushed, allocates two
Values on the js stack. One contains the context itself, the
other one the offset to the parent context.

Things are a bit tricky for with and catch scopes, as those
are called from the generated code, and can't open a Scope
anymore. In addition, all methods iterating over the js
stack frames need to work with ExecutionContext pointers,
not ScopedContext's.

Change-Id: I6f3013749d4e73d2fac37973b976ba6029686b82
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-15 07:37:16 +00:00
Lars Knoll fb059f697a Reduce usage of context->parent
Change-Id: I31bb8019783311a7e6065e2aac7fec67c1120ebf
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-15 07:37:14 +00:00
Lars Knoll cedd732794 Explicitly push/pop ExecutionContexts
Avoid the implicit push inside the execution context constructor
and rather make this explicit in the code.

Change-Id: I1bb0fb523fddbb273fc666370d619f55f49cd40a
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-15 07:37:11 +00:00
Lars Knoll b5902bd43a Get rid of the qmlContextObject method
Change-Id: Id8c0d9e15dd85b3818e283ab6769a49bb2e6d0f7
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-09-15 07:37:06 +00:00
Lars Knoll ad55f5fd24 Move the qmlSingletonWrapper method out of the contextwrapper
One more step towards removing the class alltogether.

Change-Id: Ic9f6794eb3c5c6605ee43ad23a6d432ebbf321a1
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-08-20 20:01:25 +00:00
Ulf Hermann eb30e3d7ee Merge remote-tracking branch 'origin/5.5' into 5.6
Conflicts:
	src/qml/debugger/qv4debugservice.cpp
	src/qml/jsruntime/qv4value_inl_p.h
	src/qml/jsruntime/qv4value_p.h
	src/qml/memory/qv4mm.cpp
	src/qml/memory/qv4mm_p.h
	src/qml/qml/qqmlnotifier_p.h
	src/qml/qml/qqmlproperty.cpp
	src/quick/items/qquickflickable.cpp
	src/quick/items/qquicktextedit.cpp
	tests/auto/quick/qquickwindow/BLACKLIST

The extra changes in qqmlbinding.cpp are ported from changes to
qqmlproperty.cpp that occurred in parallel with writeBinding() being
moved to qqmlbinding.cpp.

Change-Id: I16d1920abf448c29a01822256f52153651a56356
2015-08-18 10:29:47 +02:00
Lars Knoll 415f55d140 Encapsulate and protect all accesses to the vtable of Heap objects
This is required, so we can safely access the vtable even while
we're marking objects during GC.

Change-Id: I34f56b61b4bca0d0742faf607eb5ab8b2c30685e
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-08-10 07:24:32 +00:00
Lars Knoll b288956817 Use the QmlContext to access properties of the scope object
Add some runtime methods to access properties of the scope
object directly (using the QmlContext), and generate proper
code to call those.

Change-Id: I0b29357c9a3b9ad53ba568ec6cb763e8ecb10f21
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-08-10 01:21:57 +00:00
Lars Knoll 416c0f3263 Add ability to retrieve and use the QmlContext from our generated code
Our generated code (JIT and interpreter) should operate on the
QML context to retrieve QML related things. That's better than
operating on 4 different temps.

So this commit introduces the QML context as a temp in the
code we generate for QML. The next commits will move things over
to use that context with specialized runtime methods instead of
using generic subscript/get calls on the different subobjects.

Change-Id: Ia05cf339de9cdd23003f35cf78ede17d2590f8de
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-08-10 01:21:48 +00:00
Friedemann Kleint 7da45b21b7 Fix warning about returning address of local variable by MSVC2015 in qv4engine.cpp.
qtdeclarative\src\qml\jsruntime\qv4engine.cpp(179) : warning C4172: returning address of local variable or temporary: dummy

Disable warning as using the address is intended.

Change-Id: Ide894a8dc2fb94f11d0455723c46567c84d91f8d
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-07-17 13:44:21 +00:00
Erik Verbruggen c749f37c83 V4: track C++ heap usage for Strings in the MemoryManager
... and do a GC run when it exceeds a threshold. The issue with Strings
is that they hold on to QString instances that store the real content.
However, the GC only sees the light-weight JS handle, and doesn't take
the size of the backing content into account. So it could happen that
big QStrings accumulate in the heap as long as the GC didn't reach its
threshold.

The newly introduced unmanaged heap threshold is upped by a factor of
two when exceeded, and lowered by a factor of 2 when the used heap space
falls below a quarter of the threshold. Also grow the threshold if there
is enough space after running the GC, but another GC run would be
triggered for the next allocation.

There is a special case for Heap::String::append, because this method
will copy the data from the left and right substrings into a new
QString. To track this, append notifies the memory manager directly of
the new length. The pointer to the memory manager is stored in
Heap::String, growing it from 40 bytes to 48 bytes (which makes it still
fit in the same bucket, so no extra memory is allocated).

Task-number: QTBUG-42002
Change-Id: I71313915e593a9908a2b227b0bc4d768e375ee17
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-07-10 13:52:18 +00:00
Thiago Macieira f35be0bc5a QtQml: Fix const correctness in old style casts
Found with GCC's -Wcast-qual.

Change-Id: Ia0aac2f09e9245339951ffff13c958364a2e9859
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-07-09 00:12:37 +00:00
Lars Knoll 5f162e17ed Cleanup retrieval of scope and context objects
Change-Id: I9c6174181f950bc4f829727dc6acdfe82fa4e894
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-06-18 18:24:34 +00:00
Lars Knoll f077bf13ef Clean up ExecutionContext's for QML
Create a specialized QmlContext instead of re-using
a call context with a QQmlContextWrapper as activation
object.

This saves some memory and opens up the route to getting
rid of the context wrapper in a future commit.

Change-Id: I1591c73932a08564fddf5137ac05bbc6f31dd4d5
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-06-18 16:42:58 +00:00
Lars Knoll 64199b0a58 Store a Heap::String pointer in StringObject
Change-Id: I926c5bb2dd4f1613af6737d4200e568f0ec13d58
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-06-17 09:03:48 +00:00
Lars Knoll a914b18667 Store rootcontext in a GC safe way
Change-Id: If81d638c0ccd2b34df918ae5055e309f4eae031f
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-06-17 07:40:03 +00:00
Lars Knoll 73093cbe4b Fix some function signatures
Add a const several places and pass values by pointer, not
reference. This allows us to also get rid of some Scope's.

Change-Id: I3b4c29c22511c947d024457e7b8fa2aaa6bec55d
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-06-15 17:03:21 +00:00
Lars Knoll f468f71571 Get rid of qv4qmlextensions
It only contained the proto for the value type wrapper. Instead
just create it lazily, but reserve space on the js stack for it.

Change-Id: I2301549b6dc4007bd5ac848e1dca25aafd583c4a
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-06-15 15:27:06 +00:00
Lars Knoll d32849dbe7 Remove explicit marking of the typedarray constructors
These objects live on the JS stack and are thus marked implicitly.

Change-Id: I8295d8096d0a47861e0092c36e16b95db458de3c
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-06-10 15:01:29 +00:00
Lars Knoll 864988474a Move the StringValue members of ExecutionEngine onto the JS stack
Change-Id: Ib55c05f1730b7659e2f6fee7e1fa79c10c759167
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-06-10 15:01:17 +00:00
Simon Hausmann 9556f6d075 Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	src/qml/jsruntime/qv4engine_p.h
	src/quick/items/qquickitemsmodule.cpp
	src/quick/items/qquicktext.cpp
	src/quick/util/qquickpixmapcache.cpp
	tests/auto/quick/qquickwindow/tst_qquickwindow.cpp

Change-Id: I90ecaad6a4bfaa4f36149a7463f4d7141f4a516a
2015-06-04 10:28:48 +02:00
Aleix Pol dad48f0e9c Makes it possible to extract all data from a QML DropArea
There's many types that aren't being covered by DropArea API, such as
images. getDataAsString is not acceptable, since fromUtf8 chokes on
reading non-utf8.
This patch introduces getDataAsArrayBuffer method that won't try to convert
the data into a QString and simply pass a QV4::ArrayBuffer, that internally
keeps a QByteArray.

Change-Id: I65411b3d365ee6c5e13effd9167156771ee08a05
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-05-23 13:52:36 +00:00
Simon Hausmann bf935a5359 Fix MSVC warning about unused variable
Change-Id: I9b2f21dd7cfc82a9da9aa3e4c60d47fa07fdceaf
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-05-19 10:53:32 +00:00
Kai Koehne 2cb2c8f9e1 MSVC: Fix compiler warning
Fix compiler warning introduced in commit  d76921e3082cd31:

jsruntime\qv4engine.cpp(1626) : warning C4100: 'v' : unreferenced formal parameter

Change-Id: I1f2b74f8e3fb14019f6e28b407d0336b0812c573
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
2015-05-19 07:40:02 +00:00
Erik Verbruggen d76921e308 QML: fix mixed debug/release build on OSX.
Dyld will take the debug library and link it against the release
versions of the frameworks. (Using the debug versions is an option to
dyld when starting an application.) This requires all symbols in both
debug and release libraries in frameworks to be the same.

Change-Id: I6d96bcdf8577f1dffc63c508cb7adc0db2acc486
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-05-12 08:49:09 +00:00
Simon Hausmann a690648c21 Add protection against "wrong" marking in debug builds
To protect against situations where we accidentally mark an object that belongs
to a different engine - there are many possible entry points - this patch adds
an assertion in debug builds for this situation. When it happens, it will point
more or less directly to the code that tries to push an object to the wrong JS
stack for marking. This helped in the investigation of QTBUG-44895

Change-Id: I311b9ff6d282d52e725044b03a62cd77085536be
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-05-08 14:55:32 +00:00
Simon Hausmann 94db5de2ac Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	tests/auto/quick/qquicktext/tst_qquicktext.cpp

Change-Id: I075e742da8396a268d97d3ab34bcd9e0c0cf001f
2015-04-28 14:29:59 +02:00
Simon Hausmann e2447f9f5f Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts:
	.qmake.conf
	tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp

Change-Id: I715b8a78b74cbe0dcaf599367fd6e08af4858e11
2015-04-27 14:40:00 +02:00
Lars Knoll 590c23b23c Move evalfunction and thrower onto the js stack
Change-Id: I3a0abe13d802aff8998d1c64f86b5a8f98c8335f
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-24 15:21:43 +00:00
Lars Knoll 1af88df072 Move constructor objects onto the js stack
Change-Id: I828c5f7407d90cd5df1a8fd89a0ca35074fbde43
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-24 15:21:36 +00:00
Lars Knoll f9440c704e Move more objects from the v4 engine to the js stack
Convert most of the prototype objects in the v4 engine.

Change-Id: I365f290493c20973bc991b6a383649836e42a16a
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-24 15:21:28 +00:00
Lars Knoll 7501c394d0 Continue the work to move Values inside the v4 engine to the js stack
Started with objectPrototype, the next commits will move more
of them over into the new data structure.

Change-Id: I1a048e95149ce69e4e42094db2dd738ce49b50b8
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-24 15:21:20 +00:00
Lars Knoll 0d54025cd2 Move exceptionValue and globalObject from the Engine onto the JS stack
We'll need to move all GC'ed objects currently stored in ExecutionEngine
onto the JS stack for easier management in a new garbage collection
scheme. This is the start of that change.

Change-Id: Ib3ad8e846875dade8a807ea79f063173d40e4aad
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-24 15:21:08 +00:00
Lars Knoll 0a499043fb Get rid of qv4value_inl_p.h and replace it by qv4typedvalue_p.h
This is a cleaner separation and further reduces include dependencies
in the definitions of our basic data structured.

Change-Id: I18aa86cdea0c0dfbc16075d4d617af97e638811e
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-24 15:20:43 +00:00
Liang Qi 07782f48f4 Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	src/qml/qml/qqmlbinding.cpp
	src/qml/jsruntime/qv4arraybuffer.cpp
	src/qml/jsruntime/qv4functionobject.cpp

Change-Id: Ic752e9dfd69b282093651c9234c110a49762f06d
2015-04-22 15:32:19 +02:00
Lars Knoll 484abc8159 Get rid of asFunctionObject()
Change-Id: Ib4858376dc0ec57fa473c80696abc66a570c90ec
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-21 13:01:54 +00:00
Lars Knoll b4cb71e9d7 More cleanups
Get rid of Value::asObject(), and pass const Managed pointers
into some more vtable methods.

Change-Id: Ia4f427d5fd8868f77b4015d1ce5424d32bfc2115
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-21 13:01:47 +00:00
Rolf Eike Beer 9934c075c7 QML: do not check stack size if stack grows up
On architectures where the stack grows upwards (i.e. HP PA-RISC) the
stack limit calculation fails because the variables used to check the
offset are usually close to the bottom of the stack, which is in this
case the origin of the stack grows. Since these machines are a rare
obscurity simply assume that everything is fine on these machines. The
few people that are indeed running QML on such machines will probably
be able configure their stack size properly by default.

Task-number: QTBUG-44268
Change-Id: Ia83a39179a0f6e0602ba7a5032d386e12d8d1ba3
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-21 08:52:06 +00:00
Lars Knoll b8dbd08705 Get rid of Value::asDateObject()
Change-Id: I71816a784b5175f600c5a870318b16c0d84c42fb
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-16 20:56:59 +00:00
Lars Knoll 4930941197 Further cleanups
The get and getIndexed vtable methods should take a const Managed
pointer. Start cleaning up the asFoo() methods in Value and Managed
by removing asArrayObject() and asErrorObject().

Change-Id: Ibd49bf20773ef84c15785b7ac37a7bc9fd4745d5
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-04-16 17:44:24 +00:00
Simon Hausmann d22db9e458 Speed up script binding initialization
Don't spend any time repeatedly building the same internal class for the simple
binding functions. We can do that once at engine construction time.

Change-Id: I3777b5bd15ad4a8aaf78ae13bee27e8d8cadc2ee
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-04-16 17:14:09 +00:00
Simon Hausmann b220a20552 Speed up value type binding creation
* Avoid calling QMetaType::construct/destruct(typeId, ...) as that requires
  repeated lookups in the type registry. Instead cache the constructor/destructor/etc.
  function addresses in the QQmlValueType singletons as QMetaType
* Allocate memory for the gadget pointer lazily, to accommodate the common case of
  a value type binding by property reference.

Change-Id: I98a3ac73453b8f80027c06401b4f29a9707949d2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2015-04-16 13:40:17 +00:00
Valery Kotov 175772b3de QML Engine: Share data for ArrayBuffer created from QByteArray.
ExecutionEngine performs shallow copy of internal data for ArrayBuffer
created from QByteArray.

Change-Id: I514cd9708a7fbe9a989937fac62d00b464d7362d
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Reviewed-by: Valery Kotov <kotov.valery@gmail.com>
Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
2015-04-15 09:27:59 +00:00
Liang Qi c8427a542b Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	tests/auto/qml/qqmlitemmodels/testtypes.h

Change-Id: I2f2f3f47fd873ddd4fd027414654a861b56357f4
2015-03-24 22:09:49 +01:00
Christian Strømme 90b06e2773 Fix conversion between char and string.
If a QChar (or char) was used to set a QString property, the
intermediate value used by the QML engine (int), would be
converted to a string representation of the integer and not the actual
character. To avoid this behavior, characters are now stored as string
objects and the string is then converted to the target char type if
possible.
A side effect of this solution is that it is makes it possible to
assign a string to a char property as well, but only if the string
contains exactly one character.

[ChangeLog][QtQml][Important Behavior Changes] Assigning a char to a
string will now create a string with the actual character instead of a
string representation of the character's code-point. A side effect of
this change is that a one-character string also can be assigned to a
character type.

Task-number: QTBUG-44934
Change-Id: Ifd15386933ee11354ee1bbb5598a5f0b00a08616
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-03-21 11:15:31 +00:00
Lars Knoll 7b7297470c Cleanup some of the casting code
Get rid of value_cast, and move the Managed::as()
method into Value.

Change-Id: I440ac44ae77f4fda1a8a837383fe631f432f6532
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-03-20 11:17:11 +00:00
Simon Hausmann fb0cb17cb5 Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I6033aba359ac551f450ad517d20a0986bf4655f6
2015-03-17 09:52:19 +01:00
Valery Kotov d988310434 QML Engine: ArrayBuffer XHR response type support
Support for "arraybuffer" response type for QQmlXMLHttpRequest was
added.

[ChangeLog][QtQml][QQmlXMLHttpRequest] QQmlXMLHttpRequest now
supports "arraybuffer" binary response type.

Change-Id: I866e543cc7bc6ab037ffff1ef6628057b73daf90
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-03-09 19:41:41 +00:00
Frederik Gladhorn 6dbf435ca4 Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I94f8ae93d76bd5c120de25d9c238701afe8bfbd0
2015-03-03 18:13:38 +01:00
Lars Knoll feebac8e70 Move memory management related functionality into it's own folder
Start moving the memory related functionality into it's own folder.
This will simplify refactoring of the GC related functionality later
on.

Change-Id: I70ec6f512af7a7897625afb84d914c17572b0ccd
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-03-02 16:34:16 +00:00
Friedemann Kleint 5163c11952 QtQml: Micro-optimize iterator loops.
Avoid repeated instantiation of end() in loops, use variable instead.

Change-Id: I3bb1c6918cfd16a5dcefbcc03c442e99fe9bf76b
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-02-26 15:13:34 +00:00
Frederik Gladhorn ad67ec26d0 Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts:
	.qmake.conf
	LICENSE.GPLv2
	examples/qml/networkaccessmanagerfactory/view.qml
	src/qml/jsruntime/qv4runtime.cpp
	src/qml/jsruntime/qv4stringobject.cpp

Change-Id: I5d12f436d60995e51d5c2f59d364e9cbc24f8e32
2015-02-24 17:36:04 +01:00
Jani Heikkinen c5796292ad Update copyright headers
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.

Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9
Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
2015-02-12 10:28:11 +00:00
Alex Richardson cf6e97119d Don't crash on FreeBSD when computing stack limits
On FreeBSD pthread_attr_t is a pointer and is dereferenced when calling
pthread_attr_get_np() so if we don't initialize it will probably crash.
This is not a problem on glibc systems since there pthread_attr_t is an
opaque union an doesn't need to be allocated using malloc().

Change-Id: I227685ddf9981974ade08aee8917f7262c301787
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
2015-01-28 16:13:22 +00:00
Lars Knoll 0c2ab6e20c Store a double in NumberObject
Makes more sense than storing a Value in there.

Change-Id: I2e6ca71477100c1e1639bb89cced4f4049b5e5c2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-23 12:30:41 +01:00
Lars Knoll ef6b4938b9 Cleanups
Simplify some code in BooleanObject
Simplify access to call arguments and thisObject

Change-Id: I2f8e844019bc587385608beb02f05b15f827535c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-23 12:30:38 +01:00
Lars Knoll 3dbf4e9a69 Cleanups
Remove duplicated methods. Remove some mostly unused methods,
and simplify some others.

Change-Id: I605b249e54417bb32c3dfc8e22f2c8b6b684a1e1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-23 12:30:35 +01:00
Lars Knoll 002a5d4303 Get rid of most uses of ValueRef
Instead pass a const Value & into the functions

With our new inheritance structure, we can get rid of ValueRef
and instead simply pass a pointer to a Value again. Pointers to
Values are safe to use again now, as they are now guaranteed to
be in a place where the GC knows about them.

Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-23 08:07:32 +01:00
Lars Knoll 8209f35b79 Rework QJSValue internals
Use a flagged pointer to either store a pointer to a
QV4::Value (from the persistent storage) or a pointer to
a QVariant in QJSValue::d. Like this we don't need to malloc
to create a QJSValue for most use cases.

Significantly reduces the memory consumption of QJSValue and
speeds it up a lot.

Change-Id: I10902cc4b6cc3f43d3f816875dc6c4bbb6b4490f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-21 18:22:52 +01:00
Lars Knoll d8131513b0 Add C++11 move operators, and a simpler internal constructor
Move semantics should optimize some copy operations on QJSValues,
and the internal constructor will simplify refactoring the
QJSValue class to get rid of the extra allocated private.

Change-Id: I24863b30523af2432aa81ad6b87fda7fe35749c4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-21 18:22:47 +01:00
Lars Knoll 630f118f04 Move the internalClass pointer into Heap::Object
The other classes that derive from Heap::Base don't need it
at all. So get rid of it there and save a pointer.

Change-Id: I9c5df2e43cd6eeac2e6e41f3d3b8077d3afbc8f2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-21 13:19:02 +01:00
Lars Knoll 85bf8d732b Remove the remaining bit of code that use the vtable in the internalClass
Change-Id: Ia52f0e6db325aab37477d455f163487b319dce29
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-21 13:18:38 +01:00
Lars Knoll 8a23c8a613 Move vtable out of internalClass
We can move the internalClass to Object later on, and such save
having the internalClass on lots of Heap objects.

This commit basically adds and starts making use of a new
vtable pointer in Heap::Base. In addition, the construction
methods in the memory manager now automatically setup the
correct vtable.

Removing the vtable code from InternalClass and moving it into
Object will come in a separate commit

Change-Id: If49e8d73c769bf65bf47fe4dbf8b9546c8019dbc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-20 13:29:59 +01:00
Lars Knoll 8ffb79bbd2 Refactor persistent values
Use a page wise allocation mechanism for persistent
values. This significantly reduces memory consumption
of persistent values and also improves their performance
a lot.

Change-Id: I8499d2ca5bdd871e029f643ae605a94544558bb5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-16 21:12:49 +01:00
Simon Hausmann 291aea1463 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
2015-01-16 12:46:52 +01:00
Lars Knoll 431458b685 Fold the markBit into the internalClass pointer
Change-Id: I79f9286275f833dd01a3193042976d1f86ed5019
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-12 11:04:32 +01:00
Lars Knoll 53e144ae8d Fold the inUse flag into the internalClass pointer
Revert the flag (ie. flag == 0 means the item is used), and fold it
into the second lowest bit of the internalClass/nextFree field.

Change-Id: I7b690fdce00d16aa538fa70a269a755511477c5c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-12 11:04:30 +01:00
Lars Knoll ca977a0c8f Cleanup variant conversion code
Make public methods proper members of the ExecutionEngine, and
move private methods into the .cpp file only.

Change-Id: I3ca49e39bb1c4e559a2c63346e6ae6cfa446147d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-09 10:27:57 +01:00
Lars Knoll 7041eb353a Move the variant conversion methods from qv8engine to qv4::ExecutionEngine
Change-Id: Ibd529ae5cc3ba06f46152e9daa9119a4e7a2561c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2015-01-09 10:27:55 +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
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