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 #ifndef incl_HPHP_ADDR_TO_BC_MAPPER_
18 #define incl_HPHP_ADDR_TO_BC_MAPPER_
23 #include "hphp/runtime/vm/hhbc.h"
24 #include "hphp/runtime/vm/jit/types.h"
26 #include "hphp/tools/tc-print/perf-events.h"
27 #include "hphp/tools/tc-print/offline-trans-data.h"
28 #include "hphp/tools/tc-print/offline-code.h"
29 #include "hphp/tools/tc-print/repo-wrapper.h"
31 namespace HPHP
{ namespace jit
{
33 typedef uint16_t ExtOpcode
;
37 std::string
extOpcodeToString(ExtOpcode eOpcode
);
38 std::vector
<std::pair
<std::string
, ExtOpcode
> > getValidOpcodeNames();
39 ExtOpcode
stringToExtOpcode(std::string s
);
40 std::string
tcRegionToString(TCRegion tcr
);
44 struct AddrToBcMapper
: Mapper
<TCA
, ExtOpcode
> {
45 explicit AddrToBcMapper(const OfflineTransData
* _transData
) :
46 transData(_transData
) {}
48 folly::Optional
<ExtOpcode
> operator()(const TCA
& addr
) override
;
51 const OfflineTransData
* transData
;
54 /* AddrToTransMapper */
56 struct AddrToTransMapper
: Mapper
<TCA
, TransID
> {
57 explicit AddrToTransMapper(const OfflineTransData
* _tdata
) : tdata(_tdata
) {}
59 folly::Optional
<TransID
> operator()(const TCA
& addr
) override
{
61 TransID tid
= tdata
->getTransContaining(addr
);
62 if (tid
!= INVALID_ID
) return tid
;
67 const OfflineTransData
* tdata
;
70 /* AddrToTransFragmentMapper */
72 struct TransFragment
{
81 // Since it's going into an ordered map...
82 bool operator<(const TransFragment
& other
) const {
83 return aStart
< other
.aStart
;
87 struct AddrToTransFragmentMapper
: Mapper
<TCA
, TransFragment
> {
88 AddrToTransFragmentMapper(const OfflineTransData
* _tdata
,
89 ExtOpcode _filterBy
) :
90 tdata(_tdata
), filterBy(_filterBy
) {}
92 folly::Optional
<TransFragment
> operator()(const TCA
& addr
) override
;
95 TransFragment
extractTransFragment(TCA addr
, ExtOpcode opcode
);
98 const OfflineTransData
* tdata
;
102 /* TransToFuncMapper */
104 struct TransToFuncMapper
: Mapper
<TransID
, FuncId
> {
105 explicit TransToFuncMapper(const OfflineTransData
* _tdata
) : tdata(_tdata
) {}
107 folly::Optional
<FuncId
> operator()(const TransID
& tid
) override
{
108 always_assert(tdata
);
109 return tdata
->getTransRec(tid
)->src
.funcID();
113 const OfflineTransData
* tdata
;