Commit Graph

208 Commits

Author SHA1 Message Date
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
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
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
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 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
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 e7b66a6058 Make Managed inherit Value
This completes the first milestone towards being able to move
objects across the GC heap.

Change-Id: I8e6ce90254ea767188a31f0dc85b133534c87eb0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-20 15:16:39 +01:00
Lars Knoll db7b7d4161 Return a Heap object from the getter()/setter() methods of Property
We actually need to put the returned value into a ScopedFunctionObject
before calling it, as the Property could get deleted during the call
leading to a dangling pointer. With a GC that moves objects this will
become even more important.

Change-Id: I43bece6f80eb3501c1291065846e230a59ae8aed
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-20 12:00:04 +01:00
Lars Knoll 2950064286 Use a Heap::FunctionObject to store the thrower function
Change-Id: I6b3f03080f35e39d14b377363f7546a9f7260029
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-20 07:40:02 +01:00
Lars Knoll d3a6412c66 Remove most of the places where getPointer() is used
This is no longer required, and simply uglifies the code

Change-Id: Iba91a1d7735ebe23a43437f137a488423b6eb743
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-20 07:39:55 +01:00
Lars Knoll 4479bb58a4 Store a Heap::EvalFunction pointer in the engine
Change-Id: I002eb8f94e168c9faf1ee3521170dfaf442af1a3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-20 07:39:32 +01:00
Lars Knoll 05bf96997c Return Heap::ExecutionContext for globalContext()
Change-Id: Ide7c81735be4662ff45bf268cfe750ff1f784453
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-19 18:52:07 +01:00
Lars Knoll da2b7576da Return Heap::ExecutionContext for currentContext()
Change-Id: I155ab996e24d7f36761d2ea62a04774e16469b34
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-19 16:30:19 +01:00
Lars Knoll 0de16adf3d Mark JS freed parts of the JS stack as undefined in valgrind
Change-Id: Ibee3d95762bc0a0124b65ad8986ed643b9535529
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-19 16:30:10 +01:00
Lars Knoll 9d2a5ea28a Return a Heap::Object in Object::prototype()
Change-Id: Ice0265ae558ba14497421a5bbf25ee9db76adab5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-17 11:01:10 +01:00
Lars Knoll 8afc1f7fe2 Move prototype back from the vtable into Object
This is the only way we can support a GC that moves
objects around in memory.

Change-Id: I1d168fae4aa9f575b730e469e762bc5b5549b886
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-11 15:52:13 +01:00
Lars Knoll 4322c8d768 Better encapsulate access to the global object
Change-Id: I8a76112d821cb3fc172ba0d16ee8410d39b4422a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-11 08:40:48 +01:00
Lars Knoll ddfe9defa8 Encapsulate accesses to the root context
Change-Id: I668cef1363a5c1a5c5b9a7e138f3bd0338712eea
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-11 08:40:41 +01:00
Erik Verbruggen 8397f640e8 QML Debugging: Fix crash when stepping through try-catch block.
Also fix the stack-trace generation, otherwise the debugger engine would
report a breakpoint hit on the wrong line.

Task-number: QTBUG-42723
Change-Id: I1f655a5174b28a1c9c31c85bbe023fbce5ddbb96
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-12-09 11:55:04 +01:00
Lars Knoll 9f717b650e Let the memory manager operate on Heap::Base objects, not Managed
Change-Id: Ib5c9b51dbf9c69abeda088094e6348dd545bf3c8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-21 19:32:52 +01:00
Simon Hausmann f58b5229a3 Fix run-time string handling with regards to the new heap
Changed runtimeStrings to be an array of Heap::String pointers instead of
indirect String pointers. Later that member along with other GC related members
will go into a managed subclass. Meanwhile the generated code no more loads
String pointers directly but just passes the index into the run-time strings to
the run-time functions, which in turn will load the heap string into a scoped
string.

Also replaced the template<T> Value::operator=(T *m) with a non-template
overload that takes a Managed *, in order to help the compiler choose the
non-template operator=(Heap::Base *) overload. This allows removing a bunch
of Value::fromHeapObject calls.

Change-Id: I20415c0549d33cca6813441a2495976b66d4c00e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-11-21 13:08:28 +01:00
Lars Knoll 3dc7b5ddf6 Cleanup exception catching code
Change-Id: I85afd5758f72e19c280dc196601ee145f0c25f01
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-15 13:16:28 +01:00