mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-26 18:31:29 +00:00
Bug 875929 - Now that js_bitscan_ctz64 and js_bitscan_clz64 are implemented on all platforms, clean up some compatibility code which isn't needed anymore. r=evilpies
This commit is contained in:
parent
807c4e8412
commit
6566491f07
@ -204,7 +204,6 @@ __BitScanReverse32(unsigned int val)
|
||||
}
|
||||
# define js_bitscan_ctz32(val) __BitScanForward32(val)
|
||||
# define js_bitscan_clz32(val) __BitScanReverse32(val)
|
||||
# define JS_HAS_BUILTIN_BITSCAN32
|
||||
|
||||
#if defined(_M_AMD64) || defined(_M_X64)
|
||||
unsigned char _BitScanForward64(unsigned long * Index, unsigned __int64 Mask);
|
||||
@ -246,7 +245,6 @@ __BitScanReverse64(unsigned __int64 val)
|
||||
}
|
||||
# define js_bitscan_ctz64(val) __BitScanForward64(val)
|
||||
# define js_bitscan_clz64(val) __BitScanReverse64(val)
|
||||
# define JS_HAS_BUILTIN_BITSCAN64
|
||||
#elif MOZ_IS_GCC
|
||||
|
||||
#if MOZ_GCC_VERSION_AT_LEAST(3, 4, 0)
|
||||
@ -266,12 +264,10 @@ __BitScanReverse64(unsigned __int64 val)
|
||||
JS_STATIC_ASSERT(sizeof(unsigned int) == sizeof(uint32_t));
|
||||
# define js_bitscan_ctz32(val) __builtin_ctz(val)
|
||||
# define js_bitscan_clz32(val) __builtin_clz(val)
|
||||
# define JS_HAS_BUILTIN_BITSCAN32
|
||||
|
||||
JS_STATIC_ASSERT(sizeof(unsigned long long) == sizeof(uint64_t));
|
||||
# define js_bitscan_ctz64(val) __builtin_ctzll(val)
|
||||
# define js_bitscan_clz64(val) __builtin_clzll(val)
|
||||
# define JS_HAS_BUILTIN_BITSCAN64
|
||||
|
||||
# undef USE_BUILTIN_CTZ
|
||||
|
||||
@ -281,7 +277,6 @@ JS_STATIC_ASSERT(sizeof(unsigned long long) == sizeof(uint64_t));
|
||||
** Macro version of JS_CeilingLog2: Compute the log of the least power of
|
||||
** 2 greater than or equal to _n. The result is returned in _log2.
|
||||
*/
|
||||
#ifdef JS_HAS_BUILTIN_BITSCAN32
|
||||
/*
|
||||
* Use intrinsic function or count-leading-zeros to calculate ceil(log2(_n)).
|
||||
* The macro checks for "n <= 1" and not "n != 0" as js_bitscan_clz32(0) is
|
||||
@ -292,25 +287,6 @@ JS_STATIC_ASSERT(sizeof(unsigned long long) == sizeof(uint64_t));
|
||||
unsigned int j_ = (unsigned int)(_n); \
|
||||
(_log2) = (j_ <= 1 ? 0 : 32 - js_bitscan_clz32(j_ - 1)); \
|
||||
JS_END_MACRO
|
||||
#else
|
||||
# define JS_CEILING_LOG2(_log2,_n) \
|
||||
JS_BEGIN_MACRO \
|
||||
uint32_t j_ = (uint32_t)(_n); \
|
||||
(_log2) = 0; \
|
||||
if ((j_) & ((j_)-1)) \
|
||||
(_log2) += 1; \
|
||||
if ((j_) >> 16) \
|
||||
(_log2) += 16, (j_) >>= 16; \
|
||||
if ((j_) >> 8) \
|
||||
(_log2) += 8, (j_) >>= 8; \
|
||||
if ((j_) >> 4) \
|
||||
(_log2) += 4, (j_) >>= 4; \
|
||||
if ((j_) >> 2) \
|
||||
(_log2) += 2, (j_) >>= 2; \
|
||||
if ((j_) >> 1) \
|
||||
(_log2) += 1; \
|
||||
JS_END_MACRO
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Macro version of JS_FloorLog2: Compute the log of the greatest power of
|
||||
@ -318,7 +294,6 @@ JS_STATIC_ASSERT(sizeof(unsigned long long) == sizeof(uint64_t));
|
||||
**
|
||||
** This is equivalent to finding the highest set bit in the word.
|
||||
*/
|
||||
#ifdef JS_HAS_BUILTIN_BITSCAN32
|
||||
/*
|
||||
* Use js_bitscan_clz32 or count-leading-zeros to calculate floor(log2(_n)).
|
||||
* Since js_bitscan_clz32(0) is undefined, the macro set the loweset bit to 1
|
||||
@ -328,38 +303,13 @@ JS_STATIC_ASSERT(sizeof(unsigned long long) == sizeof(uint64_t));
|
||||
JS_BEGIN_MACRO \
|
||||
(_log2) = 31 - js_bitscan_clz32(((unsigned int)(_n)) | 1); \
|
||||
JS_END_MACRO
|
||||
#else
|
||||
# define JS_FLOOR_LOG2(_log2,_n) \
|
||||
JS_BEGIN_MACRO \
|
||||
uint32_t j_ = (uint32_t)(_n); \
|
||||
(_log2) = 0; \
|
||||
if ((j_) >> 16) \
|
||||
(_log2) += 16, (j_) >>= 16; \
|
||||
if ((j_) >> 8) \
|
||||
(_log2) += 8, (j_) >>= 8; \
|
||||
if ((j_) >> 4) \
|
||||
(_log2) += 4, (j_) >>= 4; \
|
||||
if ((j_) >> 2) \
|
||||
(_log2) += 2, (j_) >>= 2; \
|
||||
if ((j_) >> 1) \
|
||||
(_log2) += 1; \
|
||||
JS_END_MACRO
|
||||
#endif
|
||||
|
||||
#if JS_BYTES_PER_WORD == 4
|
||||
# ifdef JS_HAS_BUILTIN_BITSCAN32
|
||||
# define js_FloorLog2wImpl(n) \
|
||||
((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz32(n)))
|
||||
# else
|
||||
JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n);
|
||||
# endif
|
||||
#elif JS_BYTES_PER_WORD == 8
|
||||
# ifdef JS_HAS_BUILTIN_BITSCAN64
|
||||
# define js_FloorLog2wImpl(n) \
|
||||
((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz64(n)))
|
||||
# else
|
||||
JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n);
|
||||
# endif
|
||||
#else
|
||||
# error "NOT SUPPORTED"
|
||||
#endif
|
||||
|
@ -1,63 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "jsutil.h"
|
||||
|
||||
/*
|
||||
* Check that we can use js_bitscan_clz32 to implement JS_FLOOR_LOG2 and
|
||||
* JS_FLOOR_LOG2W and js_bitscan_clz64 to implement JS_FLOOR_LOG2W on 64-bit
|
||||
* systems.
|
||||
*/
|
||||
#ifdef JS_HAS_BUILTIN_BITSCAN32
|
||||
JS_STATIC_ASSERT(sizeof(unsigned int) == sizeof(uint32_t));
|
||||
JS_STATIC_ASSERT_IF(JS_BYTES_PER_WORD == 4,
|
||||
sizeof(unsigned int) == sizeof(uintptr_t));
|
||||
#endif
|
||||
#ifdef JS_HAS_BUILTIN_BITSCAN64
|
||||
JS_STATIC_ASSERT_IF(JS_BYTES_PER_WORD == 8,
|
||||
sizeof(unsigned long long) == sizeof(uintptr_t));
|
||||
#endif
|
||||
|
||||
#if !defined(JS_HAS_BUILTIN_BITSCAN32) && JS_BYTES_PER_WORD == 4
|
||||
|
||||
size_t
|
||||
js_FloorLog2wImpl(size_t n)
|
||||
{
|
||||
size_t log2;
|
||||
|
||||
JS_FLOOR_LOG2(log2, n);
|
||||
return log2;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* js_FloorLog2wImpl has to be defined only for 64-bit non-GCC case.
|
||||
*/
|
||||
#if !defined(JS_HAS_BUILTIN_BITSCAN64) && JS_BYTES_PER_WORD == 8
|
||||
|
||||
size_t
|
||||
js_FloorLog2wImpl(size_t n)
|
||||
{
|
||||
size_t log2, m;
|
||||
|
||||
JS_ASSERT(n != 0);
|
||||
|
||||
log2 = 0;
|
||||
m = n >> 32;
|
||||
if (m != 0) { n = m; log2 = 32; }
|
||||
m = n >> 16;
|
||||
if (m != 0) { n = m; log2 |= 16; }
|
||||
m = n >> 8;
|
||||
if (m != 0) { n = m; log2 |= 8; }
|
||||
m = n >> 4;
|
||||
if (m != 0) { n = m; log2 |= 4; }
|
||||
m = n >> 2;
|
||||
if (m != 0) { n = m; log2 |= 2; }
|
||||
log2 |= (n >> 1);
|
||||
|
||||
return log2;
|
||||
}
|
||||
|
||||
#endif
|
@ -156,7 +156,6 @@ CPP_SOURCES += [
|
||||
'jsgc.cpp',
|
||||
'jsinfer.cpp',
|
||||
'jsiter.cpp',
|
||||
'jslog2.cpp',
|
||||
'jsmath.cpp',
|
||||
'jsmemorymetrics.cpp',
|
||||
'jsnativestack.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user