aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4function.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor the way we declare signal parameter namesLars Knoll2015-09-081-0/+31
| | | | | | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.5' into 5.6Ulf Hermann2015-08-181-1/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/debugger/qv4debugservice.cpp src/qml/jsruntime/qv4value_inl_p.h src/qml/jsruntime/qv4value_p.h src/qml/memory/qv4mm.cpp src/qml/memory/qv4mm_p.h src/qml/qml/qqmlnotifier_p.h src/qml/qml/qqmlproperty.cpp src/quick/items/qquickflickable.cpp src/quick/items/qquicktextedit.cpp tests/auto/quick/qquickwindow/BLACKLIST The extra changes in qqmlbinding.cpp are ported from changes to qqmlproperty.cpp that occurred in parallel with writeBinding() being moved to qqmlbinding.cpp. Change-Id: I16d1920abf448c29a01822256f52153651a56356
| * V4: track C++ heap usage for Strings in the MemoryManagerErik Verbruggen2015-07-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... and do a GC run when it exceeds a threshold. The issue with Strings is that they hold on to QString instances that store the real content. However, the GC only sees the light-weight JS handle, and doesn't take the size of the backing content into account. So it could happen that big QStrings accumulate in the heap as long as the GC didn't reach its threshold. The newly introduced unmanaged heap threshold is upped by a factor of two when exceeded, and lowered by a factor of 2 when the used heap space falls below a quarter of the threshold. Also grow the threshold if there is enough space after running the GC, but another GC run would be triggered for the next allocation. There is a special case for Heap::String::append, because this method will copy the data from the left and right substrings into a new QString. To track this, append notifies the memory manager directly of the new length. The pointer to the memory manager is stored in Heap::String, growing it from 40 bytes to 48 bytes (which makes it still fit in the same bucket, so no extra memory is allocated). Task-number: QTBUG-42002 Change-Id: I71313915e593a9908a2b227b0bc4d768e375ee17 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-1/+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>
* | 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>
* Move the internalClass pointer into Heap::ObjectLars Knoll2015-01-211-1/+1
| | | | | | | | The other classes that derive from Heap::Base don't need it at all. So get rid of it there and save a pointer. Change-Id: I9c5df2e43cd6eeac2e6e41f3d3b8077d3afbc8f2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Changed InternalClass to store Identifier* instead of String*Simon Hausmann2014-11-211-5/+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-4/+5
| | | | | | | | | | | | | | | | | 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>
* Ported ExecutionEngine::newString and newIdentifier to Heap::StringSimon Hausmann2014-11-121-1/+1
| | | | | | | | | | 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>
* Change signature or runtime methods to take an engine pointerLars Knoll2014-11-121-1/+1
| | | | | | | | | This makes a lot more sense in the long term and is the more maintainable solution, once the GC starts moving objects around in memory Change-Id: I8f327c0f5b5b0af38c5fe1a217852ee8c4a5c2fc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move Data for String into the Heap namespaceLars Knoll2014-11-081-1/+1
| | | | | Change-Id: Iefa231106b77db6d4c9d4ded2b028d21eb94ab03 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Changed Value to store Managed::Data pointers directlySimon Hausmann2014-11-041-2/+2
| | | | | | | | This is a step towards storing direct heap object pointers for the values on the JS stack, to avoid the costly indirection for data access. Change-Id: Ibb57ed6cf52a7088bbc95ee04ae3a4cb25b8c045 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>
* Change the object allocation schemeSimon Hausmann2014-07-221-1/+2
| | | | | | | | | Instead of allocating the data directly, centralize the object and its ::Data allocation in one place in the memory manager. This is in preparation for additional pointer indirection later. Change-Id: I7880e1e7354b3258b6a8965be378cd09c9467d25 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Convert String to new constructor syntaxLars Knoll2014-07-221-1/+3
| | | | | Change-Id: I07f7667d3d72a7d72e6717d194de8d7b15435777 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add a Line instruction to the interpreterLars Knoll2014-03-071-76/+0
| | | | | | | | | | 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>
* Remove unused codeSizesLars Knoll2014-03-031-2/+1
| | | | | Change-Id: I13c7d9dda7cd1e771079f6fdaa175008b3a3e0e5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove nArguments and name from QV4::FunctionLars Knoll2014-03-031-9/+0
| | | | | | | | Saves 12 bytes per Function Change-Id: I9a495805f9201eb6162a520ff5c2defeb73dc37a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Rename some filesLars Knoll2014-01-311-1/+1
| | | | | | | | | | | | Rename qv4value_def_p.h -> qv4value_p.h and qv4value_p.h to qv4value_inl_p.h. It makes more sense to have the class definition in the file that is named after the class and move the inline methods into a _inl file. Doing this now, as I expect we'll be needing a few more _inl files soon. Change-Id: Ib59e9380e9e976254c6b4369574157f39b1b5f51 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use an internalClass to represent formals and locals in CallContextsLars Knoll2013-12-041-13/+20
| | | | | | | | | | formals and locals in a CallContext where so far accessed through a linear search in ExecutionContext::getProperty. Fix this by introducing an internalClass for the Function used by the call context. Change-Id: I1141efa12b19d6de4a354bfd6e769c5ffcb8898b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove unused inline wrapperLars Knoll2013-12-041-1/+1
| | | | | | | | | The wrapper method for Function::code() was still there from the times we used C++ exceptions. It's not needed any more, so get rid of it. Change-Id: I2ec25fbca71eeef9d7a94a38b5adfa42e4de3a84 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 debugging: fix step-over and step-out.Erik Verbruggen2013-11-141-11/+14
| | | | | | | | | | | | | | | | - step-out: only stop if we’re leaving the context for the function we previously stopped at, so intermediate calls between the current position and the end do not stop the engine - step-over: set breakpoints on all lines in current function and continue to run. When hitting a breakpoint, see if we are in the same context, because recursive calls might happen. Breakpoints on all lines are needed, because the (pure) next line might be jumped over (like when doing step-over a single-line then clause, where the next line might be in the else clause). Change-Id: Idf35dc740ca64fae5079162162906490a96af2a7 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
* Fix native compilation on linux/arm with gcc 4.7.2Erik Verbruggen2013-11-131-1/+1
| | | | | | | | | | | /disk/qt5-dev/qtdeclarative/src/qml/jsruntime/qv4function.cpp: In instantiation of ‘int QV4::LineNumberMappingHelper<field, SearchType>::lowerBound(int, int, SearchType) [with int field = 0; SearchType = int]’: /disk/qt5-dev/qtdeclarative/src/qml/jsruntime/qv4function.cpp:142:49: required from here /disk/qt5-dev/qtdeclarative/src/qml/jsruntime/qv4function.cpp:106:13: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] cc1plus: all warnings being treated as errors Change-Id: Ic97d6a2a9acd392d565e9c66f30159552473e092 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Debugging with V4Erik Verbruggen2013-11-101-4/+37
| | | | | | | | | Currently missing, but coming in subsequent patches: - evaluating expressions - evaluating breakpoint conditions Change-Id: Ib43f2a3aaa252741ea7ce857a274480feb8741aa Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Refactor marking GC'ed objectsLars Knoll2013-11-051-4/+4
| | | | | | | | | | | Don't use recursive function calls anymore. Instead, push marked objects onto the JS stack, and then pop them off when their children are being marked. Should reduce stack memory usage, and improves performance by ~5%. Change-Id: I2d37d97579144fcba87ec8e9fd545dd220c01fbb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix various compiler warnings in order to remove warn_off in the near futureErik Verbruggen2013-11-041-4/+6
| | | | | Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove qv4unwindhelper classLars Knoll2013-10-291-1/+0
| | | | | | | | This class is not required anymore to generate stack traces, as we now store the required information in the JS context stack. Change-Id: I3893c805ca89dda70efde07fdd120e7dfaf3639f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix some more issues with exact GCLars Knoll2013-10-151-2/+2
| | | | | | | | | Get the formal and local names of function object from the compilation unit to avoid creating another set of strings. Use a ScopedFunctionObject in eval() Change-Id: I6693aec2e88818df9c160b3780db12d8df79c2fe Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Smaller cleanupsLars Knoll2013-10-111-2/+1
| | | | | Change-Id: I0a7eee96ef7c92ad4a3c5963010e3ac66fe6ed3a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove more direct QV4::Value usageLars Knoll2013-09-281-2/+2
| | | | | | | | Remove Value::fromString(String *), and make Encode safe against encoding raw Managed * pointers. Change-Id: Ibca4668e1cbeaf85c78169d14386281659d33ef6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix cases where mark() would access uninitialized memoryLars Knoll2013-09-221-0/+2
| | | | | Change-Id: I4e07e20d30ba57759a0ece1c298a02b098718b33 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Prevent objects from being collected while in their constructorLars Knoll2013-09-221-4/+3
| | | | | | | | | | | | | 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 <gunnar.sletta@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Change the runtime API over to using StringRef's instead of String*Lars Knoll2013-09-221-1/+1
| | | | | Change-Id: I0ea95e6cca995dc5f98871f0369204af18e48111 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Change calling convention in JIT to use ReturnedValueSimon Hausmann2013-09-181-1/+1
| | | | | | | This simplifies the masm backend as well and should be faster. Change-Id: I64ad5d9ee1b6caca950471e3aec4ef19d7503e62 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Properly unwind the js stack for generated codeLars Knoll2013-09-111-11/+4
| | | | | | | | | | | | | Surround all calls into generated code with a try {} catch {} statement that resets the jstack to the correct position. Like this we properly unwind the js stack in all cases, and can also use stricter assertions in our ScopedCallData, etc. classes to check that the stack is healthy. Change-Id: I7ca03e06ea55007be683305d9c2a6898cf5fc689 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix invalid reads with stringsSimon Hausmann2013-08-181-2/+2
| | | | | | | | | | | It may happen that a dynamically created compilation unit disappears before any QV4::Strings it created. Those strings would still have a reference to the QString data in the compilation unit. I don't see a choice other than making a copy of the string data ;(. But this patch adds a flag that would allow for avoiding it if we happen to know that the compilation unit data is static. Change-Id: Ib35a4d2a566b301a25ffe56e392809e44e7b4ae8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove unused Function::engine member and line number mapping typeSimon Hausmann2013-08-161-1/+0
| | | | | Change-Id: Id227139bf385aa92e539cdb0d0012e1360679c81 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Merge Function::init with the constructorSimon Hausmann2013-08-161-6/+16
| | | | | Change-Id: I557f8a80aa2c74398b94e87ed0f29fe8d2297150 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Get rid of the functions list in QV4::ExecutionEngineSimon Hausmann2013-08-161-2/+0
| | | | | Change-Id: I97067dbb2819936a1b2029c9f63f0627cb6b8bd2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Refcount the compilation unit and remove refcount from runtime functionSimon Hausmann2013-08-161-7/+0
| | | | | Change-Id: Iaa2f96a6814f1b39589ffcfe3c84e3c229e25f1f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Get rid of QV4::Function::generatedValues by porting moths' regexps to ↵Simon Hausmann2013-08-161-3/+0
| | | | | | | runtime expressions Change-Id: Iaae3c4855016948952159596d2528fca73341b72 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Ported identifiers in moth to use runtime stringsSimon Hausmann2013-08-161-2/+0
| | | | | Change-Id: I09f04994a2ebe631b12fa76b77a622711de31926 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Initial port of moth to the new compile data structuresSimon Hausmann2013-08-161-1/+0
| | | | | Change-Id: I2ead40c5c8c9b12b29c48c387ea424838d1f7d9e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Get rid of the QV4::Function in the masm iselSimon Hausmann2013-08-161-1/+5
| | | | | Change-Id: Ide70ca5a3f3dcc793fb96fd64f8b8df6b07d1168 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Store line number mappings in the compiled functionSimon Hausmann2013-08-161-8/+30
| | | | | Change-Id: I4e37aac3618b20ccd52ce4833098781374a3daf6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Ported lookups to use the compiled data infrastructureSimon Hausmann2013-08-151-1/+0
| | | | | Change-Id: Idf75cd51087ea825f22aabda59661be461fd3b86 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Initialize formals and locals from the compiled function data instead of in ↵Simon Hausmann2013-08-151-0/+19
| | | | | | | the isel Change-Id: I9db976df310a5986ceca66d21efeeae536dbede4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Begin using the compiled data structures for runtime stringsSimon Hausmann2013-08-151-1/+3
| | | | | Change-Id: Idbf278a96624bf101df35de40577b38e593f22be Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add reference counting to the VM functionsSimon Hausmann2013-08-121-0/+10
| | | | | | | | | This reduces memory pressure, keep engine->functions small and thus makes back trace lookup faster. It became visible for example in the QtQuickControls auto-tests that use plenty of loaders and we ended up with 30k+ functions. Change-Id: Iaa5981f44e1e49ad9417a50c1e6a74946090dd28 Reviewed-by: Lars Knoll <lars.knoll@digia.com>