- Revision
- 264400
- Author
- commit-qu...@webkit.org
- Date
- 2020-07-15 09:32:01 -0700 (Wed, 15 Jul 2020)
Log Message
[WTF] Fix PackedAlignedPtr for X86_64 canonical addresses
https://bugs.webkit.org/show_bug.cgi?id=214142
Patch by Jim Mason <jma...@ibinx.com> on 2020-07-15
Reviewed by Mark Lam
Source/_javascript_Core:
Fixed pointer test to use unsigned in place of signed.
* wasm/js/WebAssemblyFunction.cpp:
(JSC::callWebAssemblyFunction):
Source/WTF:
* wtf/Packed.h:
(WTF::PackedAlignedPtr::get const):
(WTF::PackedAlignedPtr::set):
Tools:
Revised test cases in TEST(WTF_Packed, AssignAndGet)
* TestWebKitAPI/Tests/WTF/Packed.cpp:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (264399 => 264400)
--- trunk/Source/_javascript_Core/ChangeLog 2020-07-15 16:24:23 UTC (rev 264399)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-07-15 16:32:01 UTC (rev 264400)
@@ -1,3 +1,15 @@
+2020-07-15 Jim Mason <jma...@ibinx.com>
+
+ [WTF] Fix PackedAlignedPtr for X86_64 canonical addresses
+ https://bugs.webkit.org/show_bug.cgi?id=214142
+
+ Reviewed by Mark Lam
+
+ Fixed pointer test to use unsigned in place of signed.
+
+ * wasm/js/WebAssemblyFunction.cpp:
+ (JSC::callWebAssemblyFunction):
+
2020-07-15 Alexey Shvayka <shvaikal...@gmail.com>
Emit HasOwnPropertyFunctionCallDotNode for "Reflect" identifiers
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp (264399 => 264400)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp 2020-07-15 16:24:23 UTC (rev 264399)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp 2020-07-15 16:32:01 UTC (rev 264400)
@@ -122,10 +122,10 @@
{
// We do the stack check here for the wrapper function because we don't
// want to emit a stack check inside every wrapper function.
- const intptr_t sp = bitwise_cast<intptr_t>(currentStackPointer());
- const intptr_t frameSize = (boxedArgs.size() + CallFrame::headerSizeInRegisters) * sizeof(Register);
- const intptr_t stackSpaceUsed = 2 * frameSize; // We're making two calls. One to the wrapper, and one to the actual wasm code.
- if (UNLIKELY((sp < stackSpaceUsed) || ((sp - stackSpaceUsed) < bitwise_cast<intptr_t>(vm.softStackLimit()))))
+ const uintptr_t sp = bitwise_cast<uintptr_t>(currentStackPointer());
+ const uintptr_t frameSize = (boxedArgs.size() + CallFrame::headerSizeInRegisters) * sizeof(Register);
+ const uintptr_t stackSpaceUsed = 2 * frameSize; // We're making two calls. One to the wrapper, and one to the actual wasm code.
+ if (UNLIKELY((sp < stackSpaceUsed) || ((sp - stackSpaceUsed) < bitwise_cast<uintptr_t>(vm.softStackLimit()))))
return JSValue::encode(throwException(globalObject, scope, createStackOverflowError(globalObject)));
}
vm.wasmContext.store(wasmInstance, vm.softStackLimit());
Modified: trunk/Source/WTF/ChangeLog (264399 => 264400)
--- trunk/Source/WTF/ChangeLog 2020-07-15 16:24:23 UTC (rev 264399)
+++ trunk/Source/WTF/ChangeLog 2020-07-15 16:32:01 UTC (rev 264400)
@@ -1,3 +1,14 @@
+2020-07-15 Jim Mason <jma...@ibinx.com>
+
+ [WTF] Fix PackedAlignedPtr for X86_64 canonical addresses
+ https://bugs.webkit.org/show_bug.cgi?id=214142
+
+ Reviewed by Mark Lam
+
+ * wtf/Packed.h:
+ (WTF::PackedAlignedPtr::get const):
+ (WTF::PackedAlignedPtr::set):
+
2020-07-15 Brady Eidson <beid...@apple.com>
Resolve race between IOHIDManager and GameController framework.
Modified: trunk/Source/WTF/wtf/Packed.h (264399 => 264400)
--- trunk/Source/WTF/wtf/Packed.h 2020-07-15 16:24:23 UTC (rev 264399)
+++ trunk/Source/WTF/wtf/Packed.h 2020-07-15 16:32:01 UTC (rev 264400)
@@ -143,6 +143,20 @@
#endif
if (isAlignmentShiftProfitable)
value <<= alignmentShiftSize;
+
+#if CPU(X86_64) && !(OS(DARWIN) || OS(LINUX) || OS(WINDOWS))
+ // The AMD specification requires that the most significant 16
+ // bits of any virtual address, bits 48 through 63, must be
+ // copies of bit 47 (in a manner akin to sign extension).
+ //
+ // The above-named OSes will never allocate user space addresses
+ // with bit 47 set, thus are already in canonical form.
+ //
+ // Reference: https://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details
+ constexpr unsigned shiftBits = countOfBits<uintptr_t> - OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH);
+ value = (bitwise_cast<intptr_t>(value) << shiftBits) >> shiftBits;
+#endif
+
return bitwise_cast<T*>(value);
}
@@ -156,6 +170,7 @@
#else
memcpy(m_storage.data(), bitwise_cast<uint8_t*>(&value) + (sizeof(void*) - storageSize), storageSize);
#endif
+ ASSERT(bitwise_cast<uintptr_t>(get()) == value);
}
void clear()
Modified: trunk/Tools/ChangeLog (264399 => 264400)
--- trunk/Tools/ChangeLog 2020-07-15 16:24:23 UTC (rev 264399)
+++ trunk/Tools/ChangeLog 2020-07-15 16:32:01 UTC (rev 264400)
@@ -1,3 +1,14 @@
+2020-07-15 Jim Mason <jma...@ibinx.com>
+
+ [WTF] Fix PackedAlignedPtr for X86_64 canonical addresses
+ https://bugs.webkit.org/show_bug.cgi?id=214142
+
+ Reviewed by Mark Lam
+
+ Revised test cases in TEST(WTF_Packed, AssignAndGet)
+
+ * TestWebKitAPI/Tests/WTF/Packed.cpp:
+
2020-07-15 Aakash Jain <aakash_j...@apple.com>
[ews-app] Add timeout to network requests
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/Packed.cpp (264399 => 264400)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/Packed.cpp 2020-07-15 16:24:23 UTC (rev 264399)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/Packed.cpp 2020-07-15 16:32:01 UTC (rev 264400)
@@ -62,9 +62,24 @@
{
PackedPtr<uint8_t> key { nullptr };
static_assert(OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH) != 64, "");
- uint8_t* max = bitwise_cast<uint8_t*>(static_cast<uintptr_t>(((1ULL) << OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH)) - 1));
- key = max;
- EXPECT_EQ(key.get(), max);
+ uint8_t* candidates[] = {
+ 0,
+ bitwise_cast<uint8_t*>(static_cast<uintptr_t>((1ULL << (OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH) / 2)) - 1)),
+ bitwise_cast<uint8_t*>(static_cast<uintptr_t>((1ULL << (OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH) - 1)) - 1)),
+#if !CPU(X86_64) || OS(DARWIN) || OS(LINUX) || OS(WINDOWS)
+ // These OSes will never allocate user space addresses with
+ // bit 47 (i.e. OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH) - 1) set.
+ bitwise_cast<uint8_t*>(static_cast<uintptr_t>((1ULL << OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH)) - 1)),
+#else
+ bitwise_cast<uint8_t*>(static_cast<uintptr_t>(~((1ULL << (OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH) - 1)) - 1))), // min higher half
+ bitwise_cast<uint8_t*>(std::numeric_limits<uintptr_t>::max()), // max higher half
+#endif
+ };
+ int count = sizeof(candidates) / sizeof(uint8_t*);
+ for (int i = 0; i < count; i++) {
+ key = candidates[i];
+ EXPECT_EQ(key.get(), candidates[i]);
+ }
}
}