Skip to content

Commit b14347f

Browse files
danmcdtargos
authored andcommitted
deps: patch V8 for illumos
illumos pointers are VA48, can allocate from the top of the 64-bit range as well. PR-URL: #59805 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 02cc478 commit b14347f

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.4',
41+
'v8_embedder_string': '-node.5',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/codegen/code-stub-assembler.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,16 @@ TNode<Code> CodeStubAssembler::LoadCodeObjectFromJSDispatchTable(
20432043
TNode<UintPtrT> shifted_value;
20442044
if (JSDispatchEntry::kObjectPointerOffset == 0) {
20452045
shifted_value =
2046+
#if defined(__illumos__) && defined(V8_HOST_ARCH_64_BIT)
2047+
// Pointers in illumos span both the low 2^47 range and the high 2^47 range
2048+
// as well. Checking the high bit being set in illumos means all higher bits
2049+
// need to be set to 1 after shifting right.
2050+
// Use WordSar() so any high-bit check wouldn't be necessary.
2051+
UncheckedCast<UintPtrT>(WordSar(UncheckedCast<IntPtrT>(value),
2052+
IntPtrConstant(JSDispatchEntry::kObjectPointerShift)));
2053+
#else
20462054
WordShr(value, UintPtrConstant(JSDispatchEntry::kObjectPointerShift));
2055+
#endif /* __illumos__ and 64-bit */
20472056
} else {
20482057
shifted_value = UintPtrAdd(
20492058
WordShr(value, UintPtrConstant(JSDispatchEntry::kObjectPointerShift)),

deps/v8/src/sandbox/js-dispatch-table-inl.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ void JSDispatchEntry::MakeJSDispatchEntry(Address object, Address entrypoint,
2525
uint16_t parameter_count,
2626
bool mark_as_alive) {
2727
DCHECK_EQ(object & kHeapObjectTag, 0);
28+
#if !defined(__illumos__) || !defined(V8_TARGET_ARCH_64_BIT)
2829
DCHECK_EQ((((object - kObjectPointerOffset) << kObjectPointerShift) >>
2930
kObjectPointerShift) +
3031
kObjectPointerOffset,
3132
object);
3233
DCHECK_EQ((object - kObjectPointerOffset) + kObjectPointerOffset, object);
3334
DCHECK_LT((object - kObjectPointerOffset),
3435
1ULL << ((sizeof(encoded_word_) * 8) - kObjectPointerShift));
36+
#endif /* __illumos__ & 64-bit */
3537

3638
Address payload = ((object - kObjectPointerOffset) << kObjectPointerShift) |
3739
(parameter_count & kParameterCountMask);
@@ -57,8 +59,16 @@ Address JSDispatchEntry::GetCodePointer() const {
5759
// and so may be 0 or 1 here. As the return value is a tagged pointer, the
5860
// bit must be 1 when returned, so we need to set it here.
5961
Address payload = encoded_word_.load(std::memory_order_acquire);
62+
#if defined(__illumos__) && defined(V8_TARGET_ARCH_64_BIT)
63+
// Unsigned types won't sign-extend on shift-right, but we need to do
64+
// this with illumos VA48 addressing.
65+
DCHECK_EQ(kObjectPointerOffset, 0);
66+
return (Address)((intptr_t)payload >> (int)kObjectPointerShift) |
67+
kHeapObjectTag;
68+
#else
6069
return ((payload >> kObjectPointerShift) + kObjectPointerOffset) |
6170
kHeapObjectTag;
71+
#endif /* __illumos__ & 64-bit */
6272
}
6373

6474
Tagged<Code> JSDispatchEntry::GetCode() const {
@@ -216,7 +226,12 @@ void JSDispatchEntry::MakeFreelistEntry(uint32_t next_entry_index) {
216226
bool JSDispatchEntry::IsFreelistEntry() const {
217227
#ifdef V8_TARGET_ARCH_64_BIT
218228
auto entrypoint = entrypoint_.load(std::memory_order_relaxed);
229+
#ifdef __illumos__
230+
// See the illumos definition of kFreeEntryTag for why we have to do this.
231+
return (entrypoint & 0xffff000000000000ull) == kFreeEntryTag;
232+
#else
219233
return (entrypoint & kFreeEntryTag) == kFreeEntryTag;
234+
#endif /* __illumos__ */
220235
#else
221236
return next_free_entry_.load(std::memory_order_relaxed) != 0;
222237
#endif

deps/v8/src/sandbox/js-dispatch-table.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,22 @@ struct JSDispatchEntry {
9090
#if defined(V8_TARGET_ARCH_64_BIT)
9191
// Freelist entries contain the index of the next free entry in their lower 32
9292
// bits and are tagged with this tag.
93+
#ifdef __illumos__
94+
// In illumos 64-bit apps, pointers are allocated both the bottom 2^47 range
95+
// AND the top 2^47 range in the 64-bit space. Instead of 47 bits of VA space
96+
// we have 48 bits. This means, however, the top 16-bits may be 0xffff. We
97+
// therefore pick a different value for the kFreeEntryTag. If/when we go to
98+
// VA57, aka 5-level paging, we'll need to revisit this again, as will node
99+
// by default, since the fixed-bits on the high end will shrink from top
100+
// 16-bits to top 8-bits.
101+
//
102+
// Unless illumos ships an Oracle-Solaris-like VA47 link-time options to
103+
// restrict pointers from allocating from above the Virtual Address hole,
104+
// we need to be mindful of this.
105+
static constexpr Address kFreeEntryTag = 0xfeed000000000000ull;
106+
#else
93107
static constexpr Address kFreeEntryTag = 0xffff000000000000ull;
108+
#endif /* __illumos__ */
94109
#ifdef V8_TARGET_BIG_ENDIAN
95110
// 2-byte parameter count is on the least significant side of encoded_word_.
96111
static constexpr int kBigEndianParamCountOffset =

0 commit comments

Comments
 (0)