forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirgen-state.h
140 lines (116 loc) · 4.26 KB
/
irgen-state.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#pragma once
#include <memory>
#include <vector>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include "hphp/runtime/vm/jit/bc-marker.h"
#include "hphp/runtime/vm/jit/inline-state.h"
#include "hphp/runtime/vm/jit/ir-builder.h"
#include "hphp/runtime/vm/jit/ir-unit.h"
#include "hphp/runtime/vm/jit/irgen-iter-spec.h"
#include "hphp/runtime/vm/jit/translator.h"
#include "hphp/runtime/vm/jit/types.h"
namespace HPHP::jit {
struct NormalizedInstruction;
struct SSATmp;
struct TranslateRetryContext;
namespace irgen {
//////////////////////////////////////////////////////////////////////
/*
* IR-Generation State.
*
* This structure contains the main state bag for the HHIR frontend, which
* translates HHBC into HHIR. The parse-time state in HHIR is relatively
* non-trivial, for two reasons: one is that we perform a number of
* optimizations during parse time, and two is that since the IR can not
* represent all operations on generic types some simple type analysis is
* required to determine high-level compilation strategy.
*/
struct IRGS {
explicit IRGS(IRUnit& unit, const RegionDesc* region, int32_t budgetBCInstrs,
TranslateRetryContext* retryContext);
TransContext context;
const RegionDesc* region;
IRUnit& unit;
std::unique_ptr<IRBuilder> irb;
/*
* Tracks information about the current bytecode offset and which function we
* are in.
*/
SrcKey bcState;
/*
* Tracks information about the state of inlining.
*/
InlineState inlineState;
/*
* The ids of the profiling translations for the code we're currently
* generating (may be empty).
*/
TransIDSet profTransIDs;
/*
* True if we're on the first HHBC instruction that will be executed
* for this instruction. This is the first bytecode instruction in
* either the region entry block or any other block in its
* retranslation chain (i.e. that can be reached due to guard
* failures before advancing VM state for any bytecode instruction).
*/
bool firstBcInst{true};
/*
* True if we are just forming a region. Used to pessimize return values of
* function calls that may have been inferred based on specialized type
* information that won't be available when the region is translated.
*/
bool formingRegion{false};
/*
* Profile-weight factor, to be multiplied by the region blocks'
* profile-translation counters in PGO mode.
*/
double profFactor{1};
/*
* The remaining bytecode instruction budget for this region translation.
*/
int32_t budgetBCInstrs{0};
/*
* A surprise check has already been emitted and does not need to be generated
* again for the current instruction.
*/
bool skipSurpriseCheck{false};
/*
* Context for translation retries.
*/
TranslateRetryContext* retryContext;
/*
* Used to reuse blocks of code between specialized IterInits and IterNexts.
* See irgen-iter-spec for details.
*/
jit::fast_map<Block*, std::unique_ptr<SpecializedIterator>> iters;
/*
* Func entry inputs:
* - previous (caller's) FP
*/
SSATmp* funcEntryPrevFP{nullptr};
};
//////////////////////////////////////////////////////////////////////
/*
* Debug-printable string.
*/
std::string show(const IRGS&);
//////////////////////////////////////////////////////////////////////
}}