Fix clang JS shell build bustage. No bug, r=billm over irl

This commit is contained in:
Jeff Walden 2012-04-12 18:15:26 -07:00
parent a71b6905e6
commit 2e8482d1bf
5 changed files with 56 additions and 39 deletions

View File

@ -904,6 +904,40 @@ RoundUpPow2(size_t x)
} /* namespace js */
namespace JS {
/*
* Methods for poisoning GC heap pointer words and checking for poisoned words.
* These are in this file for use in Value methods and so forth.
*
* If the moving GC hazard analysis is in use and detects a non-rooted stack
* pointer to a GC thing, one byte of that pointer is poisoned to refer to an
* invalid location. For both 32 bit and 64 bit systems, the fourth byte of the
* pointer is overwritten, to reduce the likelihood of accidentally changing
* a live integer value.
*/
inline void PoisonPtr(uintptr_t *v)
{
#if defined(JSGC_ROOT_ANALYSIS) && defined(DEBUG)
uint8_t *ptr = (uint8_t *) v + 3;
*ptr = JS_FREE_PATTERN;
#endif
}
template <typename T>
inline bool IsPoisonedPtr(T *v)
{
#if defined(JSGC_ROOT_ANALYSIS) && defined(DEBUG)
uint32_t mask = uintptr_t(v) & 0xff000000;
return mask == uint32_t(JS_FREE_PATTERN << 24);
#else
return false;
#endif
}
}
#endif /* defined(__cplusplus) */
/*

View File

@ -42,6 +42,8 @@
#include "jspubtd.h"
#include "js/Utility.h"
#ifdef __cplusplus
namespace JS {
@ -284,16 +286,13 @@ class RootedVar
{
public:
RootedVar(JSContext *cx)
: ptr(RootMethods<T>::initial()), root(cx, &ptr)
: ptr(RootMethods<T>::initial()), root(cx, &ptr)
{}
RootedVar(JSContext *cx, T initial)
: ptr(initial), root(cx, &ptr)
: ptr(initial), root(cx, &ptr)
{}
RootedVar() MOZ_DELETE;
RootedVar(const RootedVar &) MOZ_DELETE;
operator T () const { return ptr; }
T operator ->() const { return ptr; }
T * address() { return &ptr; }
@ -301,6 +300,15 @@ class RootedVar
T & reference() { return ptr; }
T raw() { return ptr; }
/*
* This method is only necessary due to an obscure C++98 requirement (that
* there be an accessible, usable copy constructor when passing a temporary
* to an implicitly-called constructor for use with a const-ref parameter).
* (Head spinning yet?) We can remove this when we build the JS engine
* with -std=c++11.
*/
operator Handle<T> () const { return Handle<T>(*this); }
T & operator =(T value)
{
JS_ASSERT(!RootMethods<T>::poisoned(value));
@ -317,6 +325,9 @@ class RootedVar
private:
T ptr;
Root<T> root;
RootedVar() MOZ_DELETE;
RootedVar(const RootedVar &) MOZ_DELETE;
};
template <typename T> template <typename S>

View File

@ -216,36 +216,6 @@ inline Anchor<T>::~Anchor()
}
#endif /* defined(__GNUC__) */
/*
* Methods for poisoning GC heap pointer words and checking for poisoned words.
* These are in this file for use in Value methods and so forth.
*
* If the moving GC hazard analysis is in use and detects a non-rooted stack
* pointer to a GC thing, one byte of that pointer is poisoned to refer to an
* invalid location. For both 32 bit and 64 bit systems, the fourth byte of the
* pointer is overwritten, to reduce the likelihood of accidentally changing
* a live integer value.
*/
inline void PoisonPtr(uintptr_t *v)
{
#if defined(JSGC_ROOT_ANALYSIS) && defined(DEBUG)
uint8_t *ptr = (uint8_t *) v + 3;
*ptr = JS_FREE_PATTERN;
#endif
}
template <typename T>
inline bool IsPoisonedPtr(T *v)
{
#if defined(JSGC_ROOT_ANALYSIS) && defined(DEBUG)
uint32_t mask = uintptr_t(v) & 0xff000000;
return mask == uint32_t(JS_FREE_PATTERN << 24);
#else
return false;
#endif
}
/*
* JS::Value is the C++ interface for a single JavaScript Engine value.
* A few general notes on JS::Value:

View File

@ -2393,7 +2393,8 @@ class SplitMatchResult {
template<class Matcher>
static JSObject *
SplitHelper(JSContext *cx, Handle<JSLinearString*> str, uint32_t limit, Matcher splitMatch, TypeObject *type)
SplitHelper(JSContext *cx, Handle<JSLinearString*> str, uint32_t limit, const Matcher &splitMatch,
TypeObject *type)
{
size_t strLength = str->length();
SplitMatchResult result;
@ -2534,7 +2535,8 @@ class SplitRegExpMatcher
static const bool returnsCaptures = true;
bool operator()(JSContext *cx, JSLinearString *str, size_t index, SplitMatchResult *result)
bool operator()(JSContext *cx, JSLinearString *str, size_t index,
SplitMatchResult *result) const
{
Value rval = UndefinedValue();
const jschar *chars = str->chars();
@ -2564,7 +2566,7 @@ class SplitStringMatcher
static const bool returnsCaptures = false;
bool operator()(JSContext *cx, JSLinearString *str, size_t index, SplitMatchResult *res)
bool operator()(JSContext *cx, JSLinearString *str, size_t index, SplitMatchResult *res) const
{
JS_ASSERT(index == 0 || index < str->length());
const jschar *chars = str->chars();

View File

@ -130,7 +130,7 @@ RegExpObjectBuilder::clone(Handle<RegExpObject *> other, Handle<RegExpObject *>
RegExpFlag staticsFlags = res->getFlags();
if ((origFlags & staticsFlags) != staticsFlags) {
RegExpFlag newFlags = RegExpFlag(origFlags | staticsFlags);
return build(RootedVar<JSLinearString*>(cx, other->getSource()), newFlags);
return build(RootedVar<JSAtom *>(cx, other->getSource()), newFlags);
}
RegExpGuard g;