aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4dateobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix handling of out-of-range year in Date's toISOString()Edward Welbourne2018-07-031-1/+1
| | | | | | | | | | ECMAScript 2015 clarified the handling of out-of-range years, requiring that an exception be raised: http://www.ecma-international.org/ecma-262/7.0/index.html#sec-corrections-and-clarifications-in-ecmascript-2015-with-possible-compatibility-impact http://www.ecma-international.org/ecma-262/7.0/index.html#sec-date.prototype.toisostring Change-Id: I91d76703705f3919d2ee77557e36af362db1adf9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Apply TimeClip() in a few places it was missingEdward Welbourne2018-07-031-3/+3
| | | | | | | | | When parsing or converting from a QDateTime, we didn't always check that the resulting Date object was within range (1e8 days either side of the start of 1970). Change-Id: I1bee69f9070829f68998d576c19907a827fabc39 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement support for new.targetLars Knoll2018-07-031-1/+1
| | | | | | | | | Support the new.target meta property in the codegen, and add support for passing the newtarget into the constructor vtable methods and the execution context. Change-Id: I62ea58e5e92d894035a76e35776203e9837c383b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Prefix vtable methods with virtualLars Knoll2018-07-031-2/+2
| | | | | | | | | 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 <simon.hausmann@qt.io>
* Clean up the property key API in StringOrSymbolLars Knoll2018-07-021-3/+3
| | | | | | | | | | | | | | 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-1/+1
| | | | | | | | 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>
* Implement toPrimitive() the way the ES7 spec wants itLars Knoll2018-05-281-0/+18
| | | | | | | | Add Dat.prototype[Symbol.toPrimitive] and make use of those methods in the toPrimitive implementation. Change-Id: I82a9a94dcae6822100de364373b3f4de1e3d749b Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-05-111-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4compilerscanfunctions.cpp tools/tools.pro Done-with: Lars Knoll <lars.knoll@qt.io> Change-Id: Ia77ee6ede6fc9760ce5a03d68079579a63e5a02f
| * Fix build without features.timezoneTasuku Suzuki2018-05-111-1/+1
| | | | | | | | | | | | Change-Id: Id40b7a9394a9027551a1334e9e520630e8967cb7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Cleanup creation code for builtin functionsLars Knoll2018-05-021-3/+1
| | | | | | | | | | | | | | | | Centralize the code in FunctionObject::createBuiltinFunction and setup function names and length properties there. Change-Id: I21f1d42b475070ee091d96d97387149af1dc47f2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove static localTZA variableLars Knoll2018-05-021-52/+51
|/ | | | | | | | | This one leads to lots of complaints from thread sanitizers as we're writing to it from multiple threads. Move it into the engine to avoid the noise. Change-Id: I081eeb1de80e623c68fcbd17df1875943c6c019c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Get rid of BuiltinFunctionLars Knoll2018-01-151-1/+1
| | | | | | | It's now unused. Change-Id: Id2941c212d488c9b0933fa06aac9922b9db13a05 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Raise minimum supported MSVC version to 2015Friedemann Kleint2018-01-061-1/+1
| | | | | | | | | | | | Remove code for older versions and streamline #ifdefs. Remove the helpers macros Q_STATIC_ASSERT_FOR_SANE_COMPILERS and V4_ASSERT_IS_TRIVIAL. Task-number: QTBUG-40658 Task-number: QTBUG-51673 Change-Id: Ifa4fab653b10ce7858739adef08364cddc6507cf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/wip/new-backend' into devSimon Hausmann2017-11-211-263/+333
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4isel_moth.cpp src/qml/compiler/qv4jsir_p.h src/qml/jsruntime/qv4engine_p.h src/qml/jsruntime/qv4vme_moth.cpp tests/auto/qml/qml.pro Change-Id: Ia7b6ec24c7fcbcbb1786d9e798d2df294020ae37
| * Convert Date methods to new calling conventionLars Knoll2017-11-131-150/+145
| | | | | | | | | | Change-Id: I5b80eb9d9f18b113a04461fc8b5217a3695269a4 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Change signature for call/callAsConstructorLars Knoll2017-11-071-12/+12
| | | | | | | | | | Change-Id: I159b57acc7a2133ef1ad545aa84e792c63449a57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Rename the construct 'virtual' method to callAsConstructorLars Knoll2017-11-071-1/+1
| | | | | | | | | | | | | | To make it consistent with the rest of the engine. Change-Id: I57b98fa26134f9864c663f47371ef3e9ca16ac9c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Further cleanup JSCallDataLars Knoll2017-11-071-1/+1
| | | | | | | | | | | | | | Avoid allocations on the JS stack if possible Change-Id: I344cd6dceb6264314f9d22c94db22b22d1d24d14 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Simplify JSCallData constructionLars Knoll2017-11-071-1/+1
| | | | | | | | | | Change-Id: Ic53532edae9a209aa7125af6f00a9d993d74f1a3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Get rid of JSCallData::call()Lars Knoll2017-11-071-3/+3
| | | | | | | | | | Change-Id: I6b99e9a7102b3dcb6a7699f54b6456eba6248699 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Rename JSCall to JSCallDataLars Knoll2017-11-071-1/+1
| | | | | | | | | | | | | | | | 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 <erik.verbruggen@qt.io>
| * Change CallData::argc to be a QV4::ValueErik Verbruggen2017-09-191-43/+43
| | | | | | | | | | | | | | | | | | | | | | 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>
| * Always set the correct FunctionObject when calling JS functionsLars Knoll2017-09-021-3/+3
| | | | | | | | | | | | | | | | | | 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 <simon.hausmann@qt.io>
| * Move ScopedCallData and ScopedStackFrame into a separate fileLars Knoll2017-09-011-0/+1
| | | | | | | | | | Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-181/+254
| | | | | | | | | | | | | | | | 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>
| * Change function signatures for call/construct backLars Knoll2017-08-041-5/+6
| | | | | | | | | | | | | | | | 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 <erik.verbruggen@qt.io>
* | V4 Date.ParseString(): use array in place of QStringListEdward Welbourne2017-11-141-50/+51
| | | | | | | | | | | | | | | | Converted a QStringList of formats (constructed on each affected call to the function) to a const array (needing no heap or run-time). Change-Id: Ia6b32a306620e3ea4dd0ec1456f6b66bc8aba322 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | V4 Date.ParseString(): fix UTC-ness of date-only formatsEdward Welbourne2017-11-141-18/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ECMA-262 stipulates that date-only formats should be treated as UTC, while date-times are handled as standard time, if no time zone is explicitly given. Tidied up the parser a bit in the process and documented what the spec says. Fixed some broken test-cases. Handling of date-times without zone as local time is a correction since edition 5.1 of ECMA-262 (which said to handle it as UTC): http://www.ecma-international.org/ecma-262/7.0/index.html#sec-corrections-and-clarifications-in-ecmascript-2015-with-possible-compatibility-impact We were previously handling both dates and date-times as local time, violating the old spec for both and the revised spec for dates. Task-number: QTBUG-56787 Change-Id: I557789d855b910ca6a859fca396af1a0205c9417 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | V4 Date: fix what we can within ECMA 262's limitationsEdward Welbourne2017-11-141-39/+80
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use QDateTime and QTimeZone to simplify code (when we can). Note which defective methods are so because the ECMAScript spec requires those defects, reference my bug report against those defects. Fix currentTime to return a UTC time. Fix getLocalTZA to actually deliver the standard offset, without daylight-saving corrections. Fix DaylightSavingTA(t) to return the difference between current standard time offset and pertinent total offset at time t (explaining why that's the least broken answer), rather than assuming DST is one hour when active. (In some places it's half an hour, in some places two hours; and the bugs in the spec break UTC() and LocalTime() if we only return actual DST offset, without adjusting for historical changes to standard offset.) Fix tests to use actual IANA IDs for zones. Change QTime-to-Time conversion to use a modernish date, for which time-zone data is likely to at least be consistently handled, instead of MakeDay(0, 0, 0); that's (nominal proleptic Gregorian) 2 BC, December 31st (represented denormally) for which any time-zone data we have is artificial and contrived. I chose Cassini's third centennary, as it's not likely to be near any zone transitions and is within the era of sane time-zone data. Task-number: QTBUG-56787 Change-Id: I5f21ee2010070a5c1798134fdd2915a723208fd9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* DateObject: Add a bunch of exception checksRobin Burchell2017-02-071-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | The ES6 spec specifies ReturnIfAbrupt between each of these steps, covering cases where for instance some strange person passes an Object to the setYear function, with a valueOf that throws. This improves our pass rate on built-ins/Date/prototype on the ES6 tests significantly. Before: === Summary === - Ran 1144 tests - Passed 1076 tests (94.1%) - Failed 68 tests (5.9%) After: === Summary === - Ran 1144 tests - Passed 1110 tests (97.0%) - Failed 34 tests (3.0%) Change-Id: I616d5727eb6ae197699aa4021631f17c7346de27 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Date.prototype: Fixes for ES6 complianceRobin Burchell2017-02-071-4/+19
| | | | | | | | | | | | * Don't return -0 from TimeClip (20.3.1.15, 1) * Mark length configurable (19.2.4.1) * toUTCString and toGMTString must be the the same object (B.2.4.3) Brings us a bit closer to passing tests. Still some failures in other areas. Change-Id: I905216b8653ac0b33cb27e6b773616521fbb5daa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Convert more builtin methods to the new calling conventionLars Knoll2017-01-251-239/+236
| | | | | Change-Id: I2cd1df437d91918001beed8dfe92d553b3bb377f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up Value::isString()/stringValue() combinationsLars Knoll2016-11-291-2/+2
| | | | | | | | It's enough to just call stringValue(), as that already does the isString() check. Change-Id: I7be0e643a7975c0704b4c9c43b337deb8db9fce0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up some duplicated methodsLars Knoll2016-11-291-2/+5
| | | | | Change-Id: Iad64dd2c330ca85a28f8f5c776b0ede623203558 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Make Heap::Object and all subclasses trivialErik Verbruggen2016-10-061-4/+6
| | | | | | | | | | | | 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>
* V4: Handle QTime->DateObject conversion betterErik Verbruggen2016-08-101-0/+22
| | | | | | | | | | | | | | | | | | | | | | By specification, date conversion functions for dates before the epoch are not DST corrected. We converted QTime to a QDateTime where we set the date part to Jan. 1, 1970, and then convert that to msecs since the epoch UTC. For places on Earth where they had DST on that day (e.g. Hobart in Australia), strange things happen: conversion from a QTime to DateObject will use DST (because it's after the epoch in local time), but conversions from DateObject to QTime won't use the DST because it's before the epoch (in UTC). Now as everyone knows, a 24-hour clock time has no meaning without a date, only "elapsed time" has. But users still expect to be able to pass QTime to QML/JS. So, we do the conversion on day 0 of month 0 of year 0, and all of it in local time. This gives a stable conversion in both directions, and the values in both C++ and QML/JS are the same for any timezone (with or without DST) on this planet. Task-number: QTBUG-54378 Change-Id: I892e16a93f015e92d311c6cae3ae7768b7373f6a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Qml: replace QStringLiteral with QL1SAnton Kudryavtsev2016-07-051-1/+1
| | | | | | | | | | | | | | ... or with QL1C in such cases: - if there is overloaded function - in QStringBuilder expressions Saves ~1.5 KB in text size. Build config: ubuntu 16.04 x64, gcc 5.3 Change-Id: Icc0789f1c244ce20a3182494b0c7f35c9d77e41d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Pass scope around as parameters inside the runtime.Erik Verbruggen2016-06-221-6/+6
| | | | | | | | | | | | | | | | The implementation of many (or all) runtime functions consist of first creating a QV4::Scope, which saves and restores the JS stack pointer. It also prevents tail-calls because of that restoring behavior. In many cases it suffices to do that at the entry-point of the runtime. The return value of a JS function call is now also stored in the scope. Previously, all return values were stored in a ScopedValue, got loaded on return, and immediately stored in another ScopedValue in the caller. This resulted in a lot of stores, where now there is only one store needed, and no extra ScopedValue for every function. Change-Id: I13d80fc0ce72c5702ef1536d41d12f710c5914fa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-131-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsapi/qjsengine.cpp src/qml/qml/qqmlengine_p.h src/quick/items/qquickanchors.cpp src/quick/items/qquickanimatedimage_p_p.h src/quick/items/qquickitem_p.h tests/auto/qml/qqmlecmascript/testtypes.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tests/benchmarks/qml/creation/tst_creation.cpp Change-Id: I65861e32f16e8a04c7090a90231627e1ebf6ba6f
| * QML: Replace qIsFinite with qt_is_finite.Erik Verbruggen2016-04-281-1/+1
| | | | | | | | | | | | | | The latter can be inlined. Change-Id: I57747b84889390839a17faa1df6d359210ef4adf Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* | Merge remote-tracking branch 'origin/5.7' into devSimon Hausmann2016-04-081-24/+24
|\| | | | | | | Change-Id: I60b8a701b6d90f8572143cf760873f6b8b453c14
| * Replace qQNaN() and friends with qt_qnan().Erik Verbruggen2016-04-051-24/+24
| | | | | | | | | | | | | | | | 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>
* | Add a QChar::unicode() calls to brush over deprecation warninghjk2016-04-061-1/+1
|/ | | | | | | ... introduced with e0ea0f6178 in QtBase. Change-Id: I5b93236a28de237b407a3eaa26078242fa8d58ff Reviewed-by: Lars Knoll <lars.knoll@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-24/+24
| | | | | | | | | | | 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>
* Move more objects over to the new allocation schemeLars Knoll2015-09-221-2/+1
| | | | | Change-Id: I0241efe10d115f8e4a646f840e47e220eb6cfc18 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move the StringValue members of ExecutionEngine onto the JS stackLars Knoll2015-06-101-4/+4
| | | | | Change-Id: Ib55c05f1730b7659e2f6fee7e1fa79c10c759167 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move more objects from the v4 engine to the js stackLars Knoll2015-04-241-1/+1
| | | | | | | Convert most of the prototype objects in the v4 engine. Change-Id: I365f290493c20973bc991b6a383649836e42a16a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Store the datetime as a double in the date objectLars Knoll2015-04-241-59/+60
| | | | | Change-Id: I6ae05a066d021e81eaed90866e09bf480f5d91d9 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>