Exception values being thrown are roots.
commit33902b1a33328cec1595257bc6959cfd20435ad8
authorEdwin Smith <smith@fb.com>
Fri, 4 Mar 2016 19:31:30 +0000 (4 11:31 -0800)
committerHhvm Bot <hhvm-bot-bot@fb.com>
Fri, 4 Mar 2016 20:16:56 +0000 (4 12:16 -0800)
tree43be320415c1344392e8b7bb01e725e1cbfc9938
parent398847d9cddda00e996ec903ef2b56f8875b0c7f
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
hphp/runtime/base/builtin-functions.cpp
hphp/runtime/base/builtin-functions.h
hphp/runtime/base/req-root.cpp
hphp/runtime/base/req-root.h
hphp/runtime/vm/bytecode.cpp