forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirgen-state.h
130 lines (108 loc) · 4.05 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
/*
+----------------------------------------------------------------------+
| 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. |
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_JIT_IRGEN_STATE_H_
#define incl_HPHP_JIT_IRGEN_STATE_H_
#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/ir-builder.h"
#include "hphp/runtime/vm/jit/ir-unit.h"
#include "hphp/runtime/vm/jit/translator.h"
namespace HPHP { namespace jit {
struct NormalizedInstruction;
struct SSATmp;
namespace irgen {
//////////////////////////////////////////////////////////////////////
struct ReturnTarget {
/*
* Block that will contain the InlineReturn and serve as a branch target for
* returning to the caller.
*/
Block* target;
};
/*
* 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);
TransContext context;
TransFlags transFlags;
const RegionDesc* region;
IRUnit& unit;
std::unique_ptr<IRBuilder> irb;
/*
* Tracks information about the current bytecode offset and which function we
* are in. We push and pop as we deal with inlined calls.
*/
std::vector<SrcKey> bcStateStack;
/*
* The current inlining level. 0 means we're not inlining.
*/
uint16_t inlineLevel{0};
/*
* Return-to-caller block targets for inlined functions. The last target is
* for the current inlining frame.
*/
std::vector<ReturnTarget> inlineReturnTarget;
/*
* The id of the profiling translation for the code we're currently
* generating, if there was one, otherwise kInvalidTransID.
*/
TransID profTransID{kInvalidTransID};
/*
* Some information is only passed through the nearly-dead
* NormalizedInstruction structure. Don't add new uses since we're gradually
* removing this (the long, ugly name is deliberate).
*/
const NormalizedInstruction* currentNormalizedInstruction{nullptr};
/*
* 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're on the last HHBC instruction that will be emitted
* for this region.
*/
bool lastBcInst{false};
/*
* Profile-weight factor, to be multiplied by the region blocks'
* profile-translation counters in PGO mode.
*/
double profFactor{1};
};
//////////////////////////////////////////////////////////////////////
/*
* Debug-printable string.
*/
std::string show(const IRGS&);
//////////////////////////////////////////////////////////////////////
}}}
#endif