forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcg-meta.cpp
More file actions
117 lines (100 loc) · 3.28 KB
/
cg-meta.cpp
File metadata and controls
117 lines (100 loc) · 3.28 KB
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
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2016 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/vm/jit/cg-meta.h"
#include "hphp/runtime/vm/jit/mc-generator.h"
#include "hphp/runtime/vm/jit/prof-data.h"
namespace HPHP { namespace jit {
TRACE_SET_MOD(mcg);
void CGMeta::setJmpTransID(TCA jmp, TransID transID, TransKind kind) {
if (kind != TransKind::Profile) return;
FTRACE(5, "setJmpTransID: adding {} => {}\n", jmp, transID);
jmpTransIDs.emplace_back(jmp, transID);
}
void CGMeta::process(
GrowableVector<IncomingBranch>* inProgressTailBranches
) {
process_only(inProgressTailBranches);
clear();
}
void CGMeta::process_only(
GrowableVector<IncomingBranch>* inProgressTailBranches
) {
mcg->assertOwnsMetadataLock();
for (auto const& pair : fixups) {
assertx(mcg->code().isValidCodeAddress(pair.first));
mcg->fixupMap().recordFixup(pair.first, pair.second);
}
fixups.clear();
auto& ctm = mcg->catchTraceMap();
for (auto const& pair : catches) {
auto const key = mcg->code().toOffset(pair.first);
auto const val = mcg->code().toOffset(pair.second);
if (auto pos = ctm.find(key)) {
*pos = val;
} else {
ctm.insert(key, val);
}
}
catches.clear();
if (auto profData = jit::profData()) {
for (auto const& elm : jmpTransIDs) {
profData->setJmpTransID(elm.first, elm.second);
}
}
jmpTransIDs.clear();
for (auto& pair : literals) {
if (mcg->literals().find(pair.first)) continue;
mcg->literals().insert(pair.first, pair.second);
}
literals.clear();
if (inProgressTailBranches) {
inProgressTailJumps.swap(*inProgressTailBranches);
}
assertx(inProgressTailJumps.empty());
for (auto& stub : reusedStubs) {
mcg->debugInfo()->recordRelocMap(stub, nullptr, "NewStub");
}
reusedStubs.clear();
}
void CGMeta::clear() {
watchpoints.clear();
fixups.clear();
catches.clear();
jmpTransIDs.clear();
literals.clear();
alignments.clear();
reusedStubs.clear();
addressImmediates.clear();
codePointers.clear();
inProgressTailJumps.clear();
bcMap.clear();
}
bool CGMeta::empty() const {
return
watchpoints.empty() &&
fixups.empty() &&
catches.empty() &&
jmpTransIDs.empty() &&
literals.empty() &&
alignments.empty() &&
reusedStubs.empty() &&
addressImmediates.empty() &&
codePointers.empty() &&
inProgressTailJumps.empty() &&
bcMap.empty() &&
true;
}
}}