aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4mathobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-11/+11
| | | | | | | | | | | | 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>
* Fix a corner case in Math.max()Lars Knoll2018-09-071-1/+3
| | | | | Change-Id: I9dffaec95b01757fb21466617d055def2edeeb30 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* JS: Encode result of Math.min and Math.max as int when possibleErik Verbruggen2018-07-131-2/+2
| | | | | | | | | | So now Math.max(array1.length, array2.length) won't return a double anymore. This improves the score in the crypto benchmark by ~10% Change-Id: I8453a671d28d7f2a39ba74b18b3155f031d9b12f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Extend V4's Math object with methods new in ES6Edward Welbourne2018-06-211-5/+193
| | | | | | | | | | Added: acosh, asinh, atanh, cbrt, clz32, cosh, expm1, fround, hypot, imul, sinh, tanh and trunc. Some needed hand-coding for android, whose std:: is defective. Fixed some buglets in existing asin and round in the process. Change-Id: I0858d45430dc0f5944c53723545717ca1ffa6ef7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use Symbol.toStringTag in Object.prototype.toStringLars Knoll2018-06-041-0/+4
| | | | | | | | | This should make toString comply fully with the JS Spec. Also add a couple of missing Symbol.toStringTag properties. Change-Id: I29e2018b486a0e1d174b58ce7a14f0e42cc78767 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* v4: add the remaining Math.log functionsShawn Rutledge2018-05-151-0/+35
| | | | | | | We only had natural log, now we have base 2 and base 10 and log1p. Change-Id: I26e3a50a27821671cf2fb4ed3905a357c23bbecc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Update to new QRandomGenerator APIThiago Macieira2017-12-051-1/+1
| | | | | | | | | | To get latest qtbase dev integrated in qt5 dev again without qtdeclarative 5.10->dev merge. Change-Id: I6905649aca2b06302df8cee2f660f1f92398d36a Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> (cherry picked from commit ee00fa01dc41deaaedfa0d1d5cc6cd750bfe75f4) Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Convert Math object's methods to new calling conventionLars Knoll2017-11-131-44/+44
| | | | | | | Makes e.g. calls to Math.abs() around 20% faster. Change-Id: I11b52e3c8693675defbc6f230db896c42acca15d Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Merge remote-tracking branch 'origin/dev' into HEADLars Knoll2017-10-221-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4compileddata.cpp src/qml/compiler/qv4compileddata_p.h src/qml/compiler/qv4isel_moth_p.h src/qml/compiler/qv4ssa.cpp src/qml/jit/qv4assembler_p.h src/qml/jit/qv4isel_masm_p.h src/qml/jit/qv4regalloc.cpp src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4qmlcontext_p.h src/qml/jsruntime/qv4regexp.cpp src/qml/jsruntime/qv4regexp_p.h src/qml/jsruntime/qv4regexpobject.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/qml/v8/qqmlbuiltinfunctions.cpp tests/auto/qml/qml.pro tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp tools/qmlcachegen/qmlcachegen.cpp Change-Id: I1577e195c736f3414089036b957a01cb91a3ca23
| * Merge remote-tracking branch 'origin/5.9' into 5.10Lars Knoll2017-09-201-0/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4compileddata.cpp src/qml/compiler/qv4compileddata_p.h src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4qmlcontext.cpp src/qml/jsruntime/qv4qmlcontext_p.h src/qml/jsruntime/qv4regexpobject.cpp src/qml/jsruntime/qv4regexpobject_p.h src/qml/types/qqmllistmodel.cpp src/quick/items/qquickanimatedimage_p.h src/quick/scenegraph/qsgrenderloop.cpp tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp Change-Id: If20ef62b2c98bdf656cb2f5d27b1897b754d3dc0
| | * Add missing math.h include for math functionsJake Petroules2017-09-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | On some platforms, math functions in the std namespace don't work even if cmath is included. Change-Id: Ia71d22b07f508e0584de5320f376fbf4b3a2887b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Change CallData::argc to be a QV4::ValueErik Verbruggen2017-09-191-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Merge remote-tracking branch 'origin/dev' into wip/new-backendSimon Hausmann2017-09-081-13/+3
|\| | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4isel_moth.cpp src/qml/compiler/qv4jsir.cpp src/qml/jsruntime/qv4mathobject.cpp Change-Id: I426f1f4f0a5302b5bcff021de11766a03fec7637
| * | Use QRandomGenerator instead of q?randThiago Macieira2017-08-231-12/+2
| |/ | | | | | | | | Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-20/+20
| | | | | | | | | | | | | | | | 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>
* | Add commonly used JumpCompare instructionsErik Verbruggen2017-08-021-1/+3
|/ | | | | Change-Id: I00d4ed5d8b6ab30ee3459d1cc7a2737144474f8a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Convert builtins in MathObject to the new calling conventionLars Knoll2017-01-251-93/+93
| | | | | Change-Id: I631515893c35213f46fbee2a5f053ccdcb03af31 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Make Heap::Object and all subclasses trivialErik Verbruggen2016-10-061-1/+2
| | | | | | | | | | | | GCC6 might dead-store-eliminate out our secret write to Base::mmdata, because it expects all memory content to be "undefined" before constructor calls. Clang might take the same approach if the constructor of Heap::Object is removed. By making these structs trivial, it also makes them memcpy-able. Change-Id: I055b2ad28311b997fbe059849ebda4d5894eaa9b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-241-8/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine_p.h src/qml/jsruntime/qv4runtime_p.h src/qml/qml/qqmldelayedcallqueue.cpp src/qml/qml/qqmlvaluetypewrapper.cpp src/qml/qml/qqmlvmemetaobject.cpp src/qml/qml/v8/qv8engine_p.h tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I3f0608c7beb88088cbbef4d0db59920f56deaea9
| * Always use ::copysign instead of std::copysign where availableRalf Nolden2016-05-201-8/+0
| | | | | | | | | | | | | | | | | | | | Change to remove the Q_OS_ANDROID define for using ::copysign there instead of std::copysign as other systems are affected as well (FreeBSD 9.3 with gcc 4.8 in particular). The distinction does cause more problems than simply using ::copysign everywhere. Change-Id: I1fe42fdee9c1c1bbb3e5930573ff29c600dfb5e0 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-041-9/+10
|\| | | | | | | Change-Id: I694ac053b53b669ef5578fd0074de5ce109f7a09
| * V4: Use std::copysign instead of home-grown bit twiddling.Erik Verbruggen2016-04-191-9/+10
| | | | | | | | | | | | | | | | Of course, not every standard library correctly implements C++11, so there we fall back to copysign from math.h Change-Id: I0283640ef69803a338ff1969c94c92c7ab1d71cb Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* | Add some ECMAScript 6 Number and Math methods and propertiesKai Uwe Broulik2016-04-281-0/+14
|/ | | | | | | | | This adds the Number.EPSILON property, the Number.isFinite, Number.isNaN, and Math.sign methods introduced in ECMAScript 6. Change-Id: Ib16408a63c202a4ef30a14334f65ac3a1a13cfaf Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Replace qQNaN() and friends with qt_qnan().Erik Verbruggen2016-04-051-32/+32
| | | | | | | | These constexpr functions can be inlined, and the compiler can be a bit smarter with code generation. Change-Id: I4ea87c794dd8e375749e18d273d01bb848231113 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7J-P Nurmi2016-03-011-2/+0
|\ | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro Change-Id: I3ca8f0422828191b7e19539c25f31f2d048e9f18
| * Remove unused static const non-constexpr variableThiago Macieira2016-02-221-2/+0
| | | | | | | | | | Change-Id: I0c94a5c2846b48c8aea7ffff14352f8a247c8cec Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Replace all occurrences of qSNaN() with qQNaN()Ulf Hermann2015-12-071-21/+21
|/ | | | | | | | | | | We generally don't want to produce signalling NaNs as those cannot be used in any further arithmetic operations. In particular -(qSNaN()) claims it's not a double. Task-number: QTBUG-49753 Change-Id: I23cec4fec2ddf08c02a7d53db7f3b9ba46b6c288 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* JS: Math.random(): fix range to not include 1.0.Erik Verbruggen2015-10-201-2/+7
| | | | | | | | | | | [15.8.2.14] specifies that the Math.random() returns a number greator or equal to 0, but less than 1. Libc however defines it to be less than or equal to 1, so we have to divide the returned value by RAND_MAX+1. Of course, in order to do this, we need to widen them to 64bits ints. Task-number: QTBUG-48753 Change-Id: Ia4d808014dbf2a5575f4226779214bf0d5981f49 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Convert FunctionObjects to new allocation syntaxLars Knoll2015-09-221-3/+2
| | | | | Change-Id: I269c20abdc7f9eb0d71a2d2d485d622b65405762 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Continue the work to move Values inside the v4 engine to the js stackLars Knoll2015-04-241-1/+1
| | | | | | | | Started with objectPrototype, the next commits will move more of them over into the new data structure. Change-Id: I1a048e95149ce69e4e42094db2dd738ce49b50b8 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* More cleanupsLars Knoll2015-04-211-1/+1
| | | | | | | | Get rid of Value::asObject(), and pass const Managed pointers into some more vtable methods. Change-Id: Ia4f427d5fd8868f77b4015d1ce5424d32bfc2115 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup math function includes and usageAllan Sandfeld Jensen2015-02-191-32/+32
| | | | | | | | Use std::math on floats and doubles, and qMath on qreals, and only include the math headers actually needed. Change-Id: I1d511d7b1bac0050eaa947c7baee760b736858bf Reviewed-by: Sean Harmer <sean.harmer@kdab.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>
* CleanupsLars Knoll2015-01-231-24/+24
| | | | | | | | Simplify some code in BooleanObject Simplify access to call arguments and thisObject Change-Id: I2f8e844019bc587385608beb02f05b15f827535c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove the remaining bit of code that use the vtable in the internalClassLars Knoll2015-01-211-1/+1
| | | | | Change-Id: Ia52f0e6db325aab37477d455f163487b319dce29 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move prototype back from the vtable into ObjectLars Knoll2014-12-111-3/+3
| | | | | | | | This is the only way we can support a GC that moves objects around in memory. Change-Id: I1d168fae4aa9f575b730e469e762bc5b5549b886 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move more Data objects into the Heap namespaceLars Knoll2014-11-091-19/+19
| | | | | Change-Id: I87866f8dcbaac1087da7bbd2902aa5b062afca53 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move Object::Data into the Heap namespaceLars Knoll2014-11-081-1/+1
| | | | | Change-Id: I9d30081f71b83bc86f5e5714e23396b18c4d54c5 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>
* Convert more objects to the new constructor schemeLars Knoll2014-07-221-31/+31
| | | | | Change-Id: I31b2a1ba4a93f0d4bde68eeb94f13e7224c0cd7b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert ExecutionContext to new storage schemeLars Knoll2014-07-221-24/+24
| | | | | Change-Id: I9fcc13da5360f37cef3149b114ed9263b9b74281 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of different macros for vtable specializationsLars Knoll2014-07-221-1/+1
| | | | | | | Detect existence of a a vtable entry at compile time. Change-Id: Ieed5d34b063184bc4435b22c6685ac0e3fabf493 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Avoid calling destroy() on most objectsLars Knoll2014-07-221-1/+1
| | | | | | | | | The method is now optional, and we can simply avoid calling it if all members an object has are themselves garbage collected. Change-Id: If560fce051908bcc10409ead1a7d8a5bd5fa71d2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Split ManagedVTable into two classesLars Knoll2014-01-211-1/+1
| | | | | | | | Keep the basic methods in ManagedVTable, but have the Object related stuff in an ObjectVTable class. Change-Id: I9b068acf3caef813686227b8d935e7df1a7d1a6e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move Managed::type and some flags into the vtableLars Knoll2014-01-031-5/+5
| | | | | | | | | | | | | Move the type flag into the vtable to free up these bits in the Managed class, and not have to set them at object construction time. As we often need to know whether a Managed object is a Object, FunctionObject or String, add some bitflags to test for these to the vtable. Change-Id: I7d08ca044544debb307b55f124f34cb086ad9e84 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Simplify & speed up function callingLars Knoll2013-11-091-18/+18
| | | | | | | | | Get rid of the SimpleCallContext, instead simply use the CallContext data structure, but don't initialize the unused variables. Change-Id: I11b311986da180c62c815b516a2c55844156d0ab 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-2/+2
| | | | | Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Seed Math.random in v4Frederik Gladhorn2013-10-291-1/+10
| | | | | | | | Task-number: QTBUG-34105 Change-Id: I6cb5c8b80f158677aaf334feeaa206a5eaf9cfc3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix the remaining objects against self destructionLars Knoll2013-10-111-0/+3
| | | | | | | | This makes pretty much all test cases pass with exact garbage collection. Change-Id: Ia874e3c17c3984afb7cfe370f9bd3ad8fe46699a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>