diff --git a/js/src/jsutil.h b/js/src/jsutil.h index 7472ac0e4b9..edbc6e877de 100644 --- a/js/src/jsutil.h +++ b/js/src/jsutil.h @@ -14,12 +14,10 @@ #include "mozilla/Assertions.h" #include "mozilla/Compiler.h" #include "mozilla/GuardObjects.h" -#include "mozilla/PodOperations.h" #include #include "js/Utility.h" -#include "js/Value.h" #define JS_ALWAYS_TRUE(expr) MOZ_ALWAYS_TRUE(expr) #define JS_ALWAYS_FALSE(expr) MOZ_ALWAYS_FALSE(expr) @@ -280,31 +278,20 @@ ClearAllBitArrayElements(size_t* array, size_t length) } /* namespace js */ static inline void* -Poison(void* ptr, uint8_t value, size_t num) +Poison(void* ptr, int value, size_t num) { - static bool poison = getenv("JSGC_DISABLE_POISONING"); - if (poison) { - // Without a valid Value tag, a poisoned Value may look like a valid - // floating point number. To ensure that we crash more readily when - // observing a poisoned Value, we make the poison an invalid ObjectValue. - uintptr_t obj; - memset(&obj, value, sizeof(obj)); -#if defined(JS_PUNBOX64) - obj >>= JSVAL_TAG_SHIFT; -#endif - jsval_layout layout = OBJECT_TO_JSVAL_IMPL((JSObject*)obj); - - size_t value_count = num / sizeof(jsval_layout); - size_t byte_count = num % sizeof(jsval_layout); - mozilla::PodSet((jsval_layout*)ptr, layout, value_count); - if (byte_count) { - uint8_t* bytes = static_cast(ptr); - uint8_t* end = bytes + num; - mozilla::PodSet(end - byte_count, value, byte_count); - } - return ptr; + static bool inited = false; + static bool poison = true; + if (!inited) { + char* env = getenv("JSGC_DISABLE_POISONING"); + if (env) + poison = false; + inited = true; } + if (poison) + return memset(ptr, value, num); + return nullptr; } diff --git a/mfbt/PodOperations.h b/mfbt/PodOperations.h index dd4e2143097..9d7b5850ab7 100644 --- a/mfbt/PodOperations.h +++ b/mfbt/PodOperations.h @@ -88,18 +88,6 @@ PodAssign(T* aDst, const T* aSrc) sizeof(T)); } -/** - * Set the first |aNElem| T elements in |aDst| to |aSrc|. - */ -template -static MOZ_ALWAYS_INLINE void -PodSet(T* aDst, T aSrc, size_t aNElem) -{ - for (const T* dstend = aDst + aNElem; aDst < dstend; aDst++) { - *aDst = aSrc; - } -} - /** * Copy |aNElem| T elements from |aSrc| to |aDst|. The two memory ranges must * not overlap!