Commit Graph

158 Commits

Author SHA1 Message Date
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
Lars Knoll 6b7c3ea49c Remove most calls to Value::managed()
Change-Id: Id5b1cca542421d749711eff68520a4138ec95531
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-11-04 20:16:37 +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
Ulf Hermann beb6667d4e Comment parameters to PageAllocation::allocate()
Change-Id: I8966fbc5f89ce470a0a16fe29086fa6e13ef408e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-10-30 13:19:51 +01:00
Ulf Hermann 2ffb01b45d Add guard pages around JavaScript stack
Like this we avoid writing to random memory if the stack overflows.

Change-Id: I0e0962daae69904a9ce21b047f3d8c0811c1d09f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-10-30 13:19:37 +01:00
Lars Knoll a3a44fc164 Basic support for typed arrays
This implements most of the spec required for the
Khronos typed array specification.

It tries to follow ECMAScript 6 as closely as possible,
but currently only implements a subset of the ECMAScript
6 specification.

Addes a test script in tests/manual/v4 to test our
implementation.

Change-Id: I8ec63869500358e088b73240e1f37120ae3cf59a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-10-29 09:07:36 +01:00
Lars Knoll 868478e92a Implement DataView
The second class that is required for typed
array support.

Change-Id: Idc2dcec7c1eee541f76dc5ab1aea6057ba03cb93
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-10-29 09:07:12 +01:00
Lars Knoll a2c97406ca Implement ArrayBuffer
This is the first class required to support typed
arrays in our JS engine.

Change-Id: I0fe1e1ca430769c171912dda207cfae772e9b9db
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-10-29 09:06:56 +01:00
Simon Hausmann db44ad2be9 Fix stack size check on systems with less than 256kb stack
We require at least 256 kbytes slack stack space, and if a system is
configured with less (or equal), then the stack size checks fail early on
and strange error message occur during engine startup and execution.

This patch calls the stack check code early on and bails out with an error
message that's more descriptive.

Change-Id: I3263f2f93f62332d08003411e1bb5b3b1140d02b
Task-number: QTBUG-41213
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-09-12 16:06:12 +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 75d8ebb3e6 Merge remote-tracking branch 'origin/5.3' into dev
Conflicts:
	src/qml/compiler/qv4ssa.cpp
	src/qml/jsruntime/qv4arrayobject.cpp
	src/qml/jsruntime/qv4engine.cpp

Change-Id: Ie3ef6202b6a3a8521971e1be10c40c6a2db6989c
2014-07-26 13:21:16 +02:00
Lars Knoll ba8416b80f Do not use mark() when marking ExecutionContexts
Some execution contexts in the parent chain can be allocated
on the C stack instead of the GC heap. Calling mark() on those would
push them onto the GC stack (which is identical to the JS stack).
In rare cases the reference can survive to live into the next call to
gc(), causing invalid accesses to already deleted contexts.

Change-Id: I709f58de27be9386cf70707c84e4c86c7c303fa7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-25 16:27:13 +02:00
Simon Hausmann b3fab495f5 Cleanup: Get rid of __data members
These are not needed anymore

Change-Id: Ib834aa294e84ca9fbdd5b6850d5bc172e8b54ba1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-07-22 13:49:21 +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 00a46fa07b Convert Execution contexts to new constructor syntax
Change-Id: I4bc6a61b7a96139353e20871ff7ff007822c64c3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:19 +02:00
Lars Knoll 2eb5416f54 Convert the last Managed types to the new constructor syntax
Change-Id: I11701c586d4715c08feba4650e12904c3fa7ca27
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:19 +02:00
Lars Knoll 903e04dead Convert String to new constructor syntax
Change-Id: I07f7667d3d72a7d72e6717d194de8d7b15435777
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:19 +02:00
Lars Knoll 133ea9d0f1 Convert more objects to the new constructor scheme
Change-Id: I31b2a1ba4a93f0d4bde68eeb94f13e7224c0cd7b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:18 +02:00
Lars Knoll 0fd24cf96e Convert most simple objects to the new constructor scheme
Change-Id: I90042037bc0555771bd98233977c7d2b735bb718
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:18 +02:00
Lars Knoll dba56a752c Convert remaining FunctionObject's to new constructor scheme
Change-Id: I440d5b128d0ee28566ebfa82c2505a4bd97bba6b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:18 +02:00
Lars Knoll 00fa904911 Convert FunctionObject derived classes to new construction scheme
Change-Id: I0d43a79ed531a9d651bd00866d73113c05d95a09
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:17 +02:00
Lars Knoll 45f7120d42 Convert regexps
Change-Id: I5b62a265a7ce363a16b1e14ae93cadbb1ab0cb5b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:17 +02:00
Lars Knoll 57f08e59fc Get rid of all uses of ObjectRef
Change-Id: I705e2362dcda542f56826dadec6b0a6f15848788
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:13 +02:00
Lars Knoll 2c7c791e3f Remove the less often used Ref classes
Change-Id: I9ee531c903317a0f324671d98af1f967b684915c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:12 +02:00
Lars Knoll 33593f00e8 Get rid of StringRef
Remove the Ref classes, as they won't be required
anymore once Managed and Managed::Data are separated.

Change-Id: Ic6bec2d5b4ecf2595ce129dbb45bbf6a385138a5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:12 +02:00
Lars Knoll d33b68e2df Convert specialized ExecutionContext's to new data layout
Change-Id: Ie3aad65e4a10aaa259ae9513f0fcff79dc7e6a39
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:11 +02:00
Lars Knoll 9744e8bd42 Convert ExecutionContext to new storage scheme
Change-Id: I9fcc13da5360f37cef3149b114ed9263b9b74281
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:11 +02:00
Lars Knoll 42b137bd1e Convert ErrorObject to new storage scheme
Change-Id: I356a9947b87a5cda4eda738d3b6d5d51ee9a98f2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:49:03 +02:00
Lars Knoll 1019b1cabf Move data of FunctionObject into an inner struct
Change-Id: Ic00b1761565f9f8881b665a3fecca723239e2279
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:48:55 +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
Lars Knoll c2ef5bff23 Use Members for storing the bound arguments in BoundFunction
Cleans up the code, and allows us to remove the destructor
for bound function objects.

Change-Id: Id32ac69171f7975ec7679d07d25c0eb6b4ca6fb5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-07-22 13:48:53 +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
Simon Hausmann 52fcb218c3 Fix marking of prototype objects in internal class pool
As per reported bug, we have to protect ourselves against potential loops
and can mark the internal classes much simpler by just walking through
the memory pool they were allocated in.

Task-number: QTBUG-38299
Change-Id: I3ae96e8082e76d06f4321c5aa6d2e9645d2830a0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2014-04-28 12:49:53 +02:00
Lars Knoll 8e556778c8 Garbage collect member data
Move the allocated member data into the garbage collected
area, so that we can avoid using malloc/free for it.

Change-Id: I20625efa67ecd60238568742b74854b0c8cb2e3e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-04-04 17:26:20 +02:00
Lars Knoll c0fe2ec596 Optimize construct calls
Optimize construction of the internalClass for the object
being constructed.

Change-Id: Id5fc02c291664ec01c3595ae0acbb6895cc5b147
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-27 20:39:59 +01:00
Lars Knoll 4606bd6683 Optimize construction of SimpleArrayData
Change-Id: I7f8a0ac8a368af23534378e8c31d820b3b9f1f4c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-19 08:14:46 +01:00
Lars Knoll c3fbec3ab9 Small optimization to RegExp
Also add markObjects() calls to all the identifiers we keep
around in the engine. It's probably pure luck this hasn't caused
any issues until now.

Change-Id: Ie31d19793efa53867e4e240ba548070dcde32ec1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-03-18 09:05:57 +01:00