aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arrayobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Cleanup our runtime methodsLars Knoll2014-03-111-4/+4
| | | | | | | | | Move all our runtime methods into the QV4::Runtime struct and give them nicer names without underscores. Sort them logically and remove a few unused methods. Change-Id: Ib69b71764ff194d0ba211aac581f9a99734d8180 Reviewed-by: Simon Hausmann <[email protected]>
* Fix copying of Property'sLars Knoll2014-03-101-1/+1
| | | | | | | | | | Data properties don't contain valid data in the set field if they are being stored in Objects. Thus we should never access that field unless we are dealing with accessor properties. Change-Id: I19dcbaee7ebd042ae24387f92a93571d75ca578a Reviewed-by: Simon Hausmann <[email protected]>
* Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-02-111-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4ssa.cpp src/qml/jsruntime/qv4arrayobject.cpp src/qml/jsruntime/qv4context.cpp Change-Id: Ied5b23bec4dc14abe51127c507aed668f855c1e1
| * V4: Array.push() on QStringList should invoke putIndexed()Alberto Mardegan2014-01-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Wrapped sequence types should cause putIndexed() method to be called when Array.push() is used. Fix suggested by Simon Hausmann. [ChangeLog][QtQml] Fix JavaScript Array.push() not working on QStringList properties. Task-number: QTBUG-36491 Change-Id: Id04409dd7466a943d8ea8d57cd0514e8de732480 Reviewed-by: Simon Hausmann <[email protected]>
* | CleanupsLars Knoll2014-01-311-2/+2
| | | | | | | | | | | | | | | | | | | | Remove SafeValue, it was used to port over to an exact GC. Since we now have that, we can now safely merge it with QV4::Value again. Also rename SafeString to StringValue for better naming consistency. Change-Id: I8553d1bec5134c53996f6b0d758738a0ec8a2e4d Reviewed-by: Simon Hausmann <[email protected]>
* | Change virtual methods in ArrayData to take Object pointerLars Knoll2014-01-241-5/+6
| | | | | | | | | | | | | | | | | | Pass a pointer to the underlying object instead of the ArrayData to virtual methods that modify the arrayData. This prepares for allocating the ArrayData together with the array itself. Change-Id: I66fe187f8b1e4d382ab243a518dbde5f18a1d16d Reviewed-by: Simon Hausmann <[email protected]>
* | Split ManagedVTable into two classesLars Knoll2014-01-211-2/+2
| | | | | | | | | | | | | | | | Keep the basic methods in ManagedVTable, but have the Object related stuff in an ObjectVTable class. Change-Id: I9b068acf3caef813686227b8d935e7df1a7d1a6e Reviewed-by: Simon Hausmann <[email protected]>
* | Add a SimpleArrayData classLars Knoll2014-01-201-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the ArrayData class 'pure virtual'. SimpleArrayData now contains the implementation of simple arrays. This makes the separation between simple and sparse arrays a lot cleaner. It also allows us to move len and offset from the base class into the SimpleArrayClass. This fixes some bugs where we accessed len for sparse arrays leading to some buggy behavior. Added a virtual length() method to ArrayData to query the highes used index in the Array. Change-Id: Iab2ba2a48ebe5b7031759eeb4ebe02b4d86233f0 Reviewed-by: Simon Hausmann <[email protected]>
* | Save memory on array dataLars Knoll2014-01-201-19/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Store a simple vector of Values in the array data, instead of a Vector of Property's. This halfes the memory consumption on 64bit and simplifies our code. If an indexed property gets converted to an accessor property, we simply convert the ArrayData into a SparseArrayData. Add support in SparseArrayData to allocate double slots (two Value's) to hold a full Property in case someone sets an accessor on an indexed property. Some methods still return a Property*, but this is safe, as only the first Value in the Property pointer will ever get accessed if the Property doesn't contain an accessor. Change-Id: Ic9b0f309b09a2772a328d947a10faaf3be9fe56f Reviewed-by: Simon Hausmann <[email protected]>
* | Rework array handling for JS objectsLars Knoll2014-01-091-97/+98
| | | | | | | | | | | | | | | | | | Split up ArrayData into two classes, one for regular arrays, one for sparse arrays and cleanly separate the two cases. Only create array data on demand. Change-Id: I9ca8d0b53592174f213ba0f20caf93e77dba690a Reviewed-by: Simon Hausmann <[email protected]>
* | Merge remote-tracking branch 'origin/stable' into devSimon Hausmann2014-01-081-1/+1
|\| | | | | | | Change-Id: Ied8d65aaf57e897a3dbc4df100744a594e8ee2cf
| * [ChangeLog][QtQml] Fix JavaScript Array.pop() not updating the internal ↵Simon Hausmann2014-01-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | array length correctly While the length property was reporting the correct value, the internal array length was out-of-sync. Task-number: QTBUG-35979 Change-Id: I68820a349cf1ce88c6aabc6a2301a8a861018a10 Reviewed-by: Liang Qi <[email protected]> Reviewed-by: Lars Knoll <[email protected]>
* | Move array data into it's own structLars Knoll2014-01-031-39/+39
|/ | | | | | | First step of separating the array data from Object. Change-Id: I5c857397f0ef53cff0807debdb1e405424e1046a Reviewed-by: Simon Hausmann <[email protected]>
* Fix regression in QML string list concatenationsSimon Hausmann2013-12-111-2/+12
| | | | | | | | | | | | | | | | | | | | String lists and other QList property types (wrapped as QQmlSequence) should behave like arrays and have the Array prototype. Therefore it should be possible to pass them also as parameter to concat and they get composed correctly, i.e. the individual items get appended instead of the list being appened as one item. In the spec for concat this "special" casing should be applied if the "class internal property" is "Array", and concat appears to be the only place where this check is done. Therefore this patch adds another exception to match the expected behavior in QML and extends the "internal class is Array" meaning to QML list types. This is a regression from Qt <= 5.1.x Task-number: QTBUG-33149 Change-Id: Iab9522ac3c4ae6b746e790a99d87501b1cc1b655 Reviewed-by: Michael Brasser <[email protected]> Reviewed-by: Lars Knoll <[email protected]>
* Encapsulate the current context and fix it's usageLars Knoll2013-12-041-1/+1
| | | | | | | | | | | Encapsulate accesses to the current context, and rework the way we push and pop this context from the context stack. Largely a cleanup, but simplifies the code in the long term Change-Id: I409e378490d0ab027be6a4c01a4031b2ea35c51d Reviewed-by: Simon Hausmann <[email protected]>
* Move the vtable pointer from the object to the internal classLars Knoll2013-12-041-1/+1
| | | | | | | | This saves one pointer per object, and willmake other optimizations easier in the future. Change-Id: I1324cad31998896b5dc76af3c8a7ee9d86283bfe Reviewed-by: Simon Hausmann <[email protected]>
* Fix interaction between head room and appending in arraysLars Knoll2013-11-181-0/+1
| | | | | | | | | | We reserve space on both ends of the JS array for appending and prepending. Make sure they interact well with each other and don't cause any memory corruption. Task-number: QTBUG-34853 Change-Id: I184280178690e3cb12ab9b199a8436b32383af38 Reviewed-by: Simon Hausmann <[email protected]>
* Simplify & speed up function callingLars Knoll2013-11-091-22/+22
| | | | | | | | | Get rid of the SimpleCallContext, instead simply use the CallContext data structure, but don't initialize the unused variables. Change-Id: I11b311986da180c62c815b516a2c55844156d0ab Reviewed-by: Simon Hausmann <[email protected]>
* Fix various compiler warnings in order to remove warn_off in the near futureErik Verbruggen2013-11-041-7/+7
| | | | | Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a Reviewed-by: Simon Hausmann <[email protected]>
* Protect write accesses to objectsLars Knoll2013-10-291-10/+44
| | | | | | | | Don't write to objects if we have a pending exception to avoid any side effects. Change-Id: I9f93a9195a652dbae7033cc6ebb355d5d86e9b5e Reviewed-by: Simon Hausmann <[email protected]>
* Avoid side effects when en exception has been thrown.Lars Knoll2013-10-291-12/+50
| | | | | | | | | | | | | | We don't want to check for exceptions after every single line on our runtime methods. A better way to handle this is to add the check in all methods that have direct side effects (as e.g. writing to a property of the JS stack). We also need to return whereever we throw an exception. To simplify the code, ExecutionContext::throwXxx methods now return a ReturnedValue (always undefined) for convenience. Change-Id: Ide6c804f819c731a3f14c6c43121d08029c9fb90 Reviewed-by: Simon Hausmann <[email protected]>
* Avoid creating array attributes if possibleLars Knoll2013-10-141-1/+1
| | | | | | | | | | | Holes in arrays should be represented by an empty value, not by creating/setting array attributes. Reason is that the creation is irreversable, and slows down execution. This speeds up crypto.js by 10% Change-Id: I2e5472575479a5f2dbe53f59ecb8ed3aeab1be7a Reviewed-by: Simon Hausmann <[email protected]>
* Use SafeValue instead of Value in ScopedValue methodsLars Knoll2013-10-021-2/+2
| | | | | Change-Id: Ie463efe600d498ce77d4b9e8b48abcfd61c1ab78 Reviewed-by: Simon Hausmann <[email protected]>
* V4: fix ArrayPrototype::method_isArray() build breakJ-P Nurmi2013-10-011-1/+1
| | | | | | | | | With a recent Clang in C++11 mode: error: incompatible operand types ('QV4::ArrayObject *' and 'bool') Task-number: QTBUG-33706 Change-Id: I7bd4fe01176745fb6f8dbdf8f271edb7121eb35e Reviewed-by: Simon Hausmann <[email protected]>
* Remove some uses of raw Object pointersLars Knoll2013-09-301-20/+20
| | | | | Change-Id: I7c715f33d197ebbf6f0c00040099b27ed7221d42 Reviewed-by: Simon Hausmann <[email protected]>
* Remove more occurrences of QV4::ValueLars Knoll2013-09-301-5/+5
| | | | | Change-Id: I66c370680d7e6bee2e73a7a940aa96ab4009ec57 Reviewed-by: Simon Hausmann <[email protected]>
* Fix API for Object::define*PropertyLars Knoll2013-09-281-5/+7
| | | | | | | use ValueRef instead of const Value &. Change-Id: I3fd0ca829870db27f036825d713c53dc0600be07 Reviewed-by: Simon Hausmann <[email protected]>
* Fix Value usage in ErrorObjectsLars Knoll2013-09-281-2/+4
| | | | | Change-Id: Iaa14ad5a8d3f085843e49195f8f4bb7bb020b9b6 Reviewed-by: Simon Hausmann <[email protected]>
* Remove more direct QV4::Value usageLars Knoll2013-09-281-4/+5
| | | | | | | | Remove Value::fromString(String *), and make Encode safe against encoding raw Managed * pointers. Change-Id: Ibca4668e1cbeaf85c78169d14386281659d33ef6 Reviewed-by: Simon Hausmann <[email protected]>
* Move Value::fromBool, ... to a new Primitive classLars Knoll2013-09-281-28/+28
| | | | | | | | This will simplify finding the remaining direct usages of QV4::Value that need fixing. Change-Id: I223099727436d5748027c84c53d9dfc4028e38ed Reviewed-by: Simon Hausmann <[email protected]>
* Fix CallContext to not hold arguments on the C stack anymoreLars Knoll2013-09-281-56/+56
| | | | | Change-Id: I35f46cce4f243d4b8b2bac9244f8fc26836f413b Reviewed-by: Simon Hausmann <[email protected]>
* Fix cases where mark() would access uninitialized memoryLars Knoll2013-09-221-47/+35
| | | | | Change-Id: I4e07e20d30ba57759a0ece1c298a02b098718b33 Reviewed-by: Simon Hausmann <[email protected]>
* Prevent objects from being collected while in their constructorLars Knoll2013-09-221-1/+1
| | | | | | | | | | | | | While objects are being constructed, we don't have a reference to them on the JS stack yet. So the constructor needs to protect itself against being collected by putting the this object onto the JS stack. Added an environment switch MM_EXACT_GC to test exact garbage collection. Change-Id: Ie37665a954de800359c272ffbebbe1488e7a8ace Reviewed-by: Gunnar Sletta <[email protected]> Reviewed-by: Simon Hausmann <[email protected]>
* Convert the last methods in qv4object_p.hLars Knoll2013-09-221-1/+1
| | | | | | Change-Id: I4fda83a0832760c277e629d4e658da718c0bf92b Reviewed-by: Gunnar Sletta <[email protected]> Reviewed-by: Simon Hausmann <[email protected]>
* Fix some more methods to take ValueRef'sLars Knoll2013-09-221-5/+3
| | | | | | Change-Id: Ia0e30ba98c16e51c9992027c7e5f78d4def8697a Reviewed-by: Simon Hausmann <[email protected]> Reviewed-by: Gunnar Sletta <[email protected]>
* Fix some smaller spec incompliances in Array.concatLars Knoll2013-09-221-11/+5
| | | | | | Change-Id: I4a2252ef590c0d48ba734f96c7478637e1ddfd07 Reviewed-by: Simon Hausmann <[email protected]> Reviewed-by: Gunnar Sletta <[email protected]>
* convert Managed::put() API to be GC safeLars Knoll2013-09-221-13/+15
| | | | | Change-Id: I09198ce372fa545372db389fac26828d21ad5731 Reviewed-by: Simon Hausmann <[email protected]>
* Use a StringRef for Managed::get()Lars Knoll2013-09-221-8/+9
| | | | | | | | | also store "toString" and "valueOf" as identifiers in the engine and fix two places where we compared strings the wrong way. Change-Id: I70612221e72d43ed0e3c496e4209681bf254cded Reviewed-by: Simon Hausmann <[email protected]>
* Cleanup Object::define*Property APILars Knoll2013-09-221-26/+26
| | | | | Change-Id: I99125908a9bc1d41a2642c409af9704def7a0832 Reviewed-by: Simon Hausmann <[email protected]>
* Further work towards an exact GCLars Knoll2013-09-221-74/+67
| | | | | | | | | | | Add some more convenience in the helper classes in qscopedvalue_p.h Make accesses to CallData safer, and change ExecutionEngine::newObject() to return a safe pointer. Change-Id: I980909754ce9681cf6faa1355bab3a1e5d6dd186 Reviewed-by: Simon Hausmann <[email protected]>
* Convert more methods to return a Returned<>Lars Knoll2013-09-181-13/+15
| | | | | Change-Id: If294c9c4f574824c308b63a11da1337226180105 Reviewed-by: Simon Hausmann <[email protected]>
* Convert most remaining return values from Value to ReturnedValueLars Knoll2013-09-181-1/+1
| | | | | Change-Id: If8b0c3b91be50678693868c10fefc3678008834d Reviewed-by: Simon Hausmann <[email protected]>
* Convert builtin methods to return a ReturnedValueLars Knoll2013-09-181-58/+58
| | | | | Change-Id: I6b75adbf53a5be0deab023d2eed98ce2a7915551 Reviewed-by: Simon Hausmann <[email protected]>
* Use a ReturnedValue for Managed::getIndexed()Lars Knoll2013-09-181-21/+43
| | | | | Change-Id: I0371ed21c4ef99564d3ffa1082dd109e890a78bf Reviewed-by: Simon Hausmann <[email protected]>
* Use ReturnedValue for Managed::get().Lars Knoll2013-09-181-18/+23
| | | | | Change-Id: Ia8f35d227b69d32e1f6a041283abbbd083aa34ca Reviewed-by: Simon Hausmann <[email protected]>
* Use ReturnedValue for Managed::construct()Lars Knoll2013-09-181-3/+3
| | | | | Change-Id: I9e702d60c4e1b7ba19a699ff7a8d53876d6cd5f7 Reviewed-by: Simon Hausmann <[email protected]>
* Rename QV4::ValueScope to QV4::ScopeLars Knoll2013-09-181-10/+10
| | | | | | | | The class is going to be used all over the place, so let's give it a short name :) Change-Id: If61543cb2c885e7fbb95c8fc4d0e870097c352ed Reviewed-by: Simon Hausmann <[email protected]>
* Require a ValueScope for ScopedCallData as wellLars Knoll2013-09-181-18/+22
| | | | | | | | This brings things more in line with ScopedValue, and also simplifies cleanup of Scoped values. Change-Id: If5f1466b4e13c629d56c1e7c638937f61ba48f77 Reviewed-by: Simon Hausmann <[email protected]>
* Use a ReturnedValue for Managed::call()Lars Knoll2013-09-181-22/+33
| | | | | Change-Id: Ief2d75e9789dd367c603d90dc0fe5316a0d055e3 Reviewed-by: Simon Hausmann <[email protected]>
* Continue conversion to using scoped valuesLars Knoll2013-09-111-4/+10
| | | | | | | | | | | This converts all methods in qv4runtime_p.h to not use raw values in arguments anymore. The conversion of return values will be done in a separate commit. Change-Id: Ie6e8f3bed459d09cb831f7f87920b7eada161502 Reviewed-by: Simon Hausmann <[email protected]>