Modified: branches/safari-610-branch/Source/_javascript_Core/assembler/ARM64Assembler.h (269090 => 269091)
--- branches/safari-610-branch/Source/_javascript_Core/assembler/ARM64Assembler.h 2020-10-28 01:42:59 UTC (rev 269090)
+++ branches/safari-610-branch/Source/_javascript_Core/assembler/ARM64Assembler.h 2020-10-28 01:49:53 UTC (rev 269091)
@@ -340,18 +340,28 @@
class LinkRecord {
public:
- LinkRecord(intptr_t from, intptr_t to, JumpType type, Condition condition)
+ LinkRecord(const ARM64Assembler* assembler, intptr_t from, intptr_t to, JumpType type, Condition condition)
{
data.realTypes.m_from = from;
+#if CPU(ARM64E)
+ data.realTypes.m_to = tagInt(to, static_cast<PtrTag>(from ^ bitwise_cast<intptr_t>(assembler)));
+#else
+ UNUSED_PARAM(assembler);
data.realTypes.m_to = to;
+#endif
data.realTypes.m_type = type;
data.realTypes.m_linkType = LinkInvalid;
data.realTypes.m_condition = condition;
}
- LinkRecord(intptr_t from, intptr_t to, JumpType type, Condition condition, bool is64Bit, RegisterID compareRegister)
+ LinkRecord(const ARM64Assembler* assembler, intptr_t from, intptr_t to, JumpType type, Condition condition, bool is64Bit, RegisterID compareRegister)
{
data.realTypes.m_from = from;
+#if CPU(ARM64E)
+ data.realTypes.m_to = tagInt(to, static_cast<PtrTag>(from ^ bitwise_cast<intptr_t>(assembler)));
+#else
+ UNUSED_PARAM(assembler);
data.realTypes.m_to = to;
+#endif
data.realTypes.m_type = type;
data.realTypes.m_linkType = LinkInvalid;
data.realTypes.m_condition = condition;
@@ -358,10 +368,15 @@
data.realTypes.m_is64Bit = is64Bit;
data.realTypes.m_compareRegister = compareRegister;
}
- LinkRecord(intptr_t from, intptr_t to, JumpType type, Condition condition, unsigned bitNumber, RegisterID compareRegister)
+ LinkRecord(const ARM64Assembler* assembler, intptr_t from, intptr_t to, JumpType type, Condition condition, unsigned bitNumber, RegisterID compareRegister)
{
data.realTypes.m_from = from;
+#if CPU(ARM64E)
+ data.realTypes.m_to = tagInt(to, static_cast<PtrTag>(from ^ bitwise_cast<intptr_t>(assembler)));
+#else
+ UNUSED_PARAM(assembler);
data.realTypes.m_to = to;
+#endif
data.realTypes.m_type = type;
data.realTypes.m_linkType = LinkInvalid;
data.realTypes.m_condition = condition;
@@ -375,8 +390,24 @@
data.copyTypes.content[2] = other.data.copyTypes.content[2];
}
intptr_t from() const { return data.realTypes.m_from; }
- void setFrom(intptr_t from) { data.realTypes.m_from = from; }
- intptr_t to() const { return data.realTypes.m_to; }
+ void setFrom(const ARM64Assembler* assembler, intptr_t from)
+ {
+#if CPU(ARM64E)
+ data.realTypes.m_to = tagInt(to(assembler), static_cast<PtrTag>(from ^ bitwise_cast<intptr_t>(assembler)));
+#else
+ UNUSED_PARAM(assembler);
+#endif
+ data.realTypes.m_from = from;
+ }
+ intptr_t to(const ARM64Assembler* assembler) const
+ {
+#if CPU(ARM64E)
+ return untagInt(data.realTypes.m_to, static_cast<PtrTag>(data.realTypes.m_from ^ bitwise_cast<intptr_t>(assembler)));
+#else
+ UNUSED_PARAM(assembler);
+ return data.realTypes.m_to;
+#endif
+ }
JumpType type() const { return data.realTypes.m_type; }
JumpLinkType linkType() const { return data.realTypes.m_linkType; }
void setLinkType(JumpLinkType linkType) { ASSERT(data.realTypes.m_linkType == LinkInvalid); data.realTypes.m_linkType = linkType; }
@@ -2523,7 +2554,7 @@
{
ASSERT(to.isSet());
ASSERT(from.isSet());
- m_jumpsToLink.append(LinkRecord(from.m_offset, to.m_offset, type, condition));
+ m_jumpsToLink.append(LinkRecord(this, from.m_offset, to.m_offset, type, condition));
}
void linkJump(AssemblerLabel from, AssemblerLabel to, JumpType type, Condition condition, bool is64Bit, RegisterID compareRegister)
@@ -2530,7 +2561,7 @@
{
ASSERT(to.isSet());
ASSERT(from.isSet());
- m_jumpsToLink.append(LinkRecord(from.m_offset, to.m_offset, type, condition, is64Bit, compareRegister));
+ m_jumpsToLink.append(LinkRecord(this, from.m_offset, to.m_offset, type, condition, is64Bit, compareRegister));
}
void linkJump(AssemblerLabel from, AssemblerLabel to, JumpType type, Condition condition, unsigned bitNumber, RegisterID compareRegister)
@@ -2537,7 +2568,7 @@
{
ASSERT(to.isSet());
ASSERT(from.isSet());
- m_jumpsToLink.append(LinkRecord(from.m_offset, to.m_offset, type, condition, bitNumber, compareRegister));
+ m_jumpsToLink.append(LinkRecord(this, from.m_offset, to.m_offset, type, condition, bitNumber, compareRegister));
}
static void linkJump(void* code, AssemblerLabel from, void* to)
Modified: branches/safari-610-branch/Source/_javascript_Core/assembler/LinkBuffer.cpp (269090 => 269091)
--- branches/safari-610-branch/Source/_javascript_Core/assembler/LinkBuffer.cpp 2020-10-28 01:42:59 UTC (rev 269090)
+++ branches/safari-610-branch/Source/_javascript_Core/assembler/LinkBuffer.cpp 2020-10-28 01:49:53 UTC (rev 269091)
@@ -292,10 +292,15 @@
// Calculate absolute address of the jump target, in the case of backwards
// branches we need to be precise, forward branches we are pessimistic
const uint8_t* target;
- if (jumpsToLink[i].to() >= jumpsToLink[i].from())
- target = codeOutData + jumpsToLink[i].to() - offset; // Compensate for what we have collapsed so far
+#if CPU(ARM64)
+ const intptr_t to = jumpsToLink[i].to(¯oAssembler.m_assembler);
+#else
+ const intptr_t to = jumpsToLink[i].to();
+#endif
+ if (to >= jumpsToLink[i].from())
+ target = codeOutData + to - offset; // Compensate for what we have collapsed so far
else
- target = codeOutData + jumpsToLink[i].to() - executableOffsetFor(jumpsToLink[i].to());
+ target = codeOutData + to - executableOffsetFor(to);
JumpLinkType jumpLinkType = MacroAssembler::computeJumpType(jumpsToLink[i], codeOutData + writePtr, target);
// Compact branch if we can...
@@ -307,7 +312,11 @@
recordLinkOffsets(m_assemblerStorage, jumpsToLink[i].from() - delta, readPtr, readPtr - writePtr);
}
}
+#if CPU(ARM64)
+ jumpsToLink[i].setFrom(¯oAssembler.m_assembler, writePtr);
+#else
jumpsToLink[i].setFrom(writePtr);
+#endif
}
} else {
if (ASSERT_ENABLED) {
@@ -349,7 +358,12 @@
for (unsigned i = 0; i < jumpCount; ++i) {
uint8_t* location = codeOutData + jumpsToLink[i].from();
- uint8_t* target = codeOutData + jumpsToLink[i].to() - executableOffsetFor(jumpsToLink[i].to());
+#if CPU(ARM64)
+ const intptr_t to = jumpsToLink[i].to(¯oAssembler.m_assembler);
+#else
+ const intptr_t to = jumpsToLink[i].to();
+#endif
+ uint8_t* target = codeOutData + to - executableOffsetFor(to);
if (useFastJITPermissions())
MacroAssembler::link<memcpyWrapper>(jumpsToLink[i], outData + jumpsToLink[i].from(), location, target);
else
Modified: branches/safari-610-branch/Source/WTF/wtf/PtrTag.h (269090 => 269091)
--- branches/safari-610-branch/Source/WTF/wtf/PtrTag.h 2020-10-28 01:42:59 UTC (rev 269090)
+++ branches/safari-610-branch/Source/WTF/wtf/PtrTag.h 2020-10-28 01:49:53 UTC (rev 269091)
@@ -390,6 +390,13 @@
return bitwise_cast<IntType>(ptrauth_sign_unauthenticated(bitwise_cast<void*>(ptrInt), ptrauth_key_process_dependent_data, tag));
}
+template <typename IntType>
+inline IntType untagInt(IntType ptrInt, PtrTag tag)
+{
+ static_assert(sizeof(IntType) == sizeof(uintptr_t));
+ return bitwise_cast<IntType>(ptrauth_auth_data(bitwise_cast<void*>(ptrInt), ptrauth_key_process_dependent_data, tag));
+}
+
template<typename PtrType>
void assertIsCFunctionPtr(PtrType value)
{
@@ -569,13 +576,6 @@
template<PtrTag, typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value>>
inline PtrType untagCFunctionPtr(PtrType ptr) { return ptr; }
-template <typename IntType>
-inline IntType tagInt(IntType ptrInt, PtrTag)
-{
- static_assert(sizeof(IntType) == sizeof(uintptr_t), "");
- return ptrInt;
-}
-
template<typename PtrType> void assertIsCFunctionPtr(PtrType) { }
template<typename PtrType> void assertIsNullOrCFunctionPtr(PtrType) { }
@@ -588,6 +588,20 @@
template<typename PtrType> void assertIsTaggedWith(PtrType, PtrTag) { }
template<typename PtrType> void assertIsNullOrTaggedWith(PtrType, PtrTag) { }
+template <typename IntType>
+inline IntType tagInt(IntType ptrInt, PtrTag)
+{
+ static_assert(sizeof(IntType) == sizeof(uintptr_t));
+ return ptrInt;
+}
+
+template <typename IntType>
+inline IntType untagInt(IntType ptrInt, PtrTag)
+{
+ static_assert(sizeof(IntType) == sizeof(uintptr_t));
+ return ptrInt;
+}
+
inline bool usesPointerTagging() { return false; }
#define WTF_VTBL_FUNCPTR_PTRAUTH(discriminator)
@@ -618,6 +632,7 @@
using WTF::tagCFunctionPtr;
using WTF::untagCFunctionPtr;
using WTF::tagInt;
+using WTF::untagInt;
using WTF::assertIsCFunctionPtr;
using WTF::assertIsNullOrCFunctionPtr;