2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 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_TRANSL_TYPES_H_
18 #define incl_HPHP_TRANSL_TYPES_H_
22 #include "hphp/util/assertions.h"
23 #include "hphp/util/hash-map-typedefs.h"
25 #include "hphp/runtime/base/types.h"
27 namespace HPHP
{ namespace jit
{
29 ///////////////////////////////////////////////////////////////////////////////
34 typedef unsigned char* TCA
; // "Translation cache address."
35 typedef const unsigned char* CTCA
;
37 struct ctca_identity_hash
{
38 size_t operator()(CTCA val
) const {
39 // Experiments show that this is a sufficient "hash function" on
40 // TCAs for now; using stronger functions didn't help given current
41 // data. Patterns of code emission in the translator could invalidate
42 // this finding going forward, though; e.g., if we frequently emit
43 // a call instruction N bytes into a cache-aligned region.
44 return uintptr_t(val
);
48 ///////////////////////////////////////////////////////////////////////////////
50 typedef hphp_hash_set
<TransID
> TransIDSet
;
51 typedef std::vector
<TransID
> TransIDVec
;
53 ///////////////////////////////////////////////////////////////////////////////
56 * The different kinds of translations that the JIT generates:
58 * - Anchor : a service request for retranslating
59 * - Prologue : function prologue
60 * - Interp : a service request to interpret at least one instruction
61 * - Live : translate one tracelet by inspecting live VM state
62 * - Profile : translate one block by inspecting live VM state and
63 * inserting profiling counters
64 * - Optimize : translate one region performing optimizations that may
65 * leverage data collected by Profile translations
66 * - Proflogue: a profiling function prologue
78 enum class TransKind {
79 #define DO(KIND) KIND,
84 constexpr size_t NumTransKinds
=
90 inline std::string
show(TransKind k
) {
91 #define DO(name) case TransKind::name: return "Trans" #name;
92 switch (k
) { TRANS_KINDS
}
98 * Compact flags which may be threaded through a service request to provide
99 * hints or demands for retranslations.
102 /* implicit */ TransFlags(uint64_t flags
= 0) : packed(flags
) {}
106 bool noinlineSingleton
: 1;
112 static_assert(sizeof(TransFlags
) <= sizeof(uint64_t), "Too many TransFlags!");
114 ///////////////////////////////////////////////////////////////////////////////
117 * The "kind" of code being generated.
119 * Different contexts of code generation constrain codegen differently; e.g.,
120 * cross-trace code has fewer available registers.
122 enum class CodeKind
{
128 * Enumeration representing the various areas that we emit code.
130 * kNumAreas must be kept up to date.
132 enum class AreaIndex
: unsigned { Main
, Cold
, Frozen
};
133 constexpr size_t kNumAreas
= 3;
135 inline std::string
areaAsString(AreaIndex area
) {
137 case AreaIndex::Main
:
139 case AreaIndex::Cold
:
141 case AreaIndex::Frozen
:
144 always_assert(false);
147 ///////////////////////////////////////////////////////////////////////////////