Exception values being thrown are roots.
Summary:C++ exception-throwing machinery copies the value thrown into
its own memory (allocated with new, but that's not specified),
prior to unwinding. We can execute PHP, and therefore perform
collections, during unwinding, so the types we throw must be rooted.
Two main categories:
1. user-defined exception structs containing req-heap pointers
(eg Object or Array): use root<T> inside the struct. This includes
ExtendedException and subclasses, as well as some types that extend
std::exception.
2. raw Object gets thrown quite a bit. Nearly all cases are PHP
exception objects: use throw_object() instead of throw Object(...),
which roots the object being thrown, and buries the actual throw in
a function, reducing code size.
Reviewed By: ricklavoie
Differential Revision:
D2823604
fb-gh-sync-id:
252bd2bfe1dbb5e17f4d9b51f34701ecab6b028e
shipit-source-id:
252bd2bfe1dbb5e17f4d9b51f34701ecab6b028e