Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/gc/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 3 kB image not shown  

Quelle  Policy.h   Sprache: C

 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


/* JS Garbage Collector. */

#ifndef gc_Policy_h
#define gc_Policy_h

#include <type_traits>

#include "gc/Barrier.h"
#include "gc/Marking.h"
#include "gc/Tracer.h"
#include "js/GCPolicyAPI.h"

namespace js {

// Define the GCPolicy for all internal pointers.
template <typename T>
struct InternalGCPointerPolicy : public JS::GCPointerPolicy<T> {
  using Type = std::remove_pointer_t<T>;

#define IS_BASE_OF_OR(_1, BaseType, _2, _3) std::is_base_of_v<BaseType, Type> ||
  static_assert(
      JS_FOR_EACH_TRACEKIND(IS_BASE_OF_OR) false,
      "InternalGCPointerPolicy must only be used for GC thing pointers");
#undef IS_BASE_OF_OR

  static void trace(JSTracer* trc, T* vp, const char* name) {
    // It's not safe to trace unbarriered pointers except as part of root
    // marking. If you get an assertion here you probably need to add a barrier,
    // e.g. HeapPtr<T>.
    TraceRoot(trc, vp, name);
  }
};

}  // namespace js

namespace JS {

// Internally, all pointer types are treated as pointers to GC things by
// default.
template <typename T>
struct GCPolicy<T*> : public js::InternalGCPointerPolicy<T*> {};
template <typename T>
struct GCPolicy<T* const> : public js::InternalGCPointerPolicy<T* const> {};

template <typename T>
struct GCPolicy<js::HeapPtr<T>> : public GCPolicyBase<js::HeapPtr<T>> {
  static void trace(JSTracer* trc, js::HeapPtr<T>* thingp, const char* name) {
    js::TraceEdge(trc, thingp, name);
  }
  static bool traceWeak(JSTracer* trc, js::HeapPtr<T>* thingp) {
    return js::TraceWeakEdge(trc, thingp, "HeapPtr");
  }
};

template <typename T>
struct GCPolicy<js::PreBarriered<T>>
    : public GCPolicyBase<js::PreBarriered<T>> {
  static void trace(JSTracer* trc, js::PreBarriered<T>* thingp,
                    const char* name) {
    js::TraceEdge(trc, thingp, name);
  }
};

template <typename T>
struct GCPolicy<js::WeakHeapPtr<T>> : public GCPolicyBase<js::WeakHeapPtr<T>> {
  static void trace(JSTracer* trc, js::WeakHeapPtr<T>* thingp,
                    const char* name) {
    js::TraceEdge(trc, thingp, name);
  }
  static bool traceWeak(JSTracer* trc, js::WeakHeapPtr<T>* thingp) {
    return js::TraceWeakEdge(trc, thingp, "traceWeak");
  }
};

template <typename T>
struct GCPolicy<js::UnsafeBarePtr<T>>
    : public GCPolicyBase<js::UnsafeBarePtr<T>> {
  static bool traceWeak(JSTracer* trc, js::UnsafeBarePtr<T>* vp) {
    if (*vp) {
      return js::TraceManuallyBarrieredWeakEdge(trc, vp->unbarrieredAddress(),
                                                "UnsafeBarePtr");
    }
    return true;
  }
};

template <>
struct GCPolicy<JS::GCCellPtr> : public GCPolicyBase<JS::GCCellPtr> {
  static void trace(JSTracer* trc, JS::GCCellPtr* thingp, const char* name) {
    // It's not safe to trace unbarriered pointers except as part of root
    // marking.
    js::TraceGCCellPtrRoot(trc, thingp, name);
  }
};

}  // namespace JS

#endif  // gc_Policy_h

Messung V0.5 in Prozent
C=88 H=100 G=94

¤ Dauer der Verarbeitung: 0.8 Sekunden  (vorverarbeitet am  2026-09-29) ¤

*© Formatika GbR, Deutschland






Wurzel

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.