GCAnnotations.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. * This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef js_GCAnnotations_h
  6. #define js_GCAnnotations_h
  7. // Set of annotations for the rooting hazard analysis, used to categorize types
  8. // and functions.
  9. #ifdef XGILL_PLUGIN
  10. // Mark a type as being a GC thing (eg js::gc::Cell has this annotation).
  11. # define JS_HAZ_GC_THING __attribute__((tag("GC Thing")))
  12. // Mark a type as holding a pointer to a GC thing (eg JS::Value has this
  13. // annotation.)
  14. # define JS_HAZ_GC_POINTER __attribute__((tag("GC Pointer")))
  15. // Mark a type as a rooted pointer, suitable for use on the stack (eg all
  16. // Rooted<T> instantiations should have this.)
  17. # define JS_HAZ_ROOTED __attribute__((tag("Rooted Pointer")))
  18. // Mark a type as something that should not be held live across a GC, but which
  19. // is not itself a GC pointer.
  20. # define JS_HAZ_GC_INVALIDATED __attribute__((tag("Invalidated by GC")))
  21. // Mark a type that would otherwise be considered a GC Pointer (eg because it
  22. // contains a JS::Value field) as a non-GC pointer. It is handled almost the
  23. // same in the analysis as a rooted pointer, except it will not be reported as
  24. // an unnecessary root if used across a GC call. This should rarely be used,
  25. // but makes sense for something like ErrorResult, which only contains a GC
  26. // pointer when it holds an exception (and it does its own rooting,
  27. // conditionally.)
  28. # define JS_HAZ_NON_GC_POINTER __attribute__((tag("Suppressed GC Pointer")))
  29. // Mark a function as something that runs a garbage collection, potentially
  30. // invalidating GC pointers.
  31. # define JS_HAZ_GC_CALL __attribute__((tag("GC Call")))
  32. // Mark an RAII class as suppressing GC within its scope.
  33. # define JS_HAZ_GC_SUPPRESSED __attribute__((tag("Suppress GC")))
  34. #else
  35. # define JS_HAZ_GC_THING
  36. # define JS_HAZ_GC_POINTER
  37. # define JS_HAZ_ROOTED
  38. # define JS_HAZ_GC_INVALIDATED
  39. # define JS_HAZ_NON_GC_POINTER
  40. # define JS_HAZ_GC_CALL
  41. # define JS_HAZ_GC_SUPPRESSED
  42. #endif
  43. #endif /* js_GCAnnotations_h */