aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4debugging.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QmlDebug: Split QV4::Debugging::Debuggerhjk2015-10-141-24/+24
| | | | | | | | | | ... into a pure interface and a QV4::Debugging::V4Debugger implementation. This is in preparation of a second implementation of this interface to be used with 'native mixed' debugging. Change-Id: I3078dcfe4bdee392a2d13ef43a55ca993e7b88d8 Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
* Rename currentExecutionContext to currentContextLars Knoll2015-09-151-5/+5
| | | | | | | | 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-11/+10
| | | | | Change-Id: Ic79d6da162375928ec25871cd0341daeab6483d2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Store the stack of executioncontext's on the JS stackLars Knoll2015-09-151-1/+1
| | | | | | | | | | | | | | | | 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>
* Cleanup the ExecutionContextSaverLars Knoll2015-09-151-1/+1
| | | | | | | | Always operate on the current context (as that's what we do in practice anyway). Change-Id: I4171207a7a86e69aa685754956c0764ac6e152a7 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* V4 debugger: Fix expression evaluationUlf Hermann2015-08-191-1/+9
| | | | | | | | | | | | We need to collect the refs in the debugService's list in order for them to show up on addRefs() and we need to generate proper error responses if either the debugger is not stopped or the evaluation throws an exception. Task-number: QTBUG-47797 Task-number: QTBUG-47816 Change-Id: I98f17c1f3976859ee50b9bfac41091276ff60982 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move DataCollector into debugger pluginUlf Hermann2015-08-101-563/+31
| | | | | | | | The data collector and all the jobs it uses to interact with the engine are only used from the debugger plugin. We can as well move them there. Change-Id: Ia48251f08b48c7e1e607b8ae2a3d1de29f80f742 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* Move V4 debugger agent into the debugger pluginUlf Hermann2015-08-101-142/+2
| | | | | | | | | | The debugger is the only thing that actually needs it. Note that for this to work we need to make QV4::Debugging::Debugger a QObject and add some signals. The net effect is still a reduction in binary size of about 1kb. Change-Id: Ibecb8cfa140fc26fc13c8cbefb3d027ebdcd28a4 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* Change data collection for debugging to use QV4::Value.Ulf Hermann2015-08-101-94/+259
| | | | | | | | | | | | | | | | This patch changes the variable collection to store QV4::Value values into a JS array, which is retained by the collector. This prevents any GC issues, and gives a nice mapping from handle (used in the debugging protocol) to JS value. It also allows for easy "shallow" object serialization: any lookup can start with the QV4::Value, and add any values it encounters to the array. Testing is changed to use this collector directly, thereby testing the class that is actually used to generate protocol data. Task-number: QTBUG-47061 Change-Id: Iec75c4f74c08495e2a8af0fedf304f76f8385fd7 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* Add namespace declarations to qv4debugging.cppUlf Hermann2015-07-291-0/+4
| | | | | Change-Id: Ia7c4e6e29726276bbfe8888b2b2902abc971cad3 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove type punning from QV4::Value.Erik Verbruggen2015-07-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* 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 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>
* Get rid of asManaged()Lars Knoll2015-04-211-1/+1
| | | | | Change-Id: I853417fdf1cc339f7d43a006c20e1626b6bfb288 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>
* 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>
* Merge remote-tracking branch 'origin/5.4' into devSimon Hausmann2015-01-161-8/+10
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Fix GC crash with conditional breakpoints and JS consoleSimon Hausmann2014-12-191-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | We may choose to execute an expression in a specific frame within the debugger, which is where we pop context's until we reached the frame in question. If we are trying to execute an expression at the top of the stack (or with a conditional breakpoint expression), then we don't have a frame and don't need to pop contexts. But also also don't need to call Scope::alloc(-1). Change-Id: I1f6754a3d77d943aed9bf4468e817a5269a3c547 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * QML Debugging: Fix crash when stepping through try-catch block.Erik Verbruggen2014-12-091-8/+9
| | | | | | | | | | | | | | | | | | Also fix the stack-trace generation, otherwise the debugger engine would report a breakpoint hit on the wrong line. Task-number: QTBUG-42723 Change-Id: I1f655a5174b28a1c9c31c85bbe023fbce5ddbb96 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Make sure we always have an engine when assigning to a PersistentLars Knoll2015-01-131-7/+6
| | | | | | | | | | | | | | This prepares things for a rewrite of the internals of Persistent. Change-Id: Ib93ec5911984d1bfce87ffdc3f86bc75f6ecafe9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use QV4::ScopedContext typedef instead of actual typeOleg Shparber2015-01-021-4/+4
| | | | | | | | | | Change-Id: I71c6c9cf030e347fbc5e4073e9ca338a9ce95999 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Return Heap::ExecutionContext for currentContext()Lars Knoll2014-12-191-22/+22
| | | | | | | | | | Change-Id: I155ab996e24d7f36761d2ea62a04774e16469b34 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Fix GC crash with conditional breakpoints and JS consoleSimon Hausmann2014-12-191-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | We may choose to execute an expression in a specific frame within the debugger, which is where we pop context's until we reached the frame in question. If we are trying to execute an expression at the top of the stack (or with a conditional breakpoint expression), then we don't have a frame and don't need to pop contexts. But also also don't need to call Scope::alloc(-1). Change-Id: I1f6754a3d77d943aed9bf4468e817a5269a3c547 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Make ExecutionContextSaver GC safeLars Knoll2014-12-191-2/+2
| | | | | | | | | | Change-Id: I29f00366d24c770afe4ba4579106d81a8c9043df Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Merge remote-tracking branch 'origin/5.4' into devSimon Hausmann2014-12-091-14/+22
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4arraydata.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4globalobject.cpp src/qml/jsruntime/qv4internalclass.cpp src/quick/items/qquicktext_p.h src/quick/items/qquicktextedit_p.h src/quick/items/qquicktextinput_p.h Change-Id: If07e483e03197cb997ef47a9c647a479cdb09f4c
| * Fix conditional breakpoints in QMLSimon Hausmann2014-12-031-1/+3
| | | | | | | | | | | | | | | | | | | | We need to set "inheritContext" to true for the QV4::Script that's used during conditional break point evaluation, because that will also disable fast property lookups, which is still required for QML lookups to work. Change-Id: I8976df1c827b5058eae9bdce6e86e5ea856cbfe1 Task-number: QTBUG-43018 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Fix expression evaluation in specific frames in the debuggerSimon Hausmann2014-12-031-13/+19
| | | | | | | | | | | | | | | | | | | | | | | | Expressions from the QML/JS console are intended to be executed in a specific frame / context. However that wasn't implemented properly, we should pop the current context frameNr times. [ChangeLog][QtQml] Fix inspecting objects in QML/JS console in different frames. Change-Id: If575d4005c52a9fe6805538a7b1a02b9e32049d6 Task-number: QTBUG-42831 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Changed InternalClass to store Identifier* instead of String*Simon Hausmann2014-11-211-4/+5
| | | | | | | | | | | | | | | | | | 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>
* | Cleanup exception catching codeLars Knoll2014-11-151-1/+1
| | | | | | | | | | Change-Id: I85afd5758f72e19c280dc196601ee145f0c25f01 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Cleanup debugger to be safe for the new GCLars Knoll2014-11-121-6/+5
| | | | | | | | | | | | | | Added a bit of convenience to PersistentValue as well. Change-Id: I5a858079543b41ce1ef48a84e9350a7d6fa64501 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Convert ExecutionContext::parent/outer to use a heap objectLars Knoll2014-11-121-10/+23
| | | | | | | | | | Change-Id: I1b8ee831cfcdd5b1904ce24a341f5a796dce41cf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Use Heap object for CallData::function memberLars Knoll2014-11-111-1/+1
| | | | | | | | | | Change-Id: I5cae1b16c68751da9481a1cdae2601efa2a500a2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Refactor ExecutionContextsLars Knoll2014-11-081-4/+4
| | | | | | | | | | | | | | Move the Data class out into the Heap namespace. Change-Id: I2b798deb53812a08155c92a0e6ef2dcd2ea137b8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Cleanup header file dependenciesLars Knoll2014-11-041-0/+1
|/ | | | | 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>
* Add support for conditional breakpoints and evaluate.Erik Verbruggen2014-08-081-8/+72
| | | | | | | | | | | | Also centralized the context state saver and added line number saving, so that the JS jobs for evaluation of breakpoint conditions don't change the state of the current engine context. Task-number: QTBUG-37119 Task-number: QTCREATORBUG-11516 Change-Id: Ia21b3d64e239e5b67f3c07e1c006d8e6748f29b6 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert Execution contexts to new constructor syntaxLars Knoll2014-07-221-5/+5
| | | | | Change-Id: I4bc6a61b7a96139353e20871ff7ff007822c64c3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of all uses of ObjectRefLars Knoll2014-07-221-1/+1
| | | | | Change-Id: I705e2362dcda542f56826dadec6b0a6f15848788 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert ExecutionContext to new storage schemeLars Knoll2014-07-221-11/+11
| | | | | Change-Id: I9fcc13da5360f37cef3149b114ed9263b9b74281 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move data of FunctionObject into an inner structLars Knoll2014-07-221-1/+1
| | | | | Change-Id: Ic00b1761565f9f8881b665a3fecca723239e2279 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Allow detaching V4 debuggers in agent destructorUlf Hermann2014-03-111-0/+3
| | | | | | | | We don't know in which order the QML engines and the debug service are deleted on shutdown. Change-Id: I9d23b3c88eee125a93c5b0f8ea85466013233737 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fixes to breakpoint handlingLars Knoll2014-03-071-26/+23
| | | | | | | | Make sure stepping works correctly, and we always break at a valid breakpoint. Change-Id: I6a3032b3ae204484b8a92b2031904a7f681c7f80 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add a Line instruction to the interpreterLars Knoll2014-03-071-4/+4
| | | | | | | | | | This unifies the way we handle line numbers in the JIT and Interpreter. Remove the now unused lineNumberMapping code and data. Change-Id: I1d60b1fbb77e70b531fa73d93410683e84dd1e3c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Simplify our breakpoint handlingLars Knoll2014-03-071-201/+32
| | | | | | | | | | | | | | | | | Only store a Hash of break points in the debugger, instead of the involved logic that currently adds and removes break points. Add the current line number to the Debug statements in the interpreter, and pass them on to the debugger for checking whether we should really break. This adds a slight additional overhead to running inside the debugger, but greatly simplifies the logic and doesn't require modifying the bytecode anymore. This in turn opens up the possibility to run the debugger on JIT generated code later on. Change-Id: If2a3ae8f8d08b69a3a704cbbe0a84000f917a32e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Clean up our internal namespacesLars Knoll2014-02-231-2/+2
| | | | | | | | QQmlJS::MASM -> QV4::JIT QQmlJS::V4IR -> QV4::IR Change-Id: I707e8990459114a699c200fe3c22cec3c8df1afc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make the Ref classes not template basedLars Knoll2014-02-071-1/+1
| | | | | | | | | | Move to a class hierarchy that mirrors the main classes. This will allow moving functionality over into the Ref classes, as the current Managed classes become mainly something that holds the data. This is required to make objects movable by the GC. Change-Id: I4ca88ab0e5d8c88c8dc56d51937990500a33e0d9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add a special Debug instruction to the interpreter and use itLars Knoll2014-02-051-4/+4
| | | | | | | | | | | | | | | This avoid having to check for the debugger at every instruction we execute. Instead we only add debug instructions at the beginning of every line and every basic block when we have a debugger. This still allows interrupting the JS execution at any time (as we can't loop inside a basic block), and single stepping through lines. But it has no overhead when the debugger is not running and a lot less when it is running. Change-Id: Ib17170b42944b608fc6caa1891082205dd2b2763 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* Encapsulate the current context and fix it's usageLars Knoll2013-12-041-9/+9
| | | | | | | | | | | 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 <simon.hausmann@digia.com>
* Move the vtable pointer from the object to the internal classLars Knoll2013-12-041-2/+2
| | | | | | | | This saves one pointer per object, and willmake other optimizations easier in the future. Change-Id: I1324cad31998896b5dc76af3c8a7ee9d86283bfe Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>