rfc:bigint
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:bigint [2015/01/17 03:18] – ajf | rfc:bigint [2015/02/15 21:06] – Withdrew RFC and cancelled vote ajf | ||
---|---|---|---|
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: | ||
- | * core, ctype, curl, date, dom, ereg, fileinfo, gd, gettext, hash, iconv, intl, json, libxml, mbstring, mysql, mysqli, mysqlnd, pcre, pgsql, phar, reflection, session, shmop, simplexml, spl, sqlite3, standard, tidy, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl | + | * 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 |
* Need doing: | * Need doing: | ||
* Basically everything, but in particular: | * Basically everything, but in particular: | ||
- | * Important exts (json (wait until [[rfc: | + | * Important exts (session, PDO, etc.) |
* Make PHP at least build without '' | * Make PHP at least build without '' | ||
* Opcache | * Opcache | ||
Line 194: | Line 206: | ||
* '' | * '' | ||
+ | * 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 202: | 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 208: | Line 220: | ||
None I can think of particularly. | None I can think of particularly. | ||
- | ===== Proposed Voting Choices | + | ===== Vote ===== |
- | In some respects | + | As this is a language change (it affects |
+ | |||
+ | 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. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | A work-in-progress, | + | A work-in-progress, |
The branch itself is here: https:// | The branch itself is here: https:// | ||
Line 220: | Line 239: | ||
The LibTomMath backend (the default) is a work-in-progress. Use '' | The LibTomMath backend (the default) is a work-in-progress. Use '' | ||
- | It is based off the phpng branch. | + | Many tests are still broken, as as mentioned previously, I still need to deal with extensions and opcache. It is very much unfinished, but it does work to a degree. |
See the TODO section in Open Issues (above) for unfinished areas. | See the TODO section in Open Issues (above) for unfinished areas. | ||
+ | |||
+ | There is also an incomplete language specification pull request here, which currently lacks updated tests: https:// | ||
===== Implementation ===== | ===== Implementation ===== | ||
Line 245: | Line 266: | ||
==== General ==== | ==== General ==== | ||
- | * http:// | + | * http:// |
* https:// | * https:// | ||
* Yasuo' | * Yasuo' | ||
Line 251: | 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.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1