[ext-code-space] Fix Code::constant_pool() after refactoring

The Code::constant_pool() segfaulted on configurations with disabled
external code space when it was called on mallocced copy of a Code
object.

Bug: v8:11880
Change-Id: I86919002ef080486f1e4532c3a2d3352f4526508
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3772004
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Patrick Thier <pthier@chromium.org>
Commit-Queue: Patrick Thier <pthier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81811}
This commit is contained in:
ishell@chromium.org 2022-07-19 15:07:54 +02:00 committed by V8 LUCI CQ
parent 3118c60cb5
commit 5edce1b228

View File

@ -587,7 +587,10 @@ bool CodeDataContainer::has_handler_table() const {
int Code::constant_pool_size() const {
const int size = code_comments_offset() - constant_pool_offset();
DCHECK_IMPLIES(!FLAG_enable_embedded_constant_pool, size == 0);
if (!FLAG_enable_embedded_constant_pool) {
DCHECK_EQ(size, 0);
return 0;
}
DCHECK_GE(size, 0);
return size;
}
@ -977,6 +980,7 @@ Address Code::raw_constant_pool() const {
}
Address Code::constant_pool() const {
if (!has_constant_pool()) return kNullAddress;
return V8_UNLIKELY(is_off_heap_trampoline())
? OffHeapConstantPoolAddress(*this, builtin_id())
: raw_constant_pool();
@ -984,6 +988,7 @@ Address Code::constant_pool() const {
#ifdef V8_EXTERNAL_CODE_SPACE
Address CodeDataContainer::constant_pool() const {
if (!has_constant_pool()) return kNullAddress;
return V8_UNLIKELY(is_off_heap_trampoline())
? OffHeapConstantPoolAddress(*this, builtin_id())
: code().raw_constant_pool();