Skip to content

Commit 5fb74d1

Browse files
Dan McDonaldnodejs-github-bot
authored andcommitted
deps: patch V8 for illumos
illumos pointers are VA48, can allocate from the top of the 64-bit range as well. Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: #66537 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent ea41e65 commit 5fb74d1

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

‎common.gypi‎

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

4545
# Reset this number to 0 on major V8 upgrades.
4646
# Increment by one for each non-official patch applied to deps/v8.
47-
'v8_embedder_string': '-node.11',
47+
'v8_embedder_string': '-node.12',
4848

4949
##### V8 defaults for Node.js #####
5050

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,16 @@ TNode<Code> CodeStubAssembler::LoadCodeObjectFromJSDispatchTable(
22172217
TNode<UintPtrT> shifted_value;
22182218
if (JSDispatchEntry::kObjectPointerOffset == 0) {
22192219
shifted_value =
2220+
#if defined(__illumos__) && defined(V8_HOST_ARCH_64_BIT)
2221+
// Pointers in illumos span both the low 2^47 range and the high 2^47 range
2222+
// as well. Checking the high bit being set in illumos means all higher bits
2223+
// need to be set to 1 after shifting right.
2224+
// Use WordSar() so any high-bit check wouldn't be necessary.
2225+
UncheckedCast<UintPtrT>(WordSar(UncheckedCast<IntPtrT>(value),
2226+
IntPtrConstant(JSDispatchEntry::kObjectPointerShift)));
2227+
#else
22202228
WordShr(value, UintPtrConstant(JSDispatchEntry::kObjectPointerShift));
2229+
#endif /* __illumos__ and 64-bit */
22212230
} else {
22222231
shifted_value = UintPtrAdd(
22232232
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
@@ -29,13 +29,15 @@ void JSDispatchEntry::MakeJSDispatchEntry(Address object, Address entrypoint,
2929
bool mark_as_alive) {
3030
DCHECK_NE(entrypoint, kNullAddress);
3131
DCHECK_EQ(object & kHeapObjectTag, 0);
32+
#if !defined(__illumos__) || !defined(V8_TARGET_ARCH_64_BIT)
3233
DCHECK_EQ((((object - kObjectPointerOffset) << kObjectPointerShift) >>
3334
kObjectPointerShift) +
3435
kObjectPointerOffset,
3536
object);
3637
DCHECK_EQ((object - kObjectPointerOffset) + kObjectPointerOffset, object);
3738
DCHECK_LT((object - kObjectPointerOffset),
3839
1ULL << ((sizeof(encoded_word_) * 8) - kObjectPointerShift));
40+
#endif /* __illumos__ & 64-bit */
3941

4042
Address payload = ((object - kObjectPointerOffset) << kObjectPointerShift) |
4143
(parameter_count & kParameterCountMask);
@@ -61,8 +63,16 @@ Address JSDispatchEntry::GetCodePointer() const {
6163
// and so may be 0 or 1 here. As the return value is a tagged pointer, the
6264
// bit must be 1 when returned, so we need to set it here.
6365
Address payload = encoded_word_.load(std::memory_order_acquire);
66+
#if defined(__illumos__) && defined(V8_TARGET_ARCH_64_BIT)
67+
// Unsigned types won't sign-extend on shift-right, but we need to do
68+
// this with illumos VA48 addressing.
69+
DCHECK_EQ(kObjectPointerOffset, 0);
70+
return (Address)((intptr_t)payload >> (int)kObjectPointerShift) |
71+
kHeapObjectTag;
72+
#else
6473
return ((payload >> kObjectPointerShift) + kObjectPointerOffset) |
6574
kHeapObjectTag;
75+
#endif /* __illumos__ & 64-bit */
6676
}
6777

6878
Tagged<Code> JSDispatchEntry::GetCode() const {
@@ -269,7 +279,12 @@ void JSDispatchEntry::MakeFreelistEntry(uint32_t next_entry_index) {
269279

270280
#ifdef V8_TARGET_ARCH_64_BIT
271281
bool JSDispatchEntry::IsFreelistEntry(Address entrypoint) const {
282+
#ifdef __illumos__
283+
// See the illumos definition of kFreeEntryTag for why we have to do this.
284+
return (entrypoint & 0xffff000000000000ull) == kFreeEntryTag;
285+
#else
272286
return (entrypoint & kFreeEntryTag) == kFreeEntryTag;
287+
#endif /* __illumos__ */
273288
}
274289
#endif
275290

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

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

0 commit comments

Comments
 (0)