[snapshot] Fix mksnapshot fails

... when enable V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE.
When enable V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE and
V8_EXTERNAL_CODE_SPACE, because of the external code space,
we could not get the isolate using RoundDown directly, which
may cause wrong isolate address. We should use memory chunk
like in V8_COMPRESS_POINTERS_IN_SHARED_CAGE instead.

Bug: v8:12664, v8:12715
Change-Id: Ib78770fdb66fa509d6d8acc836803ec9d6804ef1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3532599
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#79774}
This commit is contained in:
jameslahm 2022-04-04 23:12:14 +08:00 committed by V8 LUCI CQ
parent 43232bf024
commit 8502508962

View File

@ -42,7 +42,8 @@ V8_INLINE Heap* GetHeapFromWritableObject(HeapObject object) {
#if defined V8_ENABLE_THIRD_PARTY_HEAP #if defined V8_ENABLE_THIRD_PARTY_HEAP
return Heap::GetIsolateFromWritableObject(object)->heap(); return Heap::GetIsolateFromWritableObject(object)->heap();
#elif defined V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE #elif defined(V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE) && \
!defined(V8_EXTERNAL_CODE_SPACE)
Isolate* isolate = Isolate* isolate =
Isolate::FromRootAddress(GetIsolateRootAddress(object.ptr())); Isolate::FromRootAddress(GetIsolateRootAddress(object.ptr()));
DCHECK_NOT_NULL(isolate); DCHECK_NOT_NULL(isolate);
@ -57,7 +58,8 @@ V8_INLINE Heap* GetHeapFromWritableObject(HeapObject object) {
V8_INLINE Isolate* GetIsolateFromWritableObject(HeapObject object) { V8_INLINE Isolate* GetIsolateFromWritableObject(HeapObject object) {
#ifdef V8_ENABLE_THIRD_PARTY_HEAP #ifdef V8_ENABLE_THIRD_PARTY_HEAP
return Heap::GetIsolateFromWritableObject(object); return Heap::GetIsolateFromWritableObject(object);
#elif defined V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE #elif defined(V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE) && \
!defined(V8_EXTERNAL_CODE_SPACE)
Isolate* isolate = Isolate* isolate =
Isolate::FromRootAddress(GetIsolateRootAddress(object.ptr())); Isolate::FromRootAddress(GetIsolateRootAddress(object.ptr()));
DCHECK_NOT_NULL(isolate); DCHECK_NOT_NULL(isolate);