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 +----------------------------------------------------------------------+
17 #include "hphp/runtime/vm/act-rec.h"
19 #include "hphp/runtime/base/types.h"
20 #include "hphp/runtime/vm/bytecode.h"
21 #include "hphp/runtime/vm/func.h"
23 #include "hphp/runtime/vm/jit/tc.h"
24 #include "hphp/runtime/vm/jit/types.h"
25 #include "hphp/runtime/vm/jit/unique-stubs.h"
27 #include "hphp/util/assertions.h"
28 #include "hphp/util/trace.h"
32 TRACE_SET_MOD(bcinterp
);
34 ///////////////////////////////////////////////////////////////////////////////
36 bool isReturnHelper(uint64_t address
) {
37 auto tca
= reinterpret_cast<jit::TCA
>(address
);
38 auto& u
= jit::tc::ustubs();
39 return tca
== u
.retHelper
||
40 tca
== u
.genRetHelper
||
41 tca
== u
.asyncGenRetHelper
;
44 bool isCallToExit(uint64_t address
) {
45 return reinterpret_cast<jit::TCA
>(address
) == jit::tc::ustubs().callToExit
;
48 ///////////////////////////////////////////////////////////////////////////////
50 void ActRec::setReturn(ActRec
* fp
, PC callPC
, void* retAddr
,
51 bool asyncEagerReturn
) {
52 assertx(fp
->func()->contains(callPC
));
53 assertx(isReturnHelper(reinterpret_cast<uintptr_t>(retAddr
)));
55 m_savedRip
= reinterpret_cast<uintptr_t>(retAddr
);
56 m_callOffAndFlags
= encodeCallOffsetAndFlags(
57 Offset(callPC
- fp
->func()->entry()),
58 asyncEagerReturn
? (1 << AsyncEagerRet
) : 0
62 void ActRec::setJitReturn(void* retAddr
) {
63 FTRACE(1, "Replace m_savedRip in fp {}, {:#x} -> {}, func {}\n",
64 this, m_savedRip
, retAddr
, func()->fullName()->data());
65 m_savedRip
= reinterpret_cast<uintptr_t>(retAddr
);
68 bool ActRec::skipFrame() const {
69 return func() && func()->isSkipFrame();
72 ///////////////////////////////////////////////////////////////////////////////