aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compileddata.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Inline the rest of qv4compileddata.cppUlf Hermann2019-06-261-157/+0
| | | | | | | | | This way we get a header-only representation usable for the QmlCommon module. Change-Id: Ia75e445ffbee0c3b2d473a2a3a6309b2f12e8eea Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Inline CompiledData::unlink() into the only callerUlf Hermann2019-06-241-10/+0
| | | | | | | | | | | | | The compiler never links anything and therefore it doesn't need to unlink, either. Change-Id: I9ccdc012f9333abc5f4b60174b794e490772e1fd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move unit checksum generation into qv4compilerUlf Hermann2019-06-241-19/+0
| | | | | | | | | | | | | 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 saveToDisk into SaveableUnitPointerUlf Hermann2019-06-241-33/+0
| | | | | | | | | This way we can keep the flag mutilation closely local to the place where we write the data. Also, SaveableUnitPointer doesn't need a full CompilationUnit this way. Change-Id: I01872e4c406cb2ccbaa1fa35325cc063b1e8a7df Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the header checking into ExecutableCompilationUnitUlf Hermann2019-06-141-57/+0
| | | | | | | | | 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>
* Move AST -> CompiledData location transformation to scan functionsUlf Hermann2019-06-131-7/+0
| | | | | | | | | | That's the only place where we use it and this way we can remove the AST dependency from the compiled data. Change-Id: I530a0f18a08672acd7031a552885b819e6fe2b84 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split QV4::Value into a static and a dynamic partUlf Hermann2019-05-311-4/+4
| | | | | | | | 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>
* Remove V4_BOOTSTRAP condition around header verificationUlf Hermann2019-05-091-6/+0
| | | | | | | | | | | It's unclear why that was needed. Change-Id: I0b4d4ebe1992cd2252cfc3eb10baa7f1b3ae1a5a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add abstraction for temporarily setting StaticData when savingUlf Hermann2019-05-171-16/+3
| | | | | | | | | The StaticData flag needs to be saved to disk, but removed again afterwards so that we can free() the malloc'd data. This also allows us to avoid copying all the data into a byte array before saving. Change-Id: I96513f8d98acf0ea0b4514d96376b487e8444917 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split CompiledData::CompilationUnit in twoUlf Hermann2019-05-161-733/+9
| | | | | | | | 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>
* Generate the compilation unit checksum whenever we have MD5Ulf Hermann2019-05-091-1/+1
| | | | | | | | This is actually not dependent on V4_BOOTSTRAP. There are various conditions that might influence QCryptographicHash. Change-Id: Iad0384a2cf8360e6db8ef398bd45f63161c0b70f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Drop some dead bootstrap codeUlf Hermann2019-05-081-7/+4
| | | | | | | | | | The dependencies are only hashed if a dependencyHasher is given. This is generally not the case when compiling ahead of time. There is also no need to hide the declaration of DependentTypesHasher from the bootstrap code. Change-Id: I0ea74c3079656ce1fe353956999820916c8ff626 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-04-181-2/+6
|\ | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlimport.cpp Change-Id: I6add6267297ea50a646d43d212027a168dca8916
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-04-171-0/+2
| |\ | | | | | | | | | | | | | | | | | | Conflicts: tests/auto/qml/qv4assembler/tst_qv4assembler.cpp Change-Id: I9d31c982881a617099354bf8acceb76332f11496
| | * QML: Check for (valid) compilation units while hashingErik Verbruggen2019-04-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | When an error occurred while creating a compilation unit, the pointer might be set to null. Subsequent use in hashing should check for this, and not use a nullptr. Change-Id: I62650917a740c9c1be29608285670153bed8703c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * | Merge remote-tracking branch 'origin/5.12' into 5.13v5.13.0-beta3Qt Forward Merge Bot2019-04-151-2/+4
| |\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/3rdparty/masm/assembler/LinkBuffer.h src/qmltest/doc/src/qtquicktest-index.qdoc tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp Change-Id: I7d83ad95cf489dda794dd7a0a33bad3ef3b05609
| | * Only create the imports array if importCount is greater than 0Andy Shaw2019-04-141-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since it is possible that CompilationUnit::instantiate() might be called more than once when the importCount is 0 then it should only create the imports array when it is greater than 0. This prevents a memory leak due to the recreation of this array each time it is called even though there is no imports to assign. Change-Id: I5d84b01de10bff2ca25248251e8337839e434bd5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-03-261-1/+9
|\| | | | | | | | | | | Change-Id: Iaaf9749a812c21c065ded0374ce0aa07de7752cf
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-251-1/+9
| |\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qmltest/quicktest.cpp tests/auto/qml/qmlcachegen/qmlcachegen.pro Change-Id: I70e96e8817d59647f876b8b77b30cdeede8f0662
| | * Fix memory "leaks" in qmlcachegenSimon Hausmann2019-03-221-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CompilationUnit class owns the unit data. An exception was made in bootstrap builds, where it was up to the caller to free the memory. This lead to cases in qmlcachegen where we didn't free the memory. This is best fixed by unifying the behavior. This fixes the build when using an ASAN enabled build, as the runtime aborts after calling qmlcachegen due to "leaks". Change-Id: I8b55b4e302a9569a1d4e09eeb488c479368b50f0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into HEADUlf Hermann2019-03-221-0/+22
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+22
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| | * Accelerate access to scope object properties in lookupsMichael Brasser2019-03-201-0/+5
| | | | | | | | | | | | | | | | | | Task-number: QTBUG-69898 Change-Id: I94bf1aa85c9b2302894f3224e41de81a456211f9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| | * Implement dummy QML lookups for "global" variablesSimon Hausmann2019-03-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| | * Enable lookups in QMLSimon Hausmann2019-03-191-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main feature that needs to be implemented in order to enable lookups in QML files is to respect that the QObject wrapper has its own storage layer (meta-object properties). Lookups need to be able to index those when the base is a QObject. This is done by caching the property data and guarding the validity by comparing property cache pointers. The same lookup logic is also implemented for value type wrappers. OVerall there's more that can be done with lookups in meta-objects, for constant properties for example. For "global" lookups we have a safeguard in place that generates a LoadName instruction for property access that should end up in the qml context wrapper. So no changes are needed here at first, but the lookup in the QML context can be optimized in the future. The way of storing the property cache in the lookup itself trades ugliness on destruction against the creation of less internal classes. Another option would be to store the property cache in the internal class and let QObjectWrapper always transition via the property cache. Task-number: QTBUG-69898 Change-Id: I9c378c071acc6d7d4a34a2a76616f9594119d515 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-02-251-1/+1
|\| | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlmetatype.cpp Change-Id: I517c001ea4eb0fdd8e469f9fffe5b7559a5b0795
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-02-221-1/+1
| |\| | | | | | | | | | | | | | | | | | | Conflicts: tests/auto/quick/qquicktableview/tst_qquicktableview.cpp Change-Id: If3bf1abc23a59c458be0bb862d92f2edcb16b79f
| | * QML: Pass type minor version when creating property dataUlf Hermann2019-02-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Depending on the type minor version recursive properties should be available or not. Check for that when resolving grouped properties. Fixes: QTBUG-33179 Change-Id: Id8f62befdc4a29d879710499e19d3d289bd18775 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | QML: Split propertyCache into multiple filesUlf Hermann2019-02-011-1/+0
|/ / | | | | | | | | | | | | I want to be able to read the code. Change-Id: I063143ff63b0a476d783c892e1d328e7f5133fab Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | V4: Collect trace information in the interpreterErik Verbruggen2019-01-251-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2019-01-221-1/+1
|\| | | | | | | | | | | | | | | Conflicts: .qmake.conf tests/auto/quick/qquickpathview/tst_qquickpathview.cpp Change-Id: Ic1f5e219a255d0613f7654368a5ce3eccb8f0ee9
| * Fix build error when building with -no-feature-translationUlf Hermann2019-01-111-1/+1
| | | | | | | | | | | | Change-Id: Ie97ae901283cf431fc38d238ddbc88a18bd630c8 Fixes: QTBUG-72352 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QML: Special case null as binding typeUlf Hermann2019-01-211-0/+2
|/ | | | | | | | | | | | This gives us the opportunity to map the JavaScript null to QVariant's concept of isNull(). [ChangeLog][QML] Assigning JavaScript null to incompatibly typed properties generates a compile error now, rather than a runtime error. Fixes: QTBUG-72098 Change-Id: I72fd1c30d84128c774230eaaea10455b2a0e064c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix ICC warning about old-style scoping rulesThiago Macieira2018-12-121-2/+2
| | | | | | | | | | It's only been 20 years that the new style is the rule... qv4compileddata.cpp(206): error #823: reference is to variable "i" (declared at line 198) -- under old for-init scoping rules it would have been variable "i" (declared at line 204) Change-Id: I4ac1156702324f0fb814fffd156f80ecb6849ee8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.12.0' into 5.12Qt Forward Merge Bot2018-11-161-21/+17
|\ | | | | | | Change-Id: I7623438dde316ae1e97802f91991f2e7ccc205a5
| * Fix translation bindings when qtquickcompiler is usedFrederik Gladhorn2018-11-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that the context information is lost when using the compiler. The unit->unitData()->sourceFileIndex is wrong (always 0), which should probably be fixed. This change only works around that by using unit->fileName(); instead. Make sure that the test actually verifies translations happen and have a context. Done-with: Jan Arve Sæther Fixes: QTBUG-71553 Change-Id: Ib5926bd4b9a6267644f5c9328a84c23d61ca5466 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Expose let/const variables from imported JS scriptsJüri Valdmann2018-11-021-20/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows QML to access let/const variables defined in JS files. Detailed changes: - The recently added ContextType::ScriptImportedByQML is changed to avoid creating Push/PopScriptContext instructions, similar to ContextType::ESModule. - QV4::Module is changed to also work with CompilationUnits which are not ESModules. In this case QV4::Module will behave as if all lexically scoped variables were exported. - CompilationUnit is changed to support instantiating and evaluating QV4::Modules for non-ESModules as well. - QQmlTypeLoader is changed to always create QV4::Modules for evaluating scripts. For the non-ESModule case, the QV4::Module is evaluated inside a QV4::QmlContext, as before. - A pointer to the QV4::Module is added to QV4::QQmlContextWrapper, and used in virtualGet to access the let/const variables in the CallContext. Access is read-only. Fixes: QTBUG-69408 Change-Id: I6f299363fdf5e1c5a4a0f1d9e655b4dc5112dd00 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Create proper template objects for tagged templatesLars Knoll2018-11-051-0/+34
|/ | | | | | | | 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-2/+9
| | | | | | | | 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>
* Refactor InternalClass::find()Lars Knoll2018-09-271-2/+2
| | | | | | | | | Specialize find() into several methods for different purposes. Prepares for further cleanups and being able to split up getter and setter for accessor properties. Change-Id: Id4ec5509ac1a1361e2170bbfc2347b89b520c782 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-2/+2
| | | | | | | | | | | | 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 compiling ES modules ahead of timeSimon Hausmann2018-08-171-2/+2
| | | | | | | | | | | | This is also pretty straight-forward by adding .mjs as supported extension in the qmake and cmake support. This also tweaks qv4engine.cpp to share the same module compilation function across all code paths. Change-Id: Ia0e23c78a794f2330ecf8f991ee6ea948f4ac89d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix order of own property names of module namespace objectsSimon Hausmann2018-08-151-0/+42
| | | | | | | They must be sorted, no duplicates and only one default entry at most. Change-Id: Ia9c0e54a761ce7cbfebb837330bf3769d505eb3b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup RegExpObjectLars Knoll2018-08-151-13/+3
| | | | | | | | | | | 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 explicit export of imported variablesSimon Hausmann2018-08-141-3/+5
| | | | | | | | | | | | | | | | | | | | Instead of using a re-export, it's also possible to write import { foo } from "./bar.js" and then export it again export { foo } Typically exported variables are referenced from the locals, but since we don't add imports to the locals, we need another way of locating them. This patch uses the index space after the locals in the internal class for imports, so that after we've identifier the export in the local export entry table, we can use the local name to search in the internal class and find imports past the locals. Change-Id: I58ab79ad3df1bbc1b972f0a2771d9ca1268de27b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix module dependency handlingSimon Hausmann2018-08-141-16/+3
| | | | | | | | | | | | | | | | | | | | | 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>
* Implement star re-exportsSimon Hausmann2018-08-141-1/+30
| | | | | | | | | | | An export such as export * from "./foo.js" allows re-directing imports. Change-Id: I359ce7d4516ed4a7b95e6fcefb4725d854f9c2ce Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement initial support for import namespacesSimon Hausmann2018-08-141-0/+3
| | | | | | | | | | | | | The import via import * as foo from "./bar.js" allows accessing all exports via the special namespace object. This is conceptually quite similar to the existing import of .js files in QtQuick. Change-Id: Ia6d79342f0884a89dfe4dc07316570ca7789cac0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement indirect exports in modulesSimon Hausmann2018-08-141-11/+51
| | | | | | | | | This allows exports in the style of export { foo as bar } from "./baz.js" Change-Id: I2f723c3d9c5fbc530a30ac5bcb12a02f21918648 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Enable unicode regular expressionsLars Knoll2018-08-101-1/+4
| | | | | | | Add support for the 'u' flag for regular expressions. Change-Id: I409054eaa9c50183619752d14f2638f5a38c0ea7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>