aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4enginebase_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Long live incremental garbage collection in QML!Fabian Kosmale2023-12-201-1/+2
| | | | | | | | | | | | | | | | | The design of the garbage collector is described in src/qml/memory/design.md. The gc and gcdone test helpers are adjusted to drive the gc to completion, even when in incremental mode. Parts of tst_qv4mm and tst_qqmlqt need to run with the incremental gc disabled, as they call gc inside QML and assumes that the GC finishes before returning. Initial-patch-by: Rafal Chomentowski <rafal.chomentowski@ge.com> Task-number: QTBUG-119274 Change-Id: I1d94f41bc7a434fad67de0fd46454b6db285f2eb Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Add an accurate stack bounds checkerUlf Hermann2022-12-091-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This re-introduces a stack bounds checker. The previous stack bounds checker was removed in commit 74f75a3a120b07bbfe6904512b338db8850874e4 because the cost of determining the stack base was deemed too high. Indeed, determining the stack base on linux using the pthread functions costs about 200.000 instructions and the cost grows with the number of concurrently running threads. However, by reading /proc/self/maps directly we can trim this to about 125k instructions. Furthermore, with the new implementation we only need to do this once per engine. Calling JavaScript functions of the same engine from different threads is not supported. So we don't have to consider the case of checking the bounds of a different thread than the one the engine was created in. Furthermore, we get a more accurate number now, which means we don't have to re-check when we get near the boundary. Also, change QV4::markChildQObjectsRecursively() to use an actual QQueue instead of being recursive. This avoids the stack from overflowing when the stack is already almost full, and was leading to crashes in the stackOverflow tests. Make the stack smaller for the the tst_qquickloader::stackOverflow{,2} tests to run faster in the CI (and avoid the timeout). Task-number: QTBUG-106875 Fixes: QTBUG-108182 Change-Id: Ia5d13caa7d072526ff2a3e1713ec7781afc154a9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Do not update proto usage before engine is fully initializedUlf Hermann2022-08-301-1/+2
| | | | | | | | | Updating the prototype usage is very expensive. We only need to do it once there are lookups. Before the engine is fully initialized there are no lookups. Change-Id: Ic919a1f8955718d417e7747ea72e009d443c42fd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie GĂ©rard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QV4::EngineBase: Remove pragma packFabian Kosmale2021-04-131-7/+0
| | | | | | | | | | | This was only used on a subset of our compilers, and caused issues with pointer alignment. We have static_assert's in place to verify that the struct members are in the correct place, and pack had no effect anyway after we added the alignment padding to the struct. Change-Id: I162664ec01d4b5d97ac800afc354d0ab2e04de42 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QV4EngineBase: Do not create zero-sized array on 32 bit platformsFabian Kosmale2021-04-121-1/+3
| | | | | | | | | | | Zero-sized arrays are a non-standard extension, and do not work on MSVC. We can instead conditionally add an explicit padding member on platforms where POINTER_SIZE == 8. Fixes: QTBUG-92562 Pick-to: 6.1 6.1.0 Change-Id: I8462eb05e16c42045c0c95f026321c6e20e5c6bb Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Fix EngineBase::globalObject being misalignedMaximilian Goldstein2021-01-061-1/+3
| | | | | | Fixes: QTBUG-85602 Change-Id: I7cdd83c16bec76c8f902c9136fa89decfc1cbd3d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4Engine: Remove runtime memberFabian Kosmale2019-12-091-2/+0
| | | | | | | | Runtime is nowadays only a collection of static methods, there is no point in having it as a member anymore. Change-Id: Ibe9fba3c7e52fbc0b16b6a5d717dd2d23ab21088 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove now dead V4_BOOTSTRAP #if-eryUlf Hermann2019-05-131-3/+0
| | | | | | | Change-Id: I04f8f69ed8ee415ca330e2f7beeffc4ee4c38e65 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't include qv4enginebase_p.h in qmldevtoolsUlf Hermann2019-05-101-3/+0
| | | | | | | | We don't need it and we don't need to check for V4_BOOTSTRAP in there. Shuffle some includes around to provide everything we do need. Change-Id: I3e75f1c6f9dc518006aabc9dcee21e5153899ac5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make JavaScript execution interruptibleUlf Hermann2019-04-301-1/+19
| | | | | | | | | | | Add an atomic isInterrupted flag to BaseEngine and check that in addition to the hasException flag on checkException(). Add some more exception checks to cover all possible infinite loops. Also, remove the writeBarrierActive member from QV4::EngineBase. It isn't used. Fixes: QTBUG-49080 Change-Id: I86b3114e3e61aff3e5eb9b020749a908ed801c2b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Better inheritance structure for functionsLars Knoll2018-09-231-0/+1
| | | | | | | | Give Arrow functions their own representation. This also prepares for further optimizations especially for the instanceof operator. Change-Id: I1f70c0271169a237e1acdeb7fe855be957ba2ea5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for call/callAsConstructor in Proxy objectsLars Knoll2018-08-231-0/+1
| | | | | | | | | | | This adds the last missing piece of functionality for Proxy objects. Also fix a bug where we ignored the newTarget in Reflect.construct. Change-Id: I2443470f2ca13fb6223768c3bf6bdc3766bb4fc3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Update Yarr to the latest version from WebKitLars Knoll2018-08-101-4/+3
| | | | | | | | | | | Updated Yarr to a to commit 4d2a53d60487cb1f8b2a9a1e9f684af336fd7d2c in WebKit. Adjusted the yarr code base to work with our older version of wtf and masm. Change-Id: I04b4593ece051e1d7aa087b87aa08c92595d1098 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix class members that are generatorsLars Knoll2018-07-031-0/+1
| | | | | | | Properly support member functions that are generators in classes. Change-Id: I5fc8d5b58a17c61a446b43d6576bb83de5ecd920 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add a MemberFunction function objectLars Knoll2018-06-261-0/+1
| | | | | | | | | | | Member functions in ES7 can not be called as constructors and will throw a type error when trying. Some more fixes are needed here, as they also do not have a prototype property. Change-Id: Ieb920163acaa68d4ff0ff73ae4c1015e883b406f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add basic support for EcmaScript classesYulong Bai2018-06-261-0/+1
| | | | | | | | | | | | | | | | Most of the class creation is done inside the runtime in the CreateClass method. Added a corresponding instruction to the interpreter and jit. The compiled data now contains an array of classes containing the compile time generated layout of the class. Currently, classes without an explicit constructor and classes with inheritance are not supported. Done-with: Yulong Bai <yulong.bai@qt.io> Change-Id: I0185dcc1e3b0b8f44deff74e44a8262fc646aa9e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Partial Proxy supportLars Knoll2018-06-251-0/+1
| | | | | | | | get, set and deleteProperty proxying is implemented, the others require some more changes in our engine. Change-Id: I4dd4b154b1a582f5e36cdc9429fa049fd37d5167 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Generator supportLars Knoll2018-05-031-0/+2
| | | | | | | | | | | | | Add support for ES6 generators. Those are currently always executed in the interpreter (we never JIT them), to simplify the initial implementation. Most functionality, except for 'yield *' expressions are supported. 'yield *' will have to wait until we support for(... of ...) Change-Id: I7c059d1e3b301cbcb79e3746b4bec346738fd426 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add SymbolObject, well known symbols and fix most remaining issuesLars Knoll2018-05-021-0/+1
| | | | | | | | | Added SymbolObject, the equivalent to StringObject which was still missing so far. Added the predefined standard symbols, and fixed most test failures related to symbols. Change-Id: I1e28b439e7c4f5141b4a09bd8fb666c60691f192 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement Symbol.for and Symbol.keyForLars Knoll2018-05-021-1/+0
| | | | | Change-Id: I5fde731b3a1a6d7c15154881ed82549b2800d104 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Partial Symbol supportLars Knoll2018-05-021-0/+2
| | | | | | | | | Added basic infrastructure to create symbols and convert them back to strings. In addition, storing and retrieving of symbol based properties in Objects works. Change-Id: I185f7aa46e7afa19db5a801102142892e03b7bf1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rework catch context handlingLars Knoll2018-05-021-1/+0
| | | | | | | | | | | | Remove the need for a specialized catch context, instead use a regular block context, that also captures the catched variable. This also removes the need to do lookups by name inside a catch expression. Change-Id: I8b037add7f423922e2a76b4c0da646ca7e25813a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* garbage collect InternalClassLars Knoll2018-04-121-2/+2
| | | | | | | | | | | | | | | | Internal classes are now allocated and collected through the GC. As they are important to the deletion of other objects (because of the vtable pointer living inside the internal class), they need to get destroyed after regular objects have been sweeped. Achieve this by using a separate block allocator for internal class objects. Our lookups do often contain pointers to internal classes, so those need to be marked as well, so we don't accidentally collect them. Change-Id: I4762b054361c70c31f79f920f669ea0e8551601f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Better encapsulation for EngineBase::internalClassLars Knoll2018-04-121-2/+3
| | | | | | | | Turn it into a method instead of accessing the array directly to simplify refactoring. Change-Id: I197b56c8f58cfdfd294f429e6b15268c755f9837 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Optimize MM::allocManaged()Lars Knoll2018-04-121-1/+2
| | | | | | | | We can manage without calls to changeVTable() here, as the set of classes allocated with this is rather limited. Change-Id: I804e4850b91c61ebbca8a04edbe51deac911928d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.10' into devLiang Qi2018-02-021-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp src/qml/compiler/qqmlirbuilder.cpp src/qml/compiler/qqmlirbuilder_p.h src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4codegen_p.h src/qml/compiler/qv4compileddata_p.h src/qml/compiler/qv4compiler.cpp src/qml/compiler/qv4compilercontext_p.h src/qml/compiler/qv4isel_moth.cpp src/qml/compiler/qv4jsir.cpp src/qml/compiler/qv4jsir_p.h src/qml/jit/qv4isel_masm.cpp src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4functionobject.cpp src/qml/jsruntime/qv4runtimecodegen.cpp src/qml/jsruntime/qv4script.cpp src/qml/jsruntime/qv4script_p.h src/qml/qml/qqmltypeloader.cpp src/quick/items/qquickanimatedimage.cpp src/quick/items/qquickanimatedimage_p_p.h src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp tests/auto/qml/qmlplugindump/qmlplugindump.pro tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp tools/qmlcachegen/qmlcachegen.cpp tools/qmljs/qmljs.cpp Done-with: Shawn Rutledge <shawn.rutledge@qt.io> Done-with: Lars Knoll <lars.knoll@qt.io> Done-with: Ulf Hermann <ulf.hermann@qt.io> Change-Id: I010e6525440a85f3b9a10bb9083f8e4352751b1d
| * Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2018-01-241-0/+2
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4compileddata_p.h src/qml/debugger/qqmlprofiler_p.h src/qml/jsruntime/qv4engine.cpp src/qml/memory/qv4mm.cpp src/qml/qml/qqmlcomponent.cpp src/qml/qml/qqmlobjectcreator.cpp src/qml/qml/qqmlobjectcreator_p.h src/qml/types/qqmldelegatemodel.cpp src/quick/items/qquickitem_p.h src/quick/items/qquickwindow.cpp tests/auto/quick/touchmouse/BLACKLIST tests/benchmarks/qml/holistic/tst_holistic.cpp Change-Id: I520f349ab4b048dd337d9647113564fc257865c2
| | * Speed up V4 QML context creationSimon Hausmann2018-01-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After commit cae7975a036352ca4bbcf1381a445362f8e01367 the vtable became part of the internal class, which meant that for allocating the V4::QmlContext and the QV4::QmlContextWrapper we had one additional IC transition upon allocation. We can avoid that by providing a default IC for both types. Task-number: QTBUG-65708 Change-Id: I22815a24a8389b59103309806f6ac4ca382405f0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Get rid of BuiltinFunctionLars Knoll2018-01-151-1/+0
| | | | | | | | | | | | | | | | | | | | | It's now unused. Change-Id: Id2941c212d488c9b0933fa06aac9922b9db13a05 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Move a couple of data members required for new JITLars Knoll2017-11-071-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Mark CompilationUnit final and get rid of it's vtable. Fix initializations with 0 instead of nullptr. Change-Id: Ieec260bd45d8f08cf5d8964becd312b221cbb2a9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Cleanup naming of Stack frame structuresLars Knoll2017-08-101-26/+3
| | | | | | | | | | | | | | | Change-Id: I0b392040b6726e6d93f237ccccc9f053256ed819 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Split StoreName into StoreNameStrict and StoreNameSloppyLars Knoll2017-08-101-0/+5
| | | | | | | | | | | | | | | | | | | | | And adjust the name of the corresponding runtime functions. Change-Id: I4adf7b0e069d9b0dff9162cd1271dafc60be854b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Refactor context handlingLars Knoll2017-08-101-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the push/pop context instructions to not modify the JS stack anymore, as that can cause conflicts with the VME (and was an ugly hack in any case). Instead, these instructions not return the old context, that is then stored in a temporary. Get rid of Engine::current and Engine::currentContext. The StackFrame structures do now contain the only and authoritive data. This finally gives us a nice setup where we create and destroy frames on the stack when entering/leaving functions. Change-Id: If161e3e941f59865c47ecfe1e094faf62b52bfa0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Avoid creating a CallContext for simple functionsLars Knoll2017-08-101-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | This cuts out quite a bit of overhead when entering and leaving functions. Change-Id: I32670c98a4087ea3b2d45853d9cabff9066399e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Introduce a JS stack frame that corresponds to the C++ stack frameLars Knoll2017-08-101-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | The frame currently contains the function itself and the current context. Change-Id: I7d3402627fbc90e860a7bdc277585f365f5b4cb5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix frame handlingLars Knoll2017-08-041-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | Fix some regressions introduced by change 1ae1eaf59e0475a2dc9c5e22e53e9be19d0f2feb. Change-Id: I24c1db78634e3beb1ab090325b60e70f788f92a7 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Don't store the current line number in the ExecutionContextLars Knoll2017-08-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Instead modify our StackFrame struct to hold the QV4::Function and have a linked list of those for the frames. Change-Id: I8676e16bc51a5ba6cf25a5b3423576d44e8a926a Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Unify SimpleCallContext and CallContextLars Knoll2017-07-051-1/+1
|/ / | | | | | | | | | | | | Plan is to completely remove the need for the simple call context. Change-Id: Ie5e4673a6746dc110adbf526e45188f218fd7bfc Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* / Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-061-2/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qml/jsruntime/qv4argumentsobject.cpp src/qml/jsruntime/qv4arraydata.cpp src/qml/jsruntime/qv4context.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4errorobject.cpp src/qml/jsruntime/qv4functionobject.cpp src/qml/jsruntime/qv4internalclass.cpp src/qml/jsruntime/qv4lookup.cpp src/qml/jsruntime/qv4managed.cpp src/qml/jsruntime/qv4managed_p.h src/qml/jsruntime/qv4object.cpp src/qml/jsruntime/qv4object_p.h src/qml/jsruntime/qv4qmlcontext.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/memory/qv4heap_p.h src/qml/memory/qv4mm.cpp src/qml/memory/qv4mm_p.h src/qml/memory/qv4mmdefs_p.h src/quick/scenegraph/util/qsgdistancefieldutil.cpp src/quick/scenegraph/util/qsgdistancefieldutil_p.h tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp Change-Id: I7ed925d4f5d308f872a58ddf51fdce0c8494ec9c
* Move the prototype into the internal classLars Knoll2017-05-191-0/+2
| | | | | | | | | | This saves another pointer on all Objects. Currently introduces a slight performance regression on some of the v8 benchmarks, that needs addressing. Change-Id: I87de8e1d198d2683f4e903c467ce2a60ba542243 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the internalClass field from Heap::Object to Heap::BaseLars Knoll2017-05-191-1/+3
| | | | | | | | | | | | And do not store the vtable in Heap::Base anymore. This change makes the internal class the main distinguishing feature of all garbage collected objects. It also saves one pointer on all Objects. No measurable impact on runtime performance. Change-Id: I040a28b7581b993f1886b5219e279173dfa567e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add ICs for String, MemberData and ArrayDataLars Knoll2017-05-191-0/+4
| | | | | Change-Id: I43ddcb4842e501cbea8a950ab6ffa2d906014efd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the list of default internal classes into EngineBaseLars Knoll2017-05-191-0/+19
| | | | | | | | And store them in an enumerated array. This will simplify upcoming changes. Change-Id: I82eac03b9f6264843ae625e36e150464fe08be9d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the EngineBase class into it's own header fileLars Knoll2017-05-191-0/+99
Change-Id: Idf87618e4ebff99f3b3c269c950191d67a0182b2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>