aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4scopedvalue_p.h
Commit message (Collapse)AuthorAgeFilesLines
* QV4::Scoped: Use explicit operator boolJüri Valdmann2018-11-051-4/+1
| | | | | Change-Id: Ibf41d6051fe35aac37fb40ca3c499d0daacebc65 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-4/+4
| | | | | | | | | | | | 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>
* Fix some details in class initializationLars Knoll2018-08-061-0/+13
| | | | | Change-Id: Ib8a76362686f1bbba49daca59fa4a30773150103 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Identifier by PropertyKeyLars Knoll2018-07-021-0/+3
| | | | | | | | 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>
* Introduce a PropertyKey class that inherits from ValueLars Knoll2018-07-021-0/+29
| | | | | | | | | | | This will replace Identifier over the next few commits. The advantage of PropertyKey is that it can be stored on the JS stack, so that a GC run won't accidentally clean up the string/symbol referenced by the key. Change-Id: Ib4daa4616bcfa537e6d371ef7c7740bc7727a50d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanup JS stack allocationsLars Knoll2018-05-261-18/+55
| | | | | | | | 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>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-3/+3
| | | | | | | | | | | | | 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>
* Fix CallData setup for Script::runErik Verbruggen2017-09-151-2/+2
| | | | | | | | | | | | | | By calling JSCall with an ExecutionContext as first parameter, the compiler would implicitly create a temporary Scope object in order to be able to do the call. However, the scope would then wipe the stack when it is being destructed. So subsequently retrieving argc would always result in 0 arguments. To prevent accidents like this, all Scope constructors are now explicit, and the QV4::Script's ExecutionContext is renamed from scope to context. Change-Id: Iea7930748a0544382a20b6617fa9818a8a2bea7f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move ScopedCallData and ScopedStackFrame into a separate fileLars Knoll2017-09-011-41/+0
| | | | | Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify JSStackFrame and CallDataLars Knoll2017-09-011-1/+1
| | | | | Change-Id: I4494dae8166026074c9efc74bac62de9d3fa2342 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanup naming of Stack frame structuresLars Knoll2017-08-101-2/+2
| | | | | Change-Id: I0b392040b6726e6d93f237ccccc9f053256ed819 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Refactor context handlingLars Knoll2017-08-101-19/+19
| | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | This cuts out quite a bit of overhead when entering and leaving functions. Change-Id: I32670c98a4087ea3b2d45853d9cabff9066399e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Avoid creating a separate Scope in the ExecutionContextSaverLars Knoll2017-08-081-7/+7
| | | | | | | There's no reason this class should create a scope on it's own. Change-Id: I93bddea8be42a908a1aca1bcb0ec867aae0d29f8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-23/+11
| | | | | | | | Allow for faster calling of builtins, and completely avoid scope creation in many cases. Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the engine() accessor from Object to ManagedLars Knoll2017-05-191-1/+1
| | | | | | | | | | | | We can easily do this now that Managed has a pointer to an internal class (which always has a back pointer to the ExecutionEngine). Remove the extra engine pointer from ExecutionContext, and clean up tow methods in String. Change-Id: I98d750b1afbdeadf42e66ae0c92c48db1a7adc31 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Fix calling of JS functions with more than 6 parameters from C++Simon Hausmann2017-04-271-1/+1
| | | | | | | | | | Make sure to allocate enough space on the JS stack to include the calldata members _and_ the parameters when using more than ReservedArgumentCount parameters. Task-number: QTBUG-60396 Change-Id: I7fb2e44550fe081c43b8583f0cd370feb70db159 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix value type encoding constant usage when cross-compilingSimon Hausmann2017-03-301-1/+1
| | | | | | | | | | | | | | | Our two value encodings use different masks for the upper 4 bytes. Depending on the target architecture we must use different values when generating code that uses these masks. This patch replaces the #ifdef'ed ValueTypeInternal_* enum values with two C++11 scoped enums that allows for the co-existence of both throughout the code base as well as selective use in the code generators. Change-Id: I380c8c28b84df2874cca521b78bfe7f9388ed228 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Protect CallData usage against cross-compilation word size differencesSimon Hausmann2017-03-171-1/+1
| | | | | | | | | | Ensure via static asserts that the members always have the same offsets. Since the class has standard layout, we can also use the C++11 offsetof macro instead of qOffsetOf. Task-number: QTBUG-58666 Change-Id: I7dcecf517c771c7081334cd9d0b7ae133b23b23a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Convert more builtin functions to the new calling conventionLars Knoll2017-01-251-0/+6
| | | | | Change-Id: I053215261e1186aff25f29e0967219ef667f7678 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Convert more builtin functionsLars Knoll2017-01-251-2/+2
| | | | | Change-Id: I2dc8797e2240fcfc4176cb08b982e3e98b879646 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Speed up invocation of builtin functionsLars Knoll2017-01-251-0/+26
| | | | | | | | Completely avoid creation of a CallContext for those methods, as we don't need it. Change-Id: Iff1a38fd3c7e846df6ec0374cb7b3fb8f1b4de3a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Scoped<T>::operator-> will always return a T*Erik Verbruggen2016-12-011-3/+8
| | | | | | | | There is no need to do a Value::cast, because that is already done in the constructors and in the assignment operators. Change-Id: I65b896c1eae91bf63ead3762437c35aea504ac62 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Help the C++ compiler to do more DSE by inlining more codeErik Verbruggen2016-11-291-16/+21
| | | | | | | | | | The JS stack allocation initializes the contents, but in most cases the caller will immediately store a value in that stack slot. When the allocation code is inlined, the compiler can use dead store elimination to remove the unnecessary initialization code. Change-Id: I0495417adc7c1c8764f845032611bd506a8b7df9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-10-101-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/quick/quickwidgets/quickwidget/main.cpp src/qml/jsruntime/qv4jsonobject.cpp src/qml/jsruntime/qv4qobjectwrapper.cpp src/qml/jsruntime/qv4qobjectwrapper_p.h src/qml/qml/qqmlengine.cpp src/qml/qml/qqmlpropertycache.cpp src/qml/qml/qqmlpropertycache_p.h src/quick/items/qquickanimatedsprite.cpp src/quick/items/qquickitem.cpp src/quick/items/qquickitem.h src/quick/items/qquickitem_p.h src/quick/items/qquickview_p.h src/quick/scenegraph/qsgcontext.cpp src/quick/scenegraph/qsgdefaultrendercontext.cpp Change-Id: I172c6fbff97208f21ed4c8b6db3d1747a889f22b
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-301-1/+1
| |\ | | | | | | | | | | | | | | | | | | Conflicts: tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I241cd418bb7e7b95e0a0a2ee4c465d48be2a5582
| | * V4: Free up 2 address bits in 64bit modeErik Verbruggen2016-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This allows for the OS to use 49 address bits. It also maps JS Undefined to the C++ nullptr on 64bit. Task-number: QTBUG-54822 Change-Id: I7cc90620f499be1506a61aac77d72d067308838c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | QML: Specialize bindings based on target property type.Erik Verbruggen2016-06-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we can determine the type of a target property during type compilation, we can skip a whole bunch of code that deals with converting the result of a binding to the correct (target) type. This removes 65 instructions on x86 for such typed bindings. Change-Id: Id2c7c57b9ae6dfbeb921121beae9630604ca1d17 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | V4: Pass scope around as parameters inside the runtime.Erik Verbruggen2016-06-221-22/+27
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.6' into 5.7Liang Qi2016-06-201-14/+2
|\| | | | | | | | | | | | | | | Conflicts: src/qml/jit/qv4targetplatform_p.h src/quick/accessible/qaccessiblequickitem_p.h Change-Id: Ic95075a5fad81ec997a61561bd65979dfa3b9d4d
| * V4: Always set the tag when boxing a pointer in QV4::Value.Erik Verbruggen2016-06-161-14/+2
| | | | | | | | | | | | | | | | | | All setters now store tags, so no-one can play loosy-goosy with the boxed values (and accidentally forget to "tag" a value, resulting in random garbage). Change-Id: Ia0b78aa038d3ff46d5292b14bd593de310da16a0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-06-101-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of 0e053528 was reverted in the merge, about lastTimestamp. It will be applied later in separate commit. qmltest::shadersource-dynamic-sourceobject::test_endresult() was blacklisted on linux. Conflicts: .qmake.conf tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp tests/auto/qmltest/BLACKLIST tests/auto/qmltest/qmltest.pro Task-number: QTBUG-53590 Task-number: QTBUG-53971 Change-Id: I48af90b49a3c7b29de16f4178a04807f8bc05130
| * V4: Mirror jsAlloc behavior at stack allocation.Erik Verbruggen2016-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | Allocating from the JS stack will zero out the memory, and thus indicate to valgrind that memory is not uninitialized. By first marking the whole stack as uninitialized and only then allocating 2 entries, the behavior for those two entries will now match the allocation behavior. This fixes a false positive when using valgrind. Change-Id: Icdb5279e1cfbfe6b5c385cc42c556edf721fa74b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Updated license headersJani Heikkinen2016-01-191-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Remove prohibited uses of underscore + capital letterThiago Macieira2016-01-081-3/+3
| | | | | | | | | | | | | | All identifiers starting with an underscore and a capital letter are reserved to the compiler and must never be used by the user code. Try to find a better name or, in the worst case, move the underscore to the last position in these identifiers. See commit cf63c63d558227fdbef09699c261560e7474f5ea in qtbase for a case of such an identifier causing a build breakage when the compiler began treating it specially (it was _Nullable). Change-Id: I1d0f78915b5942aab07cffff140f9f39c29f0fdf Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* Use the correct macro to detect 64-bit value encodingThiago Macieira2015-10-291-4/+4
| | | | | | | We have a macro for it, so let's use it. Change-Id: I1d0f78915b5942aab07cffff140fa0ac23392362 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* Add missing "We mean it" comments to private headers.Friedemann Kleint2015-10-061-0/+11
| | | | | | Task-number: QTBUG-48594 Change-Id: Ifc207938de7f0c8995fc712df92665f222612647 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* Rename currentExecutionContext to currentContextLars Knoll2015-09-151-4/+4
| | | | | | | | Now that the other method is gone, let's use the shorter currentContext Change-Id: I2a6fb3b77f83a1ffdf314ad29081e303d17030ed Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of Scope.sizeLars Knoll2015-09-151-57/+0
| | | | | | | | | The value was only set in debug builds, but never checked against. As this can't work with how ExecutionContexts are now stacked, let's get rid of it. Change-Id: I20f26afd7872a4783d163f913dde01858c3df792 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Store the stack of executioncontext's on the JS stackLars Knoll2015-09-151-7/+6
| | | | | | | | | | | | | | | | This saves one pointer per allocated execution context. Now every execution context that is pushed, allocates two Values on the js stack. One contains the context itself, the other one the offset to the parent context. Things are a bit tricky for with and catch scopes, as those are called from the generated code, and can't open a Scope anymore. In addition, all methods iterating over the js stack frames need to work with ExecutionContext pointers, not ScopedContext's. Change-Id: I6f3013749d4e73d2fac37973b976ba6029686b82 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup the ExecutionContextSaverLars Knoll2015-09-151-12/+3
| | | | | | | | Always operate on the current context (as that's what we do in practice anyway). Change-Id: I4171207a7a86e69aa685754956c0764ac6e152a7 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove type punning from QV4::Value.Erik Verbruggen2015-07-241-25/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The union in QV4::Value is used to do type punning. In C++, this is compiler-defined behavior. For example, Clang and GCC will try to detect it and try to do the proper thing. However, it can play havoc with Alias Analysis, and it is not guaranteed that some Undefined Behavior (or Compiler depenedent behavior) might occur. The really problematic part is the struct inside the union: depending on the calling convention and the register size, it results in some exciting code. For example, the AMD64 ABI specifies that a struct of two values of INTEGER class can be passed in separate registers when doing a function call. Now, if the AA in the compiler looses track of the fact that the tag overlaps with the double, you might get: ecx := someTag ... conditional jumps double_case: rdx := xorredDoubleValue callq someWhere If the someWhere function checks for the tag first, mayhem ensues: the double value in rdx does not overwrite the tag that is passed in ecx. Changing the code to do reinterpret_cast<>s might also give problems on 32bit architectures, because there is a double, whose size is not the same as the size of the tag, which could confuse AA. So, to fix this, the following is changed: - only have a quint64 field in the QV4::Value, which has the added benefit that it's very clear for the compiler that it's a POD - as memcpy is the only approved way to ensure bit-by-bit "conversion" between types (esp. FP<->non-FP types), change all conversions to use memcpy. Use bitops (shift/and/or) for anything else. - only use accessor functions for non-quint64 values As any modern compiler has memcpy as an intrinsic, the call will be replaced with one or a few move instructions. The accessor functions also get inlined, the bitops get optimized, so in all cases the compiler can generate the most compact code possible. This patch obsoletes f558bc48585c69de36151248c969a484a969ebb4 (which had the exact aliassing problem of the double and the tag as described above). Change-Id: I60a39d8564be5ce6106403a56a8de90943217006 Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
* Remove another wrong commentLars Knoll2015-06-171-1/+0
| | | | | | | The code below looks perfectly ok. Change-Id: I966b54b0ea1fd71898c0305da61b046195ab86a5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of TypedValueLars Knoll2015-06-101-27/+0
| | | | | | | | Now that Managed inherits from Value, this class doesn't make sense anymore. Change-Id: I04e10f53ef305658d902bd0f1c7d7280068c0dc3 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move exceptionValue and globalObject from the Engine onto the JS stackLars Knoll2015-04-241-4/+1
| | | | | | | | | We'll need to move all GC'ed objects currently stored in ExecutionEngine onto the JS stack for easier management in a new garbage collection scheme. This is the start of that change. Change-Id: Ib3ad8e846875dade8a807ea79f063173d40e4aad Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup some of the casting codeLars Knoll2015-03-201-12/+10
| | | | | | | | Get rid of value_cast, and move the Managed::as() method into Value. Change-Id: I440ac44ae77f4fda1a8a837383fe631f432f6532 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* CleanupsLars Knoll2015-01-231-37/+7
| | | | | | | | Remove duplicated methods. Remove some mostly unused methods, and simplify some others. Change-Id: I605b249e54417bb32c3dfc8e22f2c8b6b684a1e1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove all remaining usages of ValueRefLars Knoll2015-01-231-21/+0
| | | | | Change-Id: Icd76d3d03fac2e57530e55f8ec15b97109dcdcbc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of most uses of ValueRefLars Knoll2015-01-231-26/+18
| | | | | | | | | | | | Instead pass a const Value & into the functions With our new inheritance structure, we can get rid of ValueRef and instead simply pass a pointer to a Value again. Pointers to Values are safe to use again now, as they are now guaranteed to be in a place where the GC knows about them. Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>