Bug 903193 - Part 2: Refactor isThreadLocal to ThreadSafeContext. (r=bhackett)

This commit is contained in:
Shu-yu Guo 2013-10-08 15:14:03 -07:00
parent 1a7724306d
commit 304fdd6a5e
4 changed files with 27 additions and 4 deletions

View File

@ -43,8 +43,7 @@ bool
jit::IsThreadLocalObject(ForkJoinSlice *slice, JSObject *object)
{
JS_ASSERT(ForkJoinSlice::Current() == slice);
return !IsInsideNursery(slice->runtime(), object) &&
slice->allocator()->arenas.containsArena(slice->runtime(), object->arenaHeader());
return slice->isThreadLocal(object);
}
#ifdef DEBUG

View File

@ -15,9 +15,9 @@ namespace jit {
ForkJoinSlice *ForkJoinSlicePar();
JSObject *NewGCThingPar(ForkJoinSlice *slice, gc::AllocKind allocKind);
bool IsThreadLocalObject(ForkJoinSlice *context, JSObject *object);
bool IsThreadLocalObject(ForkJoinSlice *slice, JSObject *object);
bool CheckOverRecursedPar(ForkJoinSlice *slice);
bool CheckInterruptPar(ForkJoinSlice *context);
bool CheckInterruptPar(ForkJoinSlice *slice);
// We pass the arguments to PushPar in a structure because, in code
// gen, it is convenient to store them on the stack to avoid

View File

@ -248,6 +248,9 @@ struct ThreadSafeContext : ContextFriendFields,
return thing->compartment() == compartment_;
}
template <typename T>
inline bool isThreadLocal(T thing) const;
void *onOutOfMemory(void *p, size_t nbytes) {
return runtime_->onOutOfMemory(p, nbytes, maybeJSContext());
}

View File

@ -49,6 +49,27 @@ ThreadSafeContext::allocator()
return allocator_;
}
template <typename T>
inline bool
ThreadSafeContext::isThreadLocal(T thing) const
{
if (!isForkJoinSlice())
return true;
if (!IsInsideNursery(runtime_, thing) &&
allocator_->arenas.containsArena(runtime_, thing->arenaHeader()))
{
// GC should be suppressed in preparation for mutating thread local
// objects, as we don't want to trip any barriers.
JS_ASSERT(!thing->zoneFromAnyThread()->needsBarrier());
JS_ASSERT(!thing->runtimeFromAnyThread()->needsBarrier());
return true;
}
return false;
}
namespace gc {
static inline AllocKind