author Steve Fink <sfink@mozilla.com>
Tue, 16 Oct 2018 14:35:48 -0700
changeset 500024 f2e06bf4ba8e7a8fbcab9e83d1eabb03c94d3cb0
parent 500023 06ffaf98e1e97cf3ad13d9e752f05f4f4e44c129
child 502616 22dd687dfbd20c801af28af8fc40e89dc09c4bc9
permissions -rw-r--r--
Backed out changeset c7b32ffa822e (bug 1321014) on a CLOSED TREE

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * vim: set ts=8 sts=4 et sw=4 tw=99:
 * 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/. */

#ifndef js_GCAnnotations_h
#define js_GCAnnotations_h

// Set of annotations for the rooting hazard analysis, used to categorize types
// and functions.

// Mark a type as being a GC thing (eg js::gc::Cell has this annotation).
# define JS_HAZ_GC_THING __attribute__((annotate("GC Thing")))

// Mark a type as holding a pointer to a GC thing (eg JS::Value has this
// annotation.)
# define JS_HAZ_GC_POINTER __attribute__((annotate("GC Pointer")))

// Mark a type as a rooted pointer, suitable for use on the stack (eg all
// Rooted<T> instantiations should have this.)
# define JS_HAZ_ROOTED __attribute__((annotate("Rooted Pointer")))

// Mark a type as something that should not be held live across a GC, but which
// is not itself a GC pointer.
# define JS_HAZ_GC_INVALIDATED __attribute__((annotate("Invalidated by GC")))

// Mark a class as a base class of rooted types, eg CustomAutoRooter. All
// descendants of this class will be considered rooted, though classes that
// merely contain these as a field member will not be. "Inherited" by
# define JS_HAZ_ROOTED_BASE __attribute__((annotate("Rooted Base")))

// Mark a type that would otherwise be considered a GC Pointer (eg because it
// contains a JS::Value field) as a non-GC pointer. It is handled almost the
// same in the analysis as a rooted pointer, except it will not be reported as
// an unnecessary root if used across a GC call. This should rarely be used,
// but makes sense for something like ErrorResult, which only contains a GC
// pointer when it holds an exception (and it does its own rooting,
// conditionally.)
# define JS_HAZ_NON_GC_POINTER __attribute__((annotate("Suppressed GC Pointer")))

// Mark a function as something that runs a garbage collection, potentially
// invalidating GC pointers.
# define JS_HAZ_GC_CALL __attribute__((annotate("GC Call")))

// Mark an RAII class as suppressing GC within its scope.
# define JS_HAZ_GC_SUPPRESSED __attribute__((annotate("Suppress GC")))

// Mark a function as one that can run script if called.  This obviously
// subsumes JS_HAZ_GC_CALL, since anything that can run script can GC.`
# define JS_HAZ_CAN_RUN_SCRIPT __attribute__((annotate("Can run script")))


# define JS_HAZ_GC_THING
# define JS_HAZ_ROOTED
# define JS_HAZ_GC_CALL


#endif /* js_GCAnnotations_h */