Commit Graph

240 Commits

Author SHA1 Message Date
Xinchen Hui
60e01e5d64 Added folder mark and codes style 2014-05-24 21:35:36 +08:00
Nikita Popov
c838f6c5b9 Remove UB in signed printing macro
Signed->unsigned conversion and unsigned negation are well-defined
(unlike signed negation for LONG_MIN.)
2014-05-23 13:15:08 +02:00
Nikita Popov
1d8c499b51 Optimize int to string conversion
Probably platform depedentant, but for me snprintf is terribly
slow.

The code for the long printing is taken from the smart string
API.
2014-05-23 13:10:50 +02:00
Dmitry Stogov
17d027ed47 Split IS_BOOL into IS_FALSE and IS_TRUE 2014-04-30 18:32:42 +04:00
Nikita Popov
dd419d24ca Replace more convert_to_* calls 2014-04-25 23:21:05 +02:00
Nikita Popov
93f9518a58 Align zval_get_long/double with zval_get_string 2014-04-25 23:21:04 +02:00
Dmitry Stogov
f9927a6c97 Merge mainstream 'master' branch into refactoring
During merge I had to revert:
	Nikita's patch for php_splice() (it probably needs to be applyed again)
	Bob Weinand's patches related to constant expression handling (we need to review them carefully)
	I also reverted all our attempts to support sapi/phpdbg (we didn't test it anyway)

Conflicts:
	Zend/zend.h
	Zend/zend_API.c
	Zend/zend_ast.c
	Zend/zend_compile.c
	Zend/zend_compile.h
	Zend/zend_constants.c
	Zend/zend_exceptions.c
	Zend/zend_execute.c
	Zend/zend_execute.h
	Zend/zend_execute_API.c
	Zend/zend_hash.c
	Zend/zend_highlight.c
	Zend/zend_language_parser.y
	Zend/zend_language_scanner.c
	Zend/zend_language_scanner_defs.h
	Zend/zend_variables.c
	Zend/zend_vm_def.h
	Zend/zend_vm_execute.h
	ext/date/php_date.c
	ext/dom/documenttype.c
	ext/hash/hash.c
	ext/iconv/iconv.c
	ext/mbstring/tests/zend_multibyte-10.phpt
	ext/mbstring/tests/zend_multibyte-11.phpt
	ext/mbstring/tests/zend_multibyte-12.phpt
	ext/mysql/php_mysql.c
	ext/mysqli/mysqli.c
	ext/mysqlnd/mysqlnd_reverse_api.c
	ext/mysqlnd/php_mysqlnd.c
	ext/opcache/ZendAccelerator.c
	ext/opcache/zend_accelerator_util_funcs.c
	ext/opcache/zend_persist.c
	ext/opcache/zend_persist_calc.c
	ext/pcre/php_pcre.c
	ext/pdo/pdo_dbh.c
	ext/pdo/pdo_stmt.c
	ext/pdo_pgsql/pgsql_driver.c
	ext/pgsql/pgsql.c
	ext/reflection/php_reflection.c
	ext/session/session.c
	ext/spl/spl_array.c
	ext/spl/spl_observer.c
	ext/standard/array.c
	ext/standard/basic_functions.c
	ext/standard/html.c
	ext/standard/mail.c
	ext/standard/php_array.h
	ext/standard/proc_open.c
	ext/standard/streamsfuncs.c
	ext/standard/user_filters.c
	ext/standard/var_unserializer.c
	ext/standard/var_unserializer.re
	main/php_variables.c
	sapi/phpdbg/phpdbg.c
	sapi/phpdbg/phpdbg_bp.c
	sapi/phpdbg/phpdbg_frame.c
	sapi/phpdbg/phpdbg_help.c
	sapi/phpdbg/phpdbg_list.c
	sapi/phpdbg/phpdbg_print.c
	sapi/phpdbg/phpdbg_prompt.c
2014-04-26 00:32:51 +04:00
Dmitry Stogov
4ed452c1b5 Convert zval_get_string() into "fast path" macro and "slow path" function 2014-04-21 22:36:01 +04:00
Nikita Popov
0d43a277b8 Use zval_get_string in a few more places 2014-04-21 17:55:58 +02:00
Nikita Popov
7a1a6092f6 Add functions for extracting long/double/string from zval
These function get the long / double / string value of a zval with
usual cast semantics, but without actually modifying the zval.

Didn't go on a killing spree for convert_to_* yet...
2014-04-15 20:32:47 +02:00
Dmitry Stogov
76cc99fe60 Refactored ZVAL flags usage to simplify various checks (e.g. Z_REFCOUNTED(), candidate for GC, etc) 2014-04-03 15:26:23 +04:00
Dmitry Stogov
d8099d0468 Changed data layout to allow more efficient operations 2014-04-02 14:34:44 +04:00
Dmitry Stogov
d83d34ba6d Cleanup 2014-03-27 14:55:52 +04:00
Dmitry Stogov
40e053e7f3 Use better data structures (incomplete) 2014-02-13 17:54:23 +04:00
Dmitry Stogov
f4cfaf36e2 Use better data structures (incomplete) 2014-02-10 10:04:30 +04:00
datibbaw
aff56f3c45 add T_POW (**) operator
Fixed recognition of the operator

Added opcode, still doing multiply instead of pow()

opcode now always returns int(42)

The right answer, but always a float

Yanked code from pow() implementation.

Should not handle negative long as exponent ourselves

Added test cases from pow()

Moved precedence higher than '~'

Added GMP operator overloading

Added ZEND_ASSIGN_POW (**=) operator.

Added pow() as a language construct.

Adjusted test cases for changed precedence.

Reduced pow() to shell function around ZEND_API pow_function()

Reduced test case to only contain edge cases
Added overloading test case

Moved unary minus above T_POW

Revert "Added pow() as a language construct."

Bad bad bad idea.

This reverts commit f60b98cf7a8371233d800a6faa286ddba4432d02.

Reverted unary minus behaviour due to previous revert.
Convert arrays to int(0)
Exponent with array as a base becomes int(0)

Rebase against master

Fixed tokenizer test case
2014-02-06 14:41:21 +01:00
Xinchen Hui
c081ce628f Bump year 2014-01-03 11:08:10 +08:00
Ard Biesheuvel
60d2e70c06 Zend: fix overflow handling bug in non-x86 fast_add_function()
The 'result' argument of fast_add_function() may alias with either
of its operands (or both). Take care not to write to 'result' before
reading op1 and op2.
2013-12-10 12:12:14 +01:00
Bob Weinand
d36cf90291 Merge branch 'const_scalar_exprs' into PHP-5.6
Conflicts:
	Zend/zend_extensions.h
2013-11-28 13:41:42 +01:00
Anatol Belski
c694d1df7b Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  permanently deactivate that place, not on runtime only
2013-11-20 10:12:06 +01:00
Anatol Belski
18b2b2a0bc Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
  permanently deactivate that place, not on runtime only
2013-11-20 10:11:39 +01:00
Anatol Belski
b902a25cc3 permanently deactivate that place, not on runtime only
besides the two "if" checks, this fixes static analyze which is sometimes
broken because of this
2013-11-20 10:09:11 +01:00
Dmitry Stogov
9647c61dc1 Constant expressions refactoring 2013-11-06 22:21:07 +04:00
Bob Weinand
ad967e1329 Added a few more operators 2013-11-03 01:58:39 +01:00
Bob Weinand
466c5dd1fe Fixed mem leaks, added tests and ternary operator 2013-10-31 18:21:37 +01:00
Bob Weinand
2361745806 Working commit for constant scalar expressions (with constants).
Tests will follow.
2013-10-31 08:57:12 +01:00
Xinchen Hui
72f80b2997 Merge branch 'PHP-5.5' 2013-08-27 15:45:27 +08:00
Xinchen Hui
0119bbba6b Fixed compiler warnings
warning: 'local_dval' may be used uninitialized in this function
[-Wmaybe-uninitialized]

warning: 'dval2' may be used uninitialized in this function
[-Wmaybe-uninitialized]
2013-08-27 15:44:30 +08:00
Andrey Hristov
92d27ccb05 Constify streams API and a few other calls down the rabbit hole.
(`char *` to `const char *` for parameters and few return values)
In a few places int len moved to size_t len.
2013-07-30 12:49:36 +02:00
Nikita Popov
3823321c5c Implement internal operator overloading
As pre RFC https://wiki.php.net/rfc/operator_overloading_gmp
2013-06-17 17:48:13 +02:00
Ard Biesheuvel
5b121eb04d Fix #64780 (PHP 5.5 builds are broken with GCC 3)
A recent change (by me) introduced a call to __builtin_offsetof()
into zend_operators.h which is not defined by GCC prior to
version 4.

Changed the code to use offsetof() instead: this is defined in
<stddef.h>, so #include this header conditionally (#ifdef GNUC)
2013-05-07 20:37:04 +02:00
Gustavo Lopes
a86fcfbc1d Fix rounding of zend_dval_to_lval
Now rounding is always towards zero; the rounding can be though as if
occurring on the original double. Only relevant for the 32-bit long
variant.
2013-02-23 16:55:50 +00:00
Gustavo Lopes
77566edbaf Fix zend_dval_to_lval outside 64bit integers range
PHP should preserve the least significant bits when casting from double
to long. Zend.m4 contains this:

AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits])

If ZEND_DVAL_TO_LVAL_CAST_OK is not defined, zend_operators.h had an
inline implementation of zend_dval_to_lval() that would do a cast to an
int64_t (when sizeof(long) == 4), then a cast to unsigned long and
finally the cast to long.

While this works well for doubles inside the range of values of the type
used in the first cast (int64_t in the 32-bit version and unsigned long
in the 64-bit version), if outside the range, it is undefined behavior
that WILL give varying and not particularly useful results.

This commit uses fmod() to first put the double in a range that can
safely be cast to unsigned long and then casts this unsigned long to
long. This last cast is implementation defined, but it's very likely
that this gives the expected result (i.e. the internal 2's complement
representation is unchanged) on all platforms that PHP supports. In any
case, the previous implementationa already had this assumption.

This alternative code path is indeed significantly slower than simply
casting the double (almost an order of magnitude), but that should not
matter because casting doubles with a very high absolute value is a
rare event.
2013-02-23 17:23:49 +01:00
Ard Biesheuvel
aa12cdc361 Improve x86 inline assembler
- added cc annotation to inline asm that clobbers the condition
  flags
- remove hardcoded constants (IS_LONG,IS_DOUBLE)
- remove hardcoded offsets (zval->value, zval->type)
2013-02-11 13:53:27 +01:00
Remi Collet
dc47ec0490 Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
  Fixed bug #64142 (dval to lval different behavior on ppc64)
2013-02-11 09:13:27 +01:00
Remi Collet
e67a2b9e47 Fixed bug #64142 (dval to lval different behavior on ppc64)
See discussion on internals
http://marc.info/?t=136042277700003&r=1&w=2
2013-02-11 09:10:51 +01:00
Remi Collet
7b75a941ef Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
  revert
2013-02-05 12:29:01 +01:00
Remi Collet
e7ce002c01 revert 2013-02-05 12:28:47 +01:00
Remi Collet
79956330fe Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
  Fixed bug #64142 (dval to lval different behavior on ppc64)
2013-02-04 15:27:07 +01:00
Remi Collet
6533094d9e Fixed bug #64142 (dval to lval different behavior on ppc64)
On x86_64:
(long)(double)9223372036854775807+1 = -9223372036854775808
On ppc64
(long)(double)9223372036854775807-1 = 9223372036854775807
2013-02-04 15:19:32 +01:00
Lars Strojny
92965b033a Bug #46408: Fix double formatting for PostgreSQL bound parameters 2013-01-14 21:23:52 +01:00
Xinchen Hui
a666285bc2 Happy New Year 2013-01-01 16:37:09 +08:00
Xinchen Hui
0a7395e009 Happy New Year 2013-01-01 16:28:54 +08:00
Gustavo Lopes
3d0857938d zend_binary_strncasecmp_l used w/out declaration 2012-08-26 19:44:05 +02:00
Stanislav Malyshev
47db8a9aa1 fix bug #54547 2012-05-14 11:03:20 -07:00
Stanislav Malyshev
9344bf193c fix bug #54547 2012-05-13 14:40:44 -07:00
Felipe Pena
8775a37559 - Year++ 2012-01-01 13:15:04 +00:00
Felipe Pena
4e19825281 - Year++ 2012-01-01 13:15:04 +00:00
Dmitry Stogov
16c87163f0 Fixed bug #55644 (Math ops tests fail, diff min int value) 2011-09-16 07:59:34 +00:00
Dmitry Stogov
c3741ad973 Fixed bug #55644 (Math ops tests fail, diff min int value) 2011-09-16 07:59:34 +00:00
Derick Rethans
56a87c2806 - Zend engine part for bug #55158: Add SORT_NATURAL type to array_multisort
(patch by Arpad Ray).
2011-08-29 20:24:09 +00:00
Derick Rethans
b0be274324 - Zend engine part for bug #55158: Add SORT_NATURAL type to array_multisort
(patch by Arpad Ray).
2011-08-29 20:24:09 +00:00
Gwynne Raskind
ef0e34580b For 5.4, fix C++-style comments. For trunk, forward-port build fix. 2011-08-07 16:31:21 +00:00
Gwynne Raskind
9e9c9b3430 For 5.4, fix C++-style comments. For trunk, forward-port build fix. 2011-08-07 16:31:21 +00:00
Gwynne Raskind
0af1e412a4 Fix build under Clang 2.9 - see LLVM bug #9164 (http://llvm.org/bugs/show_bug.cgi?id=9164). Tested with GCC and Clang on Darwin and Ubuntu. 2011-08-07 05:20:49 +00:00
Pierre Joye
f169f6f478 - should not have been applied 2011-07-22 11:42:15 +00:00
Pierre Joye
cc1c7af037 - remove magic quotes support, functions are kept (see the NEWS entry for the details) for BC reasons but do not allow to set enable MQ 2011-07-22 11:25:30 +00:00
Felipe Pena
5f33819f9c - Removed accidental offsetof definition 2011-07-03 01:29:23 +00:00
Felipe Pena
3e6b211935 - Removed accidental offsetof definition 2011-07-03 01:29:23 +00:00
Felipe Pena
6ef38daf0e - Fixed compiler warning (redefinition of offsetof) 2011-06-18 18:11:27 +00:00
Felipe Pena
72c4e72570 - Fixed compiler warning (redefinition of offsetof) 2011-06-18 18:11:27 +00:00
Dmitry Stogov
c270347c0b MFH: Arithmetic speedup. Inlined most probable code-paths for arithmetic operations directly into executor. 2011-05-31 12:05:25 +00:00
Dmitry Stogov
b7eb3c1c5a Arithmetic speedup. Inlined most probable code-paths for arithmetic operations directly into executor. 2011-05-23 08:05:44 +00:00
Felipe Pena
0203cc3d44 - Year++ 2011-01-01 02:17:06 +00:00
Hartmut Holzgraefe
aaa2f1c30b marked char pointer arguments as const in lots of
places where strings pointed to are not modified 
to prevent compiler warnings about discarded qualifiers ...
2010-10-14 21:33:10 +00:00
Sebastian Bergmann
d2281d1dff sed -i "s#1998-2009#1998-2010#g" **/*.c **/*.h **/*.php 2010-01-05 20:46:53 +00:00
Matt Wilmas
b907aa4331 MFH:
Restored double->long conversion behavior to that of PHP 5.2 (on most platforms) and prior:
 * Out-of-range numbers overflow/preserve least significant bits (no LONG_MAX/MIN limit)
 * See bug #42868 (presumably-rare platform with different results in 5.2)
 * On 32-bit platforms with 64-bit long type, a zend_long64 cast has been added,
    otherwise it's the same as 5.2
 * Use this conversion method everywhere instead of some plain (long) casts

Added 'L' parameter parsing specifier to ensure a LONG_MAX/MIN limit:
 * Essentially what 5.3's new conversion was doing in most cases
 * Functions with "limit" or "length" type params could be updated to use this,
    and prevent confusing overflow behavior with huge numbers (*also* in 5.2)
  - See bug #47854, for example; or even #42868 again

# Test updates coming
2009-06-04 18:20:45 +00:00
Jani Taskinen
1338aa26be sync with HEAD 2009-05-10 22:39:33 +00:00
Matt Wilmas
6bb0ac9712 MFH: Fixed bug #45877 (Array key '2147483647' left as string) 2009-03-18 01:08:12 +00:00
Felipe Pena
f8689552a4 MFH:
- Fixed bug #46701 (Creating associative array with long values in the key fails on 32bit linux)
Patch by Shire
2009-01-05 20:31:54 +00:00
Sebastian Bergmann
08659c2dcd MFH: Bump copyright year, 3 of 3. 2008-12-31 11:15:49 +00:00
Felipe Pena
cf7384aa40 - MFH: Constness (Added const qualifier to several function parameters) 2008-08-12 17:20:25 +00:00
Stanislav Malyshev
4bd1aec2f9 fix memnstr bug, by Laurent Gaffie 2008-08-05 20:14:27 +00:00
Moriyoshi Koizumi
023211d8d2 - MFH: Constify read-only arguments 2008-07-24 20:39:48 +00:00
Scott MacVicar
e19f52047c Optimisation for zend_memnstr when the needle is only a single character. (Patch by Michal Dziemianko - GSoC08) 2008-07-21 18:47:02 +00:00
Antony Dovgal
54482745ba MFH 2008-03-19 12:44:13 +00:00
Antony Dovgal
7b1bc753c6 MFH: add zend_atol() 2008-03-19 12:41:23 +00:00
Dmitry Stogov
fb50ef1aab Reverted memrchr() patch, because it is broken on linux 64-bit 2008-02-14 10:25:22 +00:00
Dmitry Stogov
9fdaddc56d Use memrchr() instead of zend_memrchr() if available. (Nuno) 2008-02-13 16:22:01 +00:00
Sebastian Bergmann
d1dded8751 MFH: Bump copyright year, 2 of 2. 2007-12-31 07:17:19 +00:00
Marcus Boerger
8ce1211a62 - MFH debug object helper 2007-10-11 01:03:19 +00:00
Yiduo (David) Wang
4b4d634cb9 MFH: Added macros for managing zval refcounts and is_ref statuses 2007-10-07 05:22:07 +00:00
Jani Taskinen
226c56fe76 MFH: Fixed compiler warnings 2007-07-21 00:35:15 +00:00
Sebastian Bergmann
4223aa4d5e MFH: Bump year. 2007-01-01 09:36:18 +00:00
Ilia Alshanetsky
ff9d0fcc78 is_numeric_string() optimization
# Original Patch by Matt Wilmas
2006-12-26 16:44:20 +00:00
Antony Dovgal
698ea5f48e MFH 2006-12-20 19:08:48 +00:00
Ilia Alshanetsky
7e1973d9fc Minor optimization (2-3%) from Brian Shire 2006-12-11 15:16:07 +00:00
Stanislav Malyshev
6b651f8e60 Improve tolower()-related functions on Windows and VC2005 by caching locale and using
tolower_l function.
# Gives 10-18% speedup on bench.php
# Does not change behaviour for non-windows
2006-12-04 18:37:15 +00:00
Antony Dovgal
6277ba98d9 there is no realiable way to detect memrchr() presence because of a mess in glibc
so let's use our own implementation
2006-08-08 10:54:24 +00:00
Derick Rethans
5794832a72 - Added some docs here so that nobody needs to figure it out once more. 2006-08-08 09:46:46 +00:00
Antony Dovgal
b8617a6183 add zend_memrchr() 2006-08-08 09:41:09 +00:00
Marcus Boerger
637a40423c - MFH as discussed
. zend_exception_get_default() -> zend_exception_get_default(TSRMLS_D)
  . zend_get_error_exception()   -> zend_get_error_exception(TSRMLS_D)
  . added E_RECOVERABLE_ERROR
  . added ZEND_TOSTRING_FUNC_NAME
  . added __tostring function cache to zend_class_entry
  . added ZEND_NAMED_ME
  . modified ZEND_ME_MAPPING to support method flags
  . added ZEND_MN
  . method entries now use prefix "zim_" instead of "zif_"
  . drop EG(ze1_compatibility_mode)
  . changed cast handler, now without (int should_free):
    typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_DC);
  . changed get_iterator, now receives whether value is by ref:
    zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
  . added zend_objects_store_add_ref_by_handle
  . added zend_objects_store_del_ref_by_handle
  . convert_to_explicit_type(pzv, type)
2006-05-09 23:53:23 +00:00
Andi Gutmans
61e93ccfe8 - Update copyright notices to 2006 2006-01-04 23:53:05 +00:00
Marcus Boerger
af264f6f0d - MFH add Z_OBJVAL*() macros 2005-12-20 21:37:19 +00:00
Antony Dovgal
014729d00b MFH: make GCC happy and suppress the warning 2005-11-17 19:21:32 +00:00
Ilia Alshanetsky
b5c8fcb5fa Allow zend_parse_parameters to handle non-well formed integers, but raise
E_NOTICE in the process.
2005-11-17 00:19:23 +00:00
foobar
916815b779 Bump up the year 2005-08-03 13:30:58 +00:00
Ilia Alshanetsky
9839614829 Fixed bug #30726 (-.1 like numbers are not being handled correctly). 2005-01-18 00:29:43 +00:00
Derick Rethans
e612284ea4 - Fixed bug #30630: Added a BSD based strtod function that is
locale-independent.
2004-11-03 23:13:32 +00:00
Ilia Alshanetsky
da136e6106 MFH: Fixed a bug causing ".123" * "90" and alike to return a 0. 2004-09-15 13:41:45 +00:00