GCAnnotations.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/. */
  6. #ifndef js_GCAnnotations_h
  7. #define js_GCAnnotations_h
  8. // Set of annotations for the rooting hazard analysis, used to categorize types
  9. // and functions.
  10. #ifdef XGILL_PLUGIN
  11. // Mark a type as being a GC thing (eg js::gc::Cell has this annotation).
  12. # define JS_HAZ_GC_THING __attribute__((tag("GC Thing")))
  13. // Mark a type as holding a pointer to a GC thing (eg JS::Value has this
  14. // annotation.)
  15. # define JS_HAZ_GC_POINTER __attribute__((tag("GC Pointer")))
  16. // Mark a type as a rooted pointer, suitable for use on the stack (eg all
  17. // Rooted<T> instantiations should have this.)
  18. # define JS_HAZ_ROOTED __attribute__((tag("Rooted Pointer")))
  19. // Mark a type as something that should not be held live across a GC, but which
  20. // is not itself a GC pointer.
  21. # define JS_HAZ_GC_INVALIDATED __attribute__((tag("Invalidated by GC")))
  22. // Mark a type that would otherwise be considered a GC Pointer (eg because it
  23. // contains a JS::Value field) as a non-GC pointer. It is handled almost the
  24. // same in the analysis as a rooted pointer, except it will not be reported as
  25. // an unnecessary root if used across a GC call. This should rarely be used,
  26. // but makes sense for something like ErrorResult, which only contains a GC
  27. // pointer when it holds an exception (and it does its own rooting,
  28. // conditionally.)
  29. # define JS_HAZ_NON_GC_POINTER __attribute__((tag("Suppressed GC Pointer")))
  30. // Mark a function as something that runs a garbage collection, potentially
  31. // invalidating GC pointers.
  32. # define JS_HAZ_GC_CALL __attribute__((tag("GC Call")))
  33. // Mark an RAII class as suppressing GC within its scope.
  34. # define JS_HAZ_GC_SUPPRESSED __attribute__((tag("Suppress GC")))
  35. #else
  36. # define JS_HAZ_GC_THING
  37. # define JS_HAZ_GC_POINTER
  38. # define JS_HAZ_ROOTED
  39. # define JS_HAZ_GC_INVALIDATED
  40. # define JS_HAZ_NON_GC_POINTER
  41. # define JS_HAZ_GC_CALL
  42. # define JS_HAZ_GC_SUPPRESSED
  43. #endif
  44. #endif /* js_GCAnnotations_h */