michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "gc/Barrier.h" michael@0: michael@0: #include "jscompartment.h" michael@0: #include "jsobj.h" michael@0: michael@0: #include "gc/Zone.h" michael@0: michael@0: namespace js { michael@0: michael@0: #ifdef DEBUG michael@0: michael@0: bool michael@0: HeapValue::preconditionForSet(Zone *zone) michael@0: { michael@0: if (!value.isMarkable()) michael@0: return true; michael@0: michael@0: return ZoneOfValue(value) == zone || michael@0: zone->runtimeFromAnyThread()->isAtomsZone(ZoneOfValue(value)); michael@0: } michael@0: michael@0: bool michael@0: HeapSlot::preconditionForSet(JSObject *owner, Kind kind, uint32_t slot) michael@0: { michael@0: return kind == Slot michael@0: ? &owner->getSlotRef(slot) == this michael@0: : &owner->getDenseElement(slot) == (const Value *)this; michael@0: } michael@0: michael@0: bool michael@0: HeapSlot::preconditionForSet(Zone *zone, JSObject *owner, Kind kind, uint32_t slot) michael@0: { michael@0: bool ok = kind == Slot michael@0: ? &owner->getSlotRef(slot) == this michael@0: : &owner->getDenseElement(slot) == (const Value *)this; michael@0: return ok && owner->zone() == zone; michael@0: } michael@0: michael@0: void michael@0: HeapSlot::preconditionForWriteBarrierPost(JSObject *obj, Kind kind, uint32_t slot, Value target) michael@0: { michael@0: JS_ASSERT_IF(kind == Slot, obj->getSlotAddressUnchecked(slot)->get() == target); michael@0: JS_ASSERT_IF(kind == Element, michael@0: static_cast(obj->getDenseElements() + slot)->get() == target); michael@0: } michael@0: michael@0: bool michael@0: RuntimeFromMainThreadIsHeapMajorCollecting(JS::shadow::Zone *shadowZone) michael@0: { michael@0: return shadowZone->runtimeFromMainThread()->isHeapMajorCollecting(); michael@0: } michael@0: #endif // DEBUG michael@0: michael@0: bool michael@0: StringIsPermanentAtom(JSString *str) michael@0: { michael@0: return str->isPermanentAtom(); michael@0: } michael@0: michael@0: } // namespace js