aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Merge remote-tracking branch 'origin/5.11' into dev" into ↵Liang Qi2018-06-251-6/+0
|\ | | | | | | refs/staging/dev
| * Merge remote-tracking branch 'origin/5.11' into devUlf Hermann2018-06-251-6/+0
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp src/quick/handlers/qquickhandlerpoint.cpp src/quick/handlers/qquicksinglepointhandler.cpp tests/auto/qml/ecmascripttests/test262 Change-Id: I8908ec8c6116ca626fbd269af7625d4c429429ca
| | * revert change 353164263c55825a0ec72d30128c50560c626334Lars Knoll2018-06-191-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change was too aggressive in trying to avoid marking the array data. We didn't catch all cases where on could be inserting a GC controlled object into the array data. Let's be safe and always mark the content of array data objects. Task-number: QTBUG-68894 Change-Id: Ifbb628be898c0903596b1a483212384295b01df5 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Add Proxy support for prototype handlingLars Knoll2018-06-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Partial Proxy supportLars Knoll2018-06-251-0/+5
|/ / | | | | | | | | | | | | | | get, set and deleteProperty proxying is implemented, the others require some more changes in our engine. Change-Id: I4dd4b154b1a582f5e36cdc9429fa049fd37d5167 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add support for ReflectLars Knoll2018-06-211-0/+2
| | | | | | | | | | | | | | | | Implemented all methods in Reflect, only some smaller bugs left in there. Change-Id: I53d2304d0e59566aec64e200cd995e02afcfc33e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add the start of a Map from ES7Robin Burchell2018-06-011-0/+15
| | | | | | | | | | | | | | | | | | | | Like Set, for the time being, this is baseed on top of ArrayObject: two of them, one for keys, one for values. Again, this goes against the spirit of the spec (which requires nonlinear access), but having the API present is at least a start, and the implementation is easily changed. Change-Id: Idcf0ad8d92eb5daac734d52e8e2dd4c8e0dd5109 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Add the start of a Set from ES7Robin Burchell2018-05-301-0/+14
| | | | | | | | | | | | | | | | | | | | 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>
* | Implement toPrimitive() the way the ES7 spec wants itLars Knoll2018-05-281-0/+1
| | | | | | | | | | | | | | | | Add Dat.prototype[Symbol.toPrimitive] and make use of those methods in the toPrimitive implementation. Change-Id: I82a9a94dcae6822100de364373b3f4de1e3d749b Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* | Cleanup JS stack allocationsLars Knoll2018-05-261-0/+1
| | | | | | | | | | | | | | | | Avoid double writes to the stack, and use scope.alloc() for most allocations on the stack. Change-Id: I8b89273c1b6796d955fc8eeb72c67cff208ef786 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Fix the inheritance structure for typed arraysLars Knoll2018-05-241-0/+5
| | | | | | | | | | Change-Id: I8a16c1f5e0252b4ea85ff8f623beb39df747e383 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devLars Knoll2018-05-241-2/+5
|\| | | | | | | Change-Id: I0127f2c16de1d930bdd8cbccd42ec6785f31ab96
| * Fix crash when incubating objects with non-existent initial propertiesSimon Hausmann2018-05-231-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When incubation is triggered from C++ and reaches the state of setting the initial properties (as supplied to incubateObject), we'd set engine->currentStackFrame to a CppStackFrame that provides access to the correct QML context. As we're not called from the interpreter, the v4Function pointer would be a null pointer. If during the initial property setting an exception is thrown (due to non-existent property access) and a back-trace is created, we'd end up dereferencing v4Function. Change-Id: I7f6b0ba7893bfb4186f55d4c213b4bb602d29aa0 Task-number: QTBUG-68416 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Fixup the throwTypeError internal functionLars Knoll2018-05-231-2/+4
| | | | | | | | | | | | | | Make the function conform to section 9.2.7.1 of the spec. Change-Id: Ieb3295198f407d4404e06a54efb51a8b8496bbd7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Implement Symbol.species getter functionsLars Knoll2018-05-151-0/+3
| | | | | | | | | | Change-Id: I18b3e382e679f95d7cb53b4ed03be2513ea0204b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Call iterator.return when required in destructuring assignmentsLars Knoll2018-05-141-0/+1
| | | | | | | | | | | | | | | | Array destructuring assignments require a call to iterator.return if the iterator hasn't been exhausted during destructuring. Change-Id: I39fe4bc01bef6fb2ad3bda92caf6779fbbddc8e2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add instructions to simplify for-of loopsLars Knoll2018-05-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | Added an IteratorNext instruction to fetch the next iteration value (empty if the iterator is done). This will also help to implement array destructuring without requiring huge amounts of byte code. Change-Id: If96c1e81471e5e2b0b7b2af122238d87741aa371 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Ensure we have a lexical scope for global codeLars Knoll2018-05-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This requires a bit more work than simply pushing a new BlockContext for the lexically declared variables, as eval() and the Function constructor operate on the global scope (including the lexically declared names). To fix this introduce Push/PopScriptContext instructions, that create a BlockContext for the lexically declared vars and pushes that one as a global script context that eval and friends use. Change-Id: I0fd0b0f682f82e250545e874fe93978449fe5e46 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Avoid accessing an object with this == nullptrLars Knoll2018-05-041-1/+1
| | | | | | | | | | | | | | | | | | Get rid of a circular dependency when initializing StringObject.prototype, by setting it's string value later during the initialization process. Change-Id: I5bdaff3936c1f8af12c4d53f95747b8aa43f4ef6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Rename ForeachIterator to ForInIteratorLars Knoll2018-05-041-2/+4
| | | | | | | | | | | | | | | | | | As it's being used for for(... in ...) loops. Also add a ES6 compatible iterator interface to it, so that we can unify the handling of for-in and for-of. Change-Id: I264f88ed049484945f5ea7e8bdf0227187456ba2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | The length property of function objects is configurableLars Knoll2018-05-031-1/+1
| | | | | | | | | | Change-Id: I657be2e2eb4dfd86850bb73e85d4ddd24f0b8986 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add Generator supportLars Knoll2018-05-031-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Implement StringIteratorLars Knoll2018-05-021-0/+4
| | | | | | | | | | | | | | | | Add support for String.prototype[Symbol.iterator] and the StringIterator object. Change-Id: I72c4f988e4f363be1af51f9cc5f8e83af43cd151 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Implement support for arguments[Symbol.iterator]Lars Knoll2018-05-021-0/+2
| | | | | | | | | | Change-Id: Ieb60e2d8f41c38146b588bc8cd225a2a567e0956 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Cleanup creation code for builtin functionsLars Knoll2018-05-021-8/+4
| | | | | | | | | | | | | | | | 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>
* | Add Array Iterator objects from ES6 (22.1.5)Robin Burchell2018-05-021-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Add SymbolObject, well known symbols and fix most remaining issuesLars Knoll2018-05-021-0/+20
| | | | | | | | | | | | | | | | | | Added SymbolObject, the equivalent to StringObject which was still missing so far. Added the predefined standard symbols, and fixed most test failures related to symbols. Change-Id: I1e28b439e7c4f5141b4a09bd8fb666c60691f192 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Implement Symbol.for and Symbol.keyForLars Knoll2018-05-021-1/+1
| | | | | | | | | | Change-Id: I5fde731b3a1a6d7c15154881ed82549b2800d104 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Partial Symbol supportLars Knoll2018-05-021-9/+21
| | | | | | | | | | | | | | | | | | Added basic infrastructure to create symbols and convert them back to strings. In addition, storing and retrieving of symbol based properties in Objects works. Change-Id: I185f7aa46e7afa19db5a801102142892e03b7bf1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Garbage collect identifiersLars Knoll2018-05-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented by storing a backpointer to the Heap object in the identifier. Since identifiers now point back to their originating String or Symbol, we can now easily mark all identifiers that are still in use and collect those that aren't. Since Identifiers are 64bit also add support for holding an array index in there. With that an identifier can describe any kind of property that can be accessed in an object. This helps speed up and simplify some code paths. To make this possible, we need to register all IdentifierHash instances with the identifier table, so that we can properly mark those identifiers. Change-Id: Icadbaf5712ab9d252d4e71aa4a520e86b14cd2a0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove String dependency from InternalClassLars Knoll2018-05-021-26/+26
| | | | | | | | | | | | | | | | This is required, so we can also use Symbols in the internal classes. Change-Id: I630e7aa7b8b16d5a94041f8d18515fd582f94264 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Rework catch context handlingLars Knoll2018-05-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | Remove the need for a specialized catch context, instead use a regular block context, that also captures the catched variable. This also removes the need to do lookups by name inside a catch expression. Change-Id: I8b037add7f423922e2a76b4c0da646ca7e25813a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Clean up handling of the 'caller' propertyLars Knoll2018-04-261-2/+7
| | | | | | | | | | | | | | | | | | | | This brings it closer in line with the ES8 spec. Also remove a couple of tests testing the 'caller' property of non strict functions, as it's not mandated by the spec and we never set it. Change-Id: Icece8a03989c474df1eae0e4e77b356e49575b32 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Get rid of some outdated codeLars Knoll2018-04-121-6/+1
| | | | | | | | | | | | | | There's no point in trying to treat syntax errors specially here. Change-Id: Idde8f9c9669f183e1b8f5b17bb7e4299fc5f1e5f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | garbage collect InternalClassLars Knoll2018-04-121-28/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Better encapsulation for EngineBase::internalClassLars Knoll2018-04-121-38/+37
| | | | | | | | | | | | | | | | Turn it into a method instead of accessing the array directly to simplify refactoring. Change-Id: I197b56c8f58cfdfd294f429e6b15268c755f9837 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Clean up Engine::newObject/newArrayObjectLars Knoll2018-04-121-10/+4
| | | | | | | | | | | | | | They don't need a prototype argument neither anymore. Change-Id: I80fa99cb382e8dca4cfa51fdd87b4c9b0f59573a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Disambiguate different allocation functions in the memory managerLars Knoll2018-04-121-47/+47
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Cleanup MM::allocObject()Lars Knoll2018-04-121-13/+15
| | | | | | | | | | | | | | | | The prototype argument has been unused for quite some time, finally remove it. Change-Id: Ifcebe413a1951ed972b370afc48640bd22969943 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Optimize MM::allocManaged()Lars Knoll2018-04-121-0/+2
| | | | | | | | | | | | | | | | We can manage without calls to changeVTable() here, as the set of classes allocated with this is rather limited. Change-Id: I804e4850b91c61ebbca8a04edbe51deac911928d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove the pool allocator from InternalClassLars Knoll2018-04-121-7/+4
| | | | | | | | | | | | | | | | Makes it easier to transition it over to be controlled by the GC. Change-Id: I6bea738b3852abfc7870b71e639efc595eeb28fc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-03-171-21/+0
|\| | | | | | | Change-Id: I2e3ba907a6afcaa69354a894259c7b7accf3e3ac
| * Fix lookup of enums declared in QML singletonsSimon Hausmann2018-03-161-21/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given the following expression var x = MySingleton.MyEnumValue where MySingleton is a QML (composite) singleton and MyEnumValue comes from a QML declared enum, we had code in place up to (and including) 5.10 to attempt to optimize that expression to a enum constant at compile time. In 5.10 that optimization does not exist anymore. In <= 5.10 we would also skip the optimization under certain circumstances (too many statementes, etc.). The fallback that is in place for handling this at run-time tried to be smart by avoiding the QQmlContextWrapper::get lookup and return straight a reference to the singleton as QObject. That works for regular property lookups, but it fails when trying to look up something like an enum, that isn't a meta-object property. Change-Id: I1819b9d8ae06a3f595e067bf5b018c4065be76bb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-03-031-1/+1
|\| | | | | | | Change-Id: I308b964d86ca01916f6af7d6e3f71557e3624eca
| * Silence a GCC 8 warning in qv4engineVille Voutilainen2018-02-281-1/+1
| | | | | | | | | | | | | | | | qtdeclarative/src/qml/jsruntime/qv4engine.cpp:913:78: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct QV4::Property’ with no trivial copy-assignment [-Werror=class-memaccess] memcpy(argumentsAccessors, oldAccessors, oldSize*sizeof(Property)); Change-Id: I6e3d6a1a26fda33aa47c315a183edba9dcd0c0b9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-02-271-22/+22
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4internalclass.cpp src/qml/parser/qqmljslexer.cpp src/qml/qml/v8/qv8engine.cpp src/qml/util/qqmladaptormodel_p.h src/quick/items/qquickanimatedsprite.cpp tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp Change-Id: I16702b7a0da29c2a332afee47728d6a6ebf4fb3f
| * use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-02-221-3/+3
|\| | | | | | | Change-Id: I8cca650fbb1904ecba59da909a08dba3cc574add
| * WinRT: Do not call canAllocateExecutableMemory from static initializerOliver Wolff2018-02-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the code generation capability is not set, the first call of canAllocateExecutableMemory will cause a warning about suboptimal performance. The qWarning code checks, which thread caused the message and QThread::current sets QCoreApplicationPrivate;s theMainThread when it is called for the first time on Windows. If we call that function inside a static initializer, it will be called before QCoreApplication is created and thus set the main thread to the one that called the function. This will cause a warning about QApplication not being created inside the main() thread, but more importantly, delivering of events will not work in WinRT applications afterwards. Task-number: QTBUG-66418 Change-Id: I3b6bf804983644b5ae5fe2288a587dc95fab2c8b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Add a feature for QML locale supportUlf Hermann2018-02-151-0/+6
| | | | | | | | | | | | Change-Id: I1cfb2da317f52709011b67a68e87a73ed24ef6d6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>