aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Fix integer divisionErik Verbruggen2017-06-081-1/+3
| | | | | | | | 0/-1 == -0.0 in JS, which cannot be encoded in an int. Change-Id: Ice5b09fa3d42dc24d543d4581d77c6bfa743b2ca Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of the MemoryManager pointer inside StringLars Knoll2017-05-191-2/+2
| | | | | | | We can always get the pointer through the internalClass. Change-Id: If68432845e7c67da70d9e19aef1a90ebe1e6056b Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Move the list of default internal classes into EngineBaseLars Knoll2017-05-191-1/+1
| | | | | | | | And store them in an enumerated array. This will simplify upcoming changes. Change-Id: I82eac03b9f6264843ae625e36e150464fe08be9d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Optimize Runtime::method_get/setElementLars Knoll2017-05-101-25/+79
| | | | | | | | | | | | | This is now actually just as fast as the lookup code, so disable the generation of lookups for indexed accesses for now. This saves some runtime memory, as we don't need the data structures for the lookup. We can reintroduce lookups, once they offer a real performance benefit. Change-Id: Idc3fa7b248e2e25b4b2cd60d5053e2815634c8b7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Silence GCC 7 warnings about implicit fallthrough in Qt codeThiago Macieira2017-04-201-0/+2
| | | | | | | | | | | | | | | This only deals with Qt code. MASM has a lot of those left. We should just update from upstream instead to get the fixes. qv4regalloc.cpp:660:52: warning: this statement may fall through [-Wimplicit-fallthrough=] if (leftSource->type == DoubleType || rightSource->type == DoubleType) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ qv4regalloc.cpp:666:13: note: here case OpBitAnd: ^~~~ Change-Id: I7814054a102a407d876ffffd14b6b0e2d6b03689 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9Simon Hausmann2017-03-251-0/+2
|\
| * Merge remote-tracking branch 'origin/5.8' into 5.9Simon Hausmann2017-03-151-0/+2
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qqmltypecompiler_p.h src/qml/qml/qqmltypeloader.cpp src/qml/qml/qqmltypeloader_p.h Change-Id: I4894555ab7a0879b56bbda7a46d16d1c40c19e7c
| | * JS: Fix 0 == -0Erik Verbruggen2017-03-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The double representation of 0 and -0 are different in the sign bit, so the raw values are not the same. However, neither is managed, so non-strict equality comparison erroneously returned false. Task-number: QTBUG-56808 Change-Id: If966ddbc9f1a1c006dc5901aecafca063f71e404 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | | Complete transition to standard layout classes for JIT accessSimon Hausmann2017-03-211-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the Runtime function pointer array into EngineBase so that we can eliminate the last use of qOffsetOf. For improved cache locality the memory manager point is now also located in the EngineBase. Change-Id: I0b3cf44c726aa4fb8db1206cc414a56c2f522a84 Task-number: QTBUG-58666 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Protect CompilationUnit member usage against word size differencesSimon Hausmann2017-03-171-3/+3
|/ / | | | | | | | | | | | | | | | | Currently we only use the runtimeStrings offset in JIT generated code, so move that into a standard layout base class and use that instead. Task-number: QTBUG-58666 Change-Id: Id933ba5df3a6990e89886c2b328e9e814ec5e413 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Fix a potential crash in pushWithScopeLars Knoll2017-02-131-2/+6
| | | | | | | | | | | | | | | | | | | | | | toObject() can potentially allocate a new object. If a GC accurs between that allocation and newWithContext(), we'd free the withObject Fixes a crash on test262 ch12/12.10/12.10-2-1 when running it with aggressive GC. Change-Id: Id8e957a748658a8f31ae39ff83509e9574ed51f7 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* | jsruntime: Add a vtable hook on Object for instanceofRobin Burchell2017-01-261-27/+7
| | | | | | | | | | | | | | | | | | | | This will hopefully allow us to customize the behavior of QmlTypeWrapper to allow comparison QMetaObject comparison against a QObjectWrapper lhs (i.e. foo instanceof Item will hopefully be possible) Task-number: QTBUG-24799 Change-Id: I780c8b424ec14d6ed6f93eeac46390e2fc920000 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Add some asserts to help debuggingLars Knoll2017-01-221-0/+1
| | | | | | | | | | Change-Id: I49419e45ee2686e6e8646c49b839b4d77f2e05fd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-141-109/+108
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp src/qml/qml/qqmlimport.cpp src/quick/items/context2d/qquickcontext2dtexture_p.h tools/qmleasing/splineeditor.h Change-Id: I8f6630fcac243824350986c8e9f4bd6483bf20b5
| * Optimize code in instanceOf() of FunctionObject::protoForConstructor()Lars Knoll2016-12-131-10/+11
| | | | | | | | | | | | | | Saves around 1.5% instructions for the Earley Boyer benchmark Change-Id: I552d324d5e1713f655ab9909f30c9527bb4ff777 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Start cleaning up the QmlContextWrapperLars Knoll2016-12-041-1/+1
| | | | | | | | | | | | | | | | | | The class should get merged with the QV4::QmlContext class. Simplify the cleanup by moving both classes into a common file. Change-Id: I0074da79701d5f41eb51681b70fcde85bfd45fc1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Hint the compiler that exceptions are exceptional and not the hot pathErik Verbruggen2016-12-011-3/+4
| | | | | | | | | | Change-Id: I981f0cb643a67027a37db38363e26b220d3c216f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Cleanup Value::isObject/objectValue usagesLars Knoll2016-11-291-38/+47
| | | | | | | | | | | | | | | | Try to avoid calling both as objectValue() already checks isObject(). Change-Id: I1d770d4d9dabed4ea4cc3e322b8fdc5a64f5bd2b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Clean up Value::isString()/stringValue() combinationsLars Knoll2016-11-291-36/+47
| | | | | | | | | | | | | | | | It's enough to just call stringValue(), as that already does the isString() check. Change-Id: I7be0e643a7975c0704b4c9c43b337deb8db9fce0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Clean up some duplicated methodsLars Knoll2016-11-291-23/+0
| | | | | | | | | | Change-Id: Iad64dd2c330ca85a28f8f5c776b0ede623203558 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-141-2/+2
|\| | | | | | | Change-Id: I905dcd29377bf1b2e0ee086823b54277d18e78dd
| * V4: check for exceptions after convertThisToObjectErik Verbruggen2016-11-241-2/+2
| | | | | | | | | | | | | | | | | | The method_convertThisToObject method was invalidly tagged as not needing exception checks. As a side-effect method_pushCatchScope and method_popScope are now correctly tagged with a NoThrowEngine. Change-Id: I11d987e62136216a29eadcbd641546311030058f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-10-181-6/+6
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4variantobject.cpp src/qml/types/qquickworkerscript.cpp src/quick/scenegraph/util/qsgdefaultpainternode_p.h tools/qmljs/qmljs.cpp Change-Id: I876242714ec8c046238d8fd673a5ace2455b2b59
| * QML: Make Heap::RegExp and Heap::String trivialErik Verbruggen2016-10-051-3/+3
| | | | | | | | | | Change-Id: Ia8eda67c9d59069d3a64363699720a79ba1348a1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * QML: Introduce destroy() on Base subclassesErik Verbruggen2016-10-051-3/+3
| | | | | | | | | | | | | | | | This removes the destructors of subclasses of Base, making them nearly trivial. Change-Id: Ia6f7d467e87899b5ad37b8709a8f633a51689d59 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-10-011-3/+3
|\| | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4qobjectwrapper.cpp Change-Id: I1a125b2334532ec5de4af39c0d6628890f4d0587
| * QML: Make all context objects trivialErik Verbruggen2016-09-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change also adds a check to the d() calls for Managed, verifies that the object has been initialized. This is only done for debug builds. To prevent other code from tripping the check, a number of other classes are either marked as trivial, or do initialization in the constructors. Because of template function changes in them memory manager (those now call init() instead of in-place new), String has an extra parameter to force it to temporarily use an old/unmodified template function. Change-Id: I8c35161ce7680835d830638b6d21498c5129b02b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-09-211-8/+8
|\| | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4isel_moth_p.h Change-Id: I8e86a649d1ef8ad27dc66cc8c290093b2faabc69
| * Fix binding dependencies when used in together with functionsSimon Hausmann2016-08-301-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | When a function called from a binding would access a scope or context property, we would end up registering those dependencies as permanent dependencies in the expression and set m_permanentDependenciesRegistered to true. Then after the binding evaluation itself, we would not end up registering the real binding's permanent dependencies. Change-Id: I3b6c1c181aa064d535362c736b5b2bbc4f576ba9 Done-with: Erik Task-number: QTBUG-54394 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Qml jsruntime: replace 'foreach' with 'range for'Anton Kudryavtsev2016-09-161-1/+1
|/ | | | | Change-Id: Ieb99b73037bc5b07caf62121d51a17c3025df97c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-191-3/+3
|\ | | | | | | Change-Id: I326616356ee26d4532c6d57558c43c919f0a900d
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-181-3/+3
| |\ | | | | | | | | | Change-Id: I20c622263f40c322954328e4d10a8071db3ca6d1
| | * Fix throwing an exception inside a finally block with a return in catchSimon Hausmann2016-08-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When exiting a catch block with a return statement, we'll unwind the exception handling manually and emit finally statements right before jumping to the exit block. If we throw an exception in the final block, we'll end up using the exception handler of the catch block that contains the return statement, which means we'll end up popping the exception scope one too many times, once through ScopeAndFinally::CatchScope in unwindException() and then when executing the exception handler block. The latter we should not be executing, instead we should jump straight to the exit block. Therefore any statements emitted as part of the manual exception unwinding (finally block here) need to be part of a new basic block with no exception handler. This bug became visible in debug builds where the Scope destructor compares the scope mark against the engine stack top to ensure correct cleanup order (which was wrong). However that in turn was hidden in debug builds again due to an accidental = instead of == in a Q_ASSERT. With the Q_ASSERT fixed this use-case is covered by ch12/12.14/S12.14_A13_T3 Change-Id: Id74a1b2bb3e063871b89cc05353b601dd60df08e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Fix qmldevtools for QML compilerSimon Hausmann2016-08-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Re-add some run-time functions in the qmldevtools and replace the use of the WTF assert that pulls in some wtf functions with a Q_ASSERT. Change-Id: Id7b4bdb02c54e8b498db3fab78870463fa4fac9a Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Fix String(-0)Lars Knoll2016-08-091-1/+1
| | | | | | | | | | | | | | | | | | | | | According to the spec, this should give "0", not "-0". Change-Id: I7c1e2a777d41cdf13807f314c2adcc5e7ed1c757 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Revert "QML: When available, use QQmlAccessors to read properties."Simon Hausmann2016-07-141-172/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f6fee09942de7901a708c4e16db0c7c82550e8c5. The accessor pointers were embedded in the generated machine/byte code, which makes it non-relocatable. As discussed, for the moment the ability to have relocatable code is prioritized. But the goal is to re-enable accessor accelerated property access through lookups. Change-Id: I18ec9ce31901c1fae3e58ac0c41bc87791e8c380 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Proper construction of QString with known size and known charAnton Kudryavtsev2016-07-061-2/+2
| | | | | | | | | | | | | | | | | | | | | ... by corresponding ctor. Don't use fill() for this case. Change-Id: Ife5711a946524c0bbac6c5431ef7052275fc3d33 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Replace QString::trimmed() with QStringRef::trimmed()Anton Kudryavtsev2016-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | ... where it's possible. Reduce allocations. Change-Id: I503507f8f29e2455113c48e50389a6fdf80e1d16 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | V4: Pass scope around as parameters inside the runtime.Erik Verbruggen2016-06-221-31/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-241-0/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine_p.h src/qml/jsruntime/qv4runtime_p.h src/qml/qml/qqmldelayedcallqueue.cpp src/qml/qml/qqmlvaluetypewrapper.cpp src/qml/qml/qqmlvmemetaobject.cpp src/qml/qml/v8/qv8engine_p.h tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I3f0608c7beb88088cbbef4d0db59920f56deaea9
| * | V4: allow inlining of ExecutionEngine::{qml,js}Engine()Erik Verbruggen2016-05-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | All other changes are just to be able to include qv8engine_p.h in qv4engine_p.h Change-Id: I71ba2ec42cdc20d5c7d97a74b99b4d1ada1a5ed8 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-131-3/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsapi/qjsengine.cpp src/qml/qml/qqmlengine_p.h src/quick/items/qquickanchors.cpp src/quick/items/qquickanimatedimage_p_p.h src/quick/items/qquickitem_p.h tests/auto/qml/qqmlecmascript/testtypes.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tests/benchmarks/qml/creation/tst_creation.cpp Change-Id: I65861e32f16e8a04c7090a90231627e1ebf6ba6f
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-061-3/+2
| |\| | | | | | | | | | Change-Id: I3c6a93917cb46868cdb9dd50566b90c70f67102e
| | * Fix crash when trying to call a property of the scope or context objectSimon Hausmann2016-05-011-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For calls on properties of the scope or context object the thisObject parameter in the callData is a reference to the QmlContext, not a real object - therefore the toString conversion fails. Task-number: QTBUG-52340 Change-Id: I08d01cc5c05920c2fac46ddd40fa41e630bcade3 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | | De-inline static methods of struct Runtime.Friedemann Kleint2016-05-091-0/+345
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They are accessed via function pointer, so, inlining them does not have any effect. Move the implementation into qv4runtime.cpp, fixing MinGW-errors: qtdeclarative/src/qml/jsruntime/qv4runtime_p.h:144:22: error: 'static QV4::ReturnedValue QV4::Runtime::method_uPlus(const QV4::Value&)' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline ReturnedValue Runtime::method_uPlus(const Value &value) ^ qtdeclarative/src/qml/jsruntime/qv4runtime_p.h:157:22: error: 'static QV4::ReturnedValue QV4::Runtime::method_uMinus(const QV4::Value&)' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline ReturnedValue Runtime::method_uMinus(const Value &value) ^ qtdeclarative/src/qml/jsruntime/qv4runtime_p.h:170:22: error: 'static QV4::ReturnedValue QV4::Runtime::method_complement(const QV4::Value&)' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline ReturnedValue Runtime::method_complement(const Value &value) Task-number: QTBUG-53222 Change-Id: I5a9bd162e0b1f52c66cd6a8efbf407fcd46d7fc7 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | | QML: When available, use QQmlAccessors to read properties.Erik Verbruggen2016-04-121-0/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a property is read from a QObject or the QML scope object, and we can statically resolve the type to qreal/QObject/int/bool/QString, and the property has an accessor declared for it, then use that accessor to do the read. This collapses the path of e.g.: Runtime::getQmlScopeObjectProperty -> QObjectWrapper::getProperty -> QObjectWrapper::getProperty -> LoadProperty -> QQmlAccessor::read (all of which do various checks for all the stuff mentioned above) to: Runtime::accessQmlScopeObjectQRealProperty -> QQmlAccessor::read which is a simple 4-line function, and doesn't need to do any check. According to valgrind, this saves 170 instructions on x86 for the simple binding: Item { width: height } Change-Id: I0761d01e8f1a3c13ecbffe2d8e0317ce9c0a4db0 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | | Convert the remaining runtime methods to new calling conventionLars Knoll2016-04-111-5/+5
| | | | | | | | | | | | | | | Change-Id: I88ad3ca430508617d527715aa85ae8474ab7c621 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | | Convert comparison methods to the new runtime syntaxLars Knoll2016-04-111-14/+14
| | | | | | | | | | | | | | | Change-Id: Iad4dadddefca2d6322d4f778272b75d64e1a746f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | | Convert unary operations to new calling conventionLars Knoll2016-04-111-2/+2
| | | | | | | | | | | | | | | Change-Id: I629e336ec41f46390b7ed9f9365a832e1722b61a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>