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/jit/bc-marker.h"
19 #include <folly/Format.h>
20 #include <folly/Conv.h>
22 #include "hphp/runtime/base/runtime-option.h"
23 #include "hphp/runtime/vm/resumable.h"
24 #include "hphp/runtime/vm/jit/extra-data.h"
25 #include "hphp/runtime/vm/jit/ir-instruction.h"
26 #include "hphp/runtime/vm/jit/ssa-tmp.h"
30 //////////////////////////////////////////////////////////////////////
32 std::string
BCMarker::show() const {
33 if (!valid()) return "invalid BCMarker";
36 "--- bc {}, fp {}, fixupFP {}, spOff {}, {}",
38 m_fp
? folly::to
<std::string
>(m_fp
->id()) : "_",
39 m_fixupFP
? folly::to
<std::string
>(m_fixupFP
->id()) : "_",
41 m_profTransIDs
.empty()
43 : folly::sformat(" [profTrans={}]", folly::join(',', m_profTransIDs
))
47 bool BCMarker::valid() const {
48 // Note, we can't check stack bounds here because of inlining, and
49 // instructions like idx, which can create php-level calls.
50 assertx(m_profTransIDs
.find(kInvalidTransID
) == m_profTransIDs
.end());
54 SBInvOffset
BCMarker::fixupSBOff() const {
56 if (fp() == fixupFP()) return SBInvOffset
{0};
57 auto const begin_inlining
= fp()->inst();
58 assertx(begin_inlining
->is(BeginInlining
));
59 auto const fpSBOffset
= begin_inlining
->extra
<BeginInlining
>()->sbOffset
;
61 auto const fixupFPStackBaseOffset
= [&] {
62 if (fixupFP()->inst()->is(BeginInlining
)) {
63 return fixupFP()->inst()->extra
<BeginInlining
>()->sbOffset
;
65 assertx(fixupFP()->inst()->is(DefFP
, DefFuncEntryFP
));
66 auto const defSP
= fp()->inst()->src(0)->inst();
67 auto const irSPOff
= defSP
->extra
<DefStackData
>()->irSPOff
;
68 return SBInvOffset
{0}.to
<IRSPRelOffset
>(irSPOff
);
70 return SBInvOffset
{fixupFPStackBaseOffset
- fpSBOffset
};
73 SrcKey
BCMarker::fixupSk() const {
75 if (fp() == fixupFP()) return sk();
79 assertx(curFP
->inst()->is(BeginInlining
));
80 // Walking the FP chain created from the marker is suspect, but we aren't
81 // using it to materialize the fp SSATmp, or offsets based on the begin
82 // inlinings. We are only materializing srckey info.
83 auto const nextFP
= curFP
->inst()->marker().fp();
84 if (nextFP
== fixupFP()) return curFP
->inst()->marker().sk();
89 //////////////////////////////////////////////////////////////////////