Store num args instead of offset in prologue and func entry SrcKeys
[hiphop-php.git] / hphp / runtime / vm / jit / unwind-itanium.h
blob0584269a53c15bd0619838ad66e9baff32157dc5
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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 +----------------------------------------------------------------------+
17 #pragma once
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"
29 #include <cstddef>
31 #ifndef _MSC_VER
32 #include <unwind.h>
33 #else
34 #include "hphp/util/unwind-itanium-msvc.h"
35 #endif
37 namespace HPHP {
39 struct ActRec;
40 struct EHFrameWriter;
42 namespace jit {
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.
50 struct UnwindRDS {
51 /* PHP/C++ exception or Failed Static WaitHandle, nullptr if SetM exception */
52 union {
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. */
60 TypedValue tv;
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. */
64 bool doSideExit;
66 /* Indicates that we entered tc_unwind_resume directly rather than through
67 * itanium ABI
69 bool sideEnter;
71 /* Indicates whether this is the first frame the unwinder will unwind
73 bool isFirstFrame;
75 /* The instruction pointer that async functions will use to return to
77 TCA savedRip;
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)
87 IMPLEMENT_OFF(TV, tv)
88 IMPLEMENT_OFF(SideExit, doSideExit)
89 IMPLEMENT_OFF(SideEnter, sideEnter)
90 IMPLEMENT_OFF(SavedRip, savedRip)
91 #undef IMPLEMENT_OFF
93 ///////////////////////////////////////////////////////////////////////////////
96 * The personality routine for code emitted by the jit.
98 _Unwind_Reason_Code
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,
106 _Unwind_Exception*,
107 _Unwind_Context*);
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 {
118 TCA catchTrace;
119 ActRec* fp;
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
126 * TC.
128 void initUnwinder(TCA base, size_t size, PersonalityFunc fn);
130 ///////////////////////////////////////////////////////////////////////////////