aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4context.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Split QV4::Value into a static and a dynamic partUlf Hermann2019-05-311-2/+4
| | | | | | | | The static part can be used for compilation and won't resolve managed objects. This allows us to remove all the remaining V4_BOOTSTRAP. Change-Id: Id2f6feb64c48beb2a407697881aea8c0d791a532 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split CompiledData::CompilationUnit in twoUlf Hermann2019-05-161-2/+2
| | | | | | | | We need a CompilationUnit that only holds the data needed for compilation and another one that is executable by the runtime. Change-Id: I704d859ba028576a18460f5e3a59f210f64535d3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Clean up the runtime functions declarationsErik Verbruggen2019-02-051-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | The declarations and usage of runtime functions have seen a number of changes: - we don't use the array of method pointers anymore because we don't use cross-platform AOT JITting - the check if a method can throw a JS exception was invalid, and was not used anymore - value-pointer vs. const-value-ref was inconsistent This patch cleans that up. By fixing the exception checking, we can now use it in the baseline JIT to automatically insert those checks. To make that work correctly, all runtime methods are in a struct, which gets annotated to indicate if that method throws. (The old way of checking which type of engine was used is fragile: some non-throwing methods do not take an engine parameter at all, and those got flagged as throwing). By using a struct, we can also get rid of a bunch of interesting macros. The flags in the struct (as mentioned above) can later be extended to capture more information, e.g. if a method will change the context. Change-Id: I1e0b9ba62a0bf538eb728b4378e2678136e29a64 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Differentiate between finding for get and set in InternalClassLars Knoll2018-09-271-3/+3
| | | | | | | | This is required, so we can get rid of the requirement that getter and setter live next to each other in the member data. Change-Id: I2ed57a171628af4dfecd1836d00e958c6bed9d4f Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Refactor InternalClass::find()Lars Knoll2018-09-271-5/+5
| | | | | | | | | Specialize find() into several methods for different purposes. Prepares for further cleanups and being able to split up getter and setter for accessor properties. Change-Id: Id4ec5509ac1a1361e2170bbfc2347b89b520c782 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-1/+1
| | | | | | | | | | | | Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement the dead temporal zoneSimon Hausmann2018-08-281-0/+4
| | | | | | | | | | | | | | With const and let it is possible to access the declared member before initialization. This is expected to throw a type reference error at run-time. We initialize such variables with the empty value when entering their scope and check upon access for that. For locals we place the lexically scoped variables at the end. For register allocated lexical variables we group them into one batch and remember the index/size. Change-Id: Icb493ee0de0525bb682e1bc58981a4dfd33f750e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add support for @@unscopablesLars Knoll2018-07-301-12/+79
| | | | | | | See ES7 spec, chapter 22.1.3.32 Change-Id: Ibe7df71cbc1bc848e205b9ca682f24841adfa2d9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the C++ and JS stack frame definitions into it's own fileLars Knoll2018-07-031-0/+1
| | | | | Change-Id: I86e89e07197aec6071809c2d32bd5c98cb7ac6f6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up the property key API in StringOrSymbolLars Knoll2018-07-021-11/+6
| | | | | | | | | | | | | | Get rid of makeIdentifier(), as toPropertyKey() will take care of it. Rename identifier() to propertyKey() and check that the key is valid. Remove String/StringOrSymbol::asArrayIndex(), we don't need it anymore. Change-Id: I3c490fabc1475c9ea288b49b1638b6fa1bc237b7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Identifier by PropertyKeyLars Knoll2018-07-021-5/+5
| | | | | | | | Change all uses of Identifier to use the new PropertyKey class and get rid of Identifier. Change-Id: Ib7e83b06a3c923235e145b6e083fe980dc240452 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanup defineOwnPropertyLars Knoll2018-06-261-2/+3
| | | | | | | | | | | | | | | | Make it a vtable method as required by the ES7 spec. Change all calls sites to call through the virtual function. Adjust ArgumentsObject and give it it's own defineOwnProperty implementation instead of hacking it into the base implementation. Move the array object specific handling into a reimplementation. Change-Id: I48c960c4c69f99b178628c94b4808be2bab0dccc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify deleteProperty and deleteIndexedProperty vtable methodsLars Knoll2018-06-261-1/+1
| | | | | Change-Id: I25245818c6ff2104642594476cb9684bac824f29 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add virtual interface for hasPropertyLars Knoll2018-06-251-2/+2
| | | | | | | This is required to correctly support Proxy Change-Id: I95ec17e919915290a05ad9501cd649452ab82135 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement a virtual interface for getOwnPropertyLars Knoll2018-06-251-1/+1
| | | | | | | | | | | | This is required to support Proxy properly, and at the same time fixes a couple of test failures. The new interface also replaces the old query and queryIndexed virtual interfaces, as those where doing a subset of what getOwnProperty does. Change-Id: I750e366b475ce971d6d9edf35fa17b7a2b07f771 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanup JS stack allocationsLars Knoll2018-05-261-1/+1
| | | | | | | | Avoid double writes to the stack, and use scope.alloc() for most allocations on the stack. Change-Id: I8b89273c1b6796d955fc8eeb72c67cff208ef786 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Give for loops a per-iteration context as wellLars Knoll2018-05-111-1/+14
| | | | | | | | Regular for loops also have a per iteration context for lexically declared variables as well. Change-Id: I35cb58bfb198c7dc32d70f41ea0ced7ddefcc37e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Ensure we have a lexical scope for global codeLars Knoll2018-05-111-4/+6
| | | | | | | | | | | | | | | This requires a bit more work than simply pushing a new BlockContext for the lexically declared variables, as eval() and the Function constructor operate on the global scope (including the lexically declared names). To fix this introduce Push/PopScriptContext instructions, that create a BlockContext for the lexically declared vars and pushes that one as a global script context that eval and friends use. Change-Id: I0fd0b0f682f82e250545e874fe93978449fe5e46 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use Identifier by value and don't new them anymoreLars Knoll2018-05-021-4/+4
| | | | | Change-Id: Ib25c08027013217657beb2675dafa9a8c85cbaf9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rework catch context handlingLars Knoll2018-05-021-41/+7
| | | | | | | | | | | | Remove the need for a specialized catch context, instead use a regular block context, that also captures the catched variable. This also removes the need to do lookups by name inside a catch expression. Change-Id: I8b037add7f423922e2a76b4c0da646ca7e25813a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for proper lexical scopingLars Knoll2018-05-021-0/+28
| | | | | | | | | | | | | This is still to some extend work in progress as lexically scoped for loops won't yet do the right thing. let and const variables are still accessible before they are declared, and the global scope doesn't yet have a proper context for lexically declared variables. Change-Id: Ie39f74a8fccdaead437fbf07f9fc228a444c26ed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-1/+1
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't copy unnamed arguments onto the JS stackLars Knoll2017-11-151-5/+11
| | | | | | | | | These can only be referenced through the arguments objects, and have so far messed up initialization of local variables. Change-Id: I3100520ed55c93204dd7953da8cc3d2b7d200d11 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Finally get rid of the QV4::Function pointer in the contextLars Knoll2017-11-131-30/+5
| | | | | Change-Id: Iad6018f67faa956d385087865fca9d73419e363e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove superfluous zero fill on 32bitErik Verbruggen2017-09-201-6/+1
| | | | | | | | | | Now that we use the same encoding on 32bit as on 64bit, undefined is encoded as 0. So no need to do a separate fill-with-undefined, because the memory manager will already zero-initialize the freshly allocated memory. Change-Id: Ia1e0f5385d86f5ab283dd114e202cc48c2a27f23 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Change CallData::argc to be a QV4::ValueErik Verbruggen2017-09-191-2/+2
| | | | | | | | | | | Instead of mimicking a Value. This makes sure that argc now stays correct even when anything on Value changes. Most of the change is mechanical: replace callData->argc by callData->argc(). Change-Id: I521831ae1ffb3966bad6589c18d7a373e13439d7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove superfluous call to String::makeIdentifierErik Verbruggen2017-09-121-1/+0
| | | | | | | | | This is already done at the top of the method. Also mark the slow path of makeIdentifier as never-inline, so it won't bloat functions when makeIdentifier is inlined. Change-Id: I707f9b82f555314bea154014d8cbb876b26d0d4b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of the hack for named expressionsLars Knoll2017-09-021-10/+0
| | | | | | | | Instead simply use the pointer to the FunctionObject we have in the CallData now. Change-Id: I6d7ed8af22e89e0217bef427110611b661ac7965 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of the FunctionObject parameter to VME::exec()Lars Knoll2017-09-011-3/+2
| | | | | Change-Id: I5b833d1f76899a5b8fceb0f4fc109b77b1b431fc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanup argument handling in contextsLars Knoll2017-08-181-43/+14
| | | | | | | | | | | | | | | | | | Fix the compiler to already deal with duplicated argument names. Doing this at runtime was not ideal. Remove the callData member from the context. Instead use the fact that the arguments already followed the locals in the context. Don't copy the thisObject over into the CallContext anymore, it's never used from there anyway. Fix the ordering of names in the internalclass, so that arguments don't require special handling anymore when looking them up by name. Adjust all places that used callData, and related methods. Change-Id: I0bc45e1be3f1fcd38dc3b4f04e91edaf7b9ed103 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Get rid of CallData in the ExecutionContextLars Knoll2017-08-181-2/+0
| | | | | | | | Part 1, where the callData member is moved to CallContext. We'll get rid of it there in a subsequent commit. Change-Id: I6218992802133913f7766ebb3d2f47bd29f33907 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Remove one more layer of function calls when entering JS functionsLars Knoll2017-08-101-1/+3
| | | | | Change-Id: I7d8b2e16d2eacf5e0eafb8b8574de51527fd0ac2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Always create a valid CallData object for interpreter callsLars Knoll2017-08-101-29/+0
| | | | | | | | This will allow removing a few more special cases and to simplify the code further. Change-Id: I3a958e9f68e3c103ea4f2ee6825f893e5931b11d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split StoreName into StoreNameStrict and StoreNameSloppyLars Knoll2017-08-101-11/+15
| | | | | | | And adjust the name of the corresponding runtime functions. Change-Id: I4adf7b0e069d9b0dff9162cd1271dafc60be854b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove stuff related to simple call contextsLars Knoll2017-08-101-10/+5
| | | | | | | Those are not being used anymore. Change-Id: Ia33dd7c3c7ea7828caef0fbf397253249580a4e1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of simpleCallLars Knoll2017-08-101-31/+18
| | | | | | | | After the recent changes this can easily be unified with the call method without loss of performance. Change-Id: I0385b47b6a86e890f97dcbada3a1be1129ae0b84 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Refactor context handlingLars Knoll2017-08-101-19/+12
| | | | | | | | | | | | | | | Fix the push/pop context instructions to not modify the JS stack anymore, as that can cause conflicts with the VME (and was an ugly hack in any case). Instead, these instructions not return the old context, that is then stored in a temporary. Get rid of Engine::current and Engine::currentContext. The StackFrame structures do now contain the only and authoritive data. This finally gives us a nice setup where we create and destroy frames on the stack when entering/leaving functions. Change-Id: If161e3e941f59865c47ecfe1e094faf62b52bfa0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Avoid creating a CallContext for simple functionsLars Knoll2017-08-101-10/+10
| | | | | | | | This cuts out quite a bit of overhead when entering and leaving functions. Change-Id: I32670c98a4087ea3b2d45853d9cabff9066399e8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of ExecutionContext::strictModeLars Knoll2017-08-101-4/+1
| | | | | | | | | This should be done by generating different byte code for the strict/non strict cases. For now the VME has a workaround checking the isStrict() flag of QV4::Function. Change-Id: I2faa9e9184ffc5274491067e67f665d6989b54c2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't throw exceptions in Object::delete(indexed) anymoreLars Knoll2017-08-101-3/+1
| | | | | Change-Id: I8613ab21eb1435903e2a8514c21fe51f4a305a2f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't throw errors from the internal put methods anymoreLars Knoll2017-08-101-16/+10
| | | | | | | | Instead do it in the VME, where we can then easily separate into throwing and non throwing versions by bytecode. Change-Id: Ie63bd5b3610bb85f26fb8979179b2e239876cd97 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce a JS stack frame that corresponds to the C++ stack frameLars Knoll2017-08-101-2/+2
| | | | | | | | The frame currently contains the function itself and the current context. Change-Id: I7d3402627fbc90e860a7bdc277585f365f5b4cb5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Reduce usage of Scope's in ExecutionContextLars Knoll2017-08-081-60/+61
| | | | | Change-Id: I5679d02449c86511c8f3139048af783aa19e0232 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove dead codeLars Knoll2017-08-081-7/+1
| | | | | | | | Context::getProperty and friends will never get called with 'this' as the name. Change-Id: I715996ce4ce6508e4734d2b3bdb1a4ad44208eeb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Completely avoid intermediate scopes for simple functionsLars Knoll2017-08-081-15/+16
| | | | | Change-Id: I1fe2ff987e79cf590ad5ad3fc520b17925f8b616 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Avoid creating a separate Scope in the ExecutionContextSaverLars Knoll2017-08-081-2/+2
| | | | | | | There's no reason this class should create a scope on it's own. Change-Id: I93bddea8be42a908a1aca1bcb0ec867aae0d29f8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove Scope dependency from registerQmlDependenciesLars Knoll2017-08-081-2/+2
| | | | | | | An engine pointer is sufficient. Change-Id: I6430cfeac3bd2881e89bbbd22ff31ffbd2a2339a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-4/+8
| | | | | | | | Allow for faster calling of builtins, and completely avoid scope creation in many cases. Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of the compilation unit related members in ExecutionContextLars Knoll2017-08-031-13/+2
| | | | | | | | | | And change the signature for VME::exec to take the QV4::Function that should be executed. This is in preparation to being able to run functions that will not need to allocate an execution context on their own. Change-Id: I34538a8723006f4ec24583805e88a66e750100c3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Unify QV4::Function::internalClass and the ic used in CallContextLars Knoll2017-08-031-7/+7
| | | | | | | | | Set the internal class of the V4 function on the CallContext, as that one is describing it's layout, and use it to lookup variables. Change-Id: I49d9b9afe1f504fbd059d6a350b7a4e62e2e505b Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>