forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguard-constraint-inl.h
More file actions
91 lines (75 loc) · 2.97 KB
/
Copy pathguard-constraint-inl.h
File metadata and controls
91 lines (75 loc) · 2.97 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
/*
+----------------------------------------------------------------------+
| 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/vm/class.h"
namespace HPHP::jit {
///////////////////////////////////////////////////////////////////////////////
inline GuardConstraint::GuardConstraint(DataTypeCategory cat
/* = DataTypeGeneric */)
: category(cat)
, weak(false)
, m_specialized(0)
{}
inline GuardConstraint::GuardConstraint(const Class* cls)
: GuardConstraint(DataTypeSpecialized)
{
setDesiredClass(cls);
}
inline GuardConstraint& GuardConstraint::setWeak(bool w /* = true */) {
weak = w;
return *this;
}
inline bool GuardConstraint::empty() const {
return category == DataTypeGeneric && !weak;
}
inline bool GuardConstraint::operator==(GuardConstraint gc2) const {
return category == gc2.category &&
weak == gc2.weak &&
m_specialized == gc2.m_specialized;
}
inline bool GuardConstraint::operator!=(GuardConstraint gc2) const {
return !(*this == gc2);
}
///////////////////////////////////////////////////////////////////////////////
// Specialization.
inline bool GuardConstraint::isSpecialized() const {
return category == DataTypeSpecialized;
}
inline GuardConstraint& GuardConstraint::setArrayLayoutSensitive() {
assertx(!wantClass());
assertx(isSpecialized());
m_specialized |= kWantArrayLayout;
return *this;
}
inline bool GuardConstraint::isArrayLayoutSensitive() const {
return m_specialized & kWantArrayLayout;
}
inline GuardConstraint& GuardConstraint::setDesiredClass(const Class* cls) {
assertx(m_specialized == 0 ||
desiredClass()->classof(cls) || cls->classof(desiredClass()));
assertx(isSpecialized());
m_specialized = reinterpret_cast<uintptr_t>(cls);
assertx(wantClass());
return *this;
}
inline bool GuardConstraint::wantClass() const {
return m_specialized && !isArrayLayoutSensitive();
}
inline const Class* GuardConstraint::desiredClass() const {
assertx(wantClass());
return reinterpret_cast<const Class*>(m_specialized);
}
///////////////////////////////////////////////////////////////////////////////
}