aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4stringobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move more objects over to the new allocation schemeLars Knoll2015-09-221-13/+5
| | | | | Change-Id: I0241efe10d115f8e4a646f840e47e220eb6cfc18 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* CleanupLars Knoll2015-09-151-1/+1
| | | | | | | | The property is always value based, so there's no need to cast to a Property* when returning it. Change-Id: I095a940197aedac90ad9f5491ccb9af0ca53d722 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Don't compute the QString whenever we need to know the v4 string lengthAleix Pol2015-09-151-1/+1
| | | | | | | The length is already computed in the len attribute anyway. Change-Id: I1a406175edd9127b9b425eb21703e2184f5a3cd7 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Cleanup usage of ExecutionEngine::currentContextLars Knoll2015-09-151-1/+1
| | | | | Change-Id: Ic79d6da162375928ec25871cd0341daeab6483d2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Encapsulate and protect all accesses to the vtable of Heap objectsLars Knoll2015-08-101-1/+1
| | | | | | | | This is required, so we can safely access the vtable even while we're marking objects during GC. Change-Id: I34f56b61b4bca0d0742faf607eb5ab8b2c30685e 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>
* Minor cleanupSimon Hausmann2015-06-171-2/+1
| | | | | | | | | Narrow the scope of the match offsets counter, as suggested by the clang static code analyzer. In the second case we just wrote to the variable but never read it. Change-Id: I9e5e22bd27f892e76eccfea8b02f25795b689c36 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* Store a Heap::String pointer in StringObjectLars Knoll2015-06-171-14/+13
| | | | | Change-Id: I926c5bb2dd4f1613af6737d4200e568f0ec13d58 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of the tmpProperty in StringObjectLars Knoll2015-06-171-6/+7
| | | | | | | | | This was a bad hack. The new code is cleaner, and should also perform faster in a couple of cases (avoiding the creation of a temporary String that is then only thrown away). Change-Id: Ia6f978e037506484adbc01a61606307d4645b343 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix Object::getOwnProperty APILars Knoll2015-06-171-2/+3
| | | | | | | | | Don't return a Proprety pointer, this has issues with StringObject. Instead pass in a pointer that will get filled with the correct data. Change-Id: I28536ca129f5be3a4a1bc9583223521458411195 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move the StringValue members of ExecutionEngine onto the JS stackLars Knoll2015-06-101-6/+6
| | | | | Change-Id: Ib55c05f1730b7659e2f6fee7e1fa79c10c759167 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move constructor objects onto the js stackLars Knoll2015-04-241-2/+2
| | | | | Change-Id: I828c5f7407d90cd5df1a8fd89a0ca35074fbde43 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move more objects from the v4 engine to the js stackLars Knoll2015-04-241-2/+2
| | | | | | | Convert most of the prototype objects in the v4 engine. Change-Id: I365f290493c20973bc991b6a383649836e42a16a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of asFunctionObject()Lars Knoll2015-04-211-2/+2
| | | | | 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 asStringObject()Lars Knoll2015-04-171-4/+4
| | | | | Change-Id: Iad3afd00d2fdbd04efa4f3b841f11269ab496826 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into devFrederik Gladhorn2015-03-031-1/+1
|\ | | | | | | Change-Id: I94f8ae93d76bd5c120de25d9c238701afe8bfbd0
| * 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
| | * V4: include alloca private header as alloca is used unconditionally.Pasi Petäjäjärvi2015-01-261-0/+1
| | | | | | | | | | | | | | | Change-Id: Ic94a7ec3980ca9e2629620ef83c93b179d75162b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | | Move memory management related functionality into it's own folderLars Knoll2015-03-021-1/+1
|/ / | | | | | | | | | | | | | | | | Start moving the memory related functionality into it's own folder. This will simplify refactoring of the GC related functionality later on. Change-Id: I70ec6f512af7a7897625afb84d914c17572b0ccd Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Cleanup math function includes and usageAllan Sandfeld Jensen2015-02-191-7/+4
| | | | | | | | | | | | | | | | 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>
* | CleanupsLars Knoll2015-01-231-34/+34
| | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Get rid of all uses of Managed::engine()Lars Knoll2015-01-211-7/+4
| | | | | | | | | | Change-Id: I596f14554d81f5e9af9996294d96047f2e810bef Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove all the setVTable() calls that aren't required anymoreLars Knoll2015-01-211-2/+0
| | | | | | | | | | | | | | | | The memory manager's allocation methods now set this up correctly for us :) Change-Id: I8492bf732df601f95a1a851fb3804127ffc83935 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove the remaining bit of code that use the vtable in the internalClassLars Knoll2015-01-211-1/+1
| | | | | | | | | | Change-Id: Ia52f0e6db325aab37477d455f163487b319dce29 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Move vtable out of internalClassLars Knoll2015-01-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can move the internalClass to Object later on, and such save having the internalClass on lots of Heap objects. This commit basically adds and starts making use of a new vtable pointer in Heap::Base. In addition, the construction methods in the memory manager now automatically setup the correct vtable. Removing the vtable code from InternalClass and moving it into Object will come in a separate commit Change-Id: If49e8d73c769bf65bf47fe4dbf8b9546c8019dbc 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>
* | Make Property uses GC safeLars Knoll2014-12-201-1/+1
| | | | | | | | | | Change-Id: I5aa41a07a2d25e5c8a2d64bfa58a55fcd7aaf77e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove most of the places where getPointer() is usedLars Knoll2014-12-201-4/+4
| | | | | | | | | | | | | | This is no longer required, and simply uglifies the code Change-Id: Iba91a1d7735ebe23a43437f137a488423b6eb743 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Fix the way we set the property name during iterationLars Knoll2014-12-201-2/+2
| | | | | | | | | | | | | | This was broken due to the new inheritance scheme for Managed Change-Id: Ia9df50e7e655c3a812a01a2c78945e648aa444dc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Return Heap::ExecutionContext for currentContext()Lars Knoll2014-12-191-1/+1
| | | | | | | | | | Change-Id: I155ab996e24d7f36761d2ea62a04774e16469b34 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Return a Heap::Object in Object::prototype()Lars Knoll2014-12-171-4/+4
| | | | | | | | | | Change-Id: Ice0265ae558ba14497421a5bbf25ee9db76adab5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Add default parameter value for ExecutionEngine::newString()Oleg Shparber2014-12-121-4/+4
| | | | | | | | | | Change-Id: I8efbfb07ea61e2c6d03eeb79671006d209e4d48e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Move prototype back from the vtable into ObjectLars Knoll2014-12-111-5/+5
| | | | | | | | | | | | | | | | This is the only way we can support a GC that moves objects around in memory. Change-Id: I1d168fae4aa9f575b730e469e762bc5b5549b886 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Make QV4::RegExpObject header independent from masm headersOleg Shparber2014-11-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | Also remove pointless uint32_t for uint values and replace a few inconsistent uint16_t uses with quint16. MSVC was using uintN_t defined in masm headers instead of cstdint, so this change eliminates such situation. Change-Id: Ibd7dd50fc047dcdc78e057299883311a24dd3960 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Remove the executioncontext in a few more places where it's not neededLars Knoll2014-11-211-2/+2
| | | | | | | | | | Change-Id: I4c92c7bc9d94d8265e306f45d863fdc080a5e2a6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Fix run-time string handling with regards to the new heapSimon Hausmann2014-11-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changed runtimeStrings to be an array of Heap::String pointers instead of indirect String pointers. Later that member along with other GC related members will go into a managed subclass. Meanwhile the generated code no more loads String pointers directly but just passes the index into the run-time strings to the run-time functions, which in turn will load the heap string into a scoped string. Also replaced the template<T> Value::operator=(T *m) with a non-template overload that takes a Managed *, in order to help the compiler choose the non-template operator=(Heap::Base *) overload. This allows removing a bunch of Value::fromHeapObject calls. Change-Id: I20415c0549d33cca6813441a2495976b66d4c00e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Cleanup: remove Value::toString/Object overloads taking a contextLars Knoll2014-11-151-3/+3
| | | | | | | | | | Change-Id: I4cb63c3cc4eb9bb81f10f9826f80e581b4e1990c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Ported ExecutionEngine::newString and newIdentifier to Heap::StringSimon Hausmann2014-11-121-7/+7
| | | | | | | | | | | | | | | | | | | | Avoid the use of Returned<String> for newString and changed the identifier table to use Heap::String. This required moving some code back into Heap::String, but that's code that doesn't call back into the GC, so allocations and therefore future object moves aren't possible. Change-Id: I1dca3e9c12a9c56f09419af8cc8cba39fe04f720 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Use heap objects in the remaining managed objectsLars Knoll2014-11-121-3/+5
| | | | | | | | | | Change-Id: Id6dc6e34113a287a40e0122dfbdf977f0fc1f3b3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Convert methods in RuntimeHelpers to take an engine pointerLars Knoll2014-11-121-1/+1
| | | | | | | | | | | | | | This is safer and cleaner than to use a context pointer. Change-Id: Id5ef4e6667571897cd029125a0bdc18ce299da6d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Move more Data objects into the Heap namespaceLars Knoll2014-11-091-6/+6
| | | | | | | | | | Change-Id: I87866f8dcbaac1087da7bbd2902aa5b062afca53 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Move Data of FunctionObject and related classes into HeapLars Knoll2014-11-081-1/+1
| | | | | | | | | | Change-Id: Iadf74f953798c1884e0ec704ccb7c70d971e3273 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Move Object::Data into the Heap namespaceLars Knoll2014-11-081-2/+2
| | | | | | | | | | Change-Id: I9d30081f71b83bc86f5e5714e23396b18c4d54c5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Begin moving the data out of Managed objectsLars Knoll2014-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | We need to move the Data objects out of the Managed objects, to avoid lots of trouble because inner classes can't be forward declared in C++. Instead move them all into a Heap namespace. Change-Id: I736af60702b68a1759f4643aa16d64108693dea2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>