5 #ifndef V8_OBJECTS_PROPERTY_ARRAY_INL_H_ 6 #define V8_OBJECTS_PROPERTY_ARRAY_INL_H_ 8 #include "src/objects/property-array.h" 10 #include "src/heap/heap-write-barrier-inl.h" 11 #include "src/objects/heap-object-inl.h" 12 #include "src/objects/smi-inl.h" 15 #include "src/objects/object-macros.h" 20 OBJECT_CONSTRUCTORS_IMPL(PropertyArray, HeapObjectPtr)
21 CAST_ACCESSOR2(PropertyArray)
23 Object* PropertyArray::get(
int index)
const {
25 DCHECK_LE(index, this->length());
26 return RELAXED_READ_FIELD(
this, kHeaderSize + index * kPointerSize);
29 void PropertyArray::set(
int index, Object* value) {
30 DCHECK(IsPropertyArray());
32 DCHECK_LT(index, this->length());
33 int offset = kHeaderSize + index * kPointerSize;
34 RELAXED_WRITE_FIELD(
this, offset, value);
35 WRITE_BARRIER(
this, offset, value);
38 void PropertyArray::set(
int index, Object* value, WriteBarrierMode mode) {
40 DCHECK_LT(index, this->length());
41 int offset = kHeaderSize + index * kPointerSize;
42 RELAXED_WRITE_FIELD(
this, offset, value);
43 CONDITIONAL_WRITE_BARRIER(
this, offset, value, mode);
46 ObjectSlot PropertyArray::data_start() {
return RawField(kHeaderSize); }
48 int PropertyArray::length()
const {
49 Object* value_obj = READ_FIELD(
this, kLengthAndHashOffset);
50 int value = Smi::ToInt(value_obj);
51 return LengthField::decode(value);
54 void PropertyArray::initialize_length(
int len) {
55 SLOW_DCHECK(len >= 0);
56 SLOW_DCHECK(len < LengthField::kMax);
57 WRITE_FIELD(
this, kLengthAndHashOffset, Smi::FromInt(len));
60 int PropertyArray::synchronized_length()
const {
61 Object* value_obj = ACQUIRE_READ_FIELD(
this, kLengthAndHashOffset);
62 int value = Smi::ToInt(value_obj);
63 return LengthField::decode(value);
66 int PropertyArray::Hash()
const {
67 Object* value_obj = READ_FIELD(
this, kLengthAndHashOffset);
68 int value = Smi::ToInt(value_obj);
69 return HashField::decode(value);
72 void PropertyArray::SetHash(
int hash) {
73 Object* value_obj = READ_FIELD(
this, kLengthAndHashOffset);
74 int value = Smi::ToInt(value_obj);
75 value = HashField::update(value, hash);
76 WRITE_FIELD(
this, kLengthAndHashOffset, Smi::FromInt(value));
82 #include "src/objects/object-macros-undef.h" 84 #endif // V8_OBJECTS_PROPERTY_ARRAY_INL_H_