diff --git a/src/heap/factory-base.cc b/src/heap/factory-base.cc index 1fbf8ecbec..a4dae20eec 100644 --- a/src/heap/factory-base.cc +++ b/src/heap/factory-base.cc @@ -81,6 +81,7 @@ Handle FactoryBase::NewCodeDataContainer( SKIP_WRITE_BARRIER); data_container.set_kind_specific_flags(flags, kRelaxedStore); if (V8_EXTERNAL_CODE_SPACE_BOOL) { + data_container.set_code_cage_base(impl()->isolate()->code_cage_base()); Isolate* isolate_for_heap_sandbox = impl()->isolate_for_heap_sandbox(); data_container.AllocateExternalPointerEntries(isolate_for_heap_sandbox); data_container.set_raw_code(Smi::zero(), SKIP_WRITE_BARRIER); diff --git a/src/objects/code-inl.h b/src/objects/code-inl.h index 30d0b8d0e9..33eed5072d 100644 --- a/src/objects/code-inl.h +++ b/src/objects/code-inl.h @@ -879,21 +879,20 @@ static_assert(!V8_EXTERNAL_CODE_SPACE_BOOL, "for big endian architectures"); #endif -DEF_GETTER(CodeDataContainer, raw_code, Object) { +Object CodeDataContainer::raw_code() const { + PtrComprCageBase cage_base = code_cage_base(); + return CodeDataContainer::raw_code(cage_base); +} + +Object CodeDataContainer::raw_code(PtrComprCageBase cage_base) const { CHECK(V8_EXTERNAL_CODE_SPACE_BOOL); - // Given the fields layout we can write the Code reference as a full word - // (see the static asserts above). - Address* p = reinterpret_cast(address() + kCodeOffset); - Object value = Object(*p); + Object value = TaggedField::load(cage_base, *this); return value; } void CodeDataContainer::set_raw_code(Object value, WriteBarrierMode mode) { CHECK(V8_EXTERNAL_CODE_SPACE_BOOL); - // Given the fields layout we can write the Code reference as a full word - // (see the static asserts above). - Address* p = reinterpret_cast(address() + kCodeOffset); - *p = value.ptr(); + TaggedField::store(*this, value); CONDITIONAL_WRITE_BARRIER(*this, kCodeOffset, value, mode); }