aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4mm.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move memory management related functionality into it's own folderLars Knoll2015-03-021-617/+0
| | | | | | | | | 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>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | 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>
* QML: Fix MSVC 2013/64bit warnings.Friedemann Kleint2015-01-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | compiler\qv4ssa.cpp(687) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data compiler\qv4ssa.cpp(950) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data compiler\qv4ssa.cpp(1117) : warning C4267: 'return' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(1120) : warning C4267: 'return' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(1148) : warning C4267: 'initializing' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(1266) : warning C4267: 'initializing' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(1622) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data compiler\qv4ssa.cpp(2246) : warning C4267: 'initializing' : conversion from 'size_t' to 'unsigned int', possible loss of data compiler\qv4ssa.cpp(4289) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data compiler\qv4ssa.cpp(4351) : warning C4267: 'initializing' : conversion from 'size_t' to 'unsigned int', possible loss of data jit\qv4regalloc.cpp(1383) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data jit\qv4regalloc.cpp(1769) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jit\qv4regalloc.cpp(1814) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jsruntime\qv4mm.cpp(496) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jsruntime\qv4mm.cpp(503) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jsruntime\qv4mm.cpp(506) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data jsruntime\qv4regexp.cpp(60) : warning C4267: 'return' : conversion from 'size_t' to 'uint', possible loss of data jsruntime\qv4typedarray.cpp(85) : warning C4309: '=' : truncation of constant value Change-Id: I0b04e1a9d379c068fb3efe90a9db8b592061e448 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move vtable out of internalClassLars Knoll2015-01-201-7/+7
| | | | | | | | | | | | | | | | 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>
* Refactor persistent valuesLars Knoll2015-01-161-53/+17
| | | | | | | | | | 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>
* Use a list of lists for free chunks instead of merging in one listJocelyn Turcotte2015-01-131-104/+83
| | | | | | | | | | | | | | This remove the tedious merging of free heap slots into one big list after sweeping. It now lets each chunk keep its 0-terminated list of free items and by then linking chunks together in a list for those containing at least one free item. The chunk metadata is moved at the beginning of the allocated VM region to avoid moving it all around while sorting MemoryManager::Data::heapChunks. Change-Id: Ia93c2eb7feca0779a28aea5149dd066dacbfa494 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fold the markBit into the internalClass pointerLars Knoll2015-01-121-11/+22
| | | | | Change-Id: I79f9286275f833dd01a3193042976d1f86ed5019 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fold the inUse flag into the internalClass pointerLars Knoll2015-01-121-26/+28
| | | | | | | | 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>
* Fix valgrind support in the memory managerLars Knoll2014-12-191-2/+11
| | | | | | | | Fix compilation and ensure the memory manager doesn't create bogus warnings. Change-Id: I78ccfc7a11944f3275b7c03f6005874a561fa977 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Revert parts of "Fix the V4 valgrind integration"Jocelyn Turcotte2014-12-181-7/+7
| | | | | | | | Keep the MemoryManager as the pool argument of VALGRIND MEMPOOL functions and access it through ExecutionEngine::memoryManager. Change-Id: Iadb881ce8676088efe81870680aa75f6ba834248 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix the V4 valgrind integrationJocelyn Turcotte2014-12-121-8/+14
| | | | | | | | | | | | | 87a055bc8eee653a18d51f94a546cd452732223a broke the build and introduced invalid writes to chunks outside of the existing VALGRIND_DISABLE_ERROR_REPORTING block. Fix the build by using MemoryManager::Data* instead of MemoryManager* as the pool argument to VALGRIND MEMPOOL calls since the Data pointer is protected. Change-Id: I24136e25291570ade825dcd84a9568d8169a235b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Release the VM of unused heap chunksJocelyn Turcotte2014-12-111-44/+98
| | | | | | | | | | | | | | | | | | | | | | This changes the way that available items are linked together to allow releasing chunks not containing any inUse item after being swept. Instead of putting a freed item at the top of the stack and make it link to the item previously at the top, relink all items !inUse to point to the previously visited unused item during sweeping. This allows any chunk to be released in the process while making sure that no previous or next item will link to an address in that chunk. The performance penality of relinking the list has been measured to be ~0.6% with v8-bench.js tst_QJSEngine::largeSweep. In exchange, this helps keeping the amount of chunks to sweep lower after peaks of heap allocation, even though that ability will be restrained by heap fragmentation in long running applications. Task-number: QTBUG-41099 Change-Id: I81a70f0a930b679a1bef47e630b23dab5f6d1218 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merge remote-tracking branch 'origin/5.4' into devSimon Hausmann2014-12-091-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4arraydata.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4globalobject.cpp src/qml/jsruntime/qv4internalclass.cpp src/quick/items/qquicktext_p.h src/quick/items/qquicktextedit_p.h src/quick/items/qquicktextinput_p.h Change-Id: If07e483e03197cb997ef47a9c647a479cdb09f4c
| * Regression: Fix array data corruptionSimon Hausmann2014-12-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | When inserting into a sparse JS array, we may have to re-allocate the underlying data vector. When that happens we must reload the ArrayData pointer, to avoid returning a wrong pointer in ArrayData::insert. This patch also fixes the valgrind support in the memory allocator by correctly marking the mmap'ed memory region as inaccessible. Change-Id: I86aabc2cec74a4f3c8396463910d90c8968a741d Task-number: QTBUG-42956 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Let the memory manager operate on Heap::Base objects, not ManagedLars Knoll2014-11-211-21/+21
| | | | | | | | | | Change-Id: Ib5c9b51dbf9c69abeda088094e6348dd545bf3c8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Cleanup destruction of heap objectsLars Knoll2014-11-211-2/+2
| | | | | | | | | | | | | | | | 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>
* | Remove the remaining uses of Returned<T>Simon Hausmann2014-11-151-4/+4
| | | | | | | | | | Change-Id: I493b75365d3c6fbf6965986d73e7aa0b659ded67 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Begin moving the data out of Managed objectsLars Knoll2014-11-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Let markObjects() operate directly on HeapObjectsLars Knoll2014-11-041-3/+3
| | | | | | | | | | | | | | | | | | 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>
* | Remove some unneeded reinterpret_cast'sLars Knoll2014-11-041-2/+2
| | | | | | | | | | Change-Id: I29ebc1f06bb3f0d20e6e21840c7fe326a0f4546d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Changed Value to store Managed::Data pointers directlySimon Hausmann2014-11-041-0/+5
|/ | | | | | | | 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>
* Reduce memory pressure on system malloc when allocating large items on the ↵Simon Hausmann2014-10-271-0/+7
| | | | | | | | | | | 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>
* Reduce memory pressure on the JS stack during garbage collectionSimon Hausmann2014-10-221-6/+16
| | | | | | | | | | | | 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>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - 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>
* Change the object allocation schemeSimon Hausmann2014-07-221-1/+1
| | | | | | | | | 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>
* Rename Managed::managedData() to d() to be consistentLars Knoll2014-07-221-2/+2
| | | | | | | | 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>
* Move Managed data into it's own subclassLars Knoll2014-07-221-17/+16
| | | | | | | | | 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>
* v4: Manually inline the access to the execution engineHolger Hans Peter Freyther2014-07-201-12/+7
| | | | | | | | | | | | | | | | | | | | | | 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>
* Properly initialize heap profiler when starting profilingUlf Hermann2014-06-121-6/+20
| | | | | Change-Id: Ia994464b2150dc9a9185280ae0e2f8c615393310 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Javascript heap profilerUlf Hermann2014-06-061-4/+16
| | | | | | | | | 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>
* Make the destroy method optionalLars Knoll2014-04-041-4/+5
| | | | | | | | | | | | 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>
* Making the CHUNKSIZE setable via environment variableKarim Pinter2014-04-011-4/+8
| | | | | | | | | 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>
* Fix double deletionSimon Hausmann2014-03-281-1/+1
| | | | | | | | | | | | | | Small regression from commit 7ae796cb141b73a1b215b2b0fd64b7ffbbd1e510. 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>
* Be a bit more conservative with allocating memoryLars Knoll2014-03-271-2/+2
| | | | | | | | | | 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>
* Remove the scribble option from the memory managerLars Knoll2014-03-271-7/+0
| | | | | | | | 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>
* Get rid of collectDeletablesLars Knoll2014-03-271-9/+12
| | | | | | | | | 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>
* Optional reporting of GC statistics to stdoutLars Knoll2014-03-251-13/+45
| | | | | | | | 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>
* Remove unused methodLars Knoll2014-03-251-12/+4
| | | | | Change-Id: Ia7df68e78ac105fe5519cb4f80a64561310d3324 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove code for conservative GCLars Knoll2014-03-251-186/+0
| | | | | | | | | | 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>
* Allow maximum block size to be specified as an environment variable.Michael Brasser2014-03-131-3/+11
| | | | | | | | 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>
* CleanupsLars Knoll2014-01-311-3/+3
| | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-01-241-0/+8
|\ | | | | | | | | | | | | | | | | | | | | 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
| * Make compile on DragonFly BSD.Alex Blasche2014-01-211-0/+8
| | | | | | | | | | | | | | | | | | [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>
* | Split ManagedVTable into two classesLars Knoll2014-01-211-2/+3
| | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-01-171-5/+10
|\| | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/imports/dialogs/DefaultFileDialog.qml src/imports/widgets/qquickqfiledialog.cpp Change-Id: I00de6dd05cb773f01254061d585a82c90b229acd
| * Do not crash if /proc is not mountedAlbert Astals Cid2014-01-151-5/+10
| | | | | | | | | | | | | | | | 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>
* | Clear out memory in the GC, not when constructing objectsLars Knoll2014-01-031-0/+2
|/ | | | | | | | 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>
* Move the vtable pointer from the object to the internal classLars Knoll2013-12-041-5/+5
| | | | | | | | 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>
* Fix MSVC-64-warnings about truncation of integers.Friedemann Kleint2013-11-261-3/+4
| | | | | Change-Id: Ib92ce4b7e42061bb1892957f04cbfc1fcfe43615 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Fix MSVC-64-warning about shift word size.Friedemann Kleint2013-11-261-1/+1
| | | | | | | | 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>