aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4context.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Properly resolve the context to create mutable bindings onLars Knoll2015-10-201-4/+13
| | | | | | | | | This fixes a regression introduced in 5.5, where eval() calls in strict mode would still modify outer properties. Change-Id: I3ab70b45217eea16da68a4537e3c107b76794f2c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* Simplify Object::putValue()Lars Knoll2015-09-151-1/+1
| | | | | Change-Id: I1cc43f0081f63aed27c82875192e0f415ec995d5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Store the stack of executioncontext's on the JS stackLars Knoll2015-09-151-7/+9
| | | | | | | | | | | | | | | | 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>
* Reduce usage of context->parentLars Knoll2015-09-151-22/+22
| | | | | Change-Id: I31bb8019783311a7e6065e2aac7fec67c1120ebf Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Explicitly push/pop ExecutionContextsLars Knoll2015-09-151-2/+0
| | | | | | | | 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>
* Smaller cleanupLars Knoll2015-09-091-0/+5
| | | | | | | Move the takeContextOwnership method over to the QmlContext. Change-Id: I9330b31a0cb079b1c7e68a00236a69e25ed2c5af Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Don't push new QML contexts onto the context stackLars Knoll2015-09-081-2/+6
| | | | | | | | | | When creating new QML contexts, these are not used directly, but rather as scopes for other functions. Change the behavior, so that newQmlContext doesn't push the new context onto the context stack. Change-Id: I8254da3f660c4791941835c925b9892274ea51b0 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Refactor the way we declare signal parameter namesLars Knoll2015-09-081-0/+6
| | | | | | | | | | | | | | Qml Connection objects where using an awkward way to make the parameter names of signals available to the signal handler. This now uses an approach that is equivalent to what we do with other functions. The main difference is that we can't know the parameter names at type compile time, so we have to rewrite the internal class of the QV4::Function at connect time. Change-Id: I5e538ac840b5a46ccb14ff71684404d947948324 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Smaller cleanupsLars Knoll2015-08-141-0/+11
| | | | | Change-Id: I14eb7e2b4031c8a033740ed1ef34f3b2efdc3649 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove type punning from QV4::Value.Erik Verbruggen2015-07-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Smaller code cleanupsLars Knoll2015-06-191-1/+1
| | | | | Change-Id: Id3bc6ea5615a462d7a41ceb1fa18b4fb090e0d51 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Add some typesafetyLars Knoll2015-06-181-2/+3
| | | | | | | | Even though the goal is to get rid of the contextwrapper, this helps in the meantime. Change-Id: I234ef39f74fb0eee78710884de6a1c90763bce74 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Clean up ExecutionContext's for QMLLars Knoll2015-06-181-120/+180
| | | | | | | | | | | | 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>
* Move the StringValue members of ExecutionEngine onto the JS stackLars Knoll2015-06-101-3/+3
| | | | | Change-Id: Ib55c05f1730b7659e2f6fee7e1fa79c10c759167 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move exceptionValue and globalObject from the Engine onto the JS stackLars Knoll2015-04-241-3/+3
| | | | | | | | | 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>
* More cleanups in qv4value_p.hLars Knoll2015-04-241-5/+5
| | | | | Change-Id: Ie48dc8f95daa4738e690902b5d33010afa7b974f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-221-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlbinding.cpp src/qml/jsruntime/qv4arraybuffer.cpp src/qml/jsruntime/qv4functionobject.cpp Change-Id: Ic752e9dfd69b282093651c9234c110a49762f06d
| * Avoid strict mode for the surrounding QML call contextsSimon Hausmann2015-04-161-1/+1
| | | | | | | | | | | | | | | | | | The strict mode is not necessary from a correctness point of view but comes with the extra cost that for each script binding additional caller and arguments accessor members are a installed on the internal class. Change-Id: I13b688bc8344ee2f027679821586ca7670d17cc5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Reduce dependenciesLars Knoll2015-03-201-0/+1
| | | | | | | | | | Change-Id: I4190c1a6d8a06a130e50cb727feafa7cf11f21cd Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.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>
* 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>
* Properly mark all arguments in the call contextLars Knoll2015-01-261-5/+3
| | | | | | | | | This broke in change d24b7fb904771ba078ac52e05984b23327ddff3b, where argc changed to contain the number of arguments passed into the function, not the number of arguments it really has. Change-Id: I2d25f159a9f60922b863c238147564f542d62ba0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove the realArgumentsCount member in CallContextLars Knoll2015-01-231-2/+0
| | | | | | | | | | | The data is easily available through the CallData, only used by the Arguments object and we save a pointer in Heap::CallData this way. For this to work, let CallData::argc always return the real number of arguments passed into the function. Change-Id: I59c7c41e8c1af160db09fa794977ab7084c9e12d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* CleanupsLars Knoll2015-01-231-3/+3
| | | | | | | | 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-6/+6
| | | | | | | | Remove duplicated methods. Remove some mostly unused methods, and simplify some others. Change-Id: I605b249e54417bb32c3dfc8e22f2c8b6b684a1e1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of most uses of ValueRefLars Knoll2015-01-231-6/+6
| | | | | | | | | | | | 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 vtable out of internalClassLars Knoll2015-01-201-2/+2
| | | | | | | | | | | | | | | | 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>
* Don't require an ExecutionEngine member in String anymoreLars Knoll2015-01-161-2/+2
| | | | | Change-Id: I7c1a5471507669871564d79dc17d1026c268b6d0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merge remote-tracking branch 'origin/5.4' into devSimon Hausmann2015-01-161-0/+16
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4debugging.cpp src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4functionobject_p.h src/qml/jsruntime/qv4qobjectwrapper.cpp src/quick/scenegraph/shaders/visualization.frag tests/auto/qml/qjsengine/tst_qjsengine.cpp Change-Id: I492e8546c278f80a300a2129e9a29d861e144a30
* | Define vtable for CatchContextLars Knoll2015-01-121-0/+1
| | | | | | | | | | Change-Id: I987e38f843881137b4e3241f68ecdf5516f95515 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Get rid of the needsActivation flag in Heap::BaseLars Knoll2015-01-121-1/+1
| | | | | | | | | | | | Change-Id: Idcec374cb6d16aabf919c23d7236b76d9d047527 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use QV4::ScopedContext typedef instead of actual typeOleg Shparber2015-01-021-5/+5
| | | | | | | | | | Change-Id: I71c6c9cf030e347fbc5e4073e9ca338a9ce95999 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>
* | Fix Context::getPropertyAndBase to use Heap based objectsLars Knoll2014-12-201-4/+4
| | | | | | | | | | Change-Id: I4f885a8af5e963445959871b7f26f3bcb3dfa654 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Remove most of the places where getPointer() is usedLars Knoll2014-12-201-48/+48
| | | | | | | | | | | | | | This is no longer required, and simply uglifies the code Change-Id: Iba91a1d7735ebe23a43437f137a488423b6eb743 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Return a Heap::Object in Object::prototype()Lars Knoll2014-12-171-2/+3
| | | | | | | | | | Change-Id: Ice0265ae558ba14497421a5bbf25ee9db76adab5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Better encapsulate access to the global objectLars Knoll2014-12-111-3/+3
| | | | | | | | | | Change-Id: I8a76112d821cb3fc172ba0d16ee8410d39b4422a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Get rid of a not required reinterpret_castLars Knoll2014-12-111-1/+1
| | | | | | | | | | Change-Id: I076fa02589cc91eca46dd652375585bc7ca5b559 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Let the memory manager operate on Heap::Base objects, not ManagedLars Knoll2014-11-211-1/+1
| | | | | | | | | | Change-Id: Ib5c9b51dbf9c69abeda088094e6348dd545bf3c8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Changed InternalClass to store Identifier* instead of String*Simon Hausmann2014-11-211-2/+2
| | | | | | | | | | | | | | | | | | All members are identifiers anyway, so this gets rid of a ### and also simplifies some of the call sites by removing the need for a scoped string. Change-Id: Ic6b550cdb97afa5a4b0fa7e9b13e7768ed3f6bd8 Reviewed-by: Lars Knoll <lars.knoll@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>
* | Cleanup exception catching codeLars Knoll2014-11-151-5/+0
| | | | | | | | | | Change-Id: I85afd5758f72e19c280dc196601ee145f0c25f01 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>
* | Remove the remaining uses of Returned<T>Simon Hausmann2014-11-151-2/+2
| | | | | | | | | | Change-Id: I493b75365d3c6fbf6965986d73e7aa0b659ded67 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Changed MemoryManager::alloc<T> to return Heap::T* instead of T*Simon Hausmann2014-11-151-2/+2
| | | | | | | | | | Change-Id: Iede1ba624d1313fbe2f8e5e979e936f1f32efdc9 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Replaced more usages of Returned<T> with Heap::T*Simon Hausmann2014-11-141-6/+6
| | | | | | | | | | Change-Id: I451128ee71610bfeb71139c28da89a00a8209ec6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Ported most ExecutionEnginew::new* factory methods away from Returned<T>Simon Hausmann2014-11-121-1/+1
| | | | | | | | | | | | | | | | We don't need Returned<T> anymore with the QV4:: vs. Heap:: separation. Eliminating Returned<T> simplifies also some code. Change-Id: Ic2a9cd3c1a94f2ea37b539d3984d63997121c2b9 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Store all data members in FunctionObject as heap dataLars Knoll2014-11-121-2/+2
| | | | | | | | | | Change-Id: Ic061baaf7f5ff08c5e6e7130abd6a650148d3d2d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Convert ExecutionContext::parent/outer to use a heap objectLars Knoll2014-11-121-32/+36
| | | | | | | | | | Change-Id: I1b8ee831cfcdd5b1904ce24a341f5a796dce41cf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use Heap object for CallData::function memberLars Knoll2014-11-111-12/+12
| | | | | | | | | | Change-Id: I5cae1b16c68751da9481a1cdae2601efa2a500a2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>