Commit af608d4b authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[utils] Remove unused classes and functions

This removes dead classes and functions from utils.h.

R=sigurds@chromium.org

Bug: v8:9810, v8:8912
Change-Id: I8e15600f77b8ccc8ce25b4fd25e6a1b4303ad657
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1903969
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64853}
parent 08c0abb5
......@@ -90,24 +90,6 @@ inline bool ClampToBounds(T index, T* length, T max) {
return !oob;
}
inline int MostSignificantBit(uint32_t x) {
static const int msb4[] = {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4};
int nibble = 0;
if (x & 0xffff0000) {
nibble += 16;
x >>= 16;
}
if (x & 0xff00) {
nibble += 8;
x >>= 8;
}
if (x & 0xf0) {
nibble += 4;
x >>= 4;
}
return nibble + msb4[x];
}
template <typename T>
static T ArithmeticShiftRight(T x, int shift) {
DCHECK_LE(0, shift);
......@@ -122,26 +104,6 @@ static T ArithmeticShiftRight(T x, int shift) {
}
}
template <typename T>
int Compare(const T& a, const T& b) {
if (a == b)
return 0;
else if (a < b)
return -1;
else
return 1;
}
// Compare function to compare the object pointer value of two
// handlified objects. The handles are passed as pointers to the
// handles.
template <typename T>
class Handle; // Forward declaration.
template <typename T>
int HandleObjectPointerCompare(const Handle<T>* a, const Handle<T>* b) {
return Compare<T*>(*(*a), *(*b));
}
// Returns the maximum of the two parameters.
template <typename T>
constexpr T Max(T a, T b) {
......@@ -185,13 +147,6 @@ typename std::make_unsigned<T>::type Abs(T a) {
return (x ^ y) - y;
}
// Returns the negative absolute value of its argument.
template <typename T,
typename = typename std::enable_if<std::is_signed<T>::value>::type>
T Nabs(T a) {
return a < 0 ? a : -a;
}
inline double Modulo(double x, double y) {
#if defined(V8_OS_WIN)
// Workaround MS fmod bugs. ECMA-262 says:
......@@ -485,45 +440,6 @@ static const int kInt64LowerHalfMemoryOffset = 4;
static const int kInt64UpperHalfMemoryOffset = 0;
#endif // V8_TARGET_LITTLE_ENDIAN
// A static resource holds a static instance that can be reserved in
// a local scope using an instance of Access. Attempts to re-reserve
// the instance will cause an error.
template <typename T>
class StaticResource {
public:
StaticResource() : is_reserved_(false) {}
private:
template <typename S>
friend class Access;
T instance_;
bool is_reserved_;
};
// Locally scoped access to a static resource.
template <typename T>
class Access {
public:
explicit Access(StaticResource<T>* resource)
: resource_(resource), instance_(&resource->instance_) {
DCHECK(!resource->is_reserved_);
resource->is_reserved_ = true;
}
~Access() {
resource_->is_reserved_ = false;
resource_ = nullptr;
instance_ = nullptr;
}
T* value() { return instance_; }
T* operator->() { return instance_; }
private:
StaticResource<T>* resource_;
T* instance_;
};
// A pointer that can only be set once and doesn't allow NULL values.
template <typename T>
class SetOncePointer {
......@@ -607,41 +523,6 @@ inline int TenToThe(int exponent) {
return answer;
}
template <typename ElementType, int NumElements>
class EmbeddedContainer {
public:
EmbeddedContainer() : elems_() {}
int length() const { return NumElements; }
const ElementType& operator[](int i) const {
DCHECK(i < length());
return elems_[i];
}
ElementType& operator[](int i) {
DCHECK(i < length());
return elems_[i];
}
private:
ElementType elems_[NumElements];
};
template <typename ElementType>
class EmbeddedContainer<ElementType, 0> {
public:
int length() const { return 0; }
const ElementType& operator[](int i) const {
UNREACHABLE();
static ElementType t = 0;
return t;
}
ElementType& operator[](int i) {
UNREACHABLE();
static ElementType t = 0;
return t;
}
};
// Helper class for building result strings in a character buffer. The
// purpose of the class is to use safe operations that checks the
// buffer bounds on all operations in debug mode.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment