|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #include "gc/Barrier.h" |
|
8 |
|
9 #include "jscompartment.h" |
|
10 #include "jsobj.h" |
|
11 |
|
12 #include "gc/Zone.h" |
|
13 |
|
14 namespace js { |
|
15 |
|
16 #ifdef DEBUG |
|
17 |
|
18 bool |
|
19 HeapValue::preconditionForSet(Zone *zone) |
|
20 { |
|
21 if (!value.isMarkable()) |
|
22 return true; |
|
23 |
|
24 return ZoneOfValue(value) == zone || |
|
25 zone->runtimeFromAnyThread()->isAtomsZone(ZoneOfValue(value)); |
|
26 } |
|
27 |
|
28 bool |
|
29 HeapSlot::preconditionForSet(JSObject *owner, Kind kind, uint32_t slot) |
|
30 { |
|
31 return kind == Slot |
|
32 ? &owner->getSlotRef(slot) == this |
|
33 : &owner->getDenseElement(slot) == (const Value *)this; |
|
34 } |
|
35 |
|
36 bool |
|
37 HeapSlot::preconditionForSet(Zone *zone, JSObject *owner, Kind kind, uint32_t slot) |
|
38 { |
|
39 bool ok = kind == Slot |
|
40 ? &owner->getSlotRef(slot) == this |
|
41 : &owner->getDenseElement(slot) == (const Value *)this; |
|
42 return ok && owner->zone() == zone; |
|
43 } |
|
44 |
|
45 void |
|
46 HeapSlot::preconditionForWriteBarrierPost(JSObject *obj, Kind kind, uint32_t slot, Value target) |
|
47 { |
|
48 JS_ASSERT_IF(kind == Slot, obj->getSlotAddressUnchecked(slot)->get() == target); |
|
49 JS_ASSERT_IF(kind == Element, |
|
50 static_cast<HeapSlot *>(obj->getDenseElements() + slot)->get() == target); |
|
51 } |
|
52 |
|
53 bool |
|
54 RuntimeFromMainThreadIsHeapMajorCollecting(JS::shadow::Zone *shadowZone) |
|
55 { |
|
56 return shadowZone->runtimeFromMainThread()->isHeapMajorCollecting(); |
|
57 } |
|
58 #endif // DEBUG |
|
59 |
|
60 bool |
|
61 StringIsPermanentAtom(JSString *str) |
|
62 { |
|
63 return str->isPermanentAtom(); |
|
64 } |
|
65 |
|
66 } // namespace js |