Fix some used-but-not-defined warnings, and some format-string warnings about needing to cast T* to void* for the %p specifier. No bug, r=themaid

This commit is contained in:
Jeff Walden 2013-01-16 19:47:34 -08:00
parent af29d559b0
commit dd2fbe0549
8 changed files with 275 additions and 220 deletions

View File

@ -17,6 +17,7 @@
#include "jsnum.h"
#include "jsprobes.h"
#include "jsstr.h"
#include "methodjit/MethodJIT.h"
#include "jsatominlines.h"
@ -31,6 +32,7 @@
#include "ion/IonCompartment.h"
#endif
#include "vm/GlobalObject-inl.h"
#include "vm/Stack-inl.h"
namespace js {

View File

@ -1269,7 +1269,8 @@ class CallCompiler : public BaseCompiler
JaegerSpew(JSpew_PICs, "generated CALL clone stub %p (%lu bytes)\n",
start.executableAddress(), (unsigned long) masm.size());
JaegerSpew(JSpew_PICs, "guarding %p with clone %p\n", original.get(), fun.get());
JaegerSpew(JSpew_PICs, "guarding %p with clone %p\n",
static_cast<void*>(original.get()), static_cast<void*>(fun.get()));
Repatcher repatch(f.chunk());
repatch.relink(ic.funJump, start);

View File

@ -8,6 +8,11 @@
#ifndef GlobalObject_inl_h___
#define GlobalObject_inl_h___
#include "vm/GlobalObject.h"
#include "gc/Barrier-inl.h"
#include "vm/ObjectImpl-inl.h"
namespace js {
inline void
@ -201,6 +206,18 @@ GlobalObject::setProtoGetter(JSFunction *protoGetter)
setSlot(PROTO_GETTER, ObjectValue(*protoGetter));
}
bool
GlobalObject::setIntrinsicValue(JSContext *cx, PropertyName *name, HandleValue value)
{
#ifdef DEBUG
RootedObject self(cx, this);
JS_ASSERT(cx->runtime->isSelfHostingGlobal(self));
#endif
RootedObject holder(cx, intrinsicsHolder());
RootedValue valCopy(cx, value);
return JSObject::setProperty(cx, holder, holder, name, &valCopy, false);
}
void
GlobalObject::setIntrinsicsHolder(JSObject *obj)
{

View File

@ -394,15 +394,7 @@ class GlobalObject : public JSObject
return true;
}
bool setIntrinsicValue(JSContext *cx, PropertyName *name, HandleValue value) {
#ifdef DEBUG
RootedObject self(cx, this);
JS_ASSERT(cx->runtime->isSelfHostingGlobal(self));
#endif
RootedObject holder(cx, intrinsicsHolder());
RootedValue valCopy(cx, value);
return JSObject::setProperty(cx, holder, holder, name, &valCopy, false);
}
inline bool setIntrinsicValue(JSContext *cx, PropertyName *name, HandleValue value);
inline RegExpStatics *getRegExpStatics() const;

View File

@ -17,6 +17,7 @@
#include "jsstrinlines.h"
#include "RegExpStatics-inl.h"
#include "String-inl.h"
inline js::RegExpObject &
JSObject::asRegExp()
@ -99,6 +100,12 @@ RegExpObject::setSticky(bool enabled)
setSlot(STICKY_FLAG_SLOT, BooleanValue(enabled));
}
inline void
RegExpShared::writeBarrierPre()
{
JSString::writeBarrierPre(source);
}
/* This function should be deleted once bad Android platforms phase out. See bug 604774. */
inline bool
RegExpShared::isJITRuntimeEnabled(JSContext *cx)
@ -129,6 +136,69 @@ RegExpShared::prepareForUse(JSContext *cx)
gcNumberWhenUsed = cx->runtime->gcNumber;
}
RegExpGuard::RegExpGuard(JSContext *cx)
: re_(NULL), source_(cx)
{
}
RegExpGuard::RegExpGuard(JSContext *cx, RegExpShared &re)
: re_(&re), source_(cx, re.source)
{
re_->incRef();
}
RegExpGuard::~RegExpGuard()
{
release();
}
inline void
RegExpGuard::init(RegExpShared &re)
{
JS_ASSERT(!initialized());
re_ = &re;
re_->incRef();
source_ = re_->source;
}
inline void
RegExpGuard::release()
{
if (re_) {
re_->decRef();
re_ = NULL;
source_ = NULL;
}
}
RegExpHeapGuard::RegExpHeapGuard(RegExpShared &re)
{
init(re);
}
RegExpHeapGuard::~RegExpHeapGuard()
{
release();
}
inline void
RegExpHeapGuard::init(RegExpShared &re)
{
JS_ASSERT(!initialized());
re_ = &re;
re_->incRef();
}
inline void
RegExpHeapGuard::release()
{
if (re_) {
re_->writeBarrierPre();
re_->decRef();
re_ = NULL;
}
}
} /* namespace js */
#endif

View File

@ -156,9 +156,7 @@ class RegExpShared
void trace(JSTracer *trc) {
MarkStringUnbarriered(trc, &source, "regexpshared source");
}
void writeBarrierPre() {
JSString::writeBarrierPre(source);
}
inline void writeBarrierPre();
/* Static functions to expose some Yarr logic. */
static inline bool isJITRuntimeEnabled(JSContext *cx);
@ -221,32 +219,13 @@ class RegExpGuard
void operator=(const RegExpGuard &) MOZ_DELETE;
public:
RegExpGuard(JSContext *cx)
: re_(NULL), source_(cx)
{ }
RegExpGuard(JSContext *cx, RegExpShared &re)
: re_(&re), source_(cx, re.source)
{
re_->incRef();
}
~RegExpGuard() { release(); }
inline RegExpGuard(JSContext *cx);
inline RegExpGuard(JSContext *cx, RegExpShared &re);
inline ~RegExpGuard();
public:
void init(RegExpShared &re) {
JS_ASSERT(!initialized());
re_ = &re;
re_->incRef();
source_ = re_->source;
}
void release() {
if (re_) {
re_->decRef();
re_ = NULL;
source_ = NULL;
}
}
inline void init(RegExpShared &re);
inline void release();
bool initialized() const { return !!re_; }
RegExpShared *re() const { JS_ASSERT(initialized()); return re_; }
@ -264,22 +243,12 @@ class RegExpHeapGuard
public:
RegExpHeapGuard() : re_(NULL) { }
RegExpHeapGuard(RegExpShared &re) { init(re); }
~RegExpHeapGuard() { release(); }
inline RegExpHeapGuard(RegExpShared &re);
inline ~RegExpHeapGuard();
public:
void init(RegExpShared &re) {
JS_ASSERT(!initialized());
re_ = &re;
re_->incRef();
}
void release() {
if (re_) {
re_->writeBarrierPre();
re_->decRef();
re_ = NULL;
}
}
inline void init(RegExpShared &re);
inline void release();
void trace(JSTracer *trc) {
if (initialized())

View File

@ -10,10 +10,181 @@
#include "RegExpStatics.h"
#include "vm/RegExpObject-inl.h"
#include "vm/String-inl.h"
namespace js {
class RegExpStatics
{
/* The latest RegExp output, set after execution. */
VectorMatchPairs matches;
HeapPtr<JSLinearString> matchesInput;
/* The previous RegExp input, used to resolve lazy state. */
RegExpHeapGuard regexp;
size_t lastIndex;
/* The latest RegExp input, set before execution. */
HeapPtr<JSString> pendingInput;
RegExpFlag flags;
/*
* If true, |matchesInput|, |regexp|, and |lastIndex| may be used
* to replay the last executed RegExp, and |matches| is invalid.
*/
bool pendingLazyEvaluation;
/* Linkage for preserving RegExpStatics during nested RegExp execution. */
RegExpStatics *bufferLink;
bool copied;
public:
RegExpStatics() : bufferLink(NULL), copied(false) { clear(); }
static JSObject *create(JSContext *cx, GlobalObject *parent);
private:
bool executeLazy(JSContext *cx);
inline void aboutToWrite();
inline void copyTo(RegExpStatics &dst);
inline void restore();
bool save(JSContext *cx, RegExpStatics *buffer) {
JS_ASSERT(!buffer->copied && !buffer->bufferLink);
buffer->bufferLink = bufferLink;
bufferLink = buffer;
if (!buffer->matches.allocOrExpandArray(matches.length())) {
js_ReportOutOfMemory(cx);
return false;
}
return true;
}
inline void checkInvariants();
/*
* Check whether the index at |checkValidIndex| is valid (>= 0).
* If so, construct a string for it and place it in |*out|.
* If not, place undefined in |*out|.
*/
bool makeMatch(JSContext *cx, size_t checkValidIndex, size_t pairNum, Value *out);
bool createDependent(JSContext *cx, size_t start, size_t end, Value *out);
void markFlagsSet(JSContext *cx);
struct InitBuffer {};
explicit RegExpStatics(InitBuffer) : bufferLink(NULL), copied(false) {}
friend class PreserveRegExpStatics;
public:
/* Mutators. */
inline void updateLazily(JSContext *cx, JSLinearString *input,
RegExpShared *shared, size_t lastIndex);
inline bool updateFromMatchPairs(JSContext *cx, JSLinearString *input, MatchPairs &newPairs);
inline void setMultiline(JSContext *cx, bool enabled);
inline void clear();
/* Corresponds to JSAPI functionality to set the pending RegExp input. */
inline void reset(JSContext *cx, JSString *newInput, bool newMultiline);
inline void setPendingInput(JSString *newInput);
public:
/* Default match accessor. */
const MatchPairs &getMatches() const {
/* Safe: only used by String methods, which do not set lazy mode. */
JS_ASSERT(!pendingLazyEvaluation);
return matches;
}
JSString *getPendingInput() const { return pendingInput; }
RegExpFlag getFlags() const { return flags; }
bool multiline() const { return flags & MultilineFlag; }
/* Returns whether results for a non-empty match are present. */
bool matched() const {
/* Safe: only used by String methods, which do not set lazy mode. */
JS_ASSERT(!pendingLazyEvaluation);
JS_ASSERT(matches.pairCount() > 0);
return matches[0].limit - matches[0].start > 0;
}
void mark(JSTracer *trc) {
/*
* Changes to this function must also be reflected in
* RegExpStatics::AutoRooter::trace().
*/
if (pendingInput)
MarkString(trc, &pendingInput, "res->pendingInput");
if (matchesInput)
MarkString(trc, &matchesInput, "res->matchesInput");
if (regexp.initialized())
regexp->trace(trc);
}
/* Value creators. */
bool createPendingInput(JSContext *cx, Value *out);
bool createLastMatch(JSContext *cx, Value *out);
bool createLastParen(JSContext *cx, Value *out);
bool createParen(JSContext *cx, size_t pairNum, Value *out);
bool createLeftContext(JSContext *cx, Value *out);
bool createRightContext(JSContext *cx, Value *out);
/* Infallible substring creators. */
void getParen(size_t pairNum, JSSubString *out) const;
void getLastMatch(JSSubString *out) const;
void getLastParen(JSSubString *out) const;
void getLeftContext(JSSubString *out) const;
void getRightContext(JSSubString *out) const;
/* PreserveRegExpStatics helpers. */
class AutoRooter : private AutoGCRooter
{
public:
explicit AutoRooter(JSContext *cx, RegExpStatics *statics_
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: AutoGCRooter(cx, REGEXPSTATICS), statics(statics_), skip(cx, statics_)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
friend void AutoGCRooter::trace(JSTracer *trc);
void trace(JSTracer *trc);
private:
RegExpStatics *statics;
SkipRoot skip;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
};
class PreserveRegExpStatics
{
RegExpStatics * const original;
RegExpStatics buffer;
RegExpStatics::AutoRooter bufferRoot;
public:
explicit PreserveRegExpStatics(JSContext *cx, RegExpStatics *original)
: original(original),
buffer(RegExpStatics::InitBuffer()),
bufferRoot(cx, &buffer)
{}
bool init(JSContext *cx) {
return original->save(cx, &buffer);
}
inline ~PreserveRegExpStatics();
};
inline js::RegExpStatics *
js::GlobalObject::getRegExpStatics() const
{

View File

@ -21,175 +21,8 @@
namespace js {
class RegExpStatics
{
/* The latest RegExp output, set after execution. */
VectorMatchPairs matches;
HeapPtr<JSLinearString> matchesInput;
/* The previous RegExp input, used to resolve lazy state. */
RegExpHeapGuard regexp;
size_t lastIndex;
/* The latest RegExp input, set before execution. */
HeapPtr<JSString> pendingInput;
RegExpFlag flags;
/*
* If true, |matchesInput|, |regexp|, and |lastIndex| may be used
* to replay the last executed RegExp, and |matches| is invalid.
*/
bool pendingLazyEvaluation;
/* Linkage for preserving RegExpStatics during nested RegExp execution. */
RegExpStatics *bufferLink;
bool copied;
public:
RegExpStatics() : bufferLink(NULL), copied(false) { clear(); }
static JSObject *create(JSContext *cx, GlobalObject *parent);
private:
bool executeLazy(JSContext *cx);
inline void aboutToWrite();
inline void copyTo(RegExpStatics &dst);
inline void restore();
bool save(JSContext *cx, RegExpStatics *buffer) {
JS_ASSERT(!buffer->copied && !buffer->bufferLink);
buffer->bufferLink = bufferLink;
bufferLink = buffer;
if (!buffer->matches.allocOrExpandArray(matches.length())) {
js_ReportOutOfMemory(cx);
return false;
}
return true;
}
inline void checkInvariants();
/*
* Check whether the index at |checkValidIndex| is valid (>= 0).
* If so, construct a string for it and place it in |*out|.
* If not, place undefined in |*out|.
*/
bool makeMatch(JSContext *cx, size_t checkValidIndex, size_t pairNum, Value *out);
bool createDependent(JSContext *cx, size_t start, size_t end, Value *out);
void markFlagsSet(JSContext *cx);
struct InitBuffer {};
explicit RegExpStatics(InitBuffer) : bufferLink(NULL), copied(false) {}
friend class PreserveRegExpStatics;
public:
/* Mutators. */
inline void updateLazily(JSContext *cx, JSLinearString *input,
RegExpShared *shared, size_t lastIndex);
inline bool updateFromMatchPairs(JSContext *cx, JSLinearString *input, MatchPairs &newPairs);
inline void setMultiline(JSContext *cx, bool enabled);
inline void clear();
/* Corresponds to JSAPI functionality to set the pending RegExp input. */
inline void reset(JSContext *cx, JSString *newInput, bool newMultiline);
inline void setPendingInput(JSString *newInput);
public:
/* Default match accessor. */
const MatchPairs &getMatches() const {
/* Safe: only used by String methods, which do not set lazy mode. */
JS_ASSERT(!pendingLazyEvaluation);
return matches;
}
JSString *getPendingInput() const { return pendingInput; }
RegExpFlag getFlags() const { return flags; }
bool multiline() const { return flags & MultilineFlag; }
/* Returns whether results for a non-empty match are present. */
bool matched() const {
/* Safe: only used by String methods, which do not set lazy mode. */
JS_ASSERT(!pendingLazyEvaluation);
JS_ASSERT(matches.pairCount() > 0);
return matches[0].limit - matches[0].start > 0;
}
void mark(JSTracer *trc) {
/*
* Changes to this function must also be reflected in
* RegExpStatics::AutoRooter::trace().
*/
if (pendingInput)
MarkString(trc, &pendingInput, "res->pendingInput");
if (matchesInput)
MarkString(trc, &matchesInput, "res->matchesInput");
if (regexp.initialized())
regexp->trace(trc);
}
/* Value creators. */
bool createPendingInput(JSContext *cx, Value *out);
bool createLastMatch(JSContext *cx, Value *out);
bool createLastParen(JSContext *cx, Value *out);
bool createParen(JSContext *cx, size_t pairNum, Value *out);
bool createLeftContext(JSContext *cx, Value *out);
bool createRightContext(JSContext *cx, Value *out);
/* Infallible substring creators. */
void getParen(size_t pairNum, JSSubString *out) const;
void getLastMatch(JSSubString *out) const;
void getLastParen(JSSubString *out) const;
void getLeftContext(JSSubString *out) const;
void getRightContext(JSSubString *out) const;
/* PreserveRegExpStatics helpers. */
class AutoRooter : private AutoGCRooter
{
public:
explicit AutoRooter(JSContext *cx, RegExpStatics *statics_
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: AutoGCRooter(cx, REGEXPSTATICS), statics(statics_), skip(cx, statics_)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
friend void AutoGCRooter::trace(JSTracer *trc);
void trace(JSTracer *trc);
private:
RegExpStatics *statics;
SkipRoot skip;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
};
class PreserveRegExpStatics
{
RegExpStatics * const original;
RegExpStatics buffer;
RegExpStatics::AutoRooter bufferRoot;
public:
explicit PreserveRegExpStatics(JSContext *cx, RegExpStatics *original)
: original(original),
buffer(RegExpStatics::InitBuffer()),
bufferRoot(cx, &buffer)
{}
bool init(JSContext *cx) {
return original->save(cx, &buffer);
}
inline ~PreserveRegExpStatics();
};
class PreserveRegExpStatics;
class RegExpStatics;
size_t SizeOfRegExpStaticsData(const JSObject *obj, JSMallocSizeOfFun mallocSizeOf);