aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix qmlcompiler build on win32.Erik Verbruggen2015-10-291-2/+2
| | | | | Change-Id: Ie1239b6ba5f5ba77dd081ad6392d962822d124dc Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* QML: Fix typeof context property.Erik Verbruggen2015-10-271-0/+22
| | | | | | | | This was missing from f21e8c641af6b2d10f0d7e7e0fc6a755dab3673c. Task-number: QTBUG-48524 Change-Id: I5cc6a979d965a1ef6b7fbc916a7ca9df868b459a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Speed up creation of Array literalsLars Knoll2015-09-251-9/+1
| | | | | | | Gives around 10% speedup on the v8 splay benchmark. Change-Id: I47f64e7b73bde59ac3bdd2c94fc199ecfbbf290e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Convert FunctionObjects to new allocation syntaxLars Knoll2015-09-221-1/+2
| | | | | Change-Id: I269c20abdc7f9eb0d71a2d2d485d622b65405762 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* CleanupsLars Knoll2015-09-151-1/+1
| | | | | | | | | | | There's only one place where we need to resize our member data, namely when we call setInternalClass() on an object. In addition, encapsulate the access to the memberdata better in preparation for inline property data later on. Change-Id: Ia34d0253d5d1792f1d7c4981556d78375fa7a755 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Rename currentExecutionContext to currentContextLars Knoll2015-09-151-14/+14
| | | | | | | | Now that the other method is gone, let's use the shorter currentContext Change-Id: I2a6fb3b77f83a1ffdf314ad29081e303d17030ed Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup usage of ExecutionEngine::currentContextLars Knoll2015-09-151-43/+34
| | | | | Change-Id: Ic79d6da162375928ec25871cd0341daeab6483d2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Store the stack of executioncontext's on the JS stackLars Knoll2015-09-151-13/+16
| | | | | | | | | | | | | | | | 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>
* Explicitly push/pop ExecutionContextsLars Knoll2015-09-151-2/+2
| | | | | | | | Avoid the implicit push inside the execution context constructor and rather make this explicit in the code. Change-Id: I1bb0fb523fddbb273fc666370d619f55f49cd40a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move the qmlSingletonWrapper method out of the contextwrapperLars Knoll2015-08-201-2/+1
| | | | | | | One more step towards removing the class alltogether. Change-Id: Ic9f6794eb3c5c6605ee43ad23a6d432ebbf321a1 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into 5.6Ulf Hermann2015-08-181-3/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/debugger/qv4debugservice.cpp src/qml/jsruntime/qv4value_inl_p.h src/qml/jsruntime/qv4value_p.h src/qml/memory/qv4mm.cpp src/qml/memory/qv4mm_p.h src/qml/qml/qqmlnotifier_p.h src/qml/qml/qqmlproperty.cpp src/quick/items/qquickflickable.cpp src/quick/items/qquicktextedit.cpp tests/auto/quick/qquickwindow/BLACKLIST The extra changes in qqmlbinding.cpp are ported from changes to qqmlproperty.cpp that occurred in parallel with writeBinding() being moved to qqmlbinding.cpp. Change-Id: I16d1920abf448c29a01822256f52153651a56356
| * V4: track C++ heap usage for Strings in the MemoryManagerErik Verbruggen2015-07-101-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... and do a GC run when it exceeds a threshold. The issue with Strings is that they hold on to QString instances that store the real content. However, the GC only sees the light-weight JS handle, and doesn't take the size of the backing content into account. So it could happen that big QStrings accumulate in the heap as long as the GC didn't reach its threshold. The newly introduced unmanaged heap threshold is upped by a factor of two when exceeded, and lowered by a factor of 2 when the used heap space falls below a quarter of the threshold. Also grow the threshold if there is enough space after running the GC, but another GC run would be triggered for the next allocation. There is a special case for Heap::String::append, because this method will copy the data from the left and right substrings into a new QString. To track this, append notifies the memory manager directly of the new length. The pointer to the memory manager is stored in Heap::String, growing it from 40 bytes to 48 bytes (which makes it still fit in the same bucket, so no extra memory is allocated). Task-number: QTBUG-42002 Change-Id: I71313915e593a9908a2b227b0bc4d768e375ee17 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Access the id objects through a specialized runtime methodLars Knoll2015-08-121-6/+17
| | | | | | | | | | | | | | | | This brings us one step closer to getting rid of the QQmlContextWrapper. Change-Id: Ied57f4c174c2ebd95096310a4ad4c0c28787e7a4 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Access context properties through the qml contextLars Knoll2015-08-101-8/+24
| | | | | | | | | | | | | | And get rid of another temp in the IR. Change-Id: I039393e020e5141f1986aee276246c30fd8057f3 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Use the QmlContext to access properties of the scope objectLars Knoll2015-08-101-5/+24
| | | | | | | | | | | | | | | | | | Add some runtime methods to access properties of the scope object directly (using the QmlContext), and generate proper code to call those. Change-Id: I0b29357c9a3b9ad53ba568ec6cb763e8ecb10f21 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Add ability to retrieve and use the QmlContext from our generated codeLars Knoll2015-08-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Our generated code (JIT and interpreter) should operate on the QML context to retrieve QML related things. That's better than operating on 4 different temps. So this commit introduces the QML context as a temp in the code we generate for QML. The next commits will move things over to use that context with specialized runtime methods instead of using generic subscript/get calls on the different subobjects. Change-Id: Ia05cf339de9cdd23003f35cf78ede17d2590f8de Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Remove type punning from QV4::Value.Erik Verbruggen2015-07-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Cleanup retrieval of scope and context objectsLars Knoll2015-06-181-9/+5
| | | | | | | | | | Change-Id: I9c6174181f950bc4f829727dc6acdfe82fa4e894 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Cleanup signature of get/setProperty in the object wrapperLars Knoll2015-06-181-8/+4
| | | | | | | | | | Change-Id: I3612a8fe952656da2239e4baf0b460bef46e3f62 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Clean up ExecutionContext's for QMLLars Knoll2015-06-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Create a specialized QmlContext instead of re-using a call context with a QQmlContextWrapper as activation object. This saves some memory and opens up the route to getting rid of the context wrapper in a future commit. Change-Id: I1591c73932a08564fddf5137ac05bbc6f31dd4d5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Get rid of QQmlIdObjectsArrayLars Knoll2015-06-181-3/+1
| | | | | | | | | | | | | | | | | | The context wrapper can do this directly, and give access to the array by index. Simplifies code, and is one less object we need to allocate on the JS heap. Change-Id: I9d9d3a47920e97c42234a27aa66cd5ae3cc28085 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Store a Heap::String pointer in StringObjectLars Knoll2015-06-171-1/+1
| | | | | | | | | | Change-Id: I926c5bb2dd4f1613af6737d4200e568f0ec13d58 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Move the StringValue members of ExecutionEngine onto the JS stackLars Knoll2015-06-101-21/+21
| | | | | | | | | | Change-Id: Ib55c05f1730b7659e2f6fee7e1fa79c10c759167 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Move evalfunction and thrower onto the js stackLars Knoll2015-04-241-2/+2
| | | | | | | | | | Change-Id: I3a0abe13d802aff8998d1c64f86b5a8f98c8335f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Continue the work to move Values inside the v4 engine to the js stackLars Knoll2015-04-241-1/+1
| | | | | | | | | | | | | | | | Started with objectPrototype, the next commits will move more of them over into the new data structure. Change-Id: I1a048e95149ce69e4e42094db2dd738ce49b50b8 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Move exceptionValue and globalObject from the Engine onto the JS stackLars Knoll2015-04-241-1/+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>
* | Get rid of asFunctionObject()Lars Knoll2015-04-211-5/+5
| | | | | | | | | | Change-Id: Ib4858376dc0ec57fa473c80696abc66a570c90ec Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | More cleanupsLars Knoll2015-04-211-6/+6
| | | | | | | | | | | | | | | | Get rid of Value::asObject(), and pass const Managed pointers into some more vtable methods. Change-Id: Ia4f427d5fd8868f77b4015d1ce5424d32bfc2115 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Get rid of asManaged()Lars Knoll2015-04-211-1/+1
| | | | | | | | | | Change-Id: I853417fdf1cc339f7d43a006c20e1626b6bfb288 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Get rid of Value::asDateObject()Lars Knoll2015-04-161-1/+2
|/ | | | | Change-Id: I71816a784b5175f600c5a870318b16c0d84c42fb Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Frederik Gladhorn2015-02-241-1/+1
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf LICENSE.GPLv2 examples/qml/networkaccessmanagerfactory/view.qml src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4stringobject.cpp Change-Id: I5d12f436d60995e51d5c2f59d364e9cbc24f8e32
| * Fix failing assertion in debug builds for JS that calls constantsSimon Hausmann2015-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For true() we generate IR that looks like this: temp = true result = call temp() and therefore the move at isel time has IR::Call as source and a temp as base for the call. However constant propagation in the optimizer transforms this to result = call true() and that's a case we didn't handle in the IR visitor. Since we have Runtime::callValue we can however handle this case as well and the run-time will consequently produce the expected run-time error. Change-Id: Ia94a8116388e66f9f339913307f68e33a5c18a19 Task-number: QTBUG-43819 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Jan Kundrát <jkt@kde.org> Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* | Cleanup math function includes and usageAllan Sandfeld Jensen2015-02-191-4/+3
| | | | | | | | | | | | | | | | Use std::math on floats and doubles, and qMath on qreals, and only include the math headers actually needed. Change-Id: I1d511d7b1bac0050eaa947c7baee760b736858bf Reviewed-by: Sean Harmer <sean.harmer@kdab.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>
* | Store a double in NumberObjectLars Knoll2015-01-231-1/+1
| | | | | | | | | | | | | | Makes more sense than storing a Value in there. Change-Id: I2e6ca71477100c1e1639bb89cced4f4049b5e5c2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | CleanupsLars Knoll2015-01-231-1/+1
| | | | | | | | | | | | | | | | Simplify some code in BooleanObject Simplify access to call arguments and thisObject Change-Id: I2f8e844019bc587385608beb02f05b15f827535c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | CleanupsLars Knoll2015-01-231-1/+1
| | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | Change-Id: Icd76d3d03fac2e57530e55f8ec15b97109dcdcbc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Get rid of most uses of ValueRefLars Knoll2015-01-231-168/+168
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Move the internalClass pointer into Heap::ObjectLars Knoll2015-01-211-3/+3
| | | | | | | | | | | | | | | | The other classes that derive from Heap::Base don't need it at all. So get rid of it there and save a pointer. Change-Id: I9c5df2e43cd6eeac2e6e41f3d3b8077d3afbc8f2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Get rid of subtype usage in Function objectsLars Knoll2015-01-121-1/+1
| | | | | | | | | | | | Change-Id: Ic84ddab292cb69e79dac0f2b8a87b96b096360d8 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove qv8engine usage in the contextwrapperLars Knoll2015-01-081-1/+1
| | | | | | | | | | Change-Id: Iaf807add5d971e96cac57e38e13385e901f9c930 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Further reduce v8engine dependenciesLars Knoll2015-01-081-2/+2
| | | | | | | | | | Change-Id: I9f50f5ed1928de0c389c9646b308b431b51dae37 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use QV4::ScopedObject typedef instead of actual typeOleg Shparber2015-01-031-7/+7
| | | | | | | | | | Change-Id: I0b68c534ea513a7c230b12114f6b42b069f9864b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use QV4::ScopedArrayObject typedef instead of actual typeOleg Shparber2015-01-031-1/+1
| | | | | | | | | | Change-Id: I975536745ac6c264aca074f84d223fbec7682d3d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use QV4::ScopedFunctionObject typedef instead of actual typeOleg Shparber2015-01-021-2/+2
| | | | | | | | | | Change-Id: I6b4effaa5bef992b4ae9402eea7fe655bc7b18f0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Fix Context::getPropertyAndBase to use Heap based objectsLars Knoll2014-12-201-3/+1
| | | | | | | | | | Change-Id: I4f885a8af5e963445959871b7f26f3bcb3dfa654 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove most of the places where getPointer() is usedLars Knoll2014-12-201-14/+14
| | | | | | | | | | | | | | This is no longer required, and simply uglifies the code Change-Id: Iba91a1d7735ebe23a43437f137a488423b6eb743 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Store a Heap::EvalFunction pointer in the engineLars Knoll2014-12-201-2/+2
| | | | | | | | | | Change-Id: I002eb8f94e168c9faf1ee3521170dfaf442af1a3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Return Heap::ExecutionContext for currentContext()Lars Knoll2014-12-191-40/+55
| | | | | | | | | | Change-Id: I155ab996e24d7f36761d2ea62a04774e16469b34 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>