aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4globalobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* V4: Slim down FunctionObjectUlf Hermann2024-05-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most FunctionObjects do not actually need their custom jsCall members. They will only call the functions from the vtable anyway. FunctionObject can therefore be split into a static and a dynamic variant. Only the dyanmic variant needs to carry (and invoke) the extra pointer. The jsCallWithMetaTypes pointer is completely pointless because none of the dynamic functions actually implement it. Furthermore, the QV4::Function and QV4::ExecutionContext pointers in FunctionObject are only needed by actual JavaScript functions. The builtins that like to be dynamic functions never need them. Therefore, split out another class for this. In the generic FunctionObject, we need the capability to decide at run time whether the function shall be a constructor or not. Add a flag to replace the check for jsCallAsConstructor. Also, where we can, avoid the pessimization of checking whether a function is a constructor before trying to call it as constructor. Rather have the default implementation throw the exception. As a side effect, for most functions we don't need an ExecutionContext anymore. The engine is enough. Task-number: QTBUG-124662 Change-Id: Iac657fa71288dd6ec230a33de2986ba3bcf4628c Reviewed-by: Fabian Kosmale <[email protected]>
* Move ScopedStackFrame into qv4stackframe_p.hUlf Hermann2023-05-171-14/+17
| | | | | | | | | | | This is where it belongs. We need to apply some tricks to avoid cyclic includes, but that's better than what we have so far. Also, sort and clean up the includes in the affected files. Change-Id: Ia7a957d06c0ca284045d831417740c3f9920bc92 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-7/+7
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <[email protected]>
* V4: Use an enum to categorize functions and rename aotFunctionUlf Hermann2022-09-291-1/+1
| | | | | | | | We want to use the aotFunction member also for typed JavaScript functions. Change-Id: Iad6d12ebed3ad3069832484137ed8e4d9e7a7cf4 Reviewed-by: Fabian Kosmale <[email protected]>
* QtQml: Remove unused includes in qml, first partSemih Yavuz2022-09-141-3/+0
| | | | | | | | | | | | | | | Drop unnecessary includes detected by clangd-iwyu. Add new includes due to the transitive includes. Also, some of the includes were detected as unused even if they were actually in use. In those cases, use angular brackets instead of "" which deceives the tool not to complain. Affected subfolders: Debugger, Compiler, JsApi, JsRuntime, Memory, Parser Task-number: QTBUG-106473 Change-Id: I01d996a2a2ba31cbbc5f60f5454c8f850298f528 Reviewed-by: Fabian Kosmale <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <[email protected]>
* qtdeclarative: finish fixing compilation with explicit QChar(int)David Faure2020-11-071-1/+1
| | | | | Change-Id: Idb26e2df6d4fe8940db57066a30fa8c243f6d2c9 Reviewed-by: Volker Hilsheimer <[email protected]>
* Port QtDeclarative from QStringRef to QStringViewKarsten Heimrich2020-06-161-1/+1
| | | | | | | | Task-number: QTBUG-84319 Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15 Reviewed-by: Mårten Nordheim <[email protected]> Reviewed-by: Shawn Rutledge <[email protected]> Reviewed-by: Timur Pocheptsov <[email protected]>
* QtQml: Use unicode character literalsUlf Hermann2020-06-031-5/+5
| | | | | | | This avoids the warnings on conversion to QChar. Change-Id: Ib774f24592d6f09a531c60bb6fa6e5bdbec88120 Reviewed-by: Fabian Kosmale <[email protected]>
* Check in even more places for exceptionsFabian Kosmale2020-04-211-2/+2
| | | | | | | | | Amends commit 4c5ed04e64ea9ac0038ae30e1189cfe745b29bd9 Task-number: QTBUG-83384 Pick-to: 5.15 5.12 Change-Id: I0918c27dfa73dff83cbf0f58b41ce8620dff8a0a Reviewed-by: Simon Hausmann <[email protected]>
* Split compiler and runtime more clearlyUlf Hermann2019-07-111-2/+2
| | | | | | | | Provide different export macros and different top level headers for each, don't include runtime headers from compiler sources. Change-Id: I7dc3f8c95839a00a871ba045ec65af87123154be Reviewed-by: Simon Hausmann <[email protected]>
* Remove some unneeded includesUlf Hermann2019-07-081-4/+0
| | | | | | Change-Id: Id05059dfc9910dad206e511b08f18487e241e508 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Simon Hausmann <[email protected]>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-4/+4
| | | | | | | | | | | | 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 <[email protected]>
* Fix super property accessLars Knoll2018-08-311-0/+1
| | | | | | | | | Super properties work in a rather special way by accessing a 'home object' on the function object, and reading from it's prototype. Change-Id: I666334c9c27048c6c2ba6770dd8c9f56aecbee14 Reviewed-by: Simon Hausmann <[email protected]>
* Prefix vtable methods with virtualLars Knoll2018-07-031-1/+1
| | | | | | | | | Turns out that the overloading of vtable methods and regular ones is problematic in some cases. So let's rather make it explicit which methods are part of the vtable, and which aren't. Change-Id: Ifee32a26104d30f3c82bca8b5a9cdea2d4f4f526 Reviewed-by: Simon Hausmann <[email protected]>
* Fix length properties of global constructorsLars Knoll2018-06-251-1/+1
| | | | | Change-Id: I4e9e1635f404082b0e8b333dc13a33d27e4f4b50 Reviewed-by: Simon Hausmann <[email protected]>
* Ensure we have a lexical scope for global codeLars Knoll2018-05-111-1/+1
| | | | | | | | | | | | | | | 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 <[email protected]>
* Rename the CompilationMode enum to ContextTypeLars Knoll2018-05-021-1/+1
| | | | | | | | | And make it an enum class. The new name fits better, as it's mainly used to determine the type of the context when parsing. Also already added the 'Block' value that will be needed. Change-Id: I70d963b6a0b22db1a3c607cce6bdd2054b29e000 Reviewed-by: Simon Hausmann <[email protected]>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-3/+3
| | | | | | | | | | | | | 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 <[email protected]>
* Convert more builtin methods to new calling conventionLars Knoll2017-11-131-31/+31
| | | | | | | | Convert the methods of the global object and the remaining methods in in the Function object. Change-Id: I7c9a5f39b07f9c9cb0f31e83cdf41fade71a7dc5 Reviewed-by: Erik Verbruggen <[email protected]>
* Cut out one more C++ layer when doing JS function callsLars Knoll2017-11-131-11/+4
| | | | | Change-Id: I0e2ac30b7e6d77fe41deb84a97b0a7f220437c6a Reviewed-by: Simon Hausmann <[email protected]>
* Finally get rid of the QV4::Function pointer in the contextLars Knoll2017-11-131-7/+2
| | | | | Change-Id: Iad6018f67faa956d385087865fca9d73419e363e Reviewed-by: Simon Hausmann <[email protected]>
* Change signature for call/callAsConstructorLars Knoll2017-11-071-6/+6
| | | | | Change-Id: I159b57acc7a2133ef1ad545aa84e792c63449a57 Reviewed-by: Lars Knoll <[email protected]>
* Further cleanup JSCallDataLars Knoll2017-11-071-6/+8
| | | | | | | Avoid allocations on the JS stack if possible Change-Id: I344cd6dceb6264314f9d22c94db22b22d1d24d14 Reviewed-by: Erik Verbruggen <[email protected]>
* Simplify JSCallData constructionLars Knoll2017-11-071-2/+2
| | | | | Change-Id: Ic53532edae9a209aa7125af6f00a9d993d74f1a3 Reviewed-by: Erik Verbruggen <[email protected]>
* Get rid of the implicit cast operator to a CallDataLars Knoll2017-11-071-1/+1
| | | | | Change-Id: I1c35fbf8f7355bc2393ae931f99e591b800f2f45 Reviewed-by: Erik Verbruggen <[email protected]>
* Get rid of JSCallData::call()Lars Knoll2017-11-071-4/+4
| | | | | Change-Id: I6b99e9a7102b3dcb6a7699f54b6456eba6248699 Reviewed-by: Erik Verbruggen <[email protected]>
* Rename JSCall to JSCallDataLars Knoll2017-11-071-2/+2
| | | | | | | | As, this is going to change in a simple stack based structure to keep pointers to the data to pass to calls. Change-Id: Ia9aa3f81ee3eeba36affd16aac7b2fe97d59aea9 Reviewed-by: Erik Verbruggen <[email protected]>
* Change CallData::argc to be a QV4::ValueErik Verbruggen2017-09-191-9/+9
| | | | | | | | | | | 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 <[email protected]>
* Always set the correct FunctionObject when calling JS functionsLars Knoll2017-09-021-8/+8
| | | | | | | | | Renamed ScopedCallData to JSCall, enforced passing a JS FunctionObject to it, and added call() and callAsConstructor() methods to it. Change-Id: I30db65c9765c2896b5909fe2105c0934c6dad861 Reviewed-by: Simon Hausmann <[email protected]>
* Move ScopedCallData and ScopedStackFrame into a separate fileLars Knoll2017-09-011-0/+1
| | | | | Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann <[email protected]>
* CleanupsLars Knoll2017-09-011-1/+1
| | | | | Change-Id: Iba5a238c98617f99049dc0e529e642b924e42755 Reviewed-by: Simon Hausmann <[email protected]>
* Move CallContext construction into a interpreter instructionLars Knoll2017-09-011-1/+1
| | | | | | | | | | This will allow us to further cut down on function call overhead. To make this work, introduce a proper distinction between EvalCode and GlobalCode and use the correct compilation mode in all places. Change-Id: I070621142159b7416026347c9239200c5ed7a56b Reviewed-by: Simon Hausmann <[email protected]>
* Use the context member in CallDataLars Knoll2017-09-011-1/+2
| | | | | | | | Store the current context in the context member instead of passing it along as arguments. Change-Id: If3dd0d32eddb2a02bcbf65fe6e8d15142403170e Reviewed-by: Simon Hausmann <[email protected]>
* Fix indirect, strict calls to evalLars Knoll2017-08-211-1/+4
| | | | | | | | | | | In this case, the thisObject is supposed to be the global object and not the thisObject of the parent stack frame. Amends 661f9203c411b080fce6abf606ec8fb5c17a6bfe Change-Id: I9560a0bdfe24f43f877d28c7c98a42fcc1416e86 Reviewed-by: Simon Hausmann <[email protected]>
* Get the thisObject from the current stackframeLars Knoll2017-08-181-1/+1
| | | | | | | | Retrieving it from the context might not always give the correct answer anymore (and will get removed from there). Change-Id: I40900626d9382a2b9f9dad8243b84d283f077509 Reviewed-by: Erik Verbruggen <[email protected]>
* Pass the correct this object to evalLars Knoll2017-08-101-1/+1
| | | | | Change-Id: I89e4fb440ff33c94be92632fbdf8454f4c0f6c89 Reviewed-by: Simon Hausmann <[email protected]>
* Cleanup naming of Stack frame structuresLars Knoll2017-08-101-1/+1
| | | | | Change-Id: I0b392040b6726e6d93f237ccccc9f053256ed819 Reviewed-by: Simon Hausmann <[email protected]>
* Always create a valid CallData object for interpreter callsLars Knoll2017-08-101-1/+3
| | | | | | | | This will allow removing a few more special cases and to simplify the code further. Change-Id: I3a958e9f68e3c103ea4f2ee6825f893e5931b11d Reviewed-by: Simon Hausmann <[email protected]>
* Refactor context handlingLars Knoll2017-08-101-9/+7
| | | | | | | | | | | | | | | 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 <[email protected]>
* Get rid of ExecutionContext::strictModeLars Knoll2017-08-101-2/+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 <[email protected]>
* Reduce usage of the strictMode flag in ExecutionContextLars Knoll2017-08-101-3/+3
| | | | | | | | The goal is to completely get rid of it, and replace it by calling strict/sloppy versions of runtime functions in the generated code. Change-Id: Icd516d924136109abaf0dc9f3ef0e771a709485d Reviewed-by: Simon Hausmann <[email protected]>
* Introduce a JS stack frame that corresponds to the C++ stack frameLars Knoll2017-08-101-1/+1
| | | | | | | | The frame currently contains the function itself and the current context. Change-Id: I7d3402627fbc90e860a7bdc277585f365f5b4cb5 Reviewed-by: Simon Hausmann <[email protected]>
* Avoid creating a separate Scope in the ExecutionContextSaverLars Knoll2017-08-081-1/+1
| | | | | | | There's no reason this class should create a scope on it's own. Change-Id: I93bddea8be42a908a1aca1bcb0ec867aae0d29f8 Reviewed-by: Simon Hausmann <[email protected]>
* Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-18/+30
| | | | | | | | Allow for faster calling of builtins, and completely avoid scope creation in many cases. Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c Reviewed-by: Simon Hausmann <[email protected]>
* Change function signatures for call/construct backLars Knoll2017-08-041-22/+14
| | | | | | | | Change those back again to return a value. This will be required to avoid creation of Scope objects between JS function calls. Change-Id: I05cb5cf8fd0c13dcefa60d213ccd5983fab57ea3 Reviewed-by: Erik Verbruggen <[email protected]>
* Get rid of the compilation unit related members in ExecutionContextLars Knoll2017-08-031-2/+1
| | | | | | | | | | 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 <[email protected]>
* Remove now unused filesLars Knoll2017-06-301-1/+0
| | | | | | | | | Remove all files from the old compiler pipeline that are now unused. This includes the whole IR, JIT code generation, and the old Moth Isel. Change-Id: I50d06abfbcf0e9755a54ed94638f8bb74f9512b1 Reviewed-by: Erik Verbruggen <[email protected]>
* Move the engine() accessor from Object to ManagedLars Knoll2017-05-191-1/+1
| | | | | | | | | | | | We can easily do this now that Managed has a pointer to an internal class (which always has a back pointer to the ExecutionEngine). Remove the extra engine pointer from ExecutionContext, and clean up tow methods in String. Change-Id: I98d750b1afbdeadf42e66ae0c92c48db1a7adc31 Reviewed-by: Robin Burchell <[email protected]>
* Fix arithmetic with constants inside eval() calls on 32-bit architecturesSimon Hausmann2017-03-301-0/+1
| | | | | | | | On 32-bit architectures we usually use an external constants table, which we need to make visible in the context. Change-Id: I0f7d813da1c6c893b8dd641dab5685a6db7fa9fa Reviewed-by: Robin Burchell <[email protected]>