-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix fallback paths in fast_long_{add,sub}_function #17666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -723,7 +723,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL | |
*/ | ||
|
||
if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) == (Z_LVAL_P(op2) & LONG_SIGN_MASK) | ||
&& (Z_LVAL_P(op1) & LONG_SIGN_MASK) != ((Z_LVAL_P(op1) + Z_LVAL_P(op2)) & LONG_SIGN_MASK))) { | ||
&& (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (((zend_ulong) Z_LVAL_P(op1) + (zend_ulong) Z_LVAL_P(op2)) & LONG_SIGN_MASK))) { | ||
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2)); | ||
} else { | ||
ZVAL_LONG(result, Z_LVAL_P(op1) + Z_LVAL_P(op2)); | ||
|
@@ -804,11 +804,17 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL | |
ZVAL_LONG(result, llresult); | ||
} | ||
#else | ||
ZVAL_LONG(result, Z_LVAL_P(op1) - Z_LVAL_P(op2)); | ||
/* | ||
* 'result' may alias with op1 or op2, so we need to | ||
* ensure that 'result' is not updated until after we | ||
* have read the values of op1 and op2. | ||
*/ | ||
|
||
if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(op2) & LONG_SIGN_MASK) | ||
&& (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(result) & LONG_SIGN_MASK))) { | ||
&& (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (((zend_ulong) Z_LVAL_P(op1) - (zend_ulong) Z_LVAL_P(op2)) & LONG_SIGN_MASK))) { | ||
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2)); | ||
} else { | ||
ZVAL_LONG(result, Z_LVAL_P(op1) - Z_LVAL_P(op2)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we're not actually testing this branch? Probably would only be used on some pretty esoteric platforms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
My bad (#17472) ;)
Possibly not even that. Would require a compiler without ASM goto support, no builtins (SADDL etc.) and non Windows system. Plus, that compiler would need to support C11 (or at least the subset we're using). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to perform the integer math once, keeping the result in a temporary variable. |
||
} | ||
#endif | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.