aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compiler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "QtQml: Remove dependency hashing"Ulf Hermann2025-05-151-2/+1
| | | | | | | | | | | This reverts commit 18c421fe6159dc921643c72ae335cf189eb1cc3a. Removing the dependency hashing is not safe because there are various other bits covered by it, not only the alias target IDs. Task-number: QTBUG-136806 Change-Id: I4a8a57d810203a47945ce67916ee5b54ee7a603d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove dependency hashingUlf Hermann2025-05-131-1/+2
| | | | | | | | | Since we don't store any property indices in the compilation units anymore, we don't need to hash the dependencies anymore. Task-number: QTBUG-135286 Change-Id: I2ea05c920475749f2a2d6cf309d0956a74d6c688 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make UsesArgumentsObject a scoped enumerationLuca Di Sera2025-04-101-1/+1
| | | | | Change-Id: I766dc99b8daaeaa64da9075dcfde5dff507c27f2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Avoid incorrect access to arguments in signal bindings to arrow functionsLuca Di Sera2025-04-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signal handler in QML can be bound to a Javascript expression. For example: ``` onHello: console.log(10) ``` Where "onHello" is a Signal Handler. When this is the case a certain amount of code will be generated for the Signal Handler, performing some setup routines and executing the provided expression, generally in a way that is somewhat equivalent to the same expression being executed as the body of a function call. It is possible to bind a Signal Handler to a anonymous function, say: ``` onHello: function () { ... } ``` Or: ``` onHello: () => { ... } ``` When this is the case, if the usual process was followed, executing the Signal Handler would simply produce an anonymous function, but would never actually call it. Instead, when such a literal function expression is bound to a Signal Handler, it is treated specially. In particular, while the code generation will generally behave similarly, on execution of the Signal Handler, the expression will be directly called while the "wrapping" function that was generated around the expression is ignored. While this works correctly in many cases, it can misbehave on certain occasions. For example, an arrow function doesn't generally set up its own context for a call, instead borrowing from the outer context at the time of creation. When making such a call to an arrow function, in a QML context, it is then possible to execute code in an environment that wasn't properly set up for it. In particular, if the body of the arrow function introduces a `LoadLocal` instruction, which assumes, when interpreted, an available `CallContext`, it is possible to try and access memory that was never correctly set up. It is, for example, possible to do so by usage of `arguments`, a special reference that allows access to a pack of arguments in all non-arrow functions, which will produce a `LoadLocal` instruction when accessed, for example: ``` onHello: () => { console.log(arguments) } ``` Internally, when generating code for a JavaScript program or expression, an analysis is performed to understand whether the special "arguments" reference is being used. When that is the case and the context in which the reference is used is under a context where the reference can exist, a local variable for "arguments" is injected and a "LoadLocal" instruction is later generated to access it. The analysis considers a binding scope as being able to provide the "arguments" reference, something that is generally true due to the "wrapping" that is performed when generating an expression for the binding, and which needs to be guaranteed in certain cases. While this breaks down in the face of directly calling the "inner" function in a Signal Handler binding, such that the analysis might itself not be thorough enough in those cases, at the time the analysis is performed we cannot currently know whether the binding we are dealing with is that of a Signal Handler. Furthermore, we don't always bypass the "wrapping" function in a Signal Handler, as there are other cases where this can create issues, for example the usage of "this" in an arrow function. When this is the case, instead of directly calling the "inner" function, the normal "wrapping" function is called to perform setup routines and obtain the function itself by executing the bound expression, subsequently calling the function obtained in this way. To avoid the issue with the usage of "arguments", we re-use the same methodology, ensuring that when the special "arguments" object is referenced we never bypass the setup provided by the binding expression. This ensures that the arrow function will be created in a context where `arguments` is present and where the necessary setup for the call is performed. The special object will be always be empty in that context, which aligns the behavior to that of non-signal bindings. To do so, an additional case was added to the code in `writeFunction` that sets up a binding expression to later skip to its inner function. A few test cases were added to inspect usages of the "arguments" special reference under binding contexts. Fixes: QTBUG-134215 Change-Id: Ib7fdfee91709358f2ee465b1926809ca4617d6f6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Drop checks for compile hash and Qt version from the CUsUlf Hermann2025-03-181-3/+0
| | | | | | | | | | | | | | | The data structure version is supposed to encode any incompatible changes to our compilation unit format. Checking the compile hash and Qt version in addition is redundant and excessively restrictive. [ChangeLog][QtQml] You can now use QML code compiled with Qt Quick Compiler across Qt versions as long as the compilation unit format hasn't changed between those versions. You cannot rely on the compilation unit format to stay unchanged under any specific circumstances. However, we won't change it unnecessarily. Change-Id: I8c407b505ac7fa952f53fa25bb6d4e7caf0fba0c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add pragma syntax to support translation contextLucie Gérard2023-10-261-0/+4
| | | | | | | | | | | | | Translator pragma can be used to set the translation context instead of having the file name used [ChangeLog][qml][translation][Important Behavior Changes] The context for the translation can now be controled in a given file using pragma Translator. Task-number: QTBUG-114528 Change-Id: I6d9d7fb81ea969a90d8637d7277bdbe96c102088 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Allow creation of structured value typesUlf Hermann2023-07-061-1/+25
| | | | | | | | | | | | | | | | With this change, qmlcachegen can populate structured value types from object literals. Also fix the construction of value types via Q_INVOKABLE ctors. We don't need to wrap the ctor argument in QVariant if we can store the original type, and we should always look at the base type for the creatable flag, not the extension. Task-number: QTBUG-107469 Task-number: QTBUG-112485 Change-Id: I9f3db13f00466dc9d87237bdf0b380d6eeb58a10 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Qml: Disambiguate helper roundUpToMultipleOf from MASMFriedemann Kleint2023-02-101-10/+16
| | | | | | | | | MASM can then be built with CMake Unity (Jumbo) builds, too. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Ic071dfe92732e1b6994b65582d69015e44daaf2a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Fix recognition of builtin list typesUlf Hermann2022-12-151-5/+23
| | | | | | | | | | | | | Previously all list types used as arguments or return types for methods had to be looked up via the imports. However, builtin types are not part of the imports at run time. Therefore, recognize list types already early on, when generating the IR. This is the same way we do it for property types and it allows us to easily identify lists of builtins. Pick-to: 6.5 Fixes: QTBUG-109147 Change-Id: I91fa9c8fc99c1e0155cc5db5faddd928ca7fabbc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Track the statement indices together with line numbersUlf Hermann2022-10-131-7/+13
| | | | | | | | | | We will need the statement indices when tracking value type references. New value type references shall only be written back in the same statement they were created in. Task-number: QTBUG-99766 Change-Id: I83f908df034e7da8ba46ccacaa29bd9d78020d20 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-3/+3
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-14/+14
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Optimize QObject method callsUlf Hermann2022-09-201-9/+23
| | | | | | | | | | | | | | | | | | | | | | So far, for each method call we had to allocate a new QObjectMethod as we didn't have any lookup to cache the methods. Introduce a new lookup for that and use it for all QObject methods. Since QObjectMethod contains a pointer to the concrete QObject the method was retrieved from, some more care has to be taken: If we are going to call the method right away, we don't need the object since we always have a thisObject and any further retrieval of the same method will result in a call again. This enables us to cache the method for any instance of the same class. When storing the method elsewhere, though, we need to hold on to the object since you can defer the call or connect a handler to a signal or similar. For such operations we do need the object. We can still optimize a bit by re-using the method cache we build the first time around. Fixes: QTBUG-95628 Change-Id: I5991180c5e0234cdc179c2b78a43dafc9083e525 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-39/+3
| | | | | | | | | | | | 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>
* QML: Port QV4::CompiledData::Location to new special integer bitfieldUlf Hermann2022-05-111-2/+1
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: If0d6f893f2351a4146ddf125be4079b5e312f308 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Lookup to new special integer bitfieldUlf Hermann2022-05-111-16/+4
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I8cc6db56642f1cd2d16e80ba5c49ffd7c6fdcd8c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::RegExp to new special integer bitfieldUlf Hermann2022-05-111-10/+7
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I37be080387bf086d84761b056140cc5a99d161ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::JSClassMember to new special integer bitfieldUlf Hermann2022-05-111-2/+1
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I0a7d86450011f1664d61db4d78317dafbcfbb8cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Update uses of QCryptographicHash::hash()Mårten Nordheim2022-03-111-1/+1
| | | | | | | | | The overload taking char * and size as parameters is deprecated, updated to use QByteArrayView instead. Change-Id: Ic1959ca387f7d4328d99a1d26545911ff2bd96d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Make a few member functions constUlf Hermann2021-11-151-1/+1
| | | | | | | They don't change anything. Change-Id: Iba7ecdc0658d44db5fd2060d23150e704e9446ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* When binding signals, run the outer function to get the nested oneUlf Hermann2021-08-171-3/+15
| | | | | | | | | | | | | | | The outer function may perform important tasks like setting up a call context with a "this" member for the nested function. In particular, arrow functions retain their original "this" member, no matter where they are executed later. We can detect this condition while generating the compilation unit. If the outer function is not a simple wrapper that only returns the inner function, execute it when binding a signal. Fixes: QTBUG-95659 Pick-to: 6.2 Change-Id: I7dfef2c78378588e6bfc4bedde7889c7f2ce03ef Reviewed-by: Yuya Nishihara <yuya.nishihara@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Fix ubsan errorAllan Sandfeld Jensen2020-09-231-5/+9
| | | | | | | | memcpy can't officially copy from nullptr, not even 0 bytes. Pick-to: 5.15 Change-Id: Ie6ede9a861cb2ae7ab35a50db5aa6c82cea6ad76 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Prettify QV4_SHOW_BYTECODE output for JS classesUlf Hermann2020-05-261-11/+12
| | | | | | | | | | | Drop all the double spaces, force a line break after each class, and avoid converting empty strings to utf8. Coverity-Id: 190711 Pick-to: 5.15 Pick-to: 5.12 Change-Id: I789291e257aeac97c2a931bfc604f453c39906eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make QtQml work with the latest changes in qtbaseLars Knoll2020-01-141-10/+4
| | | | | | | | | | | | Adjust the code to work with the new QString and QVector data structures that have inlined size and data pointers. Fix a large bunch of compiler warnings from QFlags. Update dependencies for qtbase and qtsvg Change-Id: Iba237aed90c140b822e0cf501b9fb7156ec27c2d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Split compiler and runtime more clearlyUlf Hermann2019-07-111-1/+1
| | | | | | | | 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>
* Add support for C++ accessible typed parameters and return types in qml ↵Simon Hausmann2019-07-091-5/+13
| | | | | | | | | | | | functions These can be declared using the new typescript-like syntax and using type names that are also used for signal parameters and property types. This merely affects their signature on the C++ side and allows the corresponding invocation. Change-Id: Icaed4ee0dc7aa71330f99d96e073a2a63d409bbe Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Collect type information for function parametersSimon Hausmann2019-07-091-2/+2
| | | | | | Change-Id: Ia9ba819ce77eee7e582cf90aacf5baa4813d9fca Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move unit checksum generation into qv4compilerUlf Hermann2019-06-241-1/+20
| | | | | | | | | | | | | Only the compiler ever has to do this, and we want the structure definition for the compiled data as a common header. Change-Id: Ie5c6d6c9dcd180dea79f54d0f7d10f3fc50fa20e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the header checking into ExecutableCompilationUnitUlf Hermann2019-06-141-1/+2
| | | | | | | | | We don't need to verify the header unless we want to execute the code. Change-Id: Ieac51c47faafcd7047228b4264aa7750ba3d8889 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Eliminate qmldevtools_buildUlf Hermann2019-05-311-11/+18
| | | | | | | | Move the relevant files into more fitting locations and build the devtools from only parser, compiler and qmldirparser. Change-Id: Ibf37a1187f36d02983f9f43c6622acb243785b7b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split QV4::Value into a static and a dynamic partUlf Hermann2019-05-311-1/+1
| | | | | | | | 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>
* Move qv4string{_p.h|.cpp} out of the devtoolsUlf Hermann2019-05-101-1/+0
| | | | | | | | The only thing we actually need is toArrayIndex() and that is a static method. We provide it in a separate file. Change-Id: I86b11e3d81a319202a0babacd17d87e7816ac88a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove tracing JIT infrastructureUlf Hermann2019-04-291-1/+0
| | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-211-48/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-44/+1
| | | | | | | | | | | | | | | | | | | | | | 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-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | V4: Generate labels for backward jumpsErik Verbruggen2019-01-311-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When analyzing the bytecode from top-to-bottom in a single pass, we don't know when a jump back to previously seen code occurs. For example, in the baseline JIT we would already have generated code for some bytecode when we see a jump back (like at the end of a loop body), and we can't go back and insert a label to jump to. As JavaScript has no goto's, the only backward jumps are at the end of loops, so there are very few cases where we need to actually generate labels. This was previously handled by analyzing the bytecode twice: once to collect all jump targets, and then second pass over the bytecode to do the actual JITting (which would use the jump targets to insert labels). We can now do that with one single pass. So the trade-off is to store 4 bytes more per function plus 4 bytes for each loop, instead of having to analyze all functions only to find where all jumps are each time that function is JITted. Change-Id: I3abfcb69f65851a397dbd4a9762ea5e9e57495f6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | V4: Collect trace information in the interpreterErik Verbruggen2019-01-251-1/+1
|/ | | | | | | | | | | | | | | 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>
* Create proper template objects for tagged templatesLars Knoll2018-11-051-3/+50
| | | | | | | | 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>
* Fix error reporting when imports or re-exports in modules failSimon Hausmann2018-10-111-0/+2
| | | | | | | | Collect the location of the import/export statement and include it in the exception thrown. Change-Id: I7966dfd53ed67d2d7087acde2dd8ff67c64cb044 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* properly align string table in compiled dataRolf Eike Beer2018-09-141-1/+3
| | | | | Change-Id: Ie6534d5443ad046211620c4e0b586d189d0adbef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use WTF::roundUpToMultipleOf() instead of open coding itRolf Eike Beer2018-09-131-10/+7
| | | | | | Change-Id: I3d6bbfcf02748e03c653763175c1904b4c2c8604 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* make pointer operations more explicit when building string tableRolf Eike Beer2018-09-101-3/+4
| | | | | Change-Id: Iff8a45cecc63751f0daae5844f89cf452619d58d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* avoid duplicate offset calculations when building string tableRolf Eike Beer2018-09-071-3/+3
| | | | | Change-Id: I5bfc46b9d9cdc3bde35f60de75cb8e9e51b0b0ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement the dead temporal zoneSimon Hausmann2018-08-281-0/+5
| | | | | | | | | | | | | | With const and let it is possible to access the declared member before initialization. This is expected to throw a type reference error at run-time. We initialize such variables with the empty value when entering their scope and check upon access for that. For locals we place the lexically scoped variables at the end. For register allocated lexical variables we group them into one batch and remember the index/size. Change-Id: Icb493ee0de0525bb682e1bc58981a4dfd33f750e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup RegExpObjectLars Knoll2018-08-151-0/+2
| | | | | | | | | | | Move properties from RegExpObject to getters in RegExp.prototype to be compliant with the JS spec. Implement support for the sticky flags ('y') and correctly parse the flags in the RegExp constructor. Change-Id: I5cf05d14e8139cf30d46235b8d466fb96084fcb7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix module dependency handlingSimon Hausmann2018-08-141-0/+17
| | | | | | | | | | | | | | | | | | | | | The evaluation of a module can have side-effects by modifying the global object or objects in it. Therefore even a seemingly empty import such as import "./foo.js" needs to be listed in the module requests. It's also important that they are evaluated in the order of declaration. Therefore we collect all module requests separately - even those that don't have import variables to process. This patch also ensures that the export and import declarations are visited in the correct order, by unifying both AST nodes to be hooked into the statement list. The fact that we connect the module list items into a statement list is solely an artifact of re-using defineFunction() which takes a StatementList as body. Change-Id: I75dc357b2aecfc324d9a9fe66952eff1ec1dfd8a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Enable unicode regular expressionsLars Knoll2018-08-101-0/+2
| | | | | | | Add support for the 'u' flag for regular expressions. Change-Id: I409054eaa9c50183619752d14f2638f5a38c0ea7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add initial basic support for ES6 modulesSimon Hausmann2018-08-091-1/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The entry point from the parsing perspective into modules is not QV4::Script but QV4::ExecutionEngine::compileModule. For convenience, the ESModule AST node gets a body, which is the statement list connected between the ModuleItemList items that are not import/export declarations. The QV4::Module allocates a call context where the exported variables are stored as named locals. This will also become the module namespace object. The imports in turn is an array of value pointers that point into the locals array of the context of the imported modules. The default module loading in ExecutionEngine assumes the accessibility of module urls via QFile (so local file system or resource). This is what qmljs also uses and QJSEngine as well via public API in the future. The test runner compiles the modules manually and injects them, because they need to be compiled together with the test harness code. The QML type loader will the mechanism for injection in the future for module imports from .qml files. Change-Id: I93be9cfe54c651fdbd08c5e1d22d58f47284e54f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Reduce memory consumption when loading AOT generated cache filesSimon Hausmann2018-08-011-4/+1
| | | | | | | | | | | | | | | | | Separate the qml data (objects/imports) from the general compilation unit data. It's only the former that needs to be re-generated as part of the type re-compilation and by separating it we can allocate memory just for that and keep using the mmap'ed general unit data for everything else (including byte code). Another upside of this change is that it allows eliminating the recently introduced concept of a backing unit again. Saves ~149K RAM with the QQC1 gallery. Task-number: QTBUG-69588 Change-Id: Ie88a4286feb7e2f472f58a28fa5dd6ff0a91c4b6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>