1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/gc/Barrier.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "gc/Barrier.h" 1.11 + 1.12 +#include "jscompartment.h" 1.13 +#include "jsobj.h" 1.14 + 1.15 +#include "gc/Zone.h" 1.16 + 1.17 +namespace js { 1.18 + 1.19 +#ifdef DEBUG 1.20 + 1.21 +bool 1.22 +HeapValue::preconditionForSet(Zone *zone) 1.23 +{ 1.24 + if (!value.isMarkable()) 1.25 + return true; 1.26 + 1.27 + return ZoneOfValue(value) == zone || 1.28 + zone->runtimeFromAnyThread()->isAtomsZone(ZoneOfValue(value)); 1.29 +} 1.30 + 1.31 +bool 1.32 +HeapSlot::preconditionForSet(JSObject *owner, Kind kind, uint32_t slot) 1.33 +{ 1.34 + return kind == Slot 1.35 + ? &owner->getSlotRef(slot) == this 1.36 + : &owner->getDenseElement(slot) == (const Value *)this; 1.37 +} 1.38 + 1.39 +bool 1.40 +HeapSlot::preconditionForSet(Zone *zone, JSObject *owner, Kind kind, uint32_t slot) 1.41 +{ 1.42 + bool ok = kind == Slot 1.43 + ? &owner->getSlotRef(slot) == this 1.44 + : &owner->getDenseElement(slot) == (const Value *)this; 1.45 + return ok && owner->zone() == zone; 1.46 +} 1.47 + 1.48 +void 1.49 +HeapSlot::preconditionForWriteBarrierPost(JSObject *obj, Kind kind, uint32_t slot, Value target) 1.50 +{ 1.51 + JS_ASSERT_IF(kind == Slot, obj->getSlotAddressUnchecked(slot)->get() == target); 1.52 + JS_ASSERT_IF(kind == Element, 1.53 + static_cast<HeapSlot *>(obj->getDenseElements() + slot)->get() == target); 1.54 +} 1.55 + 1.56 +bool 1.57 +RuntimeFromMainThreadIsHeapMajorCollecting(JS::shadow::Zone *shadowZone) 1.58 +{ 1.59 + return shadowZone->runtimeFromMainThread()->isHeapMajorCollecting(); 1.60 +} 1.61 +#endif // DEBUG 1.62 + 1.63 +bool 1.64 +StringIsPermanentAtom(JSString *str) 1.65 +{ 1.66 + return str->isPermanentAtom(); 1.67 +} 1.68 + 1.69 +} // namespace js