Bug 791608 (part 3) - Fix compile warnings about JSContext::{enter,leave}Compartment(). r=jwalden.

--HG--
extra : rebase_source : 8b184f95cdcff660b9837490e62dbb5c15f267b2
This commit is contained in:
Nicholas Nethercote 2012-09-17 17:16:23 -07:00
Родитель 0c5055a283
Коммит 427c4d2b3d
2 изменённых файлов: 31 добавлений и 41 удалений

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

@ -1250,9 +1250,37 @@ struct JSContext : js::ContextFriendFields
private:
unsigned enterCompartmentDepth_;
public:
inline bool hasEnteredCompartment() const;
inline void enterCompartment(JSCompartment *c);
inline void leaveCompartment(JSCompartment *c);
bool hasEnteredCompartment() const {
return enterCompartmentDepth_ > 0;
}
void enterCompartment(JSCompartment *c) {
enterCompartmentDepth_++;
compartment = c;
if (throwing)
wrapPendingException();
}
inline void leaveCompartment(JSCompartment *oldCompartment) {
JS_ASSERT(hasEnteredCompartment());
enterCompartmentDepth_--;
/*
* Before we entered the current compartment, 'compartment' was
* 'oldCompartment', so we might want to simply set it back. However, we
* currently have this terrible scheme whereby defaultCompartmentObject_
* can be updated while enterCompartmentDepth_ > 0. In this case,
* oldCompartment != defaultCompartmentObject_->compartment and we must
* ignore oldCompartment.
*/
if (hasEnteredCompartment() || !defaultCompartmentObject_)
compartment = oldCompartment;
else
compartment = defaultCompartmentObject_->compartment();
if (throwing)
wrapPendingException();
}
/* See JS_SaveFrameChain/JS_RestoreFrameChain. */
private:

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

@ -567,44 +567,6 @@ JSContext::propertyTree()
return compartment->propertyTree;
}
inline bool
JSContext::hasEnteredCompartment() const
{
return enterCompartmentDepth_ > 0;
}
inline void
JSContext::enterCompartment(JSCompartment *c)
{
enterCompartmentDepth_++;
compartment = c;
if (throwing)
wrapPendingException();
}
inline void
JSContext::leaveCompartment(JSCompartment *oldCompartment)
{
JS_ASSERT(hasEnteredCompartment());
enterCompartmentDepth_--;
/*
* Before we entered the current compartment, 'compartment' was
* 'oldCompartment', so we might want to simply set it back. However, we
* currently have this terrible scheme whereby defaultCompartmentObject_
* can be updated while enterCompartmentDepth_ > 0. In this case,
* oldCompartment != defaultCompartmentObject_->compartment and we must
* ignore oldCompartment.
*/
if (hasEnteredCompartment() || !defaultCompartmentObject_)
compartment = oldCompartment;
else
compartment = defaultCompartmentObject_->compartment();
if (throwing)
wrapPendingException();
}
inline void
JSContext::setDefaultCompartmentObject(JSObject *obj)
{