aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Move model types into their own libraryUlf Hermann2019-05-021-6/+6
| | | | | | | | | | The model types are not part of the core QML runtime and should only be loaded if you explicitly import them. We cannot enforce that in Qt5 as some of them are available from the QtQml import, but we can change it in Qt6. Change-Id: I1e49e84d748e352537ec2d4af901c034c91d038f Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com>
* ES7: Implement Tail Position Calls in the runtimeErik Verbruggen2018-10-051-1/+3
| | | | | Change-Id: If1629109722496b3fd10b36b2376548440f2fee9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Speed up instanceof operationsLars Knoll2018-09-271-4/+15
| | | | | | | | | | | 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>
* Unify layout of function objectsLars Knoll2018-09-271-6/+3
| | | | | | | | | | Ensure we have the proto property at always the same place. This will be used in a subsequent commit to optimize accesses to the prototype property e.g. when doing instanceof operations or constructor calls. Change-Id: I6e9a19e0b7d0e8ab583648a60d1978f5cf838b06 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Better inheritance structure for functionsLars Knoll2018-09-231-14/+31
| | | | | | | | 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>
* Cleanup init method for ScriptFunctionLars Knoll2018-09-231-2/+3
| | | | | Change-Id: I913f9429a9238860a5b4e9dc84d217ec824f25c1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove unused argumentLars Knoll2018-09-231-2/+2
| | | | | Change-Id: I1f2c796b50d05c238fad36434b2545604a401fbf Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Member functions should not have a prototype propertyLars Knoll2018-09-041-1/+5
| | | | | Change-Id: I19eb4012c8fee51a7e5bf264d11ab5337ac2a88d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't define a prototype property for most functionsLars Knoll2018-09-041-3/+2
| | | | | | | | Only functions that are constructors should have a prototype property. Change-Id: Ifcf6f8b6c38de055d871d57ada38a23432974263 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix super property accessLars Knoll2018-08-311-13/+15
| | | | | | | | | 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>
* Implement IsConstructor for Function objectsLars Knoll2018-08-231-2/+11
| | | | | | | | 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>
* Fix naming of methods defined in object or class literalsLars Knoll2018-08-011-3/+3
| | | | | Change-Id: I01b7774097a447520c85ae6766e6ca1162e921ba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix a cornercase for instanceofLars Knoll2018-08-011-2/+3
| | | | | | | | | It's possible to define a getter function for the prototype property of Function objects. Ensure this doesn't mess up things by not taking shortcuts. Change-Id: Id981f3080f5c5c0714a1b7b6de27b4af04e794c8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Minor cleanupLars Knoll2018-08-011-5/+4
| | | | | Change-Id: I70d59b20761403a3f05ec31f91adda2ff7e5ff5f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for super callsLars Knoll2018-07-031-1/+4
| | | | | | | | Implement super call support for class constructor functions. Change-Id: I3c64276234689cf4f644b095e0fc8ca1c634ac53 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for new.targetLars Knoll2018-07-031-8/+8
| | | | | | | | | Support the new.target meta property in the codegen, and add support for passing the newtarget into the constructor vtable methods and the execution context. Change-Id: I62ea58e5e92d894035a76e35776203e9837c383b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Prefix vtable methods with virtualLars Knoll2018-07-031-12/+12
| | | | | | | | | Turns out that the overloading of vtable methods and regular ones is problematic in some cases. So let's rather make it explicit which methods are part of the vtable, and which aren't. Change-Id: Ifee32a26104d30f3c82bca8b5a9cdea2d4f4f526 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify the managed and object vtablesLars Knoll2018-07-031-3/+3
| | | | | | | | | | Allow for nullptr entries in the vtable. To nevertheless get some decent error checking if one of the methods is reimplemented, use a base class for Managed that contains a full set of the vtable entries all being nullptr's. Change-Id: Ibc53973b539f87331e8e465a6c44436a30acbefd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanups in FunctionObjectLars Knoll2018-06-271-3/+4
| | | | | | | rename init() to setName() as that's the only thing it's doing. Change-Id: Iecf586bc6b6df0f169bc7d2969b711e758ea3813 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add a MemberFunction function objectLars Knoll2018-06-261-0/+14
| | | | | | | | | | | 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>
* Various fixes for class supportLars Knoll2018-06-261-0/+10
| | | | | | | | | | | | | | | | Add support for a default constructor if none is given. Fix support for computed method names, by unifying the handling between static and non static methods. Fix our table generation, so that we write UINT_MAX as the string index for undefined strings and not a reference to the empty string, as that can actually be a valid method name. Add support for getter and setter methods in classes. Change-Id: If52c57d6a67424b0218b86339b95aed9d0351e47 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add basic support for EcmaScript classesYulong Bai2018-06-261-0/+10
| | | | | | | | | | | | | | | | 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>
* Add Generator supportLars Knoll2018-05-031-0/+6
| | | | | | | | | | | | | 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>
* Cleanup creation code for builtin functionsLars Knoll2018-05-021-8/+1
| | | | | | | | Centralize the code in FunctionObject::createBuiltinFunction and setup function names and length properties there. Change-Id: I21f1d42b475070ee091d96d97387149af1dc47f2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make instanceOf compliant with the ES7 specLars Knoll2018-05-021-0/+1
| | | | | | | | Add implementation for Function.prototype[Symbol.hasInstance] and call it when defined. Change-Id: Iad6b0c075452b46ba710ffe7b94b74b71f715d22 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-04-181-0/+2
|\ | | | | | | Change-Id: I4a9c7802c180757e70fa4dd16df3287104a088bc
| * Fix calling Qt.binding() on bound functionsLars Knoll2018-04-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling Qt.binding() on a bound function object is a valid use case and used to work until Qt 5.8. The problem was that we optimized the code in QQmlBinding and QQmlJavascriptExpression to directly work on a QV4::Function, so this wouldn't work anymore. To fix this make sure recursive calls to Function.bind() are unrolled (so that the BoundFunction's target is never a bound function itself), then add the bound function as an optional member to the QQmlBinding and use it's bound arguments if present. Task-number: QTBUG-61927 Change-Id: I472214ddd82fc2a1212efd9b769861fc43d2ddaf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | garbage collect InternalClassLars Knoll2018-04-121-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Remove dependency from qv4heap_p.h onto qv4internalclass_p.hLars Knoll2018-04-121-1/+1
| | | | | | | | | | | | | | | | This is required to be able to turn the internal class into something that lives on the GC heap. Change-Id: Ie4318588d420743b1e1ab1cd596a1c9d153eb793 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Disambiguate different allocation functions in the memory managerLars Knoll2018-04-121-2/+2
|/ | | | | | | | | | | Some compilers (in this case MingW 5.3) don't manage to properly disambiguate the template overloads, and try to instantiate the wrong template function. Solve this by renaming the one of the template functions. Change-Id: I3574e617fe96c4bd52920a0127a1dfe39cc3d302 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-2/+2
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of BuiltinFunctionLars Knoll2018-01-151-25/+6
| | | | | | | It's now unused. Change-Id: Id2941c212d488c9b0933fa06aac9922b9db13a05 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Convert more builtin functions to use the new calling conventionLars Knoll2018-01-121-6/+6
| | | | | | | | Convert most of the methods used QML objects to the new calling convention. Converted IndexedBuiltinFunction to do the same. Change-Id: I41b26042c2f56f24988485b06e8ccd214e2573c0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Allow tuning the amount of inline properties per object typeLars Knoll2017-11-151-0/+2
| | | | | | | | | Different JS objects need different amount of properties by default. Tune the amount of inline properties we pre-allocate by what's usually needed for the object. Change-Id: I2703d123939f9b7e3a06531361cbb6a3a3c04944 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Bring back markObjects(), this time generatedLars Knoll2017-11-141-2/+2
| | | | | | | | Doing the marking of objects in a function instead of using the table seems to be somewhat faster. Change-Id: I9ec00cc0264f9a15c69b285db493bee31d99bf96 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Convert more builtin methods to new calling conventionLars Knoll2017-11-131-2/+2
| | | | | | | | Convert the methods of the global object and the remaining methods in in the Function object. Change-Id: I7c9a5f39b07f9c9cb0f31e83cdf41fade71a7dc5 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Introduce new calling convention for builtin functionsLars Knoll2017-11-131-2/+8
| | | | | | | And implement Function.apply()/call() with it. Change-Id: I028c82d5f9adfd23328d669db1adccec9de5824c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Change signature for call/callAsConstructorLars Knoll2017-11-071-10/+10
| | | | | Change-Id: I159b57acc7a2133ef1ad545aa84e792c63449a57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Rename the construct 'virtual' method to callAsConstructorLars Knoll2017-11-071-5/+5
| | | | | | | To make it consistent with the rest of the engine. Change-Id: I57b98fa26134f9864c663f47371ef3e9ca16ac9c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Add a FunctionObject::call(AsConstructor) overloadLars Knoll2017-11-071-0/+3
| | | | | | | add an overload taking a JSCallData for convenience. Change-Id: I8ebc190354943e6ceed676c3c0e1803586426769 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Rename JSCall to JSCallDataLars Knoll2017-11-071-1/+1
| | | | | | | | As, this is going to change in a simple stack based structure to keep pointers to the data to pass to calls. Change-Id: Ia9aa3f81ee3eeba36affd16aac7b2fe97d59aea9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Change signature of call/constructLars Knoll2017-11-071-6/+6
| | | | | Change-Id: I139a7a31651d9a2ea46ced88978ac4633294bc60 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Add functions pointers for call/construct to FunctionObjectLars Knoll2017-11-071-3/+13
| | | | | | | | This will allow us to avoid one level of indirection when calling js functions in the future. Change-Id: I814b72d18adb5a5580c11053e53b582549b629fc Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Unify IndexedBuiltinFunction with BuiltinFunctionLars Knoll2017-08-081-14/+7
| | | | | | | | | Now that we pass the function object to the runtime method, we can retrieve the index from there, and don't need a different calling convention for the indexed version anymore. Change-Id: I6c7d747ddb0c217b23fe9ba06435afb4ec0ee24a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-12/+7
| | | | | | | | Allow for faster calling of builtins, and completely avoid scope creation in many cases. Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Change function signatures for call/construct backLars Knoll2017-08-041-13/+13
| | | | | | | | Change those back again to return a value. This will be required to avoid creation of Scope objects between JS function calls. Change-Id: I05cb5cf8fd0c13dcefa60d213ccd5983fab57ea3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-061-14/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Get rid of the old way of defining builtin functionsLars Knoll2017-05-191-11/+0
| | | | | | | | | | | | | | | | | | | | The old calling convention used for builtin functions is very inefficient. It was still being used in a few places. Clean those up and convert them to the new and much more effiecient calling convention. Change-Id: I6b769c6185df7e9be1e80709330fc1ca868576c1 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
| * Move the prototype into the internal classLars Knoll2017-05-191-1/+4
| | | | | | | | | | | | | | | | | | | | 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 list of default internal classes into EngineBaseLars Knoll2017-05-191-2/+2
| | | | | | | | | | | | | | | | And store them in an enumerated array. This will simplify upcoming changes. Change-Id: I82eac03b9f6264843ae625e36e150464fe08be9d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>