@@ -23,6 +23,17 @@ 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)
27+ // See VA hole discussion in js-dispatch-table.h
28+ if (((uintptr_t )object >> 47 ) != 0 ) {
29+ // Above VA hole.
30+ // If illumos changes the VA hole, this may have to be revisited.
31+ CHECK_EQ ((object & 0xffff800000000000ull ), 0xffff800000000000ull );
32+ } // Else implies addr is below the VA hole.
33+
34+ Address payload = (object << kObjectPointerShift ) |
35+ (parameter_count & kParameterCountMask );
36+ #else
2637 DCHECK_EQ ((((object - kObjectPointerOffset ) << kObjectPointerShift ) >>
2738 kObjectPointerShift ) +
2839 kObjectPointerOffset ,
@@ -33,6 +44,7 @@ void JSDispatchEntry::MakeJSDispatchEntry(Address object, Address entrypoint,
3344
3445 Address payload = ((object - kObjectPointerOffset ) << kObjectPointerShift ) |
3546 (parameter_count & kParameterCountMask );
47+ #endif /* __illumos__ 64-bit */
3648 DCHECK (!(payload & kMarkingBit ));
3749 if (mark_as_alive) payload |= kMarkingBit ;
3850#ifdef V8_TARGET_ARCH_32_BIT
@@ -55,6 +67,14 @@ Address JSDispatchEntry::GetCodePointer() const {
5567 // and so may be 0 or 1 here. As the return value is a tagged pointer, the
5668 // bit must be 1 when returned, so we need to set it here.
5769 Address payload = encoded_word_.load (std::memory_order_relaxed);
70+ #if defined(__illumos__) && defined(V8_TARGET_ARCH_64_BIT)
71+ // illumos has two values for the higher bits, aka kObjectPointerOffset.
72+ // Lucky us, they are determined by the value of the highest bit in payload,
73+ // and one of them (below the VA hole) is 0.
74+ if (payload < 0x8000000000000000 )
75+ return ((payload >> kObjectPointerShift ) | kHeapObjectTag );
76+ // Else we continue, and the pointer is above the VA hole.
77+ #endif /* __illumos__ */
5878 return ((payload >> kObjectPointerShift ) + kObjectPointerOffset ) |
5979 kHeapObjectTag ;
6080}
@@ -183,11 +203,22 @@ void JSDispatchEntry::SetCodeAndEntrypointPointer(Address new_object,
183203 Address old_payload = encoded_word_.load (std::memory_order_relaxed);
184204 Address marking_bit = old_payload & kMarkingBit ;
185205 Address parameter_count = old_payload & kParameterCountMask ;
206+ #if defined(__illumos__) && defined(V8_TARGET_ARCH_64_BIT)
207+ // See VA hole discussion in js-dispatch-table.h
208+ if (((uintptr_t )new_object >> 47 ) != 0 ) {
209+ // Above VA hole.
210+ // If illumos changes the VA hole, this may have to be revisited.
211+ CHECK_EQ ((new_object & 0xffff800000000000ull ), 0xffff800000000000ull );
212+ } // Else implies addr is below the VA hole.
213+
214+ Address object = (new_object << kObjectPointerShift ) & ~kMarkingBit ;
215+ #else
186216 // We want to preserve the marking bit of the entry. Since that happens to
187217 // be the tag bit of the pointer, we need to explicitly clear it here.
188218 Address object =
189219 ((new_object - kObjectPointerOffset ) << kObjectPointerShift ) &
190220 ~kMarkingBit ;
221+ #endif /* __illumos__ 64-bit */
191222 Address new_payload = object | marking_bit | parameter_count;
192223 encoded_word_.store (new_payload, std::memory_order_relaxed);
193224 entrypoint_.store (new_entrypoint, std::memory_order_relaxed);
@@ -214,7 +245,12 @@ void JSDispatchEntry::MakeFreelistEntry(uint32_t next_entry_index) {
214245bool JSDispatchEntry::IsFreelistEntry () const {
215246#ifdef V8_TARGET_ARCH_64_BIT
216247 auto entrypoint = entrypoint_.load (std::memory_order_relaxed);
248+ #ifdef __illumos__
249+ // See the illumos definition of kFreeEntryTag for why we have to do this.
250+ return (entrypoint & 0xffff000000000000 ) == kFreeEntryTag ;
251+ #else
217252 return (entrypoint & kFreeEntryTag ) == kFreeEntryTag ;
253+ #endif /* __illumos__ */
218254#else
219255 return next_free_entry_.load (std::memory_order_relaxed) != 0 ;
220256#endif
0 commit comments