aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Split CompiledData::CompilationUnit in twoUlf Hermann2019-05-161-18/+32
| | | | | | | | 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>
* Don't include qv4enginebase_p.h in qmldevtoolsUlf Hermann2019-05-101-1/+7
| | | | | | | | 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>
* Move compileModule() into qv4codegen.cppUlf Hermann2019-05-081-1/+3
| | | | | | | | | This is a better fit for the method. In turn, remove all the V4_BOOTSTRAP conditions from qv4engine_p.h and make sure we don't include or compile it in bootstrap mode. Change-Id: I5933b0724e561313ca20c420b83e4d70e63bddf5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove tracing JIT infrastructureUlf Hermann2019-04-291-48/+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.13' into devQt Forward Merge Bot2019-04-101-1/+2
|\ | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlmetatype.cpp src/qml/types/qqmlmodelsmodule.cpp Change-Id: Idc63689ba98d83a455283674f4b5cf3014473605
| * Merge remote-tracking branch 'origin/5.12' into 5.13v5.13.0-beta2Qt Forward Merge Bot2019-04-091-0/+1
| |\ | | | | | | | | | Change-Id: I68211a7d4568a1c31c6a124fe6777709c53736a5
| | * Avoid INT_MIN % -1 and INT_MIN / -1Ulf Hermann2019-04-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Those throw arithmetic exceptions as the result doesn't fit into an integer. Fixes: QTBUG-75030 Change-Id: Ibd978848f42cf1c9da1e4af2dc9d7da123ef8f5a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * | Remove second evaluation of property nameRainer Keller2019-04-081-1/+1
| | | | | | | | | | | | | | | | | | | | | The name was evaluated already at the beginning of the function. Change-Id: I0bf6149c9bce83a543b1946330ec12f318620a71 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Remove unused includes of qv8engine_p.hUlf Hermann2019-04-091-1/+0
| | | | | | | | | | | | | | | Change-Id: Ic135a863581d29a3afb9c6c7f070d2630b3913b4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into HEADUlf Hermann2019-03-221-107/+38
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-104/+31
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-86/+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-18/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.13' into devQt Forward Merge Bot2019-03-151-5/+16
|\| | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp Change-Id: I604517d0948fb5056ce36cc104f13ac956fbcc24
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-131-5/+16
| |\| | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp src/qml/animations/qsequentialanimationgroupjob.cpp Change-Id: I8b76e509fd7c8599d4cef25181d790ee28edab54
| | * Disable tail calls for function called with more arguments than formalsUlf Hermann2019-03-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We cannot easily find the required stack space to store the extra arguments without adding a new stack frame. In principle it would be possible, but heavily recursing on such functions should be a rare problem. Change-Id: I1a53a6d29e37ce67aa7bd64acb7b1f41197e84c0 Fixes: QTBUG-72807 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| | * Unify and fix number to string conversion with radixUlf Hermann2019-02-251-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the loop that generated the string could fail to terminate with certain numbers as input. Also, the algorithm was duplicated in two places. Change-Id: Ie2075148d931e7cfcedb5bcd23af61e2e8afc232 Fixes: QTBUG-73999 Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | V4: Clean up the runtime functions declarationsErik Verbruggen2019-02-051-148/+276
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+48
|/ | | | | | | | | | | | | | | 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-0/+6
| | | | | | | | 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>
* 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-3/+22
| | | | | 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-2/+9
| | | | | | | 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>
* Speed up instanceof operationsLars Knoll2018-09-271-3/+9
| | | | | | | | | | | Introduce a shortcut if the rhs is a functionobject with the regular function proto as prototype. Add an optimized instanceOf implementation when we already have some checks done, and inline some methods. Change-Id: Iab9b648ae7bbec749b319e883b6ae90a23875454 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Better inheritance structure for functionsLars Knoll2018-09-231-5/+4
| | | | | | | | 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>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-19/+19
| | | | | | | | | | | | 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>
* Fix toNumber conversions for hex, octal and binary stringsLars Knoll2018-09-081-3/+18
| | | | | Change-Id: Ifb7159a3307c96b27530e001ab13bcd6ddd03d09 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use the correct enum value instead of hard coded intsLars Knoll2018-09-071-1/+1
| | | | | Change-Id: I2d65fe6fb3d9f299f5aeff1542c7dc1d2db8b012 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix a smaller bug in IteratorCloseLars Knoll2018-09-071-13/+20
| | | | | | | Throw the correct error in all cases Change-Id: Ic8f146cf13db605cb54cb8c96aaf0b3a1b9cca96 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for yield*Lars Knoll2018-09-071-0/+72
| | | | | Change-Id: I5b054b59519ed825459a5b0b0a7cd2c6fc8a3797 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix exception handling while destructuringLars Knoll2018-09-071-10/+20
| | | | | | | | | | | | | | | 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>
* Throw type error if this is uninitialized when accessing superLars Knoll2018-08-311-0/+5
| | | | | Change-Id: I028e198d46a2ec1c55f5dd4cce8dd868ed3e8202 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix thisObject when calling super propertiesLars Knoll2018-08-311-0/+7
| | | | | Change-Id: Ia520d43ea2c29c16cfc8ffc86a32187a78848502 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix super property accessLars Knoll2018-08-311-21/+43
| | | | | | | | | Super properties work in a rather special way by accessing a 'home object' on the function object, and reading from it's prototype. Change-Id: I666334c9c27048c6c2ba6770dd8c9f56aecbee14 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Correctly create methods for functions in object literalsLars Knoll2018-08-311-6/+24
| | | | | | | | | | Methods behave slightly different than normal functions as they have a home object and define how super property access is being done. To implement this correctly, we need to create these methods during object initialization time. Change-Id: Ib3f670c8790b882c6472de786938ca4f0b73f66f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Throw a type error if the super class is not a constructorLars Knoll2018-08-291-5/+6
| | | | | Change-Id: I1cf83c73ea1b628f44845e1b9ea324d3e069c344 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Initialize this to empty for derived constructorsLars Knoll2018-08-291-0/+15
| | | | | | | | | As per spec, this should be uninitialized in derived constructors, and the base constructor needs to get called exactly once. Change-Id: If31804e58d7ba62efde8fbf6cd852674f8da4495 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove a bogus Q_UNIMPLEMENTED()Lars Knoll2018-08-291-1/+0
| | | | | Change-Id: I6d085ecb1a57d445a40300337f77917302a9084d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix Map and WeakMap constructorLars Knoll2018-08-281-0/+4
| | | | | Change-Id: I52c31a006b80430ea949eaac246301e51a430f89 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement the dead temporal zoneSimon Hausmann2018-08-281-0/+6
| | | | | | | | | | | | | | 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>
* Implement IsConstructor for Function objectsLars Knoll2018-08-231-1/+2
| | | | | | | | Use the jsConstruct member in the function object for this and set it to a nullptr for methods that are not a constructor. Change-Id: I63d2971b23b2596a8e3b6d2781f0d9ed3208693b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* JS: Also have modulo return integer 0 when the lhs is 0Erik Verbruggen2018-08-091-4/+7
| | | | | | | | | | | | | | When both operands of a modulo are integers, and the right-hand side is bigger than zero, it is fine to have the left-hand side be 0, as the result is (positive) zero. This also handles the somewhat common case below, where lhs is 0, and where returning a double would result in the slow path to do the actual array access: array[lhs % array.length] Change-Id: I4ca268a08604c3c77a23a92eee193c807696d5ba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Minor cleanupSimon Hausmann2018-08-061-4/+4
| | | | | | | | | | | | | | | Rename bool String::compare(const String *other) to the slightly more self-explaining bool String::lessThan(const String *other) as the returned boolean value does not relate to equality. Change-Id: Ia7b1a7f47beca0659fb199c0c9d49951468ad03d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix some details in class initializationLars Knoll2018-08-061-1/+5
| | | | | Change-Id: Ib8a76362686f1bbba49daca59fa4a30773150103 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix crash in ↵Simon Hausmann2018-08-031-1/+2
| | | | | | | | | | | | | language/statements/class/syntax/class-body-method-definition-super-property.js with JIT CallValue was changed to pass undefined as the this object, instead of a null pointer. This also needs to be done from the other call site used by the JIT, Runtime::method_callValue. Amends commit d31541fd9d7d52ef3eae29e7e5d36733d7f55375 Change-Id: I0e2c2542ae96a88bb7e6e24d012f7f7fe72aeb80 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix writing to properties of primitive dataLars Knoll2018-08-021-2/+17
| | | | | | | | In strict mode, this should throw a type error and not do an implicit toObject conversion. Change-Id: I7b8cdf1125978b9d9a047d9da84f23b547cb4a75 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix naming of methods defined in object or class literalsLars Knoll2018-08-011-2/+23
| | | | | Change-Id: I01b7774097a447520c85ae6766e6ca1162e921ba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Encapsulate the unit data in CompilationUnitSimon Hausmann2018-07-311-1/+1
| | | | | | | | This allows updating the constants table when the unit data is set / changes and removes the tie to the engine. Change-Id: Ice553650390589e30e18421c4e55422a55d0df89 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix AOT byte code generation of unary ops with constantsSimon Hausmann2018-07-301-1/+1
| | | | | | | | | When generating code for unary operations with constants, then we should produce constants in the bytecode instead of run-time codes even when compiling ahead of time. Change-Id: Ied902f3729eb6602674eac56edafc4372b209923 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix class members that are generatorsLars Knoll2018-07-031-1/+4
| | | | | | | Properly support member functions that are generators in classes. Change-Id: I5fc8d5b58a17c61a446b43d6576bb83de5ecd920 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>