зеркало из https://github.com/mozilla/pjs.git
Big changes for performance. mp_digits are now always unsigned ints.
mp_words are used only on machines that support long long arithmetic. s_mp_mod_d() was deleted. It was not being used and was not part of the public API. The code that computes squares in s_mp_sqr was broken out into a separate new function s_mpv_sqr_add_prop(), which is a target for assembly language optimization. New function s_mpv_div_2dx1d(), also a target for assembly optimization. These changes made X86 benchmark time go from 22.5 seconds to 8.3 seconds on my reference test system.
This commit is contained in:
Родитель
abe117c1ce
Коммит
79db8e17f9
|
@ -38,7 +38,7 @@
|
|||
* the GPL. If you do not delete the provisions above, a recipient
|
||||
* may use your version of this file under either the MPL or the GPL.
|
||||
*
|
||||
* $Id: mpi-priv.h,v 1.9 2000-08-22 01:57:33 nelsonb%netscape.com Exp $
|
||||
* $Id: mpi-priv.h,v 1.10 2000-08-31 02:51:23 nelsonb%netscape.com Exp $
|
||||
*/
|
||||
#ifndef _MPI_PRIV_H_
|
||||
#define _MPI_PRIV_H_ 1
|
||||
|
@ -191,14 +191,13 @@ void s_mp_div_2d(mp_int *mp, mp_digit d); /* divide by 2^d in place */
|
|||
void s_mp_mod_2d(mp_int *mp, mp_digit d); /* modulo 2^d in place */
|
||||
void s_mp_div_2(mp_int *mp); /* divide by 2 in place */
|
||||
mp_err s_mp_mul_2(mp_int *mp); /* multiply by 2 in place */
|
||||
mp_digit s_mp_norm(mp_int *a, mp_int *b); /* normalize for division */
|
||||
mp_err s_mp_norm(mp_int *a, mp_int *b, mp_digit *pd);
|
||||
/* normalize for division */
|
||||
mp_err s_mp_add_d(mp_int *mp, mp_digit d); /* unsigned digit addition */
|
||||
mp_err s_mp_sub_d(mp_int *mp, mp_digit d); /* unsigned digit subtract */
|
||||
mp_err s_mp_mul_d(mp_int *mp, mp_digit d); /* unsigned digit multiply */
|
||||
mp_err s_mp_div_d(mp_int *mp, mp_digit d, mp_digit *r);
|
||||
/* unsigned digit divide */
|
||||
mp_err s_mp_mod_d(mp_int *mp, mp_digit d, mp_digit *r);
|
||||
/* unsigned digit rem */
|
||||
mp_err s_mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu);
|
||||
/* Barrett reduction */
|
||||
mp_err s_mp_add(mp_int *a, const mp_int *b); /* magnitude addition */
|
||||
|
@ -232,6 +231,9 @@ void s_mpv_mul_d_add(const mp_digit *a, mp_size a_len, mp_digit b,
|
|||
mp_digit *c);
|
||||
void s_mpv_mul_d_add_prop(const mp_digit *a, mp_size a_len, mp_digit b,
|
||||
mp_digit *c);
|
||||
void s_mpv_sqr_add_prop(const mp_digit *a, mp_size a_len, mp_digit *sqrs);
|
||||
mp_err s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, mp_digit divisor,
|
||||
mp_digit *quot, mp_digit *rem);
|
||||
|
||||
/* c += a * b * (MP_RADIX ** offset); */
|
||||
#define s_mp_mul_d_add_offset(a, b, c, off) \
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -36,7 +36,7 @@
|
|||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
* $Id: mpi.h,v 1.8 2000-08-22 01:57:33 nelsonb%netscape.com Exp $
|
||||
* $Id: mpi.h,v 1.9 2000-08-31 02:51:23 nelsonb%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#ifndef _H_MPI_
|
||||
|
@ -72,7 +72,7 @@ typedef unsigned int mp_sign;
|
|||
typedef unsigned int mp_size;
|
||||
typedef int mp_err;
|
||||
|
||||
#ifndef MP_USE_32
|
||||
#ifndef MP_NO_MP_WORD
|
||||
#if defined(ULONG_LONG_MAX) /* GCC, HPUX */
|
||||
#define MP_ULONG_LONG_MAX ULONG_LONG_MAX
|
||||
#elif defined(ULLONG_MAX) /* Solaris */
|
||||
|
@ -81,10 +81,10 @@ typedef int mp_err;
|
|||
#define MP_ULONG_LONG_MAX ULONGLONG_MAX
|
||||
#endif
|
||||
|
||||
#if defined(MP_ULONG_LONG_MAX) && MP_ULONG_LONG_MAX > UINT_MAX
|
||||
typedef unsigned int mp_digit;
|
||||
#define MP_DIGIT_MAX UINT_MAX
|
||||
|
||||
#if defined(MP_ULONG_LONG_MAX) && MP_ULONG_LONG_MAX > UINT_MAX
|
||||
#if MP_ULONG_LONG_MAX == ULONG_MAX
|
||||
typedef unsigned long mp_word;
|
||||
typedef long mp_sword;
|
||||
|
@ -94,29 +94,29 @@ typedef unsigned long long mp_word;
|
|||
typedef long long mp_sword;
|
||||
#define MP_WORD_MAX MP_ULONG_LONG_MAX
|
||||
#endif
|
||||
#else /* MP_ULONG_LONG_MAX not defined */
|
||||
#define MP_NO_MP_WORD 1
|
||||
#endif
|
||||
#endif /* !USE_32 */
|
||||
#endif /* !MP_NO_MP_WORD */
|
||||
|
||||
#if !defined(MP_DIGIT_MAX)
|
||||
#if ULONG_MAX == UINT_MAX
|
||||
typedef unsigned short mp_digit;
|
||||
#if !defined(MP_WORD_MAX) && defined(MP_DEFINE_SMALL_WORD)
|
||||
typedef unsigned int mp_word;
|
||||
typedef int mp_sword;
|
||||
#define MP_DIGIT_MAX USHRT_MAX
|
||||
#define MP_WORD_MAX UINT_MAX
|
||||
#else
|
||||
typedef unsigned int mp_digit;
|
||||
typedef unsigned long mp_word;
|
||||
typedef long mp_sword;
|
||||
#define MP_DIGIT_MAX UINT_MAX
|
||||
#define MP_WORD_MAX ULONG_MAX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MP_DIGIT_BIT (CHAR_BIT*sizeof(mp_digit))
|
||||
#define MP_WORD_BIT (CHAR_BIT*sizeof(mp_word))
|
||||
#define MP_RADIX (1+(mp_word)MP_DIGIT_MAX)
|
||||
|
||||
#define MP_HALF_DIGIT_BIT (MP_DIGIT_BIT/2)
|
||||
#define MP_HALF_DIGIT_MAX USHRT_MAX
|
||||
#define MP_HALF_RADIX (1+(mp_digit)MP_HALF_DIGIT_MAX)
|
||||
/* MP_HALF_RADIX really ought to be called MP_SQRT_RADIX, but it's named
|
||||
** MP_HALF_RADIX because it's the radix for MP_HALF_DIGITs, and it's
|
||||
** consistent with the other _HALF_ names.
|
||||
*/
|
||||
|
||||
#if MP_DIGIT_MAX == USHRT_MAX
|
||||
#define MP_DIGIT_FMT "%04X" /* printf() format for 1 digit */
|
||||
#else
|
||||
|
|
Загрузка…
Ссылка в новой задаче