Make comparison IR ops layout agnostic
[hiphop-php.git] / hphp / runtime / base / rds-symbol.h
blobc74e4107cad8d9ca12c09bfd9a4dee786e3505cf
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 #ifndef incl_HPHP_RDS_SYMBOL_H_
18 #define incl_HPHP_RDS_SYMBOL_H_
20 #include "hphp/runtime/base/types.h"
22 #include "hphp/util/low-ptr.h"
24 #include <boost/variant.hpp>
26 #include <string>
27 #include <type_traits>
29 namespace HPHP {
31 struct Class;
32 struct StringData;
34 namespace jit {
36 struct ArrayAccessProfile;
37 struct ArrayIterProfile;
38 struct CallTargetProfile;
39 struct ClsCnsProfile;
40 struct DecRefProfile;
41 struct IncRefProfile;
42 struct IsTypeStructProfile;
43 struct MethProfile;
44 struct SwitchProfile;
45 struct TypeProfile;
49 namespace rds {
51 ///////////////////////////////////////////////////////////////////////////////
53 * RDS symbols are centrally registered here.
55 * All StringData*'s below must be static strings.
59 * Symbols for rds::Link's.
61 struct LinkID { const char* type; };
62 struct LinkName { const char* type; LowStringPtr name; };
65 * Class constant values are TypedValue's stored in RDS.
67 struct ClsConstant { LowStringPtr clsName;
68 LowStringPtr cnsName; };
71 * StaticMethod{F,}Cache allocations.
73 * These are used to cache static method dispatch targets in a given class
74 * context. The `name' field here is a string that encodes the target class,
75 * property, and source context.
77 struct StaticMethod { LowStringPtr name; };
78 struct StaticMethodF { LowStringPtr name; };
81 * Profiling translations may store various kinds of junk under symbols that
82 * are keyed on translation id.
84 * These generally should go in Mode::Local or Mode::Persistent, depending on
85 * the use case.
87 #define RDS_PROFILE_SYMBOLS \
88 PR(ArrayAccessProfile) \
89 PR(ArrayIterProfile) \
90 PR(CallTargetProfile) \
91 PR(ClsCnsProfile) \
92 PR(DecRefProfile) \
93 PR(IsTypeStructProfile) \
94 PR(IncRefProfile) \
95 PR(MethProfile) \
96 PR(SwitchProfile) \
97 PR(TypeProfile)
99 enum class ProfileKind {
100 None = 0,
101 #define PR(T) T,
102 RDS_PROFILE_SYMBOLS
103 #undef PR
106 struct Profile {
107 Profile() = default;
109 Profile(TransID transId, Offset bcOff, const StringData* name)
110 : kind{ProfileKind::None}
111 , transId{transId}
112 , bcOff{bcOff}
113 , name{name}
116 #define PR(T) \
117 Profile(const jit::T*, TransID transId, \
118 Offset bcOff, const StringData* name) \
119 : kind{ProfileKind::T} \
120 , transId{transId} \
121 , bcOff{bcOff} \
122 , name{name} \
124 RDS_PROFILE_SYMBOLS
125 #undef PR
127 ProfileKind kind;
128 TransID transId;
129 Offset bcOff;
130 LowStringPtr name;
134 * Static class properties in Mode::Local.
136 struct SPropCache { LowPtr<const Class> cls;
137 Slot slot; };
139 struct StaticMemoValue { FuncId funcId; };
140 struct StaticMemoCache { FuncId funcId; };
142 struct LSBMemoValue {
143 LowPtr<const Class> cls;
144 FuncId funcId;
147 struct LSBMemoCache {
148 LowPtr<const Class> cls;
149 FuncId funcId;
152 struct TSCache {
153 FuncId funcId;
156 using Symbol = boost::variant<
157 LinkName,
158 LinkID,
159 ClsConstant,
160 StaticMethod,
161 StaticMethodF,
162 Profile,
163 SPropCache,
164 StaticMemoValue,
165 StaticMemoCache,
166 LSBMemoValue,
167 LSBMemoCache,
168 TSCache
171 std::string symbol_kind(const Symbol&);
172 std::string symbol_rep(const Symbol&);
173 bool symbol_eq(const Symbol&, const Symbol&);
174 size_t symbol_hash(const Symbol&);
176 ///////////////////////////////////////////////////////////////////////////////
180 #endif