js/src/gc/Barrier.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     7 #include "gc/Barrier.h"
     9 #include "jscompartment.h"
    10 #include "jsobj.h"
    12 #include "gc/Zone.h"
    14 namespace js {
    16 #ifdef DEBUG
    18 bool
    19 HeapValue::preconditionForSet(Zone *zone)
    20 {
    21     if (!value.isMarkable())
    22         return true;
    24     return ZoneOfValue(value) == zone ||
    25            zone->runtimeFromAnyThread()->isAtomsZone(ZoneOfValue(value));
    26 }
    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 }
    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 }
    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 }
    53 bool
    54 RuntimeFromMainThreadIsHeapMajorCollecting(JS::shadow::Zone *shadowZone)
    55 {
    56     return shadowZone->runtimeFromMainThread()->isHeapMajorCollecting();
    57 }
    58 #endif // DEBUG
    60 bool
    61 StringIsPermanentAtom(JSString *str)
    62 {
    63     return str->isPermanentAtom();
    64 }
    66 } // namespace js

mercurial