Skip to content

Commit 9f7c68d

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.
1 parent 51ab753 commit 9f7c68d

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.5',
41+
'v8_embedder_string': '-node.6',
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
@@ -1993,7 +1993,16 @@ TNode<Code> CodeStubAssembler::LoadCodeObjectFromJSDispatchTable(
19931993
TNode<UintPtrT> shifted_value;
19941994
if (JSDispatchEntry::kObjectPointerOffset == 0) {
19951995
shifted_value =
1996+
#if defined(__illumos__) && defined(V8_HOST_ARCH_64_BIT)
1997+
// Pointers in illumos span both the low 2^47 range and the high 2^47 range
1998+
// as well. Checking the high bit being set in illumos means all higher bits
1999+
// need to be set to 1 after shifting right.
2000+
// Use WordSar() so any high-bit check wouldn't be necessary.
2001+
UncheckedCast<UintPtrT>(WordSar(UncheckedCast<IntPtrT>(value),
2002+
IntPtrConstant(JSDispatchEntry::kObjectPointerShift)));
2003+
#else
19962004
WordShr(value, UintPtrConstant(JSDispatchEntry::kObjectPointerShift));
2005+
#endif /* __illumos__ and 64-bit */
19972006
} else {
19982007
shifted_value = UintPtrAdd(
19992008
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
@@ -23,13 +23,15 @@ void JSDispatchEntry::MakeJSDispatchEntry(Address object, Address entrypoint,
2323
uint16_t parameter_count,
2424
bool mark_as_alive) {
2525
DCHECK_EQ(object & kHeapObjectTag, 0);
26+
#if !defined(__illumos__) || !defined(V8_TARGET_ARCH_64_BIT)
2627
DCHECK_EQ((((object - kObjectPointerOffset) << kObjectPointerShift) >>
2728
kObjectPointerShift) +
2829
kObjectPointerOffset,
2930
object);
3031
DCHECK_EQ((object - kObjectPointerOffset) + kObjectPointerOffset, object);
3132
DCHECK_LT((object - kObjectPointerOffset),
3233
1ULL << ((sizeof(encoded_word_) * 8) - kObjectPointerShift));
34+
#endif /* __illumos__ & 64-bit */
3335

3436
Address payload = ((object - kObjectPointerOffset) << kObjectPointerShift) |
3537
(parameter_count & kParameterCountMask);
@@ -55,8 +57,16 @@ Address JSDispatchEntry::GetCodePointer() const {
5557
// and so may be 0 or 1 here. As the return value is a tagged pointer, the
5658
// bit must be 1 when returned, so we need to set it here.
5759
Address payload = encoded_word_.load(std::memory_order_relaxed);
60+
#if defined(__illumos__) && defined(V8_TARGET_ARCH_64_BIT)
61+
// Unsigned types won't sign-extend on shift-right, but we need to do
62+
// this with illumos VA48 addressing.
63+
DCHECK_EQ(kObjectPointerOffset, 0);
64+
return (Address)((intptr_t)payload >> (int)kObjectPointerShift) |
65+
kHeapObjectTag;
66+
#else
5867
return ((payload >> kObjectPointerShift) + kObjectPointerOffset) |
5968
kHeapObjectTag;
69+
#endif /* __illumos__ & 64-bit */
6070
}
6171

6272
Tagged<Code> JSDispatchEntry::GetCode() const {
@@ -214,7 +224,12 @@ void JSDispatchEntry::MakeFreelistEntry(uint32_t next_entry_index) {
214224
bool JSDispatchEntry::IsFreelistEntry() const {
215225
#ifdef V8_TARGET_ARCH_64_BIT
216226
auto entrypoint = entrypoint_.load(std::memory_order_relaxed);
227+
#ifdef __illumos__
228+
// See the illumos definition of kFreeEntryTag for why we have to do this.
229+
return (entrypoint & 0xffff000000000000ull) == kFreeEntryTag;
230+
#else
217231
return (entrypoint & kFreeEntryTag) == kFreeEntryTag;
232+
#endif /* __illumos__ */
218233
#else
219234
return next_free_entry_.load(std::memory_order_relaxed) != 0;
220235
#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)