libraries/v8/runtime.cc
// Given a word and two range boundaries returns a word with high bit
// set in every byte iff the corresponding input byte was strictly in
// the range (m, n). All the other bits in the result are cleared.
// This function is only useful when it can be inlined and the
// boundaries are statically known.
// Requires: all bytes in the input word and the boundaries must be
// ASCII (less than 0x7F).
Given a word and two range boundaries returns a word with high bit
set in every byte iff the corresponding input byte was strictly in
the range (m, n). All the other bits in the result are cleared.
This function is only useful when it can be inlined and the
boundaries are statically known.
Requires: all bytes in the input word and the boundaries must be
ASCII (less than 0x7F).
Given a word and two range boundaries returns a word with high bit set in every byte iff the corresponding input byte was strictly in the range ( m n ) . All the other bits in the result are cleared . This function is only useful when it can be inlined and the boundaries are statically known . Requires : all bytes in the input word and the boundaries must be ASCII ( less than 0x7F ) .
static inline uintptr_t AsciiRangeMask(uintptr_t w, char m, char n) {
  ASSERT(0 < m && m < n);
  uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w;
  uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m);
  return (tmp1 & tmp2 & (kOneInEveryByte * 0x80));
}
static inline uintptr_t AsciiRangeMask ( uintptr_t w , char m , char n ) { ASSERT ( 0 < m && m < n ) ; uintptr_t tmp1 = kOneInEveryByte * ( 0x7F + n ) - w ; uintptr_t tmp2 = w + kOneInEveryByte * ( 0x7F - m ) ; return ( tmp1 & tmp2 & ( kOneInEveryByte * 0x80 ) ) ; }
Given a word and two range boundaries returns a word with high bit
set in every byte iff the corresponding input byte was strictly in
the range (m, n).
Given a word and two range boundaries returns a word with high bit set in every byte iff the corresponding input byte was strictly in the range ( m n ) .
// Use strict inequalities since in edge cases the function could be // further simplified. // Has high bit set in every w byte less than n. // Has high bit set in every w byte greater than m.