Bug 752578 - Use mfbt's guard object implementation rather than using our own in the trickier cases. r=Ms2ger

--HG--
extra : rebase_source : 7dd7e730a134114e187fda1b6b0820b37e544f9f
This commit is contained in:
Jeff Walden 2012-12-27 11:20:22 -06:00
Родитель 99654cf0f4
Коммит 261ccda306
7 изменённых файлов: 51 добавлений и 41 удалений

Просмотреть файл

@ -5545,19 +5545,21 @@ JS_GetStringEncodingLength(JSContext *cx, JSString *str);
JS_PUBLIC_API(size_t)
JS_EncodeStringToBuffer(JSString *str, char *buffer, size_t length);
class JSAutoByteString {
class JSAutoByteString
{
public:
JSAutoByteString(JSContext *cx, JSString *str
JS_GUARD_OBJECT_NOTIFIER_PARAM)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mBytes(JS_EncodeString(cx, str))
{
JS_ASSERT(cx);
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
JSAutoByteString(JS_GUARD_OBJECT_NOTIFIER_PARAM0)
: mBytes(NULL) {
JS_GUARD_OBJECT_NOTIFIER_INIT;
JSAutoByteString(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)
: mBytes(NULL)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
~JSAutoByteString() {
@ -5592,7 +5594,7 @@ class JSAutoByteString {
private:
char *mBytes;
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
/* Copy and assignment are not supported. */
JSAutoByteString(const JSAutoByteString &another);

Просмотреть файл

@ -304,18 +304,18 @@ JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *objArg, const JSFunctionSpec
}
AutoSwitchCompartment::AutoSwitchCompartment(JSContext *cx, JSCompartment *newCompartment
JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx(cx), oldCompartment(cx->compartment)
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
cx->setCompartment(newCompartment);
}
AutoSwitchCompartment::AutoSwitchCompartment(JSContext *cx, JSHandleObject target
JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx(cx), oldCompartment(cx->compartment)
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
cx->setCompartment(target->compartment());
}

Просмотреть файл

@ -7,13 +7,13 @@
#ifndef jsfriendapi_h___
#define jsfriendapi_h___
#include "mozilla/GuardObjects.h"
#include "jsclass.h"
#include "jscpucfg.h"
#include "jspubtd.h"
#include "jsprvtd.h"
#include "mozilla/GuardObjects.h"
/*
* This macro checks if the stack pointer has exceeded a given limit. If
* |tolerance| is non-zero, it returns true only if the stack pointer has
@ -220,10 +220,11 @@ class JS_FRIEND_API(AutoSwitchCompartment) {
JSCompartment *oldCompartment;
public:
AutoSwitchCompartment(JSContext *cx, JSCompartment *newCompartment
JS_GUARD_OBJECT_NOTIFIER_PARAM);
AutoSwitchCompartment(JSContext *cx, JSHandleObject target JS_GUARD_OBJECT_NOTIFIER_PARAM);
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
AutoSwitchCompartment(JSContext *cx, JSHandleObject target
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
~AutoSwitchCompartment();
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
#ifdef OLD_GETTER_SETTER_METHODS

Просмотреть файл

@ -394,10 +394,11 @@ SPSProfiler::unregisterScript(UnrootedScript script, mjit::JITChunk *chunk)
}
#endif
SPSEntryMarker::SPSEntryMarker(JSRuntime *rt JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
SPSEntryMarker::SPSEntryMarker(JSRuntime *rt
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: profiler(&rt->spsProfiler)
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (!profiler->enabled()) {
profiler = NULL;
return;

Просмотреть файл

@ -11,6 +11,7 @@
#include <stddef.h>
#include "mozilla/DebugOnly.h"
#include "mozilla/GuardObjects.h"
#include "mozilla/HashFunctions.h"
#include "js/Utility.h"
@ -262,12 +263,15 @@ class SPSProfiler
*/
class SPSEntryMarker
{
public:
SPSEntryMarker(JSRuntime *rt
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
~SPSEntryMarker();
private:
SPSProfiler *profiler;
mozilla::DebugOnly<uint32_t> size_before;
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
SPSEntryMarker(JSRuntime *rt JS_GUARD_OBJECT_NOTIFIER_PARAM);
~SPSEntryMarker();
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
/*

Просмотреть файл

@ -880,60 +880,60 @@ js::CloneStaticBlockObject(JSContext *cx, HandleObject enclosingScope, Handle<St
/*****************************************************************************/
ScopeIter::ScopeIter(JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: fp_(NULL),
cur_(cx, reinterpret_cast<JSObject *>(-1)),
block_(cx, reinterpret_cast<StaticBlockObject *>(-1)),
type_(Type(-1))
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
ScopeIter::ScopeIter(const ScopeIter &si, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: fp_(si.fp_),
cur_(cx, si.cur_),
block_(cx, si.block_),
type_(si.type_),
hasScopeObject_(si.hasScopeObject_)
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
ScopeIter::ScopeIter(JSObject &enclosingScope, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: fp_(NULL),
cur_(cx, &enclosingScope),
block_(cx, reinterpret_cast<StaticBlockObject *>(-1)),
type_(Type(-1))
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
ScopeIter::ScopeIter(StackFrame *fp, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: fp_(fp),
cur_(cx, fp->scopeChain()),
block_(cx, fp->maybeBlockChain())
{
assertSameCompartment(cx, fp);
settle();
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
ScopeIter::ScopeIter(const ScopeIter &si, StackFrame *fp, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: fp_(fp),
cur_(cx, si.cur_),
block_(cx, si.block_),
type_(si.type_),
hasScopeObject_(si.hasScopeObject_)
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
ScopeIter::ScopeIter(StackFrame *fp, ScopeObject &scope, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT)
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: fp_(fp),
cur_(cx, &scope),
block_(cx)
@ -965,7 +965,7 @@ ScopeIter::ScopeIter(StackFrame *fp, ScopeObject &scope, JSContext *cx
block_ = NULL;
}
settle();
JS_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
ScopeObject &

Просмотреть файл

@ -8,6 +8,8 @@
#ifndef ScopeObject_h___
#define ScopeObject_h___
#include "mozilla/GuardObjects.h"
#include "jscntxt.h"
#include "jsobj.h"
#include "jsweakmap.h"
@ -414,33 +416,33 @@ class ScopeIter
public:
/* The default constructor leaves ScopeIter totally invalid */
explicit ScopeIter(JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM);
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
/* Constructing from a copy of an existing ScopeIter. */
explicit ScopeIter(const ScopeIter &si, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM);
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
/* Constructing from StackFrame places ScopeIter on the innermost scope. */
explicit ScopeIter(StackFrame *fp, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM);
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
/*
* Without a StackFrame, the resulting ScopeIter is done() with
* enclosingScope() as given.
*/
explicit ScopeIter(JSObject &enclosingScope, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM);
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
/*
* For the special case of generators, copy the given ScopeIter, with 'fp'
* as the StackFrame instead of si.fp(). Not for general use.
*/
ScopeIter(const ScopeIter &si, StackFrame *fp, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM);
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
/* Like ScopeIter(StackFrame *) except start at 'scope'. */
ScopeIter(StackFrame *fp, ScopeObject &scope, JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM);
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
bool done() const { return !fp_; }
@ -459,7 +461,7 @@ class ScopeIter
StaticBlockObject &staticBlock() const { JS_ASSERT(type() == Block); return *block_; }
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class ScopeIterKey