aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4typedarray.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Allow JavaScript primitive type transformations inline in C++Ulf Hermann2020-12-181-1/+1
| | | | | | | | | | We don't want to call into the engine just for adding two numbers. This implements the most common operators on primitive JavaScript values. More are to follow in the future. Change-Id: Id51a5af59a3af9fec78a2d8f293e59e6567e9204 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-301-0/+6
|\ | | | | | | Change-Id: I1e1d9585d876a8eacd4c24afc894a33075f51a13
| * Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-291-0/+6
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp Change-Id: I133bfd4bd9dd6f704252c956c90f05e8a8a40d6a
| | * V4: Check for exceptions before we use the result of a JS callUlf Hermann2020-01-231-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | If the call resulted in an exception the return value is undefined. Task-number: QTBUG-81581 Change-Id: Ibfdd5e1229cf5437f270232d3b1a91308adeec72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | | Make QtQml work with the latest changes in qtbaseLars Knoll2020-01-141-12/+12
|/ / | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-091-2/+5
|\| | | | | | | | | | | | | | | | | Conflicts: src/particles/qquickitemparticle.cpp src/qmlmodels/qqmladaptormodel.cpp tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp Change-Id: Ibd8fbb91da6893a09f4ffe61ad0b95d8149bbc87
| * V4: Avoid integer overflow on typed array length checkUlf Hermann2020-01-081-2/+5
| | | | | | | | | | Change-Id: I370b4c4bd0d7962878849ca7c5edef6cb36eca25 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Remove a leftover unused variableVille Voutilainen2019-12-101-1/+0
| | | | | | | | | | Change-Id: I58f9c47ae968af45b9b2ce19798f220d65c59c0f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Implement TypedArray.fromVille Voutilainen2019-12-091-0/+155
| | | | | | | | | | | | Task-number: QTBUG-80030 Change-Id: I2d4c30257f543d9d7013aaf394a2a0874eacb266 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Clean up ArrayPrototype::method_joinUlf Hermann2019-10-211-31/+24
|/ | | | | | | | | | | | | The code was really convoluted. Calling join() on anything that doesn't look like an array results in an empty string. Everything else can be handled by the same algorithm. While we're at it, clean up IntrinsicTypedArrayPrototype::method_join in the same way. Change-Id: I016cd2fe069d23387797a7e58020d40cdb8d60cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Port away from QAtomicOps::load / storeGiuseppe D'Angelo2019-06-251-2/+2
| | | | | | | | | Use loadRelaxed / storeRelaxed instead. load() / store() are about to be removed from our private APIs. Task-number: QTBUG-76611 Change-Id: I3bebbd1cde7e53d7e2451f2373db1232b595a1d0 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Don't use UINT_MAX as invalid array index in PropertyKeyUlf Hermann2019-04-161-21/+19
| | | | | | | | | | | Technically UINT_MAX is actually a valid array index, although that is an academic problem right now. However, we do have a method isArrayIndex() and should just use that to determine if a PropertyKey is an array index. Fixes: QTBUG-73893 Change-Id: I302e7894331ed2ab4717f7d8d6cc7d8974dabb4e Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* V4: Clean up the runtime functions declarationsErik Verbruggen2019-02-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Make Object::getOwnProperty() constLars Knoll2018-09-231-1/+1
| | | | | | | | Object::getOwnProperty never modifies the object, so make it a const member function. Change-Id: I175bb45d61a66a1d9f577c087129562d44d62e17 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-34/+34
| | | | | | | | | | | | 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>
* Implement OwnPropertyKeys for TypedArrayLars Knoll2018-09-101-0/+32
| | | | | Change-Id: I85d6cfa4b4652863cfafad4810176d99dccdabc9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix a couple of internals in TypedArraysLars Knoll2018-09-041-14/+47
| | | | | | | | Handle property keys that are numeric strings, and implement getOwnProperty. Change-Id: I4c7ed21b6429b07f02a28bce537bcb7934a993d3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement defineOwnProperty for TypedArraysLars Knoll2018-09-041-0/+29
| | | | | Change-Id: I2e7aa05a340d54e2f34ec4e59a69f3ce66be75d9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix subclassing of ArrayBuffer and TypedArraysLars Knoll2018-09-041-2/+15
| | | | | Change-Id: I481974c224f7fdb4df6b641e8dd550add96b4c08 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix dead temporal zone checking in module namespacesSimon Hausmann2018-08-291-0/+7
| | | | | | | | | | | | | | | Accessing uninitialized imports through the module namespace object should throw a reference error. Unfortunately we can't do this check on the caller side of the namespace object get, as we have no idea that we're talking to one. Therefore we must throw in the vtable methods. When checking via Reflect.has(), the properties should be reported as existing. This means providing a virtual hasProperty() in the module as well as changing Reflect::method_has to use the vtable method instead of doing a get (which would throw). Change-Id: Ic0ec51de3832c6a67044fc8f689ac534f349c1b6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement most remaining methods of AtomicsLars Knoll2018-08-261-8/+43
| | | | | | | The only missing ones now are wait() and wake(). Change-Id: I2c0ee78cdd8a249e0e841861dd4b76c4665b0ae0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Partial Atomics supportLars Knoll2018-08-261-9/+81
| | | | | | | | | | Implement support for basic atomic operations on SharedArrayBuffers. Half of the methods still need a proper implementation. Change-Id: Ia88da358e0c2ae6d28e9bcc1feb8980b6f51a812 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up the code handling reads and writes into typed arraysLars Knoll2018-08-251-123/+76
| | | | | | | This is a preparation for supporting atomic operations on Typed arrays. Change-Id: I91d00f3aee3f35fc22e74ee010ed2cbec2d46aae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement IsConstructor for Function objectsLars Knoll2018-08-231-11/+1
| | | | | | | | 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 some remaining issues with detaching of array buffersLars Knoll2018-08-231-42/+64
| | | | | | | | | | Make sure we check for detached buffers after all other calls that could execute code have happened. To do that convert the values to numbers before calling the write() methods of the specific typed array. Change-Id: I091e41400f740dfc1d0826657e285443c9336c40 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement %TypedArray%.prototype.sliceLars Knoll2018-08-231-24/+74
| | | | | Change-Id: I50bce4ad50f27a67e53396c5283ccc84acbb8321 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement %TypedArray%.prototype.mapLars Knoll2018-08-231-0/+43
| | | | | Change-Id: Ifd2e4585cd3b9fedf2a2a4573c4f3ea68e0257fb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement %TypedArray%.prototype.filterLars Knoll2018-08-231-1/+56
| | | | | Change-Id: I37bd3ab43f2d896b62fb9afc74e5fe3313b591d2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix %TypedArray%.prototype.subarrayLars Knoll2018-08-231-5/+7
| | | | | Change-Id: I1b199111c55987434645276abfc47a254babc35a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix toLocaleString implementations in (Typed)Array.prototypeLars Knoll2018-08-231-7/+30
| | | | | Change-Id: Idcabd68b1651ad3cae315a16cb0e1361cba21253 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement a couple of methods of TypedArray.prototypeLars Knoll2018-08-231-0/+555
| | | | | | | | Implement the methods that are equivalent to the methods in Array objects. Change-Id: I22d7eeaebd7630bae26507f7d763a11845a09e31 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement TypedArray.prototype.copyWithinLars Knoll2018-08-231-0/+51
| | | | | Change-Id: If0d33cc40e79d0609ad205cfe5a08d2266403867 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix a couple of test failures for detached buffersLars Knoll2018-08-231-12/+21
| | | | | Change-Id: I76308d4699f212758274b75ea1328e7f6a6c6be8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement %TypedArray%.ofLars Knoll2018-08-231-0/+38
| | | | | Change-Id: Icad9c1bedef83be8c6124ca3456a57d528c18733 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix name property of %TypedArray% objectLars Knoll2018-08-231-1/+3
| | | | | Change-Id: Ic0d46afe1ce6c57a839803dc8defccec6b3ddfc8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement the $262.detachArrayBuffer() method for testingLars Knoll2018-08-201-4/+14
| | | | | Change-Id: I30ddca4402254e1cde17712d07ea0bff2ea5f595 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for new.targetLars Knoll2018-07-031-2/+2
| | | | | | | | | 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-8/+8
| | | | | | | | | 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>
* Replace Identifier by PropertyKeyLars Knoll2018-07-021-2/+2
| | | | | | | | Change all uses of Identifier to use the new PropertyKey class and get rid of Identifier. Change-Id: Ib7e83b06a3c923235e145b6e083fe980dc240452 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify the get and getIndexed vtable functions of QV4::ObjectLars Knoll2018-07-021-3/+7
| | | | | | | | This finalizes the refactoring of Object's vtable API. Also added the receiver argument to the method as required by the ES7 spec. Change-Id: I36f9989211c47458788fe9f7e929862bcfe7b845 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify put and putIndexedLars Knoll2018-07-021-1/+5
| | | | | | | | | | Pass an Identifier through those virtual methods to unify the string and integer based versions. Also add the receiver that's required in ES7 Change-Id: I4e7f01b4c97cc80bcb3c485f6343f28213dc9e6b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Proxy support for prototype handlingLars Knoll2018-06-251-2/+2
| | | | | | | | | | | | | | Cleanup get/setPrototypeOf and fix some smaller incompatibilities in the default implementation for Object. Add the methods to the vtable and reimplement them according to spec for ProxyObjects. Clean up the Object.prototype.get/setPrototypeOf/__proto__ methods and fix a smaller bug in the Reflect API for those methods. Change-Id: I6e438753332ec4db963d6cdcf86f340ff212777a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* TypedArray.prototype[Symbol.iterator] and .values are the same functionLars Knoll2018-06-041-2/+7
| | | | | | | | Those two properties are supposed to point to the same function object according to ES7 spec. Change-Id: Ic0917aa28836ad8d665d2177f2f5c2a8d8ad3f6d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use Symbol.toStringTag in Object.prototype.toStringLars Knoll2018-06-041-0/+10
| | | | | | | | | This should make toString comply fully with the JS Spec. Also add a couple of missing Symbol.toStringTag properties. Change-Id: I29e2018b486a0e1d174b58ce7a14f0e42cc78767 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add the start of a Set from ES7Robin Burchell2018-05-301-3/+3
| | | | | | | | | | Based on top of an ArrayObject for now, which is admittedly a bit of a cheat and not matching the "spirit" of the spec. OTOH, that makes it easy to write, and is presumably quite lightweight, so perhaps this is acceptable as a starting point. Change-Id: Ibc98137965b3e75635b960a2f88c251d45e6e837 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix the inheritance structure for typed arraysLars Knoll2018-05-241-24/+46
| | | | | Change-Id: I8a16c1f5e0252b4ea85ff8f623beb39df747e383 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix the length property of various functionsLars Knoll2018-05-241-1/+1
| | | | | Change-Id: Ic782c8c9e211db25ac9e51840957db72ac1116fb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement Symbol.species getter functionsLars Knoll2018-05-151-0/+2
| | | | | Change-Id: I18b3e382e679f95d7cb53b4ed03be2513ea0204b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix asan warningsLars Knoll2018-05-021-2/+8
| | | | | | | Don't try to allocate an array buffer with negative length. Change-Id: Ie95b9bcf7a3108b47df27ef813b7922e9da42b17 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Array Iterator objects from ES6 (22.1.5)Robin Burchell2018-05-021-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>