Commit Graph

195 Commits

Author SHA1 Message Date
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
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
Simon Hausmann ad342b0524 Changed MemoryManager::alloc<T> to return Heap::T* instead of T*
Change-Id: Iede1ba624d1313fbe2f8e5e979e936f1f32efdc9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-11-15 00:32:45 +01:00
Simon Hausmann afbf1f74af Ported ExecutionEngine::newString and newIdentifier to Heap::String
Avoid the use of Returned<String> for newString and changed the identifier
table to use Heap::String. This required moving some code back into
Heap::String, but that's code that doesn't call back into the GC, so
allocations and therefore future object moves aren't possible.

Change-Id: I1dca3e9c12a9c56f09419af8cc8cba39fe04f720
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-11-12 20:44:13 +01:00
Simon Hausmann faf13a3aa0 Ported most ExecutionEnginew::new* factory methods away from Returned<T>
We don't need Returned<T> anymore with the QV4:: vs. Heap:: separation.
Eliminating Returned<T> simplifies also some code.

Change-Id: Ic2a9cd3c1a94f2ea37b539d3984d63997121c2b9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-11-12 17:55:57 +01:00
Lars Knoll f2532fd611 Cleanups
Remove a few reinterpret_cast's

Change-Id: I800b8c41123eaa22cf879571c747b4de0375e8cb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-12 12:13:33 +01:00
Lars Knoll 19ae8cdffe Convert ExecutionContext::parent/outer to use a heap object
Change-Id: I1b8ee831cfcdd5b1904ce24a341f5a796dce41cf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-12 12:13:03 +01:00
Lars Knoll e552ca0602 Use Heap object for CallData::function member
Change-Id: I5cae1b16c68751da9481a1cdae2601efa2a500a2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-11 05:31:27 +01:00
Lars Knoll a4b8bea95f Use Heap objects as members
Change-Id: I4f447747480fb7e15975b810e2a8623acc9cde61
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-11 03:11:12 +01:00
Lars Knoll 4b850f3d1e Move Data for typedarrays into Heap namespace
Change-Id: I1737423c22e0c68c9eaa14f6d4f5b1e48aea4a77
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-10 17:15:00 +01:00
Lars Knoll ef8ad8234b Move Data of FunctionObject and related classes into Heap
Change-Id: Iadf74f953798c1884e0ec704ccb7c70d971e3273
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-08 19:47:34 +01:00
Lars Knoll 84aae25c0b Refactor ExecutionContexts
Move the Data class out into the Heap namespace.

Change-Id: I2b798deb53812a08155c92a0e6ef2dcd2ea137b8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-08 16:39:15 +01:00
Lars Knoll 878b11e0a9 Let markObjects() operate directly on HeapObjects
This decouples things a bit better and helps moving
over to directly store heapobject pointers in other
objects.

Change-Id: I798f922e018b0a3ca6f8768e4a810187f34d82f6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-04 20:18:18 +01:00
Lars Knoll 486948817b Move the throw methods from ExecutionContext to ExecutionEngine
The methods don't require a context, and thus shouldn't be
implemented there.

Change-Id: If058e0c5067093a4161f2275ac4288aa2bc500f3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-04 20:17:54 +01:00
Lars Knoll 6f6b350976 Cleanup header file dependencies
Change-Id: Ibb4658576a98b53de2eac2474ce4d5b9eb83b6ae
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-04 20:17:23 +01:00