rfc:bigint
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:bigint [2015/01/20 06:03] – ajf | rfc:bigint [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Big Integer Support ====== | ====== PHP RFC: Big Integer Support ====== | ||
- | * Version: 0.1.7 | + | * Version: 0.1.8 |
- | * Date: 2014-06-20 (Initial Draft; Put Under Discussion 2014-10-10, Last updated 2015-01-10) | + | * Date: 2014-06-20 (Initial Draft; Put Under Discussion 2014-10-10, Last updated 2015-02-15) |
* Author: Andrea Faulds, ajf@ajf.me | * Author: Andrea Faulds, ajf@ajf.me | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 36: | Line 36: | ||
==== Standard library changes ==== | ==== Standard library changes ==== | ||
- | * All math functions are updated | + | * Some math functions |
- | * '' | + | * '' |
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | | ||
+ | * '' | ||
+ | * Serialisation and unserialisation supports bigints | ||
+ | * '' | ||
==== Examples ==== | ==== Examples ==== | ||
Line 102: | Line 110: | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | This is proposed for the next PHP X, currently PHP 7. The patch is based off of phpng, and my intention is for it to be merged into phpng. | + | This is proposed for the next PHP X, currently PHP 7. The patch is based on PHP master (originally, phpng). |
===== RFC Impact ===== | ===== RFC Impact ===== | ||
Line 116: | Line 124: | ||
Firstly, if you do an operation resulting in an extremely large number, you might hit your request memory limit. | Firstly, if you do an operation resulting in an extremely large number, you might hit your request memory limit. | ||
- | Secondly, when trying to calculate a value that would require more memory than size_t can describe, GMP prints the '' | + | Secondly, when trying to calculate a value that would require more memory than '' |
==== Licensing and dependency issues ==== | ==== Licensing and dependency issues ==== | ||
- | I am current porting this to use [[http:// | + | To avoid implementing the underlying arithmetic itself, PHP needs to add a dependency on a library implementing |
- | At compile-time, it is also possible to choose | + | This patch supports two different libraries, which you can choose |
- | ==== Arrays ==== | + | * [[http:// |
+ | * [[https:// | ||
- | A problem arising from allowing integers | + | A choice is allowed |
+ | |||
+ | ==== Arrays ==== | ||
- | This also presents a further issue: inconsistency between longs, bigints | + | Since '' |
==== To SAPIs ==== | ==== To SAPIs ==== | ||
Line 136: | Line 147: | ||
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
- | Any which request numeric parameters as zvals rather than longs or doubles from zend_parse_parameters will need changes. Those dealing with numerical operations specifically will require deeper changes. Obviously, ext/ | + | Any extensions |
ext/gmp will be updated to handle bigints. However, due to behavioural and implementation differences between GMP objects and the bigint type, it won't just pass through to the built-in operator functions. With the addition of bigints, ext/gmp would quickly become irrelevant except for backwards-compatibility with existing applications, | ext/gmp will be updated to handle bigints. However, due to behavioural and implementation differences between GMP objects and the bigint type, it won't just pass through to the built-in operator functions. With the addition of bigints, ext/gmp would quickly become irrelevant except for backwards-compatibility with existing applications, | ||
Line 146: | Line 157: | ||
Both GMP and LibTomMath can only have one custom allocator, so I weighed the options and made that be emalloc, not malloc. I expect this would pose a problem for opcache, as any bigints would be destroyed upon the end of a request, so opcache would need to store bigints persistently. Hence, some sort of import/ | Both GMP and LibTomMath can only have one custom allocator, so I weighed the options and made that be emalloc, not malloc. I expect this would pose a problem for opcache, as any bigints would be destroyed upon the end of a request, so opcache would need to store bigints persistently. Hence, some sort of import/ | ||
- | I have not yet dealt with opcache | + | The patch has not yet been updated to support |
==== New Constants ==== | ==== New Constants ==== | ||
Line 158: | Line 169: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | The patch is unfinished. Many tests are still broken, I haven' | + | The patch is unfinished. Many tests are still broken and most extensions will need some updating. It does not work with opcache. |
- | ==== Open Questions ==== | + | However, there are no open questions. |
- | + | ||
- | * Should we rework array key handling? (See " | + | |
==== TODO ==== | ==== TODO ==== | ||
Line 168: | Line 177: | ||
=== Must be done === | === Must be done === | ||
+ | * Check if https:// | ||
+ | * Fix left shift overflow check for negative '' | ||
* Finish LibTomMath port | * Finish LibTomMath port | ||
* TODOs | * TODOs | ||
Line 182: | Line 193: | ||
* Partially ported: | * Partially ported: | ||
* standard | * standard | ||
+ | * Agree on some semi-sane new behaviour for '' | ||
* Compiles, not necessarily fully working: | * Compiles, not necessarily fully working: | ||
* bz2, core, ctype, curl, date, dom, ereg, exif, fileinfo, gd, gettext, hash, iconv, intl, libxml, mbstring, mysql, mysqli, mysqlnd, pcre, pdo_mysql, pdo_mysql, pdo_sqlite, pgsql, phar, reflection, session, shmop, simplexml, soap, sockets, spl, sqlite3, standard, tidy, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip | * bz2, core, ctype, curl, date, dom, ereg, exif, fileinfo, gd, gettext, hash, iconv, intl, libxml, mbstring, mysql, mysqli, mysqlnd, pcre, pdo_mysql, pdo_mysql, pdo_sqlite, pgsql, phar, reflection, session, shmop, simplexml, soap, sockets, spl, sqlite3, standard, tidy, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip | ||
Line 196: | Line 208: | ||
* Add an unsigned long type, '' | * Add an unsigned long type, '' | ||
* Optimisations: | * Optimisations: | ||
- | * We currently use clang and GCC 5.0 checked arithmetic builtins to implement faster overflow checks in '' | + | * We currently use clang and GCC 5.0 checked arithmetic builtins to implement faster overflow checks in '' |
- | * That clz/bsr assembly TODO: We need to do a clz/bsr operation for bit shift overflow checking, and currently we do this with a double conversion and '' | + | |
* Other optimisations: | * Other optimisations: | ||
* Possibly mark the zend_bigint_* functions as to be inlined and move them to the header | * Possibly mark the zend_bigint_* functions as to be inlined and move them to the header | ||
Line 203: | Line 214: | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
- | As previously mentioned, the handling of array keys might need to be looked at. Otherwise, it shouldn' | + | As previously mentioned, the handling of array keys might need to be looked at. Otherwise, it shouldn' |
===== Future Scope ===== | ===== Future Scope ===== | ||
Line 209: | Line 220: | ||
None I can think of particularly. | None I can think of particularly. | ||
- | ===== Proposed Voting Choices | + | ===== Vote ===== |
+ | |||
+ | As this is a language change (it affects the language specification), | ||
+ | |||
+ | Voting started on 2015-02-15 and was to end 10 days later on 2015-02-25, but voting was cancelled the same day it started. | ||
- | In some respects this is just an implementation detail, but as this would break backwards-compatibility for some apps and arguably changes the language, I think this requires a 2/3 majority. It would be a straight | + | <doodle title=" |
+ | | ||
+ | * No | ||
+ | </doodle> | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
Line 248: | Line 266: | ||
==== General ==== | ==== General ==== | ||
- | * http:// | + | * http:// |
* https:// | * https:// | ||
* Yasuo' | * Yasuo' | ||
Line 254: | Line 272: | ||
===== Changelog ===== | ===== Changelog ===== | ||
+ | * v0.1.8 - Decided on not touching float indexing behaviour for now | ||
* v0.1.7 - Minor changes, removed some outdated information | * v0.1.7 - Minor changes, removed some outdated information | ||
* v0.1.6 - LibTomMath built as part of PHP | * v0.1.6 - LibTomMath built as part of PHP |
rfc/bigint.1421733809.txt.gz · Last modified: 2017/09/22 13:28 (external edit)