[PHP-CVS] com php-src: Fixed bug #64142 (dval to lval different behavior on ppc64): NEWS Zend/zend_operators.h

2013-02-11 Thread Remi Collet
Commit:e67a2b9e471a7bc0b774b9056bb38745b7187969
Author:Remi Collet r...@php.net Mon, 11 Feb 2013 09:10:51 +0100
Parents:   bfdb889d4f4cdc1c602db70f956726235778aac3
Branches:  PHP-5.4 PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=e67a2b9e471a7bc0b774b9056bb38745b7187969

Log:
Fixed bug #64142 (dval to lval different behavior on ppc64)

See discussion on internals
http://marc.info/?t=13604227773r=1w=2

Bugs:
https://bugs.php.net/64142

Changed paths:
  M  NEWS
  M  Zend/zend_operators.h


Diff:
diff --git a/NEWS b/NEWS
index f205f3b..4bdd8c3 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP 
   NEWS
 |||
 ?? ??? 2012, PHP 5.4.13
 
+- Core:
+  . Fixed bug #64142 (dval to lval different behavior on ppc64). (Remi)
+
 - CLI server:
   . Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi)
 
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 02a96dd..047b92e 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -79,7 +79,8 @@ static zend_always_inline long zend_dval_to_lval(double d)
 #else
 static zend_always_inline long zend_dval_to_lval(double d)
 {
-   if (d  LONG_MAX) {
+   /* = as (double)LONG_MAX is outside signed range */
+   if (d = LONG_MAX) {
return (long)(unsigned long) d;
}
return (long) d;


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: NEWS: NEWS

2013-02-11 Thread Remi Collet
Commit:1a954ea616fb361e2f1d94bc4436f7621bcd4c24
Author:Remi Collet r...@php.net Mon, 11 Feb 2013 09:13:52 +0100
Parents:   dc47ec049007d97a4d854e5867f04d854a2551ec
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=1a954ea616fb361e2f1d94bc4436f7621bcd4c24

Log:
NEWS

Changed paths:
  M  NEWS


Diff:
diff --git a/NEWS b/NEWS
index f7882de..9a2f8b9 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ PHP   
 NEWS
   . Fixed bug #60833 (self, parent, static behave inconsistently 
 case-sensitive). (Stas, mario at include-once dot org)
   . Implemented FR #60524 (specify temp dir by php.ini). (ALeX Kazik).
+  . Fixed bug #64142 (dval to lval different behavior on ppc64). (Remi)
 
 - CLI server:
   . Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: Zend/zend_operators.h

2013-02-11 Thread Remi Collet
Commit:dc47ec049007d97a4d854e5867f04d854a2551ec
Author:Remi Collet r...@php.net Mon, 11 Feb 2013 09:13:27 +0100
Parents:   ce005c0883f64c97cd83bdd8a80db3bed7cfcb50 
e67a2b9e471a7bc0b774b9056bb38745b7187969
Branches:  PHP-5.5 master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=dc47ec049007d97a4d854e5867f04d854a2551ec

Log:
Merge branch 'PHP-5.4' into PHP-5.5

* PHP-5.4:
  Fixed bug #64142 (dval to lval different behavior on ppc64)

Bugs:
https://bugs.php.net/64142

Changed paths:
  MM  Zend/zend_operators.h


Diff:



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: Low-level ARM optimizations: Zend/zend_alloc.c Zend/zend_multiply.h

2013-02-11 Thread Ard Biesheuvel
Commit:e2453276e95165bf3b765d27781405c816821c15
Author:Ard Biesheuvel ard.biesheu...@linaro.org Mon, 11 Feb 2013 
14:36:58 +0100
Parents:   aa12cdc361b29b4050676763858b3cfa637be6cb
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=e2453276e95165bf3b765d27781405c816821c15

Log:
Low-level ARM optimizations

- added ARM versions of zend_mm_high_bit()/zend_mm_low_bit()
- improved safe_address()

Changed paths:
  M  Zend/zend_alloc.c
  M  Zend/zend_multiply.h


Diff:
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 98ab6be..1c76bd4 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -678,6 +678,8 @@ static inline unsigned int zend_mm_high_bit(size_t _size)
__asm {
bsr eax, _size
}
+#elif defined(__GNUC__)  (defined(__arm__) ||  defined(__aarch64__))
+   return (8 * SIZEOF_SIZE_T - 1) - __builtin_clzl(_size);
 #else
unsigned int n = 0;
while (_size != 0) {
@@ -704,6 +706,8 @@ static inline unsigned int zend_mm_low_bit(size_t _size)
__asm {
bsf eax, _size
}
+#elif defined(__GNUC__)  (defined(__arm__) || defined(__aarch64__))
+   return __builtin_ctzl(_size);
 #else
static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
unsigned int n;
@@ -2494,6 +2498,47 @@ static inline size_t safe_address(size_t nmemb, size_t 
size, size_t offset)
 return res;
 }
 
+#elif defined(__GNUC__)  defined(__arm__)
+
+static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
+{
+size_t res;
+unsigned long overflow;
+
+__asm__ (umlal %0,%1,%2,%3
+ : =r(res), =r(overflow)
+ : r(nmemb),
+   r(size),
+   0(offset),
+   1(0));
+
+if (UNEXPECTED(overflow)) {
+zend_error_noreturn(E_ERROR, Possible integer overflow in 
memory allocation (%zu * %zu + %zu), nmemb, size, offset);
+return 0;
+}
+return res;
+}
+
+#elif defined(__GNUC__)  defined(__aarch64__)
+
+static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
+{
+size_t res;
+unsigned long overflow;
+
+__asm__ (mul %0,%2,%3\n\tumulh %1,%2,%3\n\tadds %0,%0,%4\n\tadc 
%1,%1,%1
+ : =r(res), =r(overflow)
+ : r(nmemb),
+   r(size),
+   r(offset));
+
+if (UNEXPECTED(overflow)) {
+zend_error_noreturn(E_ERROR, Possible integer overflow in 
memory allocation (%zu * %zu + %zu), nmemb, size, offset);
+return 0;
+}
+return res;
+}
+
 #elif SIZEOF_SIZE_T == 4  defined(HAVE_ZEND_LONG64)
 
 static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h
index c3c9657..e52956f 100644
--- a/Zend/zend_multiply.h
+++ b/Zend/zend_multiply.h
@@ -13,7 +13,7 @@
| lice...@zend.com so we can mail you a copy immediately.  |
+--+
| Authors: Sascha Schumann sas...@schumann.cx|
-   |  Ard Biesheuvel a...@ard.nu |
+   |  Ard Biesheuvel ard.biesheu...@linaro.org  |
+--+
 */
 
@@ -43,6 +43,31 @@
else (lval) = __tmpvar; 
\
 } while (0)
 
+#elif defined(__arm__)  defined(__GNUC__)
+
+#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do {  \
+   long __tmpvar;  
\
+   __asm__(smull %0, %1, %2, %3\n
\
+   sub %1, %1, %0, asr #31   
\
+   : =r(__tmpvar), =r(usedval) 
\
+   : r(a), r(b));  
\
+   if (usedval) (dval) = (double) (a) * (double) (b);  
\
+   else (lval) = __tmpvar; 
\
+} while (0)
+
+#elif defined(__aarch64__)  defined(__GNUC__)
+
+#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do {  \
+   long __tmpvar;  
\
+   __asm__(mul %0, %2, %3\n  
\
+   smulh %1, %2, %3\n
\
+   sub %1, %1, %0, asr #63\n

[PHP-CVS] com php-src: Improve x86 inline assembler: Zend/zend_alloc.c Zend/zend_operators.h

2013-02-11 Thread Ard Biesheuvel
Commit:aa12cdc361b29b4050676763858b3cfa637be6cb
Author:Ard Biesheuvel ard.biesheu...@linaro.org Mon, 11 Feb 2013 
13:53:27 +0100
Parents:   5bfdf4f069975514a358473f7e7fee3710e50597
Branches:  master

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=aa12cdc361b29b4050676763858b3cfa637be6cb

Log:
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)

Changed paths:
  M  Zend/zend_alloc.c
  M  Zend/zend_operators.h


Diff:
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 1cc2c67..98ab6be 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -667,12 +667,12 @@ static inline unsigned int zend_mm_high_bit(size_t _size)
 #if defined(__GNUC__)  (defined(__native_client__) || defined(i386))
unsigned int n;
 
-   __asm__(bsrl %1,%0\n\t : =r (n) : rm  (_size));
+   __asm__(bsrl %1,%0\n\t : =r (n) : rm  (_size) : cc);
return n;
 #elif defined(__GNUC__)  defined(__x86_64__)
unsigned long n;
 
-__asm__(bsrq %1,%0\n\t : =r (n) : rm  (_size));
+__asm__(bsrq %1,%0\n\t : =r (n) : rm  (_size) : cc);
 return (unsigned int)n;
 #elif defined(_MSC_VER)  defined(_M_IX86)
__asm {
@@ -693,17 +693,17 @@ static inline unsigned int zend_mm_low_bit(size_t _size)
 #if defined(__GNUC__)  (defined(__native_client__) || defined(i386))
unsigned int n;
 
-   __asm__(bsfl %1,%0\n\t : =r (n) : rm  (_size));
+   __asm__(bsfl %1,%0\n\t : =r (n) : rm  (_size) : cc);
return n;
 #elif defined(__GNUC__)  defined(__x86_64__)
 unsigned long n;
 
-__asm__(bsfq %1,%0\n\t : =r (n) : rm  (_size));
+__asm__(bsfq %1,%0\n\t : =r (n) : rm  (_size) : cc);
 return (unsigned int)n;
 #elif defined(_MSC_VER)  defined(_M_IX86)
__asm {
bsf eax, _size
-   }
+   }
 #else
static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
unsigned int n;
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index e395fd3..93c60e4 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -477,6 +477,10 @@ ZEND_API void zend_update_current_locale(void);
 #define zend_update_current_locale()
 #endif
 
+/* The offset in bytes between the value and type fields of a zval */
+#define ZVAL_OFFSETOF_TYPE \
+   (__builtin_offsetof(zval,type) - __builtin_offsetof(zval,value))
+
 static zend_always_inline int fast_increment_function(zval *op1)
 {
if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
@@ -486,20 +490,26 @@ static zend_always_inline int 
fast_increment_function(zval *op1)
jno  0f\n\t
movl $0x0, (%0)\n\t
movl $0x41e0, 0x4(%0)\n\t
-   movb $0x2,0xc(%0)\n
+   movb %1, %c2(%0)\n
0:
:
-   : r(op1));
+   : r(op1-value),
+ n(IS_DOUBLE),
+ n(ZVAL_OFFSETOF_TYPE)
+   : cc);
 #elif defined(__GNUC__)  defined(__x86_64__)
__asm__(
incq (%0)\n\t
jno  0f\n\t
movl $0x0, (%0)\n\t
movl $0x43e0, 0x4(%0)\n\t
-   movb $0x2,0x14(%0)\n
+   movb %1, %c2(%0)\n
0:
:
-   : r(op1));
+   : r(op1-value),
+ n(IS_DOUBLE),
+ n(ZVAL_OFFSETOF_TYPE)
+   : cc);
 #else
if (UNEXPECTED(Z_LVAL_P(op1) == LONG_MAX)) {
/* switch to double */
@@ -523,20 +533,26 @@ static zend_always_inline int 
fast_decrement_function(zval *op1)
jno  0f\n\t
movl $0x0020, (%0)\n\t
movl $0xc1e0, 0x4(%0)\n\t
-   movb $0x2,0xc(%0)\n
+   movb %1,%c2(%0)\n
0:
:
-   : r(op1));
+   : r(op1-value),
+ n(IS_DOUBLE),
+ n(ZVAL_OFFSETOF_TYPE)
+   : cc);
 #elif defined(__GNUC__)  defined(__x86_64__)
__asm__(
decq (%0)\n\t
jno  0f\n\t
movl $0x, (%0)\n\t
movl $0xc3e0, 0x4(%0)\n\t
-   movb $0x2,0x14(%0)\n
+   movb %1,%c2(%0)\n
0:
:
-   : r(op1));
+   : r(op1-value),
+ n(IS_DOUBLE),
+ n(ZVAL_OFFSETOF_TYPE)
+  

[PHP-CVS] branch php-src: 5.5 deleted

2013-02-11 Thread Ard Biesheuvel
Deleted branch: 5.5
User: Ard Biesheuvel ardbiesheu...@php.net Mon, 11 Feb 2013 13:53:41 
+


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: NEWS update: NEWS

2013-02-11 Thread Ard Biesheuvel
Commit:dbad4fb3ad918307dd7a641e6b8ed2351a93f3c7
Author:Ard Biesheuvel ard.biesheu...@linaro.org Mon, 11 Feb 2013 
15:54:59 +0100
Parents:   e2453276e95165bf3b765d27781405c816821c15
Branches:  5.5

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=dbad4fb3ad918307dd7a641e6b8ed2351a93f3c7

Log:
NEWS update

Changed paths:
  M  NEWS


Diff:
diff --git a/NEWS b/NEWS
index 9a2f8b9..81ee851 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ PHP   
 NEWS
 case-sensitive). (Stas, mario at include-once dot org)
   . Implemented FR #60524 (specify temp dir by php.ini). (ALeX Kazik).
   . Fixed bug #64142 (dval to lval different behavior on ppc64). (Remi)
+  . Added ARMv7/v8 versions of various Zend arithmetic functions that are
+implemented using inline assembler (Ard Biesheuvel)
 
 - CLI server:
   . Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] branch php-src: 5.4 deleted

2013-02-11 Thread Ard Biesheuvel
Deleted branch: 5.4
User: Ard Biesheuvel ardbiesheu...@php.net Mon, 11 Feb 2013 15:01:45 
+


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] branch php-src: 5.5 deleted

2013-02-11 Thread Ard Biesheuvel
Deleted branch: 5.5
User: Ard Biesheuvel ardbiesheu...@php.net Mon, 11 Feb 2013 15:02:01 
+


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] com php-src: NEWS update: NEWS

2013-02-11 Thread Ard Biesheuvel
Commit:dbad4fb3ad918307dd7a641e6b8ed2351a93f3c7
Author:Ard Biesheuvel ard.biesheu...@linaro.org Mon, 11 Feb 2013 
15:54:59 +0100
Parents:   e2453276e95165bf3b765d27781405c816821c15
Branches:  PHP-5.5

Link:   
http://git.php.net/?p=php-src.git;a=commitdiff;h=dbad4fb3ad918307dd7a641e6b8ed2351a93f3c7

Log:
NEWS update

Changed paths:
  M  NEWS


Diff:
diff --git a/NEWS b/NEWS
index 9a2f8b9..81ee851 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ PHP   
 NEWS
 case-sensitive). (Stas, mario at include-once dot org)
   . Implemented FR #60524 (specify temp dir by php.ini). (ALeX Kazik).
   . Fixed bug #64142 (dval to lval different behavior on ppc64). (Remi)
+  . Added ARMv7/v8 versions of various Zend arithmetic functions that are
+implemented using inline assembler (Ard Biesheuvel)
 
 - CLI server:
   . Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php