Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge CTSRD master into main #18

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/heap/ConservativeRoots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ SUPPRESS_ASAN
void ConservativeRoots::genericAddSpan(void* begin, void* end, MarkHook& markHook)
{
#ifdef __CHERI_PURE_CAPABILITY__
if ((vaddr_t)begin > (vaddr_t)end) { //XXXKG: end may not be a capability hence use address_get, otherwise we will get a tag violation
if ((ptraddr_t)begin > (ptraddr_t)end) { //XXXKG: end may not be a capability hence use address_get, otherwise we will get a tag violation
#else
if (begin > end) {
#endif
Expand All @@ -123,7 +123,7 @@ void ConservativeRoots::genericAddSpan(void* begin, void* end, MarkHook& markHoo
HeapVersion newlyAllocatedVersion = m_heap.objectSpace().newlyAllocatedVersion();
for (HeapPtr<char>* it = static_cast<HeapPtr<char>*>(begin);
#ifdef __CHERI_PURE_CAPABILITY__
(vaddr_t)it != (vaddr_t)static_cast<HeapPtr<char>*>(end);
(ptraddr_t)it != (ptraddr_t)static_cast<HeapPtr<char>*>(end);
#else
it != static_cast<HeapPtr<char>*>(end);
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/heap/MachineStackMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MachineThreads {
#define GET_STACK_BOUNDED_POINTER_TO_VARIABLE(var) \
__builtin_cheri_offset_increment( \
currentStackPointer(), \
(vaddr_t) &(var) - __builtin_cheri_address_get(currentStackPointer()))
(ptraddr_t) &(var) - __builtin_cheri_address_get(currentStackPointer()))
#else
#define GET_STACK_BOUNDED_POINTER_TO_VARIABLE(var) \
&(var)
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/heap/MarkedBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ inline size_t MarkedBlock::Handle::size()
inline size_t MarkedBlock::atomNumber(const void* p)
{
#ifdef __CHERI_PURE_CAPABILITY__
return ((vaddr_t)p - (vaddr_t)this) / atomSize;
return ((ptraddr_t)p - (ptraddr_t)this) / atomSize;
#else
return (reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(this)) / atomSize;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/interpreter/CLoopStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace JSC {

bool containsAddress(Register* address) {
#ifdef __CHERI_PURE_CAPABILITY__
return ((vaddr_t)lowAddress() <= (vaddr_t)address && (vaddr_t)address < (vaddr_t)highAddress());
return ((ptraddr_t)lowAddress() <= (ptraddr_t)address && (ptraddr_t)address < (ptraddr_t)highAddress());
#else
return (lowAddress() <= address && address < highAddress());
#endif
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/runtime/PropertyMapHashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class PropertyTable final : public JSCell {
bool operator==(const ordered_iterator<T>& other)
{
#ifdef __CHERI_PURE_CAPABILITY__
return (vaddr_t)m_valuePtr == (vaddr_t)other.m_valuePtr;
return (ptraddr_t)m_valuePtr == (ptraddr_t)other.m_valuePtr;
#else
return m_valuePtr == other.m_valuePtr;
#endif
Expand All @@ -100,7 +100,7 @@ class PropertyTable final : public JSCell {
bool operator!=(const ordered_iterator<T>& other)
{
#ifdef __CHERI_PURE_CAPABILITY__
return (vaddr_t)m_valuePtr != (vaddr_t)other.m_valuePtr;
return (ptraddr_t)m_valuePtr != (ptraddr_t)other.m_valuePtr;
#else
return m_valuePtr != other.m_valuePtr;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/runtime/VM.h
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ class VM : public ThreadSafeRefCounted<VM>, public DoublyLinkedListNode<VM> {
void* curr = currentStackPointer();
#ifdef __CHERI_PURE_CAPABILITY__
// XXXKG: limit may or may not be a capability
return (vaddr_t)curr >= (vaddr_t)stackLimit;
return (ptraddr_t)curr >= (ptraddr_t)stackLimit;
#else
return curr >= stackLimit;
#endif
Expand Down
12 changes: 6 additions & 6 deletions Source/WTF/wtf/HashFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ namespace WTF {

static unsigned hash(PtrType key) {
#ifdef __CHERI_PURE_CAPABILITY__
return IntHash<vaddr_t>::hash(reinterpret_cast<vaddr_t>(key));
return IntHash<ptraddr_t>::hash(reinterpret_cast<ptraddr_t>(key));
#else
return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key));
#endif
}
static bool equal(PtrType a, PtrType b) {
#ifdef __CHERI_PURE_CAPABILITY__
return (vaddr_t)a == (vaddr_t)b;
return (ptraddr_t)a == (ptraddr_t)b;
#else
return a == b;
#endif
Expand All @@ -150,14 +150,14 @@ namespace WTF {

static unsigned hash(PtrType key) {
#ifdef __CHERI_PURE_CAPABILITY__
return IntHash<vaddr_t>::hash(reinterpret_cast<vaddr_t>(key));
return IntHash<ptraddr_t>::hash(reinterpret_cast<ptraddr_t>(key));
#else
return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key));
#endif
}
static bool equal(PtrType a, PtrType b) {
#ifdef __CHERI_PURE_CAPABILITY__
return (vaddr_t)a == (vaddr_t)b;
return (ptraddr_t)a == (ptraddr_t)b;
#else
return a == b;
#endif
Expand All @@ -181,8 +181,8 @@ namespace WTF {
template<typename T> struct IntCapHash {
typedef T IntCapType;

static unsigned hash(IntCapType key) { return IntHash<vaddr_t>::hash(static_cast<vaddr_t>(key)); }
static bool equal(IntCapType a, IntCapType b) { return (vaddr_t)(void*)a == (vaddr_t)(void*)b; }
static unsigned hash(IntCapType key) { return IntHash<ptraddr_t>::hash(static_cast<ptraddr_t>(key)); }
static bool equal(IntCapType a, IntCapType b) { return (ptraddr_t)(void*)a == (ptraddr_t)(void*)b; }
static const bool safeToCompareToEmptyOrDeleted = true;
};
template<> struct IntHash<__uintcap_t> : public IntCapHash<__uintcap_t> {};
Expand Down
2 changes: 1 addition & 1 deletion Source/WTF/wtf/RefCountedArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class RefCountedArray {
char* result = reinterpret_cast<char*>(this) + size();
//XXXKG: check alignment
#ifdef __CHERI_PURE_CAPABILITY__
ASSERT(!((vaddr_t)result & (sizeof(__uintcap_t)-1)));
ASSERT(!((ptraddr_t)result & (sizeof(__uintcap_t)-1)));
#else
ASSERT(!(bitwise_cast<uintptr_t>(result) & 7));
#endif
Expand Down
6 changes: 3 additions & 3 deletions Source/WTF/wtf/StackBounds.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ class StackBounds {
void* currentPosition = currentStackPointer();
ASSERT(m_origin != m_bound);
ASSERT(isGrowingDownward()
#ifdef __CHERI_PURE_CAPABILITY__ // XXXKG: use vaddr_t because m_bound may not have tag set (if obtained from pthreads)
? ((vaddr_t)currentPosition < (vaddr_t)m_origin && (vaddr_t)currentPosition > (vaddr_t)m_bound)
: ((vaddr_t)currentPosition > (vaddr_t)m_origin && (vaddr_t)currentPosition < (vaddr_t)m_bound));
#ifdef __CHERI_PURE_CAPABILITY__ // XXXKG: use ptraddr_t because m_bound may not have tag set (if obtained from pthreads)
? ((ptraddr_t)currentPosition < (ptraddr_t)m_origin && (ptraddr_t)currentPosition > (ptraddr_t)m_bound)
: ((ptraddr_t)currentPosition > (ptraddr_t)m_origin && (ptraddr_t)currentPosition < (ptraddr_t)m_bound));
#else
? (currentPosition < m_origin && currentPosition > m_bound)
: (currentPosition > m_origin && currentPosition < m_bound));
Expand Down
2 changes: 1 addition & 1 deletion Source/WTF/wtf/StdLibExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ inline bool is8ByteAligned(void* p)
{
static_assert(sizeof(double) == 8, "");
#ifdef __CHERI_PURE_CAPABILITY__
return !((vaddr_t)(p) & (sizeof(double) - 1));
return !((ptraddr_t)(p) & (sizeof(double) - 1));
#else
return !((uintptr_t)(p) & (sizeof(double) - 1));
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/WTF/wtf/text/ASCIIFastPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ template <uint64_t mask>
inline bool isAlignedTo(const void* pointer)
{
#ifdef __CHERI_PURE_CAPABILITY__
return !(reinterpret_cast<vaddr_t>(pointer) & mask);
return !(reinterpret_cast<ptraddr_t>(pointer) & mask);
#else
return !(reinterpret_cast<uintptr_t>(pointer) & mask);
#endif
Expand Down