2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2018-11-30 18:39:55 +03:00
|
|
|
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
2015-09-29 23:39:33 +03:00
|
|
|
* 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.
|
|
|
|
#ifdef XGILL_PLUGIN
|
|
|
|
|
2018-12-29 08:13:32 +03:00
|
|
|
# define JS_EXPECT_HAZARDS __attribute__((annotate("Expect Hazards")))
|
|
|
|
|
2015-09-29 23:39:33 +03:00
|
|
|
// Mark a type as being a GC thing (eg js::gc::Cell has this annotation).
|
2018-07-20 07:16:48 +03:00
|
|
|
# define JS_HAZ_GC_THING __attribute__((annotate("GC Thing")))
|
2015-09-29 23:39:33 +03:00
|
|
|
|
|
|
|
// Mark a type as holding a pointer to a GC thing (eg JS::Value has this
|
2018-07-21 04:36:20 +03:00
|
|
|
// annotation.) "Inherited" by templatized types with
|
|
|
|
// MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS.
|
2018-07-20 07:16:48 +03:00
|
|
|
# define JS_HAZ_GC_POINTER __attribute__((annotate("GC Pointer")))
|
2015-09-29 23:39:33 +03:00
|
|
|
|
|
|
|
// Mark a type as a rooted pointer, suitable for use on the stack (eg all
|
2018-07-21 04:36:20 +03:00
|
|
|
// Rooted<T> instantiations should have this.) "Inherited" by templatized types
|
|
|
|
// with MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS.
|
2018-07-20 07:16:48 +03:00
|
|
|
# define JS_HAZ_ROOTED __attribute__((annotate("Rooted Pointer")))
|
2015-09-29 23:39:33 +03:00
|
|
|
|
|
|
|
// Mark a type as something that should not be held live across a GC, but which
|
2018-07-21 04:36:20 +03:00
|
|
|
// is not itself a GC pointer. Note that this property is *not* inherited by
|
|
|
|
// templatized types with MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS.
|
2018-07-20 07:16:48 +03:00
|
|
|
# define JS_HAZ_GC_INVALIDATED __attribute__((annotate("Invalidated by GC")))
|
2015-09-29 23:39:33 +03:00
|
|
|
|
2018-07-25 02:52:43 +03:00
|
|
|
// 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
|
|
|
|
// templatized types with MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS
|
2018-07-20 07:16:48 +03:00
|
|
|
# define JS_HAZ_ROOTED_BASE __attribute__((annotate("Rooted Base")))
|
2018-07-25 02:52:43 +03:00
|
|
|
|
2015-09-29 23:39:33 +03:00
|
|
|
// 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.)
|
2018-07-20 07:16:48 +03:00
|
|
|
# define JS_HAZ_NON_GC_POINTER \
|
|
|
|
__attribute__((annotate("Suppressed GC Pointer")))
|
2015-09-29 23:39:33 +03:00
|
|
|
|
|
|
|
// Mark a function as something that runs a garbage collection, potentially
|
|
|
|
// invalidating GC pointers.
|
2018-07-20 07:16:48 +03:00
|
|
|
# define JS_HAZ_GC_CALL __attribute__((annotate("GC Call")))
|
2015-09-29 23:39:33 +03:00
|
|
|
|
2016-05-25 04:26:21 +03:00
|
|
|
// Mark an RAII class as suppressing GC within its scope.
|
2018-07-20 07:16:48 +03:00
|
|
|
# define JS_HAZ_GC_SUPPRESSED __attribute__((annotate("Suppress GC")))
|
2016-05-19 22:53:29 +03:00
|
|
|
|
2018-07-30 18:51:44 +03:00
|
|
|
// 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.`
|
2018-07-20 07:16:48 +03:00
|
|
|
# define JS_HAZ_CAN_RUN_SCRIPT __attribute__((annotate("Can run script")))
|
2018-07-30 18:51:44 +03:00
|
|
|
|
2018-07-24 21:53:42 +03:00
|
|
|
// Mark a function as able to call JSNatives. Otherwise, JSNatives don't show
|
|
|
|
// up in the callgraph. This doesn't matter for the can-GC analysis, but it is
|
|
|
|
// very nice for other uses of the callgraph.
|
|
|
|
# define JS_HAZ_JSNATIVE_CALLER __attribute__((annotate("Calls JSNatives")))
|
|
|
|
|
2015-09-29 23:39:33 +03:00
|
|
|
#else
|
|
|
|
|
2018-12-29 08:13:32 +03:00
|
|
|
# define JS_EXPECT_HAZARDS
|
2015-09-29 23:39:33 +03:00
|
|
|
# define JS_HAZ_GC_THING
|
|
|
|
# define JS_HAZ_GC_POINTER
|
|
|
|
# define JS_HAZ_ROOTED
|
|
|
|
# define JS_HAZ_GC_INVALIDATED
|
2018-07-25 02:52:43 +03:00
|
|
|
# define JS_HAZ_ROOTED_BASE
|
2015-09-29 23:39:33 +03:00
|
|
|
# define JS_HAZ_NON_GC_POINTER
|
|
|
|
# define JS_HAZ_GC_CALL
|
2016-05-19 22:53:29 +03:00
|
|
|
# define JS_HAZ_GC_SUPPRESSED
|
2018-07-30 18:51:44 +03:00
|
|
|
# define JS_HAZ_CAN_RUN_SCRIPT
|
2018-07-24 21:53:42 +03:00
|
|
|
# define JS_HAZ_JSNATIVE_CALLER
|
2015-09-29 23:39:33 +03:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* js_GCAnnotations_h */
|