2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
19 #include "hphp/runtime/base/types.h"
20 #include "hphp/runtime/base/rds.h"
21 #include "hphp/runtime/base/typed-value.h"
22 #include "hphp/runtime/ext/asio/ext_static-wait-handle.h"
24 #include "hphp/runtime/vm/jit/types.h"
26 #include "hphp/util/asm-x64.h"
27 #include "hphp/util/either.h"
34 #include "hphp/util/unwind-itanium-msvc.h"
44 ///////////////////////////////////////////////////////////////////////////////
47 * Information the unwinder needs stored in RDS, and the rds::Link for it.
48 * Used to pass values between unwinder code and catch traces.
51 /* PHP/C++ exception or Failed Static WaitHandle, nullptr if SetM exception */
53 Either
<ObjectData
*, Exception
*> exn
;
54 c_StaticWaitHandle
* fswh
;
56 TYPE_SCAN_CONSERVATIVE_FIELD(exn
);
58 /* Some helpers need to signal an error along with a TypedValue to be pushed
59 * on the eval stack. When present, that value lives here. */
62 /* This will be true iff the currently executing catch trace should side exit
63 * to somewhere else in the TC, rather than resuming the unwind process. */
66 /* Indicates that we entered tc_unwind_resume directly rather than through
71 /* Indicates whether this is the first frame the unwinder will unwind
75 /* The instruction pointer that async functions will use to return to
79 extern rds::Link
<UnwindRDS
, rds::Mode::Normal
> g_unwind_rds
;
81 #define IMPLEMENT_OFF(Name, member) \
82 inline ptrdiff_t unwinder##Name##Off() { \
83 return g_unwind_rds.handle() + offsetof(UnwindRDS, member); \
85 IMPLEMENT_OFF(Exn
, exn
)
86 IMPLEMENT_OFF(FSWH
, fswh
)
88 IMPLEMENT_OFF(SideExit
, doSideExit
)
89 IMPLEMENT_OFF(SideEnter
, sideEnter
)
90 IMPLEMENT_OFF(SavedRip
, savedRip
)
93 ///////////////////////////////////////////////////////////////////////////////
96 * The personality routine for code emitted by the jit.
99 tc_unwind_personality(int version
,
100 _Unwind_Action actions
,
101 uint64_t exceptionClass
,
102 _Unwind_Exception
* exceptionObj
,
103 _Unwind_Context
* context
);
105 using PersonalityFunc
= _Unwind_Reason_Code(*)(int, _Unwind_Action
, uint64_t,
110 * Resume unwinding of jitted PHP frames.
112 * This is called from the endCatchHelper stub, which is hit at the end of
113 * every catch trace. It returns the new value of vmfp(), as well as the catch
114 * trace to jump to---or nullptr if there is none, in which case the native
115 * unwinder should be invoked via _Unwind_Resume().
117 struct TCUnwindInfo
{
121 TCUnwindInfo
tc_unwind_resume(ActRec
* fp
, bool teardown
);
122 TCUnwindInfo
tc_unwind_resume_stublogue(ActRec
* fp
, TCA savedRip
);
125 * Called to initialize the unwinder and register an .eh_frame that covers the
128 void initUnwinder(TCA base
, size_t size
, PersonalityFunc fn
);
130 ///////////////////////////////////////////////////////////////////////////////