aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
Commit message (Collapse)AuthorAgeFilesLines
* Only warn about incompatible parameter types passed from QMLUlf Hermann2019-02-211-9/+22
| | | | | | | | | Throwing a TypeError is too drastic. We need to properly deprecate this pattern before we actually enforce the compatibility. Fixes: QTBUG-73943 Change-Id: I00313ad7aed4021a7368fd014e2bfc6443b177e3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix PropertyKey::isArrayIndexErik Verbruggen2019-02-191-1/+1
| | | | | | | | | PropertyKey::asArrayIndex has a hole at UINT_MAX, so make isArrayIndex have the same hole. Change-Id: I85d0f14680c27d018644056960d75d94aee68646 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Check parameter types when invoking C++ functions from QMLUlf Hermann2019-02-171-9/+31
| | | | | | | | | | | | | | | We now check if the given parameters can be converted to the expected arguments of the function being invoked and throw a type error if not. Previously we would still invoke the method with random parameters. [ChangeLog][QtQml][Important Behavior Changes] The parameters passed to C++ functions from QML are now checked for compatibility with the expected arguments. If they cannot be converted, a type error is thrown in JavaScript and the function is not invoked. Fixes: QTBUG-73405 Change-Id: If16089510d314bb7cdb7d4db86478114c61281a8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Bring behavior of String.replace() in line with other enginesLars Knoll2019-01-251-14/+25
| | | | | | | | | | | | | | | | "x".replace("x", "$1") gives "$1" in both JSC and V8, as there are no captures that could be used as a replacement for $1. Implement the same behavior as it's the most logical thing to do (even though it's undefined according to the spec). Two digit captures ($nm) work in a way that they get applied if $nm captures exist. If there are less than nm but more than n captures available $n is replaced by the n'th capture and m is copied over verbatim. Change-Id: I8b5f576f2c42c8334859ab7854dcdf07104dd35b Fixes: QTBUG-73152 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.12.1' into 5.12Qt Forward Merge Bot2019-01-212-20/+48
|\ | | | | | | Change-Id: I1e0bbc35807bd0f7f96694539d2fbec0f83ddb16
| * When matching RegExps catch JIT failuresUlf Hermann2019-01-092-20/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | The Yarr JIT can generate code that fails to evaluate the RegExp at runtime. In that case we need to fall back to the interpreter. Also, don't needlessly cast the unsigned return value of RegExp::match to signed int before range-checking it. And fix some typos in the comments for the disassembler dumps. Fixes: QTBUG-72879 Change-Id: Ic8f80c076d6461d714816a9f66e1cac1d9b0c7a8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Annotate stack traces when frames are elided through tail callsErik Verbruggen2019-01-153-0/+8
| | | | | | | | | | | | Task-number: QTBUG-72407 Change-Id: I98b96852309fc783a945797185f666196513d24b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Make sure JIT is disabled when building for ILP32 ABIDmitry Shachnev2019-01-091-1/+1
|/ | | | | | | Change-Id: Id8d06ed3708fdb9d1470fd3f83c3069138988074 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Quote stringified generic variants on JSON.stringifyUlf Hermann2018-12-201-1/+1
| | | | | | | | | | A string representation of those is unlikely to be actual JSON, and even if it is, we don't want to use it as such. Fixes: QTBUG-72674 Change-Id: I6815366a0176d9725ff4840d3fc545792ce00535 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Merge remote-tracking branch 'origin/5.12.0' into 5.12Qt Forward Merge Bot2018-12-072-1/+2
|\ | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4script.cpp src/qml/parser/qqmljslexer.cpp Change-Id: I82252a8c504a4b77c45f4f8efe849ff9acb949fd
| * Initialize Qt_AllocaWrapper allocation with zeroesJanne Koskinen2018-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | YarrJIT generated ASM assumes the data to be zeroed. In the wrapper we allocate from heap where there can be random data. It needs to be initialized to zero. Task-number: QTBUG-71663 Change-Id: I67c04e7b6d4bf4b92124aedc4f7bcfdc1a43c833 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Generate lookups into the global object more aggressivelyLars Knoll2018-11-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since change 9333ea8649838d7e0400b0e94c8cbd4fa5d216b0, we lookup properties in the QML context object before the global object to have proper scoping rules for QML. Unfortunately this lead to a performance regression when using global properties such as Math in imported script files, as the lookup would always go through the qml context first. This can be fixed, as we know that the global object is frozen in qml mode, and the standard names of properties in the global object are illegal to use in QML. So simply check for those names in the code generator and create lookups into the global object for those. Change-Id: I4b2089178c9e5f9440abdfd834cf7d92c3c0e2c3 Fixes: QTBUG-71591 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Fix line number reporting in scripts when lookups are enabledSimon Hausmann2018-12-031-0/+1
| | | | | | | | | | | | | | | | | | | | For regular object property lookups, we correctly store the byte code instruction pointer that allows us to determine the correct line number in case of a reference error. We need to do the same for lookups in the global object. Change-Id: I0f44dd06b5f66df9626576eeaa802b18fa4a26cd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Fix parsing of js files via Qt.include()Simon Hausmann2018-11-293-22/+4
| | | | | | | | | | | | | | | | | | | | | | Make sure to parse them as JavaScript, not as QML, so that certain keywords such as char or double map to identifiers as expected. Also removed an unused function. Fixes: QTBUG-71524 Change-Id: Ie8a8dabe717ee12def6af512943e6d01efcf9876 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | V4: Avoid copying WeakValues with wrapped QObjectsUlf Hermann2018-11-222-4/+9
| | | | | | | | | | | | | | | | | | | | | | Such WeakValues are kept alive until the respective QObject is deleted. Therefore they are quite expensive. In this case we don't actually need a copy as on retrieval we only want a ReturnValue and on inserting we just want to replace the value in the map. Fixes: QTBUG-71817 Change-Id: I385c55140337d468289046243941077ba1ff61a3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Ensure our builtin constructors are subclassableLars Knoll2018-11-2214-24/+100
| | | | | | | | | | | | | | | | | | 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>
* | Fix signed/unsigned warning in VS 2017Jason Erb2018-11-191-1/+1
| | | | | | | | | | | | | | Task-number: QTBUG-71862 Change-Id: I836756d004753420bfb7a00013ade0229bd5946e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.12.0' into 5.12Qt Forward Merge Bot2018-11-165-20/+87
|\| | | | | | | Change-Id: I7623438dde316ae1e97802f91991f2e7ccc205a5
| * Expose let/const variables from imported JS scriptsJüri Valdmann2018-11-024-19/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows QML to access let/const variables defined in JS files. Detailed changes: - The recently added ContextType::ScriptImportedByQML is changed to avoid creating Push/PopScriptContext instructions, similar to ContextType::ESModule. - QV4::Module is changed to also work with CompilationUnits which are not ESModules. In this case QV4::Module will behave as if all lexically scoped variables were exported. - CompilationUnit is changed to support instantiating and evaluating QV4::Modules for non-ESModules as well. - QQmlTypeLoader is changed to always create QV4::Modules for evaluating scripts. For the non-ESModule case, the QV4::Module is evaluated inside a QV4::QmlContext, as before. - A pointer to the QV4::Module is added to QV4::QQmlContextWrapper, and used in virtualGet to access the let/const variables in the CallContext. Access is read-only. Fixes: QTBUG-69408 Change-Id: I6f299363fdf5e1c5a4a0f1d9e655b4dc5112dd00 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Don't crash when compiling with QT_FORCE_ASSERTS enabledLars Knoll2018-11-021-1/+1
| | | | | | | | | | | | Change-Id: I9af3dc69cc5baf1c35e836345590baf5b55b1bed Fixes: QTBUG-70937 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Create proper template objects for tagged templatesLars Knoll2018-11-053-0/+12
| | | | | | | | | | | | | | | | If a tagged template gets evaluated multiple times, the underlying template object is shared. Change-Id: Ie2f476fbc93d5991322ce1087c42719a8d8333ae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QV4::Scoped: Use explicit operator boolJüri Valdmann2018-11-051-4/+1
|/ | | | | Change-Id: Ibf41d6051fe35aac37fb40ca3c499d0daacebc65 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clone ContextType::Global as ContextType::ScriptImportedByQMLJüri Valdmann2018-11-012-3/+5
| | | | | | | | | | Add new enum value QV4::Compiler::ContextType::ScriptImportedByQML, which behaves exactly the same as ContextType::Global. A follow-up patch will change the behavior slightly. Task-number: QTBUG-69408 Change-Id: I20d27804fd1433f2229704546bcd78a0ac108c01 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add convenience functions for creating and inspecting error objectsAllan Sandfeld Jensen2018-10-302-0/+18
| | | | | | | | | Serves to simplify porting from QtScript by replacing QScriptContext::Error and QScriptContext::throwError(). Change-Id: I4bfe404c358c50aaf3b5469a4304fec97552bf24 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add missing "We mean it." warningLiang Qi2018-10-241-0/+11
| | | | | Change-Id: I19ca6e366cb8b2ca069ac2f4b2c2c834bcea8f3d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* INTEGRITY: Fix build failures on 64-bit ARMPasi Petäjäjärvi2018-10-224-12/+12
| | | | | Change-Id: I44a90dec16dc1421a32a7770b353a4df14c057f9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Store the instruction pointer in more instructionsErik Verbruggen2018-10-151-0/+4
| | | | | | | So backtraces will show the correct line number. Change-Id: I6e79f6b3f461956f7f6d98743aff684b894426cf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* V4: Conform method_objectLiteral arguments to equal other methodsErik Verbruggen2018-10-123-3/+3
| | | | | | | This runtime function was the only one taking argc before arguments. Change-Id: If0b049697f7fcc2746e8d287193a5b1230a6ea56 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QML Engine: Support for JavaScript PromisesValery Kotov2018-10-116-2/+1308
| | | | | | | Support for JavaScript Promises. Change-Id: I90ce328b35f3bdf3fd666a8829f22b5d56b6f861 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* ES7: Implement Tail Position Calls in the runtimeErik Verbruggen2018-10-056-9/+50
| | | | | Change-Id: If1629109722496b3fd10b36b2376548440f2fee9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* ES7: Detect Tail Position Calls and pass that to the runtimeErik Verbruggen2018-10-043-2/+16
| | | | | | | Doing the tail call in the runtime will come in a follow-up patch Change-Id: I8224aac0edbdc765ee9b97703948edd52fd33f3e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove unused member variableLars Knoll2018-09-271-1/+0
| | | | | Change-Id: I6bf4f97d147f13a19a30e3bfdcadefe55fb656f8 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Get rid of ArrayData::ComplexLars Knoll2018-09-274-4/+4
| | | | | | | It's been pretty much unused. ArrayData::Simple does the job. Change-Id: I0fbd0b7787499244f4c8ca00b3ba7330a6640b75 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Speed up instanceof operationsLars Knoll2018-09-276-32/+62
| | | | | | | | | | | 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-273-12/+19
| | | | | | | | | | 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>
* Refactor deletion of propertiesLars Knoll2018-09-274-40/+46
| | | | | | | | | | | | | In line with the previous commit, allow entries with a valid PropertyKey, but invalid attributes in the InternalClass. Those entries mark a deleted property. This cleans up/unifies some of the code in the internal class implementation and allows re-using the slot if a deleted property gets added again. Change-Id: I1bada697486e3cafce7689bae87b7f884200dd99 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Don't move any property slots in Objects anymoreLars Knoll2018-09-272-70/+24
| | | | | | | | | | | | | | | Until now, changing an existing property into an accessor property would cause the slots in the object to get re-arranged to make space for the additional setter required. Change this by dropping the requirement that getter and setter slot have to be next to each other. This has the advantage, that any slot we define to be at a certain position in the internal class/object will stay there and we can use that assumption to optimize accesses to the slot. Change-Id: Ib37c2a49fc6aae42ea4b2da36ac1dc3036540c12 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Get rid of remaining assumptions about setter being next to gettersLars Knoll2018-09-2710-111/+136
| | | | | | | | The only place where we now assume that getters and setters are next to each other in the MemberData is in the internal class. Change-Id: I3285f3abb1cbfe051853e808339cd360eb602262 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Differentiate between finding for get and set in InternalClassLars Knoll2018-09-277-26/+38
| | | | | | | | This is required, so we can get rid of the requirement that getter and setter live next to each other in the member data. Change-Id: I2ed57a171628af4dfecd1836d00e958c6bed9d4f Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Refactor InternalClass::find()Lars Knoll2018-09-2710-64/+103
| | | | | | | | | Specialize find() into several methods for different purposes. Prepares for further cleanups and being able to split up getter and setter for accessor properties. Change-Id: Id4ec5509ac1a1361e2170bbfc2347b89b520c782 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Small refactoring of PropertyHash::lookup()Lars Knoll2018-09-272-10/+13
| | | | | Change-Id: I0c8cbf0914b8de4613ab203876636746f41d9718 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Better inheritance structure for functionsLars Knoll2018-09-236-33/+63
| | | | | | | | 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-233-6/+16
| | | | | Change-Id: I913f9429a9238860a5b4e9dc84d217ec824f25c1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove unused argumentLars Knoll2018-09-232-9/+8
| | | | | Change-Id: I1f2c796b50d05c238fad36434b2545604a401fbf Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Make Object::getOwnProperty() constLars Knoll2018-09-2315-20/+20
| | | | | | | | 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-1750-474/+437
| | | | | | | | | | | | 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>
* Some more optimizations to Object::internalPut()Lars Knoll2018-09-161-0/+12
| | | | | Change-Id: Ib1b224ad27428ca37450f269b491cfa9d82e559a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Optimize Object::virtualGet()Lars Knoll2018-09-162-22/+36
| | | | | | | | Optimize virtualGet() for the common case where the proto chain are all regular objects. Change-Id: I51eea9a4b96033be4effc2072fedc5b9b08e8440 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Store InternalClass::nameMap in a MemberDataLars Knoll2018-09-163-20/+124
| | | | | | | | | | This helps make that memory known to the GC as well, and makes marking of internal classes much more efficient, as we don't mark the property keys repeatedly (even if they are shared between different internal classes) Change-Id: Ibb7e5383672d7657926bd08bf13f73f7680a9f31 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Optimize some LookupsLars Knoll2018-09-141-1/+12
| | | | | Change-Id: Ia8dfe95d6a51a8645ece983e050bf27d868715f8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>