Backed out changeset 4191b252db9b (bug 1886734) for causing build bustages @netwerk...
[gecko.git] / js / src / gc / RelocationOverlay.h
blob047e763d448acc98bb2126c4b0f045fb9a8449b9
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
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 /*
8 * GC-internal definition of relocation overlay used while moving cells.
9 */
11 #ifndef gc_RelocationOverlay_h
12 #define gc_RelocationOverlay_h
14 #include "mozilla/Assertions.h"
16 #include <stdint.h>
18 #include "gc/Cell.h"
20 namespace js {
21 namespace gc {
24 * This structure overlays a Cell that has been moved and provides a way to find
25 * its new location. It's used during generational and compacting GC.
27 class RelocationOverlay : public Cell {
28 public:
29 /* The location the cell has been moved to, stored in the cell header. */
30 Cell* forwardingAddress() const {
31 MOZ_ASSERT(isForwarded());
32 return reinterpret_cast<Cell*>(header_.getForwardingAddress());
35 protected:
36 /* A list entry to track all relocated things. */
37 RelocationOverlay* next_;
39 explicit RelocationOverlay(Cell* dst);
41 public:
42 static const RelocationOverlay* fromCell(const Cell* cell) {
43 return static_cast<const RelocationOverlay*>(cell);
46 static RelocationOverlay* fromCell(Cell* cell) {
47 return static_cast<RelocationOverlay*>(cell);
50 static RelocationOverlay* forwardCell(Cell* src, Cell* dst);
52 void setNext(RelocationOverlay* next) {
53 MOZ_ASSERT(isForwarded());
54 next_ = next;
57 RelocationOverlay* next() const {
58 MOZ_ASSERT(isForwarded());
59 return next_;
63 } // namespace gc
64 } // namespace js
66 #endif /* gc_RelocationOverlay_h */