Commit Graph

57 Commits

Author SHA1 Message Date
Lars Knoll 2784a68d64 Cleanup destruction of heap objects
Generate the code from a macro instead of duplicating boiler
plate code. Operate on Heap::Base instead of Managed.

Change-Id: I84c5a705980899be3e5b931a093645e50d3923bf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-21 19:32:23 +01:00
Simon Hausmann b04b5b57e9 Remove the remaining uses of Returned<T>
Change-Id: I493b75365d3c6fbf6965986d73e7aa0b659ded67
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-11-15 00:32:59 +01:00
Lars Knoll ec8f1f68d6 Begin moving the data out of Managed objects
We need to move the Data objects out of the Managed
objects, to avoid lots of trouble because inner classes
can't be forward declared in C++.

Instead move them all into a Heap namespace.

Change-Id: I736af60702b68a1759f4643aa16d64108693dea2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-08 16:39:07 +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 43296bb5fb Remove some unneeded reinterpret_cast's
Change-Id: I29ebc1f06bb3f0d20e6e21840c7fe326a0f4546d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-04 20:16:58 +01:00
Simon Hausmann 3f1d0b27a1 Changed Value to store Managed::Data pointers directly
This is a step towards storing direct heap object pointers for the values
on the JS stack, to avoid the costly indirection for data access.

Change-Id: Ibb57ed6cf52a7088bbc95ee04ae3a4cb25b8c045
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-04 14:58:30 +01:00
Simon Hausmann 327d0886c3 Reduce memory pressure on system malloc when allocating large items on the GC heap
Try to free our large items for every 8 megabytes of additional large item
memory we allocate. This helps in particular on 32-bit builds and was noticable
in tst_qqmlecmascript::push_and_shift().

Change-Id: I4cc0b188e58ccaf32026e38c7aaf1cfadc83148b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-10-27 15:19:15 +01:00
Simon Hausmann 9a66bb751b Reduce memory pressure on the JS stack during garbage collection
As the example in QTBUG-42051 demonstrates, QML may produce a lot of binding
objects and each of them produce a QV4::Persistent. During the mark phase we
may run out of JS stack space. One fix (for the future) is to reduce the number
of QV4::Persistent objects, but in the meantime we can also reduce the pressure
on the stack by draining it earlier.

Task-number: QTBUG-42051
Change-Id: Iea73f8a869048ea0bf3f4a64dbd24b6fb8c68f6b
Reviewed-by: Ulf Hermann <ulf.hermann@digia.com>
2014-10-22 16:39:44 +02:00
Jani Heikkinen e7ceacda70 Update license headers and add new licenses
- Renamed LICENSE.LGPL to LICENSE.LGPLv21
- Added LICENSE.LGPLv3 & LICENSE.GPLv2
- Removed LICENSE.GPL

Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0
Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
2014-08-25 11:28:46 +02:00
Simon Hausmann b393c405b7 Change the object allocation scheme
Instead of allocating the data directly, centralize the object and its ::Data
allocation in one place in the memory manager. This is in preparation for
additional pointer indirection later.

Change-Id: I7880e1e7354b3258b6a8965be378cd09c9467d25
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-07-22 13:49:19 +02:00
Lars Knoll c9081fab7c Rename Managed::managedData() to d() to be consistent
No need to differentiate in the name anymore, as the data
structures all inherit from each other now.

Change-Id: Ia41f50ce4e521f9626d874311ceb57e0e194888b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:10 +02:00
Lars Knoll b11ec08570 Move Managed data into it's own subclass
This prepares for moving over to a d pointer scheme,
where Managed subclasses don't hold any data directly. This
is required to be able to move over to a modern GC.

Change-Id: I3f59633ac07a7da461bd2d4f0f9f3a8e3b0baf02
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:48:54 +02:00
Holger Hans Peter Freyther 9da3da656e v4: Manually inline the access to the execution engine
Executing an allocation heavy testcase of JavaScriptCore on my
i7 Sandy Bridge notebook 6.85% is spent inside the ::engine()
call as gcc 4.8.2 of Debian didn't inline the call. Inline the
call sites by hand. I removed the protected ::engine() as it is
now unused.

$ time qmljs JavaScriptCore/tests/perf/bench-allocate-nonretained.js
before (best run of three)
real	0m2.234s
user	0m2.228s
sys	0m0.008s

after (worse run of three)
real	0m2.097s
user	0m2.088s
sys	0m0.008s

Change-Id: I20b73b3b3dac630eb1d5e7d66bcb50c839630567
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-20 09:51:33 +02:00
Ulf Hermann 4d68155848 Properly initialize heap profiler when starting profiling
Change-Id: Ia994464b2150dc9a9185280ae0e2f8c615393310
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-06-12 18:13:45 +02:00
Ulf Hermann ac56e7cda7 Javascript heap profiler
This profiler tracks every memory allocation and deallocation, by the
MemoryManager as well as the V4 VM, and exposes them as a stream of
events to the profiler service.

Change-Id: I85297d498f0a7eb55df5d7829c4b7307de980519
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-06-06 18:18:35 +02:00
Lars Knoll 873f927fe2 Make the destroy method optional
This allows us to avoid calling a destructor on objects
that don't require one. After the memberData change this
should be most objects.

Also fix a bug where we didn't call the destroy() method on
large objects, potentially leaking memory.

Change-Id: I1708055d568d85b0a3876899d35e8c3eb92dd222
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-04 17:26:20 +02:00
Karim Pinter d06dc29738 Making the CHUNKSIZE setable via environment variable
With this modification the CHUNKSIZE is setable by QV4_MM_MAX_CHUNK_SIZE
environment variable so the memory usage which is important for embedded
devices can be finetuned.

Change-Id: I3cd75158f2255651edd341873de035c1222e3c92
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-04-01 09:43:17 +02:00
Simon Hausmann a0f82509e4 Fix double deletion
Small regression from commit 7ae796cb14.
Processing the deletables might result in the onDestruction emission, which in
turn may end up in GC allocation and thus GC runs. That in turn may result
in m_deletables processing, which at this point is nested then. For that to
work we need to set m_deletables back to zero _before_ beginning with the
iteration.

Fixes tst_qqmlecmascript with aggressive gc.

Change-Id: Ibb310b30cd496644557f4c1bb23318b18ee8f36c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-03-28 13:28:46 +01:00
Lars Knoll 37fbfa4dc0 Be a bit more conservative with allocating memory
Cap the max chunk size at 2MB. This value still still doesn't
affect the v8 benchmark noticably, but should avoid extreme
memory usage in some corner cases

Task-number: QTBUG-37134
Change-Id: If2050374c4a7df7ff74194d64880e2d660ea26fd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-27 23:27:02 +01:00
Lars Knoll 57f4d8b490 Remove the scribble option from the memory manager
This option doesn't make sense anymore, as we memset the object to
0 on destruction anyway.

Change-Id: Ie40563394f9cacda1b35fde114c9a6043f53d460
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-27 20:39:59 +01:00
Lars Knoll 7ae796cb14 Get rid of collectDeletables
The method is only required for the QObjectWrapper, but
there we can instead simply register the deletable in the
destroy method.

Change-Id: I944319d327859cce33ac31a174e8d56fc4babfc1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-27 20:39:59 +01:00
Lars Knoll 7526cb1c95 Optional reporting of GC statistics to stdout
Use QV4_MM_STATS to get some statistics about each GC run
written to stderr.

Change-Id: Idc30c06e1c3ca8353a2f16615cb26df13a8f23ed
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-25 10:01:43 +01:00
Lars Knoll a1fdf173eb Remove unused method
Change-Id: Ia7df68e78ac105fe5519cb4f80a64561310d3324
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-25 10:01:40 +01:00
Lars Knoll da7995ef2d Remove code for conservative GC
This was meant as a debugging help after we took the exact
GC into use. Turns out it doesn't help debug any issues,
aggressive garbage collection is much more helpful in
finding GC issues.

Change-Id: Idfff26d3a4a15e570615009c1e57921bca6297ca
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-25 10:01:38 +01:00
Michael Brasser f3a9176442 Allow maximum block size to be specified as an environment variable.
A smaller maximum block size helps limit RAM usage on constrained
systems, at the cost of more frequent garbage collection.

Change-Id: Iba07d9cc628e3178dfaad35664c631844540bc9d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-13 16:39:34 +01:00
Lars Knoll a78a48c532 Cleanups
Remove SafeValue, it was used to port over to an exact GC. Since
we now have that, we can now safely merge it with QV4::Value
again. Also rename SafeString to StringValue for better naming
consistency.

Change-Id: I8553d1bec5134c53996f6b0d758738a0ec8a2e4d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-01-31 11:13:48 +01:00
Simon Hausmann 22041acdfe Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
	src/imports/dialogs/qquickmessagedialog.cpp
	src/imports/dialogs/qquickmessagedialog_p.h
	src/qml/debugger/qqmlprofilerservice_p.h
	src/qml/jsruntime/qv4regexpobject.cpp
	tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro

Change-Id: Ic8a43366b44d6970966acbf03b206d0dee00c28d
2014-01-24 18:27:41 +01:00
Lars Knoll 7d4fc70e70 Split ManagedVTable into two classes
Keep the basic methods in ManagedVTable, but have
the Object related stuff in an ObjectVTable class.

Change-Id: I9b068acf3caef813686227b8d935e7df1a7d1a6e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-01-21 20:46:50 +01:00
Alex Blasche 24c43a5748 Make compile on DragonFly BSD.
[ChangeLog][Platform Specific Changes][BSD] Fixed compile errors on
DragonFly BSD and potentially FreeBSD.

Task-number: QTBUG-35867
Change-Id: Iea90b93672c34f8a4b56e9afc4dbfb82cc993548
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-01-21 12:32:58 +01:00
Simon Hausmann f596553e03 Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
	.qmake.conf
	src/imports/dialogs/DefaultFileDialog.qml
	src/imports/widgets/qquickqfiledialog.cpp

Change-Id: I00de6dd05cb773f01254061d585a82c90b229acd
2014-01-17 07:12:23 +01:00
Albert Astals Cid 14ebfef611 Do not crash if /proc is not mounted
When proc is not mounted pthread_getattr_np fails, so default
to 1MB stack in getStackLimit and to exactGC in MemoryManager

Change-Id: Ic7515fd420f2d39a656808d24a3915a657722891
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-01-15 10:45:05 +01:00
Lars Knoll 658a15a075 Clear out memory in the GC, not when constructing objects
Object construction shouldn't need to zero initialize itself,
let's rather do this in the GC, where we can use fast memset's.

Change-Id: I2f9efa1729183b0d737de5a84f92af319b2c5631
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-01-03 17:09:14 +01:00
Lars Knoll fbcd0a22f6 Move the vtable pointer from the object to the internal class
This saves one pointer per object, and willmake other optimizations
easier in the future.

Change-Id: I1324cad31998896b5dc76af3c8a7ee9d86283bfe
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-12-04 09:45:45 +01:00
Friedemann Kleint f4c91ae691 Fix MSVC-64-warnings about truncation of integers.
Change-Id: Ib92ce4b7e42061bb1892957f04cbfc1fcfe43615
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-11-26 09:48:10 +01:00
Friedemann Kleint 93304429cf Fix MSVC-64-warning about shift word size.
jsruntime\qv4mm.cpp(301) : warning C4334: '<<' : result of 32-bit shift
implicitly converted to 64 bits (was 64-bit shift intended?).

Change-Id: I6a4ca024d43776e16a323fdb8c35a339b74e6c09
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-11-26 09:46:20 +01:00
Lars Knoll bf173fe5da Turn execution contexts into Managed objects
This finally gives proper memory management for ExecutionContexts.
So far they had been garbage collected but where still allocated
using standard malloc/free(). This allows us to collect the
contexts faster and speed up context creation.

Change-Id: I02e642391d55eaa59ab3f4c2720a2ac71259caf4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-11-22 14:54:33 +01:00
Lars Knoll 855784e5a7 Add support for large items to the memory manager
This is required, so we can track ExecutionContexts
through the regular memory manager.

Change-Id: I1bd2e2ef275e6e9e1f364a35affbb991f4377b05
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-11-22 14:54:14 +01:00
Sérgio Martins d2c958199f Initialize variables before using them.
Change-Id: I7cd5a17259814b3f2405b63d7f4d2a0fd30cae4d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-11-06 16:55:09 +01:00
Andrew Knight eeabbf5548 Fix build on WinRT
Disable JIT and avoid unsupported functions under WinRT.
Also add MSVC's ARM flag to the double conversion white list.

Change-Id: I22ec340a20b113fdeefb802ac61812f78a527895
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-11-06 09:07:08 +01:00
Lars Knoll cb7948caec Don't run the GC too often
Some test cases were badly trashing the GC, running it
way too often. Fix this by only running the GC after
we allocated more than 50% of the amount of available
items.

Change-Id: Icfe6d0730552ef2298963de706213ebc9e3e342c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-11-05 22:23:25 +01:00
Lars Knoll 025365f1dc Refactor marking GC'ed objects
Don't use recursive function calls anymore. Instead, push marked
objects onto the JS stack, and then pop them off when their children
are being marked.

Should reduce stack memory usage, and improves performance by ~5%.

Change-Id: I2d37d97579144fcba87ec8e9fd545dd220c01fbb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-11-05 18:54:51 +01:00
Lars Knoll f0eaaef4ae Some minor optimizations
Change-Id: Ib2e08e7c89ca59a48f8fd52b30981e5d7e60803b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-19 14:59:02 +02:00
Lars Knoll ad7f91c59a Turn on exact garbage collection by default
Keep conservative GC as a fallback for testing
Enable all tests again that were skipped due to
GC issues.

Change-Id: I8e0fa728207bdd39a96d0acf95e27841157d8402
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-16 06:36:47 +02:00
Lars Knoll e20253ed7a Remove debug output
The output messes up some auto tests

Change-Id: I9b9b2b4fdf023bc9953939b814872e860c84f484
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-15 20:57:37 +02:00
Lars Knoll 40db24351b Smaller cleanups
Change-Id: I0a7eee96ef7c92ad4a3c5963010e3ac66fe6ed3a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-11 08:56:26 +02:00
Kai Koehne e34477bfaf Use common prefix for environment variable
Change-Id: Idbbdcad42106d30451000fc6593428a0bac4bc04
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-10-09 15:11:11 +02:00
Lars Knoll ac8afca822 Remove some more uses of QV4::Value
All remaining uses should be GC safe now.

Change-Id: I05c962de6ab896f108f70caa1bf937a24e67bfe1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-10-02 16:07:33 +02:00
Lars Knoll cf2a253f2f Move Value::fromBool, ... to a new Primitive class
This will simplify finding the remaining direct usages of
QV4::Value that need fixing.

Change-Id: I223099727436d5748027c84c53d9dfc4028e38ed
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-09-28 13:33:24 +02:00
Lars Knoll 74807c0725 Move more API over to use ValueRef
Change-Id: I372f1f3e3e78d45912a913f437e622e0acfc9646
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2013-09-26 09:05:32 +02:00
Sérgio Martins 6bb0b40083 wince: Build fix, NtCurrentTeb() is not available in this platform.
This was copied from qtscript's:
src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp

Change-Id: Iaa5549e6915aa4aa4bf532fbe7c9117a0858ff02
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-25 13:18:33 +02:00