aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4vme_moth.cpp
Commit message (Collapse)AuthorAgeFilesLines
* V4: Store instruction pointer before CmpInUlf Hermann2021-01-271-0/+1
| | | | | | | | The "in" operator may throw an exception. Change-Id: I7d0b6e2212ac6ec237fbf14719349f8e23810028 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* masm: Add error handling for failed mprotect()Ulf Hermann2021-01-121-1/+4
| | | | | | | | | | | | If we cannot mprotect() we have to abort the JIT compilation. Delete RepatchBuffer.h as it is unfixable in that regard. Luckily we don't use it. Task-number: QTBUG-89659 Pick-to: 5.15 Change-Id: Ic5ddbdf51b471db4ddeaa75aab48b24c1f7ced56 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Pass a more comprehensive context to AOT-compiled functionsUlf Hermann2021-01-111-3/+6
| | | | | | | | | | We need the compilation unit, and a way to retrieve JavaScript metatypes from it. Also, prepare for cases where we only have a QJSEngine, not a QQmlEngine, and pass the scope object as part of the AOT context. Change-Id: Ica81e92c99f3c9b6baffd04db1e0e91603fd2ac7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow JavaScript primitive type transformations inline in C++Ulf Hermann2020-12-181-1/+1
| | | | | | | | | | We don't want to call into the engine just for adding two numbers. This implements the most common operators on primitive JavaScript values. More are to follow in the future. Change-Id: Id51a5af59a3af9fec78a2d8f293e59e6567e9204 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Let AOT-compiled functions modify their argumentsUlf Hermann2020-12-021-1/+1
| | | | | | | | It allows for more natural looking generated code and there is no downside. The arguments are specially prepared for the call anyway. Change-Id: I8437e93adb1c67db1b53fbdb29cbea10f6ef278f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Construct arguments for AOT-compiled functions before metaTypeFromJSUlf Hermann2020-12-021-2/+1
| | | | | | | | metaTypeFromJS expects to assign the value using regular operator=. That destructs the old value and therefore the old value has to exist. Change-Id: Ife443b184c30d658f42b65c6717e80685f6635d5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't call alloca(0)Ulf Hermann2020-11-231-13/+28
| | | | | | | | Apparently that's not a good idea. Change-Id: Ic49f6d40135f65e39725acd7a745d17917b64be3 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Allow passing arguments to AOT-compiled functionsUlf Hermann2020-11-201-12/+25
| | | | | Change-Id: I2340f4413ae9a44c71000e840a79e904b6a0fec9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Deal with AOT-compiled functions returning QVariantUlf Hermann2020-11-171-2/+11
| | | | | | | | In this case we need to pass a pointer to the return variant itself, not to its data. Change-Id: I86e468f106f29e1f1be8adee9882d465fd6da533 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Adapt to qtbase changesFabian Kosmale2020-08-231-1/+1
| | | | | | | | | | | The internal QVariant constructor taking a QMetaTypeId has been removed. Thus, construct QMetaTypes where necessary from the id, or avoid a QMetaType -> ID -> QMetaType roundtrip where we already have a metatype. Also fix a few missing includse that were previously transitively included. Change-Id: I56ce92281d616108a4ff80fe5052b919d1282357 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* Add support for binding ahead-of-time compiled bindings to QPropertiesSimon Hausmann2020-04-221-0/+8
| | | | | | | | | | When the ahead-of-time built binding returns the same type as the QProperty, then we can connect them directly with a small shim and pass through the context and scope objects. Change-Id: I9cb49d1fa35490a4ccb06965397674d5534c067d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add more trace points to Qt QMLMilian Wolff2019-12-131-1/+1
| | | | | | | | | | | | This patch aligns the trace points more with the existing coverage from the Qt QML profiler. The following things can now be traced: - file compilation time - binding execution - signal handling Change-Id: I5b7f1a495f0556482ccd5c07474391b291742ef1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Compiler: Support >32k stack slotsUlf Hermann2019-12-051-12/+23
| | | | | | | | | | | | | | | | Previously, the code generator would truncate the stack slots when writing the compiled function, as that one only had a 16bit field for them. Also, add a debug-mode check for stack overflows to the interpreter. Unfortunately, as it triggers a stack overflow, the test will not reliably fail without this change. Fixes: QTBUG-80511 Change-Id: I3019bb2de657ae4c3e1040db798a83533f854bff Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QV4 namespace for ValueTimo Aarnipuro2019-10-171-1/+1
| | | | | | | | | | "Value" is a globally defined type on INTEGRITY platform, which causes the compiler to become confused about ambiguous use. Change-Id: Ic01ce9cf3a8a2c901b3fbe1aa68b419f2778b089 Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Qt Forward Merge Bot2019-09-171-2/+4
|\ | | | | | | | | | | | | | | | | Conflicts: src/qml/jit/qv4baselinejit.cpp src/qml/jsruntime/qv4vme_moth.cpp tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp Change-Id: Iec7cd27ddad0281bd3b7833fb6b252f66a6ae5d6
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-09-121-2/+4
| |\ | | | | | | | | | Change-Id: I6472cd72b27c69257efe54376e428274ebf68050
| | * Fix various accumulator-saving problemsUlf Hermann2019-09-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to keep the accumulator alive across function calls. This requires: 1, Saving the accumulator on the stack if the function might allocate, to protect it from the garbage collector. However, we don't need to do that if the result of the function is to be saved in the accumulator and the function itself doesn't use the accumulator as argument. In this case the previous value becomes unaccessible and we might as well GC it. 2, In the JIT, restoring the accumulator from the stack after the function call if we want to ignore the return value. 3, Therefore, also saving the accumulator on the stack before calling in case of 2. We assume that we don't need to keep the accumulator alive across the jump to the exception handler. Saving the accumulator more often than necessary is detrimental for performance. To make sure the assumption holds, explicitly load the accumulator with undefined _before_ jumping to any exception handler. Change-Id: I78cbc42847b8885a0659b23f3b81655b7f1a0bc4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Use quiet NaNs instead of signalling onesEdward Welbourne2019-09-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I see no good reason why the NaN returned when reading "nan" as a double should be a signalling one; a quiet one should be just fine. [ChangeLog][ES][] The NaN obtained by Math.pow(+/-1, +/-infinity) and (+/-1)**(+/-infinity) is now quiet rather than signalling. Change-Id: I6b5ea469c17c028328c803f54f2a6d4422a80033 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Split compiler and runtime more clearlyUlf Hermann2019-07-111-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | Provide different export macros and different top level headers for each, don't include runtime headers from compiler sources. Change-Id: I7dc3f8c95839a00a871ba045ec65af87123154be Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Port from implicit to explicit atomic operationsMarc Mutz2019-07-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old code used the implicit conversions from QAtomicPointer<T> to T*, and QAtomicInteger<T> to T, and vice versa. The semantics of these differ from the ones std::atomic uses, so we're going to deprecate these, like we did for load() and store(), too. This patch fixes some users of these APIs before we deprecate them. Change-Id: I892d705c22280f1c6fdc62c1777248b44e9c4329 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Port from QLatin1Literal to QLatin1StringGiuseppe D'Angelo2019-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | QLatin1Literal is an undocumented and deprecated typedef for QLatin1String, just use the original. Change-Id: Ib6e2b7ac369be12aed0e455c91cf31b807eae4ed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Split QV4::Value into a static and a dynamic partUlf Hermann2019-05-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | The static part can be used for compilation and won't resolve managed objects. This allows us to remove all the remaining V4_BOOTSTRAP. Change-Id: Id2f6feb64c48beb2a407697881aea8c0d791a532 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Split CompiledData::CompilationUnit in twoUlf Hermann2019-05-161-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | We need a CompilationUnit that only holds the data needed for compilation and another one that is executable by the runtime. Change-Id: I704d859ba028576a18460f5e3a59f210f64535d3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-05-091-0/+6
|\| | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmlirbuilder.cpp Change-Id: I2cfda470515e2df778ad3c89105c07344af07c6d
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-05-081-0/+6
| |\| | | | | | | | | | Change-Id: I3eb5d1affe64b6ae709d1154cc37de91db3816b6
| | * Add Q_TRACE calls to QtQml for QML profiler trace pointsMilian Wolff2019-05-051-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds tracepoints for LTTng/ETW at the positions that are also used by the QML profiler within QtQml. I.e. with the tracepoints here, you'll see which QML function is being executed which is already quite helpful. This will allow us to bridge the gap between C++ and QML when tracing with LTTng/ETW. Additionally, you'll also be able to see kernel tracepoints which bridges another gap. Combined, this approach can give much deeper insights into what the (embedded) system is doing compared to just looking at the QML profiler alone. Change-Id: Ia8f71bf6d44b7f51c3c5aaa38f032675604aeca6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Rafael Roquetto <rafael@roquetto.com>
* | | Make JavaScript execution interruptibleUlf Hermann2019-04-301-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Remove tracing JIT infrastructureUlf Hermann2019-04-291-162/+10
| | | | | | | | | | | | | | | | | | | | | | | | The tracing JIT won't be finished. Therefore, remove the parts that have already been integrated. Change-Id: If72036be904bd7fc17ba9bcba0a317f8ed6cb30d Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com>
* | | Transform V4_ENABLE_JIT into a featureUlf Hermann2019-04-251-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This way you can enable or disable the JIT when configuring Qt. The conditions for the availability of the JIT have also been cleaned up. There is no reason anymore to artificially restrict availability on x86 and x86_64. The reason for the existence of those clauses are old problems on windows that have been fixed by now. However, on arm and arm64, we need a specialization of the cacheFlush() function for each OS to be supported. Therefore, restrict to the systems for which such a specialization exists. iOS and tvOS are technically supported and you can enable the JIT via the feature flag now. Due to Apple's policy we disable it by default, though. Change-Id: I5fe2a2bf6799b2d11b7ae7c7a85962bcbf44f919 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into HEADUlf Hermann2019-03-221-50/+34
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4compileddata_p.h src/qml/jit/qv4baselinejit.cpp src/qml/jit/qv4jithelpers.cpp src/qml/jsruntime/qv4lookup.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4runtimeapi_p.h src/qml/jsruntime/qv4vme_moth.cpp src/qml/qml/qqmltypemodule_p.h Change-Id: If28793e9e08418457a11fc2c5832f03cab2fcc76
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-211-49/+11
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qv4bytecodehandler.cpp src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4compileddata_p.h src/qml/compiler/qv4compiler.cpp src/qml/compiler/qv4instr_moth.cpp src/qml/compiler/qv4instr_moth_p.h src/qml/jit/qv4baselinejit.cpp src/qml/jit/qv4baselinejit_p.h src/qml/jsruntime/qv4function.cpp src/qml/jsruntime/qv4vme_moth.cpp Change-Id: I8fb4d6f19677bcec0a4593b250f2eda5ae85e3d2
| | * Remove dead compile time QML context/scope property and id object codeSimon Hausmann2019-03-201-51/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After enabling lookups in QML files, we can remove all the code that tries to deal with (type) compile time detection of access to id objects and properties of the scope/context object. This also allows removing quite a bit of run-time code paths and even byte code instructions. Task-number: QTBUG-69898 Change-Id: I7b26d7983393594a3ef56466d3e633f1822b76f4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| | * Implement dummy QML lookups for "global" variablesSimon Hausmann2019-03-201-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When resolving names in the context of QML bindings, we now direct runtime access to QQmlContextWrapper::resolveQmlPropertyLookupGetter. At the moment this does basically the same as Runtime::method_loadName, which we called earlier. However this now provides the opportunity to optimize lookups in the QML context in a central place. When performing a call on a scope or context object property, we also did not use a CallName() instruction - which would have gotten the thisObject wrong - but instead we use a dedicated CallScopeObjectProperty and CallContextObjectProperty instruction. These rely on identifying these properties at compile time, which goes away with lookups (and also doesn't work when using ahead-of-time compilation). Therefore the qml context property lookup is using a getPropertyAndBase style signature and Runtime::method_callQmlContextPropertyLookup uses that. For the tests to pass, some error expectations need adjusting. In particular the compile-time detection of write attempts to id objects is now delayed to the run-time. The old code path is still there and will be removed separately in the next commit (as it is massive). Task-number: QTBUG-69898 Change-Id: Iad1ff93d3758c4db984a7c2d003beee21ed2275c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-181-1/+23
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp Change-Id: I66b7db42bf208855889094ace0267326595ce03c
| | * Fix type error exception messages when using member lookupsSimon Hausmann2019-03-151-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | Our tests expect those exceptions to have the same message as when not using lookups. Task-number: QTBUG-69898 Change-Id: Iab36519844a3a49ef9e34346e9afeb2eee9f9ced Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | V4: Add trace slot for UPlusErik Verbruggen2019-03-221-1/+18
| | | | | | | | | | | | | | | Change-Id: I0bb5055024e30c32b82e1555c820ea5ced8923f5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | V4: Add IR that can use traced information to JITErik Verbruggen2019-03-041-6/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the in a series of patches for a JIT that can use traced information to generate better code. In this patch, traced information is not used/stored yet. It allows testing the basic infrastructure without trying to do any optimizations, therefore making it easier to debug, test, and review. Change-Id: I589bdadf731c36542331abe64e1b39e305b6723e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | V4: Clean up the runtime functions declarationsErik Verbruggen2019-02-051-105/+77
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The declarations and usage of runtime functions have seen a number of changes: - we don't use the array of method pointers anymore because we don't use cross-platform AOT JITting - the check if a method can throw a JS exception was invalid, and was not used anymore - value-pointer vs. const-value-ref was inconsistent This patch cleans that up. By fixing the exception checking, we can now use it in the baseline JIT to automatically insert those checks. To make that work correctly, all runtime methods are in a struct, which gets annotated to indicate if that method throws. (The old way of checking which type of engine was used is fragile: some non-throwing methods do not take an engine parameter at all, and those got flagged as throwing). By using a struct, we can also get rid of a bunch of interesting macros. The flags in the struct (as mentioned above) can later be extended to capture more information, e.g. if a method will change the context. Change-Id: I1e0b9ba62a0bf538eb728b4378e2678136e29a64 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* / V4: Collect trace information in the interpreterErik Verbruggen2019-01-251-20/+133
|/ | | | | | | | | | | | | | | Collect type information about values used in a function. These include all parameters, and the results of many bytecode instructions. For array loads/stores, it also tracks if the access is in-bounds of a SimpleArrayData. Collection is only enabled when the qml-tracing feature is turned on while configuring. In subsequent patches this is used to generated optimized JITted code. Change-Id: I63985c334c3fdc55fca7fb4addfe3e535989aac5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix line number reporting in scripts when lookups are enabledSimon Hausmann2018-12-031-0/+1
| | | | | | | | | | For regular object property lookups, we correctly store the byte code instruction pointer that allows us to determine the correct line number in case of a reference error. We need to do the same for lookups in the global object. Change-Id: I0f44dd06b5f66df9626576eeaa802b18fa4a26cd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Create proper template objects for tagged templatesLars Knoll2018-11-051-0/+4
| | | | | | | | If a tagged template gets evaluated multiple times, the underlying template object is shared. Change-Id: Ie2f476fbc93d5991322ce1087c42719a8d8333ae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* INTEGRITY: Fix build failures on 64-bit ARMPasi Petäjäjärvi2018-10-221-1/+1
| | | | | Change-Id: I44a90dec16dc1421a32a7770b353a4df14c057f9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Store the instruction pointer in more instructionsErik Verbruggen2018-10-151-0/+4
| | | | | | | So backtraces will show the correct line number. Change-Id: I6e79f6b3f461956f7f6d98743aff684b894426cf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Conform method_objectLiteral arguments to equal other methodsErik Verbruggen2018-10-121-1/+1
| | | | | | | This runtime function was the only one taking argc before arguments. Change-Id: If0b049697f7fcc2746e8d287193a5b1230a6ea56 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* ES7: Implement Tail Position Calls in the runtimeErik Verbruggen2018-10-051-1/+5
| | | | | Change-Id: If1629109722496b3fd10b36b2376548440f2fee9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* ES7: Detect Tail Position Calls and pass that to the runtimeErik Verbruggen2018-10-041-0/+6
| | | | | | | Doing the tail call in the runtime will come in a follow-up patch Change-Id: I8224aac0edbdc765ee9b97703948edd52fd33f3e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-9/+9
| | | | | | | | | | | | Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for yield*Lars Knoll2018-09-071-3/+16
| | | | | Change-Id: I5b054b59519ed825459a5b0b0a7cd2c6fc8a3797 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Throw a type error when trying to destructure null or undefinedLars Knoll2018-09-071-0/+7
| | | | | Change-Id: Id1bba1a729124bccb8a90dcf40252fe5c69d27a3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix exception handling while destructuringLars Knoll2018-09-071-0/+1
| | | | | | | | | | | | | | | When an exception happens during destructuring, IteratorClose needs to be called, unless the exception happened inside the IteratorNext call (in that case the iterator is assumed to be invalid and we shouldn't call close on it). Implement this, by ensuring that we set the done return variable of IteratorNext to true whenever IteratorNext throws an exception. IteratorClose will check the done state and not do anything in that case. Change-Id: I73a27f855f2c4d3134b8cc8980e64bf797d03886 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>