aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arrayobject_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Ensure our builtin constructors are subclassableLars Knoll2018-11-221-1/+1
| | | | | | | | | Respect the newTarget passed into those constructors and make sure we set up the proto chain correctly. Change-Id: I3d12c7dbef4b33660a6715d73e9fb0f89105167a Fixes: QTBUG-71138 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Implement support for new.targetLars Knoll2018-07-031-1/+1
| | | | | | | | | 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-2/+2
| | | | | | | | | 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>
* qv4arrayobject: Implement Array.from from ES7Robin Burchell2018-05-301-0/+1
| | | | | | | | The remaining failures look to be down to the constructor hack, but this gets us a good part of the way there already. Change-Id: I6e57828a56edddd5cb70560b6f50dfc6311c88ae Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* qv4arrayobject: Implement Array.prototype.copyWithin as per ES7Robin Burchell2018-05-301-0/+1
| | | | | | | The remaining two failures are due to Proxy being missing. Change-Id: I6cc5177cd958d98600cc2ba3b1e1a18bc420530c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* qv4arrayobject: Implement Array.of from ES7Robin Burchell2018-05-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | One small difficulty: We can't accurately tell whether a thisObject is a constructor or not, so right now we're just swallowing all exceptions and creating an array if they occur. This isn't correct, but it isn't trivial to fix, either: I think we would have to somehow mark our builtins that are constructors, and allow those, but use the array fallback for other builtins, calling user functions and bubbling up if they throw. This is probably good enough for the time being though, as writing something like: function Test() { throw "Foo"; } Array.of.call(Test) ... is probably not very likely, compared to more "usual" use. Change-Id: Ied341a7fa9c3a7fd907e2815c019bc431171ce62 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* qv4arrayobject: Implement Array.prototype.includes from ES7Robin Burchell2018-05-251-0/+1
| | | | | | | | | | | | | | We also add a sameValueZero helper, to make life easier. Remaining failures: built-ins/Array/prototype/includes/get-prop.js fails (due to missing Proxy) built-ins/Array/prototype/includes/length-boundaries.js fails length-boundaries failure is due to strange treatment of edge number values in Value, I think, I haven't yet been able to rectify that one. Change-Id: Idacca528d88fb052d19a5d244662927f502f20d2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* qv4arrayobject: Implement Array.prototype.fill according to ES7Robin Burchell2018-05-251-0/+1
| | | | | | Task-number: QTBUG-56824 Change-Id: Ib12b9fe5ebdd5375f17cf4927eb9b4e292731932 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement Symbol.species getter functionsLars Knoll2018-05-151-0/+4
| | | | | Change-Id: I18b3e382e679f95d7cb53b4ed03be2513ea0204b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Array Iterator objects from ES6 (22.1.5)Robin Burchell2018-05-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And implement / expose them via: 22.1.3.4 - Array.prototype.entries() 22.1.3.13 - Array.prototype.keys() 22.1.3.29 - Array.prototype.values() 22.1.3.31 - Array.prototype[Symbol.iterator] Most tests for Array iterators now pass. At the same time, expose them on TypedArray's prototype: - 22.2.3.15 %TypedArray%.prototype.keys - 22.2.3.29 %TypedArray%.prototype.values - 22.2.3.6 %TypedArray%.prototype.entries - 22.2.3.31 %TypedArray%.prototype[Symbol.iterator] For TypedArray, test coverage improves a tiny bit (3 passing tests), but the vast majority fail as it seems like the object structure for TypedArray is currently incomplete as far as ES6 expects. It seems that ES6 expects the object structure to be: * %TypedArray% (inherits FunctionObject) (this is the TypedArray intrinsic object, and responsible for initializing the TypedArray instances) * All the TypedArray ctors (e.g. UInt8Array) These inherit %TypedArray%, and make a super call to it to do their work * %TypedArrayPrototype% (inherits Object) (this is the initial prototype for %TypedArray%) * All the ctors have their own separate instance of this * The instances also make use it So, for instance, a lot of the tests attempt to access the prototype like: var proto = Object.getPrototypeOf(Int8Array) var keys = proto.prototype.keys As ES6 expects Int8Array.prototype to be %TypedArray% (22.2.5), this expands to: Object.getPrototypeOf(%TypedArray%) which it expects to be %TypedArrayPrototype%. But since we have no intrinsic object, and the ctors inherit FunctionObject, we instead return the wrong prototype into 'var proto'. Change-Id: I5e1a95a0420ecb70a0e35a5df3f65557510c5925 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Convert methods of Array to new calling conventionLars Knoll2017-11-131-22/+22
| | | | | Change-Id: Iaac17004f36a20099bdebaca23d0d310191c2acc Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Convert Array.push/pop to new calling conventionLars Knoll2017-11-131-2/+2
| | | | | Change-Id: Id2c53adf56dff308f3953e4cea17b04f842bb2ff Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Change signature for call/callAsConstructorLars Knoll2017-11-071-2/+2
| | | | | Change-Id: I159b57acc7a2133ef1ad545aa84e792c63449a57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Rename the construct 'virtual' method to callAsConstructorLars Knoll2017-11-071-1/+1
| | | | | | | To make it consistent with the rest of the engine. Change-Id: I57b98fa26134f9864c663f47371ef3e9ca16ac9c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-24/+24
| | | | | | | | 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-2/+2
| | | | | | | | 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>
* Speed up invocation of builtin functionsLars Knoll2017-01-251-24/+24
| | | | | | | | Completely avoid creation of a CallContext for those methods, as we don't need it. Change-Id: Iff1a38fd3c7e846df6ec0374cb7b3fb8f1b4de3a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add ECMAScript 6 Array find and findIndex methodsKai Uwe Broulik2016-11-101-0/+2
| | | | | Change-Id: I318fa243ab68b8a714923ab816d62e8c544fca8c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QML: Make Heap::Object and all subclasses trivialErik Verbruggen2016-10-061-1/+1
| | | | | | | | | | | | GCC6 might dead-store-eliminate out our secret write to Base::mmdata, because it expects all memory content to be "undefined" before constructor calls. Clang might take the same approach if the constructor of Heap::Object is removed. By making these structs trivial, it also makes them memcpy-able. Change-Id: I055b2ad28311b997fbe059849ebda4d5894eaa9b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Pass scope around as parameters inside the runtime.Erik Verbruggen2016-06-221-2/+2
| | | | | | | | | | | | | | | | The implementation of many (or all) runtime functions consist of first creating a QV4::Scope, which saves and restores the JS stack pointer. It also prevents tail-calls because of that restoring behavior. In many cases it suffices to do that at the entry-point of the runtime. The return value of a JS function call is now also stored in the scope. Previously, all return values were stored in a ScopedValue, got loaded on return, and immediately stored in another ScopedValue in the caller. This resulted in a lot of stores, where now there is only one store needed, and no extra ScopedValue for every function. Change-Id: I13d80fc0ce72c5702ef1536d41d12f710c5914fa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add missing "We mean it" comments to private headers.Friedemann Kleint2015-10-061-0/+11
| | | | | | Task-number: QTBUG-48594 Change-Id: Ifc207938de7f0c8995fc712df92665f222612647 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* More cleanupsLars Knoll2015-04-211-2/+2
| | | | | | | | Get rid of Value::asObject(), and pass const Managed pointers into some more vtable methods. Change-Id: Ia4f427d5fd8868f77b4015d1ce5424d32bfc2115 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* Move Data of Variant and ArgumentsObject into Heap namespaceLars Knoll2014-11-081-5/+9
| | | | | Change-Id: Id2092a15c9fb5341d9b5cf4a9ac7a978308e4174 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move Data of FunctionObject and related classes into HeapLars Knoll2014-11-081-1/+1
| | | | | Change-Id: Iadf74f953798c1884e0ec704ccb7c70d971e3273 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Fix Managed::as<>() methodLars Knoll2014-07-221-1/+1
| | | | | | | | | | | | | | | The as<> casting method was not doing the right thing in 100% of the cases. It only checked if the object in question was exactly of the type being asked for. It however didn't check if the object was derived from the type. This commit fixes this by adding a parent chain to the vtables, that is then being used to check this safely at runtime. Change-Id: I9e0b13adbda668aee8c7451e2bb71cd6d4e316d9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert most simple objects to the new constructor schemeLars Knoll2014-07-221-2/+0
| | | | | Change-Id: I90042037bc0555771bd98233977c7d2b735bb718 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert remaining FunctionObject's to new constructor schemeLars Knoll2014-07-221-1/+4
| | | | | Change-Id: I440d5b128d0ee28566ebfa82c2505a4bd97bba6b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of all uses of ObjectRefLars Knoll2014-07-221-1/+1
| | | | | Change-Id: I705e2362dcda542f56826dadec6b0a6f15848788 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Rename V4_OBJECT_NEW back to V4_OBJECTLars Knoll2014-07-221-1/+1
| | | | | | | | The _NEW variant was there only temporarily to aid converting to the new data layout. Change-Id: I1d126ee0999c8f0a49f5a08c2e8c090497dd6dd5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert ArrayObject over to the new storage schemeLars Knoll2014-07-221-1/+1
| | | | | Change-Id: Ib453d682902ccc751fc8fadf2ef9e21c0c234f69 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Split ManagedVTable into two classesLars Knoll2014-01-211-1/+1
| | | | | | | | Keep the basic methods in ManagedVTable, but have the Object related stuff in an ObjectVTable class. Change-Id: I9b068acf3caef813686227b8d935e7df1a7d1a6e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Rework array handling for JS objectsLars Knoll2014-01-091-2/+0
| | | | | | | | | Split up ArrayData into two classes, one for regular arrays, one for sparse arrays and cleanly separate the two cases. Only create array data on demand. Change-Id: I9ca8d0b53592174f213ba0f20caf93e77dba690a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Simplify & speed up function callingLars Knoll2013-11-091-22/+22
| | | | | | | | | Get rid of the SimpleCallContext, instead simply use the CallContext data structure, but don't initialize the unused variables. Change-Id: I11b311986da180c62c815b516a2c55844156d0ab Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove some uses of raw Object pointersLars Knoll2013-09-301-1/+1
| | | | | Change-Id: I7c715f33d197ebbf6f0c00040099b27ed7221d42 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix API for Object::define*PropertyLars Knoll2013-09-281-1/+1
| | | | | | | use ValueRef instead of const Value &. Change-Id: I3fd0ca829870db27f036825d713c53dc0600be07 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup Object::define*Property APILars Knoll2013-09-221-1/+1
| | | | | Change-Id: I99125908a9bc1d41a2642c409af9704def7a0832 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Extend the ReturnedValue mechanism to pointers to Managed objectsLars Knoll2013-09-181-3/+1
| | | | | | | | | | | | | Add a Returned<T> that we can return instead of raw pointers to Managed objects. Start using the Returned<T> for a few methods. Also clean up all our classes to use the Q_MANAGED macro instead of manually defining their vtable. Change-Id: I0a2962e47f3de955cd2cd8474f8f3fcc9e36d084 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert builtin methods to return a ReturnedValueLars Knoll2013-09-181-22/+22
| | | | | Change-Id: I6b75adbf53a5be0deab023d2eed98ce2a7915551 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use ReturnedValue for Managed::construct()Lars Knoll2013-09-181-1/+1
| | | | | Change-Id: I9e702d60c4e1b7ba19a699ff7a8d53876d6cd5f7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use a ReturnedValue for Managed::call()Lars Knoll2013-09-181-1/+1
| | | | | Change-Id: Ief2d75e9789dd367c603d90dc0fe5316a0d055e3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Change signature of call/construct() to take a pointer to a CallDataLars Knoll2013-09-111-2/+2
| | | | | Change-Id: I5467aadba083e4b01fb0a7170946695207033680 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move prototype pointer into QV4::InternalClassLars Knoll2013-09-021-1/+1
| | | | | | | | | | | | | The prototype is actually the same for most objects. By moving it into the internal class, we can save 8 bytes per object, as well as allowing for some future optimizations. Also fix a bug in the implementation of the Error prototype objects. Change-Id: I4d4b641055f644a9b088f27be34bfdb0446279b7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* change calling convention for JS function callsLars Knoll2013-09-021-2/+2
| | | | | | | | | | | | This allows faster pass through of the data if we have nested calls. Also make sure we always reserve at least QV4::Global::ReservedArgumentCount Values on the stack to avoid stack corruption. Change-Id: I42976460f1ef11a333d4adda70fba8daac66acf3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Restructure source codeLars Knoll2013-08-081-0/+100
Move the v4 engine classes from a subdir of qml/qml into two subdirs (compiler and jsruntime) of the qml module Remove an unsued qv4syntaxchecker class, and move the moth code directly into compiler. Change-Id: I6929bede1f25098e6cb2e68087e779fac16b0c68 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>