5 #ifndef V8_OBJECTS_EMBEDDER_DATA_SLOT_INL_H_ 6 #define V8_OBJECTS_EMBEDDER_DATA_SLOT_INL_H_ 8 #include "src/heap/heap-write-barrier-inl.h" 9 #include "src/objects/embedder-data-array.h" 10 #include "src/objects/embedder-data-slot.h" 11 #include "src/objects/js-objects.h" 14 #include "src/objects/object-macros.h" 19 EmbedderDataSlot::EmbedderDataSlot(EmbedderDataArray array,
int entry_index)
20 : SlotBase(FIELD_ADDR(array,
21 EmbedderDataArray::OffsetOfElementAt(entry_index))) {}
23 EmbedderDataSlot::EmbedderDataSlot(JSObject*
object,
int embedder_field_index)
24 : SlotBase(FIELD_ADDR(
25 object, object->GetEmbedderFieldOffset(embedder_field_index))) {}
27 Object* EmbedderDataSlot::load_tagged()
const {
28 return ObjectSlot(address() + kTaggedPayloadOffset).Relaxed_Load();
31 void EmbedderDataSlot::store_smi(Smi value) {
32 ObjectSlot(address() + kTaggedPayloadOffset).Relaxed_Store(value);
36 void EmbedderDataSlot::store_tagged(EmbedderDataArray array,
int entry_index,
38 int slot_offset = EmbedderDataArray::OffsetOfElementAt(entry_index);
39 ObjectSlot(FIELD_ADDR(array, slot_offset + kTaggedPayloadOffset))
40 .Relaxed_Store(ObjectPtr(value->ptr()));
41 WRITE_BARRIER(array, slot_offset, value);
45 void EmbedderDataSlot::store_tagged(JSObject*
object,
int embedder_field_index,
47 int slot_offset =
object->GetEmbedderFieldOffset(embedder_field_index);
48 ObjectSlot(FIELD_ADDR(
object, slot_offset + kTaggedPayloadOffset))
49 .Relaxed_Store(ObjectPtr(value->ptr()));
50 WRITE_BARRIER(
object, slot_offset, value);
53 bool EmbedderDataSlot::ToAlignedPointer(
void** out_pointer)
const {
54 Object* tagged_value =
55 ObjectSlot(address() + kTaggedPayloadOffset).Relaxed_Load();
56 if (!tagged_value->IsSmi())
return false;
57 *out_pointer =
reinterpret_cast<void*
>(tagged_value);
61 bool EmbedderDataSlot::store_aligned_pointer(
void* ptr) {
62 Address value =
reinterpret_cast<Address
>(ptr);
63 if (!HAS_SMI_TAG(value))
return false;
64 ObjectSlot(address() + kTaggedPayloadOffset).Relaxed_Store(Smi(value));
68 EmbedderDataSlot::RawData EmbedderDataSlot::load_raw(
69 const DisallowHeapAllocation& no_gc)
const {
71 ObjectSlot(address() + kTaggedPayloadOffset).Relaxed_Load()->ptr(),
75 void EmbedderDataSlot::store_raw(
const EmbedderDataSlot::RawData& data,
76 const DisallowHeapAllocation& no_gc) {
77 ObjectSlot(address() + kTaggedPayloadOffset)
78 .Relaxed_Store(ObjectPtr(data.data_[0]));
84 #include "src/objects/object-macros-undef.h" 86 #endif // V8_OBJECTS_EMBEDDER_DATA_SLOT_INL_H_