aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix a crash in the modulus operationLars Knoll2018-05-281-1/+1
| | | | | | | | | | INT_MIN % -1 crashes in C++ with an arithmetic exception, so avoid passing negative numbers into the integer operation, use fmod() instead. Task-number: QTBUG-68513 Change-Id: Ib5a37b55a0f9d41a84c7e6c00ea3f87622155de5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix calling Qt.binding() on bound functionsLars Knoll2018-04-161-1/+3
| | | | | | | | | | | | | | | | | | | 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>
* Fix lookup of enums declared in QML singletonsSimon Hausmann2018-03-161-7/+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>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-6/+6
| | | | | | | | | | | | | 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>
* Correctly set this object when calling scope/context functionsErik Verbruggen2018-02-201-0/+31
| | | | | | | | | | | | | When a function is called that is in a QML scope or a QML context, set the 'this' object to the QML scope. This is done by introducing two new interpreter instructions, which get the context passed in. Note: this patch is 5.11 specific. 5.9 had a similair issue, but the implementation is quite different, so that was fixed separately. Task-number: QTBUG-66432 Change-Id: Ie43150cdd26360025895df28d31264985abf1c15 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split up String type into a regular and a ComplexStringLars Knoll2018-01-191-1/+1
| | | | | | | | Saves some memory for many cases, and will allow re-using the String itself as an identifier Change-Id: I462d63bc6f113dff1dce0de28ee4eea3949a4b95 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix failed assertions coming from the QML list modelLars Knoll2017-12-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | QAbstractItemModel has become more strict in sanity checking the arguments of beginInsertRows and friends with change 00c09e752ff7e482e1308e0e34721dc979204595 in qtbase. Unfortunately, the QML list model was feeding it out of bound rows in some cases, leading to failed assertions. Fix this properly, by calculating the inserted/removed and changed rows on the fly when syncing the list model from the worker thread. Adjust the code in the XML list model as well, so it does call things in the proper order. Fix two tests, one for a minimal change in behavior (more correct now), the other to remove an assertion that is not valid anymore in debug builds (where assertions in QtCore will call rowCount()). Change-Id: Ied85269f78d41b64e06388590be3ed227ac88fdb Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* fix uninitialized variable warningsShawn Rutledge2017-11-291-3/+3
| | | | | | Task-number: QTBUG-64792 Change-Id: I890f2ed57393ea3fc1c5640c56ac04e284a4ce32 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Don't create a CallContext if arguments are being used in strict modeLars Knoll2017-11-151-1/+0
| | | | | | | The strict arguments object doesn't need a callcontext. Change-Id: I1d6419c456b28741167f76937906faffd2d5d3b4 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Clean up ArgumentsObject handlingLars Knoll2017-11-141-6/+2
| | | | | | | Introduce a proper strict arguments object. Change-Id: Ie4e7f904b3a0e03893b18b3c6709f4f25dbc1030 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Finally get rid of the QV4::Function pointer in the contextLars Knoll2017-11-131-2/+4
| | | | | Change-Id: Iad6018f67faa956d385087865fca9d73419e363e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fastpath any integer compatible value in add/sub/mulErik Verbruggen2017-11-081-3/+3
| | | | | Change-Id: Idc0a272e6ee0ae032f9ff1b492e0b5e777ae5f9d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Change signature for call/callAsConstructorLars Knoll2017-11-071-6/+6
| | | | | Change-Id: I159b57acc7a2133ef1ad545aa84e792c63449a57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Further cleanup JSCallDataLars Knoll2017-11-071-62/+38
| | | | | | | Avoid allocations on the JS stack if possible Change-Id: I344cd6dceb6264314f9d22c94db22b22d1d24d14 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Simplify JSCallData constructionLars Knoll2017-11-071-8/+8
| | | | | Change-Id: Ic53532edae9a209aa7125af6f00a9d993d74f1a3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Get rid of the implicit cast operator to a CallDataLars Knoll2017-11-071-1/+1
| | | | | Change-Id: I1c35fbf8f7355bc2393ae931f99e591b800f2f45 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Get rid of JSCallData::call()Lars Knoll2017-11-071-10/+11
| | | | | Change-Id: I6b99e9a7102b3dcb6a7699f54b6456eba6248699 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Rename JSCall to JSCallDataLars Knoll2017-11-071-8/+8
| | | | | | | | 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-20/+13
| | | | | Change-Id: I139a7a31651d9a2ea46ced88978ac4633294bc60 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Move the construction of the JSCall frame into the runtimeLars Knoll2017-11-071-17/+41
| | | | | | | The VME shouldn't have to care about this part Change-Id: I9e49353dce29912f5a222b7ed1b42ace2aa8cebd Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Refactor Call/Construct instructionsLars Knoll2017-11-071-1/+2
| | | | | | | | | | | | | | | | Give them a pointer to argc and argv instead of a pointer to a full callData. Like this we can construct the callData at the end of the JS stack and avoid the need to create an additional copy in VME::exec(). This also opens up the option of completely avoiding all copies for calls into runtime methods. Also make sure that the calldata we pass into other functions is always at the top of the JS stack. Change-Id: I3d0eb49f7bfd7adb9ddabb213422087c66e5a520 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Never truncate the JS stackLars Knoll2017-10-231-0/+2
| | | | | | | | | | | | Truncating it can lead to all sorts of crazy side effects, especially as we'd be extending it again when leaving the function. When that happens already freed JS objects could suddenly become visible to the GC again. Fix this by copying the CallData to set up a new stack frame. This is not yet ideal, as we're copying too much data, but that can be fixed separately. Change-Id: I02a39ce479475bae326f9eddfe6654fbcf8e6d35 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/dev' into HEADLars Knoll2017-10-221-0/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4compileddata.cpp src/qml/compiler/qv4compileddata_p.h src/qml/compiler/qv4isel_moth_p.h src/qml/compiler/qv4ssa.cpp src/qml/jit/qv4assembler_p.h src/qml/jit/qv4isel_masm_p.h src/qml/jit/qv4regalloc.cpp src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4qmlcontext_p.h src/qml/jsruntime/qv4regexp.cpp src/qml/jsruntime/qv4regexp_p.h src/qml/jsruntime/qv4regexpobject.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/qml/v8/qqmlbuiltinfunctions.cpp tests/auto/qml/qml.pro tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp tools/qmlcachegen/qmlcachegen.cpp Change-Id: I1577e195c736f3414089036b957a01cb91a3ca23
| * Merge remote-tracking branch 'origin/5.9' into 5.10Lars Knoll2017-09-201-1/+6
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4compileddata.cpp src/qml/compiler/qv4compileddata_p.h src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4qmlcontext.cpp src/qml/jsruntime/qv4qmlcontext_p.h src/qml/jsruntime/qv4regexpobject.cpp src/qml/jsruntime/qv4regexpobject_p.h src/qml/types/qqmllistmodel.cpp src/quick/items/qquickanimatedimage_p.h src/quick/scenegraph/qsgrenderloop.cpp tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp Change-Id: If20ef62b2c98bdf656cb2f5d27b1897b754d3dc0
| | * Fix reuse of regexp objects by regexp literalsAllan Sandfeld Jensen2017-09-081-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Accoding to the standard the regexp objects created by literals should be separate objects as if calling new. We were violating that by caching the same object for every instance of a literal. This also fixes a problem with leaking values of lastIndex between separate instances of the same global regexp literal. Task-number: QTBUG-62175 Change-Id: Ib22e9ee68de1d1209fbd4212e72f576bc059d245 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Remove unused methodLars Knoll2017-09-151-28/+0
| | | | | | | | | | | | | | | Change-Id: I87291d31c9e0d575211c1d7e364b46cd93b483ed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Fix a smaller bugLars Knoll2017-09-151-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | We shouldn't allocate new ScopedValues after creating a JSCall, as the call could override the scoped values. This wasn't the case here, but it's still cleaner to avoid it. Change-Id: I557a8babe1e118cbd0c1167c1e2813e1fba792a1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Always set the correct FunctionObject when calling JS functionsLars Knoll2017-09-021-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Renamed ScopedCallData to JSCall, enforced passing a JS FunctionObject to it, and added call() and callAsConstructor() methods to it. Change-Id: I30db65c9765c2896b5909fe2105c0934c6dad861 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Move ScopedCallData and ScopedStackFrame into a separate fileLars Knoll2017-09-011-0/+1
| | | | | | | | | | | | | | | Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Don't emit bytecode just to set the thisObject to undefinedLars Knoll2017-09-011-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | The stubs doing the calls often overwrite the value, and can in any case do it more efficiently. Change-Id: I0bb2fb3dcc34e805e0a4a178db02f99816d5cf46 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Add a Value::isFunctionObject() methodLars Knoll2017-09-011-26/+27
| | | | | | | | | | | | | | | | | | | | | | | | This is just as fast as isObject(), and allows for some smaller optimizations. Change-Id: Icc2117941a2851e56e9ef2baf87ba3bca9538581 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Get rid of the FunctionObject parameter to VME::exec()Lars Knoll2017-09-011-3/+2
| | | | | | | | | | | | | | | Change-Id: I5b833d1f76899a5b8fceb0f4fc109b77b1b431fc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Add the current context and function object to CallDataLars Knoll2017-09-011-53/+45
| | | | | | | | | | | | | | | | | | | | | | | | Like this we can avoid creating Scope's when calling functions. Change-Id: I59b82c85eafd3a5437c233aba5f2e8330d5ce104 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Remove unused UnwindException instructionLars Knoll2017-08-281-7/+0
| | | | | | | | | | | | | | | Change-Id: I8b93270b5aebd39df8f88166e183814f6391c0f5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Cleanup and inline context push/pop related codeLars Knoll2017-08-281-20/+6
| | | | | | | | | | | | | | | Change-Id: I38ee6c3039663e10aee47b2005f8755fc9c50289 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Cleanups in the runtime APILars Knoll2017-08-281-37/+13
| | | | | | | | | | | | | | | Change-Id: I0a669d3b643f1120c00767a104622453decd212b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Specialize possible direct calls to evalLars Knoll2017-08-251-8/+29
| | | | | | | | | | | | | | | | | | | | | To avoid additional overhead on most function calls Change-Id: I2477b91fda6216b508c8331884a02b601f65590c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Cleanup object construction instructionsLars Knoll2017-08-251-58/+1
| | | | | | | | | | | | | | | | | | | | | | | | Remove the unused Create/Construct instructions, and rename the single remaining one to 'Construct'. Change-Id: I10163a15681156f37e34d21a05d195d3c22adcff Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Always retrieve the this object from the stackLars Knoll2017-08-101-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | There is actually no point in even having it in the context, as it's immutable and can't become part of a closure. Change-Id: I375fd07b9c442d667488430ebd246e174fdb243f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | More consistent naming of instructions and runtime methodsLars Knoll2017-08-101-15/+15
| | | | | | | | | | | | | | | Change-Id: Ib8af10a48749b16c48d75c91ad215396b201a9d5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Split StoreName into StoreNameStrict and StoreNameSloppyLars Knoll2017-08-101-2/+16
| | | | | | | | | | | | | | | | | | | | | And adjust the name of the corresponding runtime functions. Change-Id: I4adf7b0e069d9b0dff9162cd1271dafc60be854b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Remove some unused runtime methodsLars Knoll2017-08-101-39/+0
| | | | | | | | | | | | | | | Change-Id: Ief0ecf2783fa772a7738d0a6d001998c3967b727 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Refactor context handlingLars Knoll2017-08-101-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the push/pop context instructions to not modify the JS stack anymore, as that can cause conflicts with the VME (and was an ugly hack in any case). Instead, these instructions not return the old context, that is then stored in a temporary. Get rid of Engine::current and Engine::currentContext. The StackFrame structures do now contain the only and authoritive data. This finally gives us a nice setup where we create and destroy frames on the stack when entering/leaving functions. Change-Id: If161e3e941f59865c47ecfe1e094faf62b52bfa0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Avoid creating a CallContext for simple functionsLars Knoll2017-08-101-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | This cuts out quite a bit of overhead when entering and leaving functions. Change-Id: I32670c98a4087ea3b2d45853d9cabff9066399e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Don't throw exceptions in Object::delete(indexed) anymoreLars Knoll2017-08-101-9/+8
| | | | | | | | | | | | | | | Change-Id: I8613ab21eb1435903e2a8514c21fe51f4a305a2f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Don't throw errors from the internal put methods anymoreLars Knoll2017-08-101-13/+12
| | | | | | | | | | | | | | | | | | | | | | | | Instead do it in the VME, where we can then easily separate into throwing and non throwing versions by bytecode. Change-Id: Ie63bd5b3610bb85f26fb8979179b2e239876cd97 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Create separate instructions to create both types of arguments objectsLars Knoll2017-08-101-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | We know at compile time whether an arguments object should be strict or non strict (unmapped/mapped in ecmascript 6), use separate instructions for both cases. Change-Id: Ia23e68003beeda41a1f3597c0ba0980954c80ec7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Inline more of the runtime code into the interpreterLars Knoll2017-08-081-79/+0
| | | | | | | | | | | | | | | Change-Id: I4744c9b39d4de599f02dd91622dd19713c8cc7eb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Remove unused ScopeLars Knoll2017-08-081-1/+0
| | | | | | | | | | | | | | | Change-Id: Ib6a61ca09571114339b4def65140ae102bcd32df Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Change function signatures for call/construct backLars Knoll2017-08-041-55/+33
| | | | | | | | | | | | | | | | | | | | | | | | 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>