aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4jsonobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Libraries: Fix single-character string literals.Friedemann Kleint2015-10-131-2/+3
| | | | | | | Use character literals where applicable. Change-Id: I294fc4cb5cbbd23df9735ba2b398118f37cbe08a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Convert FunctionObjects to new allocation syntaxLars Knoll2015-09-221-3/+2
| | | | | Change-Id: I269c20abdc7f9eb0d71a2d2d485d622b65405762 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup usage of ExecutionEngine::currentContextLars Knoll2015-09-151-1/+1
| | | | | Change-Id: Ic79d6da162375928ec25871cd0341daeab6483d2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove type punning from QV4::Value.Erik Verbruggen2015-07-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Store a Heap::String pointer in StringObjectLars Knoll2015-06-171-2/+2
| | | | | Change-Id: I926c5bb2dd4f1613af6737d4200e568f0ec13d58 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix the GC unsafe stack variable in StringifyLars Knoll2015-06-151-6/+11
| | | | | Change-Id: Icf90f43bedebe05a148499cd2de6726eaa993293 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix another place where we were not compatible with a moving GCLars Knoll2015-06-151-15/+23
| | | | | | | | Don't store a vector of Heap::String's. Instead allocate them on the JS stack and simply keep a pointer to them. Change-Id: Ie12b5f4d56446234519b5e2f0b33120834e927ab Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup: Store a pointer to the engine not the contextLars Knoll2015-06-151-11/+11
| | | | | | | | The context is actually only ever used to get to the engine, so let's rather store that one instead. Change-Id: Id6ea8044ac3fb2c273b529f18c85af14e7104892 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix GC problem with json conversion methodsLars Knoll2015-06-151-6/+6
| | | | | | | | | The ObjectSet used to protect against recursion is not safe against a GC that moves objects around. Fix this by storing pointers to QV4::Object in there instead. Change-Id: I88bcac330246a1c9180caed13be1f6ab5c40a6ae Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix some function signaturesLars Knoll2015-06-151-2/+2
| | | | | | | | Add a const several places and pass values by pointer, not reference. This allows us to also get rid of some Scope's. Change-Id: I3b4c29c22511c947d024457e7b8fa2aaa6bec55d 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>
* Get rid of qv4value_inl_p.h and replace it by qv4typedvalue_p.hLars Knoll2015-04-241-0/+1
| | | | | | | | This is a cleaner separation and further reduces include dependencies in the definitions of our basic data structured. Change-Id: I18aa86cdea0c0dfbc16075d4d617af97e638811e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove last asFoo() methods from ManagedLars Knoll2015-04-211-1/+1
| | | | | | | | Also add some safety checks in case the heap pointer inside the Value is 0. Change-Id: I61d37410c10c34f197175dbbd9ea8fa8c95c12cd 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-2/+2
| | | | | | | | 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 asNumberObjectLars Knoll2015-04-211-3/+3
| | | | | Change-Id: Ie6355beabce3de65c215514d9dc98294b5980c9d Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of asStringObject()Lars Knoll2015-04-171-3/+3
| | | | | Change-Id: Iad3afd00d2fdbd04efa4f3b841f11269ab496826 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* QML Engine: JSON XHR response type supportValery Kotov2015-04-161-28/+0
| | | | | | | | | | | Support for "json" response type for QQmlXMLHttpRequest was added. [ChangeLog][QtQml][QQmlXMLHttpRequest] QQmlXMLHttpRequest now supports "json" binary response type. Change-Id: I21b7659c02dfdc6b64a73e1d2003e269d90b3b23 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Further cleanupsLars Knoll2015-04-161-1/+1
| | | | | | | | | The get and getIndexed vtable methods should take a const Managed pointer. Start cleaning up the asFoo() methods in Value and Managed by removing asArrayObject() and asErrorObject(). Change-Id: Ibd49bf20773ef84c15785b7ac37a7bc9fd4745d5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* QtQml: Micro-optimize iterator loops.Friedemann Kleint2015-02-261-1/+1
| | | | | | | Avoid repeated instantiation of end() in loops, use variable instead. Change-Id: I3bb1c6918cfd16a5dcefbcc03c442e99fe9bf76b Reviewed-by: Erik Verbruggen <erik.verbruggen@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>
* Store a double in NumberObjectLars Knoll2015-01-231-3/+3
| | | | | | | Makes more sense than storing a Value in there. Change-Id: I2e6ca71477100c1e1639bb89cced4f4049b5e5c2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* CleanupsLars Knoll2015-01-231-4/+4
| | | | | | | | 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-10/+10
| | | | | Change-Id: Icd76d3d03fac2e57530e55f8ec15b97109dcdcbc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of most uses of ValueRefLars Knoll2015-01-231-15/+13
| | | | | | | | | | | | 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>
* 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>
* Get rid of Value::engine()Lars Knoll2015-01-121-2/+4
| | | | | | | | | This method is not guaranteed to return an engine. We're safer checking for the value being an object first and then getting the engine from there. Change-Id: I5c95e675337e545f2421613bd31c42d1e58d6f9a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use QV4::ScopedObject typedef instead of actual typeOleg Shparber2015-01-031-2/+2
| | | | | Change-Id: I0b68c534ea513a7c230b12114f6b42b069f9864b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use QV4::ScopedArrayObject typedef instead of actual typeOleg Shparber2015-01-031-2/+2
| | | | | Change-Id: I975536745ac6c264aca074f84d223fbec7682d3d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use QV4::ScopedFunctionObject typedef instead of actual typeOleg Shparber2015-01-021-1/+1
| | | | | Change-Id: I6b4effaa5bef992b4ae9402eea7fe655bc7b18f0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use pointers to Heap object to avoid recursionLars Knoll2014-12-201-6/+6
| | | | | Change-Id: If491b35ba43758bd4792166f7213cd5a11d227d9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix JSON stringification to work with heap objectsLars Knoll2014-12-201-8/+10
| | | | | Change-Id: Ifbd7332602d67daa945da5ebbca797d0045aff68 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>
* Return Heap::ExecutionContext for currentContext()Lars Knoll2014-12-191-1/+1
| | | | | Change-Id: I155ab996e24d7f36761d2ea62a04774e16469b34 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move prototype back from the vtable into ObjectLars Knoll2014-12-111-3/+3
| | | | | | | | 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>
* Fix run-time string handling with regards to the new heapSimon Hausmann2014-11-211-2/+2
| | | | | | | | | | | | | | | | | 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>
* Fix usage of ExecutionContext in the json parserLars Knoll2014-11-151-13/+13
| | | | | Change-Id: I9b2d1389dd66ad74507dd16c4bdf7b57491c1cfb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Change signature of defineOwnProperty to take an engine instead of a contextLars Knoll2014-11-151-1/+1
| | | | | Change-Id: Ib0d558d17162a205974c6f2f0daf8af5b0b9547b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Ported ExecutionEngine::newString and newIdentifier to Heap::StringSimon Hausmann2014-11-121-5/+5
| | | | | | | | | | 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>
* 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-3/+3
| | | | | Change-Id: I87866f8dcbaac1087da7bbd2902aa5b062afca53 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move Object::Data into the Heap namespaceLars Knoll2014-11-081-1/+1
| | | | | Change-Id: I9d30081f71b83bc86f5e5714e23396b18c4d54c5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move the throw methods from ExecutionContext to ExecutionEngineLars Knoll2014-11-041-3/+3
| | | | | | | | The methods don't require a context, and thus shouldn't be implemented there. Change-Id: If058e0c5067093a4161f2275ac4288aa2bc500f3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup header file dependenciesLars Knoll2014-11-041-0/+2
| | | | | Change-Id: Ibb4658576a98b53de2eac2474ce4d5b9eb83b6ae Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Convert more objects to the new constructor schemeLars Knoll2014-07-221-5/+5
| | | | | Change-Id: I31b2a1ba4a93f0d4bde68eeb94f13e7224c0cd7b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of all uses of ObjectRefLars Knoll2014-07-221-7/+7
| | | | | Change-Id: I705e2362dcda542f56826dadec6b0a6f15848788 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove the less often used Ref classesLars Knoll2014-07-221-5/+5
| | | | | Change-Id: I9ee531c903317a0f324671d98af1f967b684915c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of StringRefLars Knoll2014-07-221-4/+4
| | | | | | | | Remove the Ref classes, as they won't be required anymore once Managed and Managed::Data are separated. Change-Id: Ic6bec2d5b4ecf2595ce129dbb45bbf6a385138a5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>