js/src/gc/Barrier.cpp
author Wes Kocher <wkocher@mozilla.com>
Tue, 10 Sep 2013 23:00:06 -0700
changeset 146872 ecfd306e73fc0f22783cdf8d3f0411984c93b292
parent 146861 45975a8112078e3a80c57de34f3bcfebdd2ef031
child 146880 6f22b81ed9b44458fc19951b3a448fd802395cb6
permissions -rw-r--r--
Backed out changeset 45975a811207 (bug 914508) for Android 2.2 NoIon build bustage

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * vim: set ts=8 sts=4 et sw=4 tw=99:
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "gc/Barrier.h"

#include "jsobj.h"

#include "vm/ObjectImpl-inl.h"

namespace js {

#ifdef DEBUG

bool
HeapValue::preconditionForSet(Zone *zone)
{
    if (!value.isMarkable())
        return true;

    return ZoneOfValue(value) == zone ||
           zone->runtimeFromAnyThread()->isAtomsZone(ZoneOfValue(value));
}

bool
HeapSlot::preconditionForSet(JSObject *owner, Kind kind, uint32_t slot)
{
    return kind == Slot
         ? &owner->getSlotRef(slot) == this
         : &owner->getDenseElement(slot) == (const Value *)this;
}

bool
HeapSlot::preconditionForSet(Zone *zone, JSObject *owner, Kind kind, uint32_t slot)
{
    bool ok = kind == Slot
            ? &owner->getSlotRef(slot) == this
            : &owner->getDenseElement(slot) == (const Value *)this;
    return ok && owner->zone() == zone;
}

void
HeapSlot::preconditionForWriteBarrierPost(JSObject *obj, Kind kind, uint32_t slot, Value target)
{
    JS_ASSERT_IF(kind == Slot, obj->getSlotAddressUnchecked(slot)->get() == target);
    JS_ASSERT_IF(kind == Element,
                 static_cast<HeapSlot *>(obj->getDenseElements() + slot)->get() == target);
}

bool
RuntimeFromMainThreadIsHeapMajorCollecting(JS::shadow::Zone *shadowZone)
{
    return shadowZone->runtimeFromMainThread()->isHeapMajorCollecting();
}
#endif // DEBUG

} // namespace js