Index: src/objects/object-macros.h |
diff --git a/src/objects/object-macros.h b/src/objects/object-macros.h |
index c03026d51b5e669b5bb0c38a1ef24b7073641ff1..127223b86dbc1e04d3e2c7fe5bf8f30db063bc8f 100644 |
--- a/src/objects/object-macros.h |
+++ b/src/objects/object-macros.h |
@@ -35,6 +35,212 @@ |
return reinterpret_cast<const type*>(object); \ |
} |
+#define INT_ACCESSORS(holder, name, offset) \ |
+ int holder::name() const { return READ_INT_FIELD(this, offset); } \ |
+ void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } |
+ |
+#define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \ |
+ set_condition) \ |
+ type* holder::name() const { \ |
+ DCHECK(get_condition); \ |
+ return type::cast(READ_FIELD(this, offset)); \ |
+ } \ |
+ void holder::set_##name(type* value, WriteBarrierMode mode) { \ |
+ DCHECK(set_condition); \ |
+ WRITE_FIELD(this, offset, value); \ |
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ |
+ } |
+#define ACCESSORS_CHECKED(holder, name, type, offset, condition) \ |
+ ACCESSORS_CHECKED2(holder, name, type, offset, condition, condition) |
+ |
+#define ACCESSORS(holder, name, type, offset) \ |
+ ACCESSORS_CHECKED(holder, name, type, offset, true) |
+ |
+// Getter that returns a Smi as an int and writes an int as a Smi. |
+#define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \ |
+ int holder::name() const { \ |
+ DCHECK(condition); \ |
+ Object* value = READ_FIELD(this, offset); \ |
+ return Smi::cast(value)->value(); \ |
+ } \ |
+ void holder::set_##name(int value) { \ |
+ DCHECK(condition); \ |
+ WRITE_FIELD(this, offset, Smi::FromInt(value)); \ |
+ } |
+ |
+#define SMI_ACCESSORS(holder, name, offset) \ |
+ SMI_ACCESSORS_CHECKED(holder, name, offset, true) |
+ |
+#define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset) \ |
+ int holder::synchronized_##name() const { \ |
+ Object* value = ACQUIRE_READ_FIELD(this, offset); \ |
+ return Smi::cast(value)->value(); \ |
+ } \ |
+ void holder::synchronized_set_##name(int value) { \ |
+ RELEASE_WRITE_FIELD(this, offset, Smi::FromInt(value)); \ |
+ } |
+ |
+#define NOBARRIER_SMI_ACCESSORS(holder, name, offset) \ |
+ int holder::nobarrier_##name() const { \ |
+ Object* value = NOBARRIER_READ_FIELD(this, offset); \ |
+ return Smi::cast(value)->value(); \ |
+ } \ |
+ void holder::nobarrier_set_##name(int value) { \ |
+ NOBARRIER_WRITE_FIELD(this, offset, Smi::FromInt(value)); \ |
+ } |
+ |
+#define BOOL_GETTER(holder, field, name, offset) \ |
+ bool holder::name() const { return BooleanBit::get(field(), offset); } |
+ |
+#define BOOL_ACCESSORS(holder, field, name, offset) \ |
+ bool holder::name() const { return BooleanBit::get(field(), offset); } \ |
+ void holder::set_##name(bool value) { \ |
+ set_##field(BooleanBit::set(field(), offset, value)); \ |
+ } |
+ |
+#define TYPE_CHECKER(type, instancetype) \ |
+ bool HeapObject::Is##type() const { \ |
+ return map()->instance_type() == instancetype; \ |
+ } |
+ |
+#define FIELD_ADDR(p, offset) \ |
+ (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) |
+ |
+#define FIELD_ADDR_CONST(p, offset) \ |
+ (reinterpret_cast<const byte*>(p) + offset - kHeapObjectTag) |
+ |
+#define READ_FIELD(p, offset) \ |
+ (*reinterpret_cast<Object* const*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define ACQUIRE_READ_FIELD(p, offset) \ |
+ reinterpret_cast<Object*>(base::Acquire_Load( \ |
+ reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR_CONST(p, offset)))) |
+ |
+#define NOBARRIER_READ_FIELD(p, offset) \ |
+ reinterpret_cast<Object*>(base::NoBarrier_Load( \ |
+ reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR_CONST(p, offset)))) |
+ |
+#ifdef V8_CONCURRENT_MARKING |
+#define WRITE_FIELD(p, offset, value) \ |
+ base::NoBarrier_Store( \ |
+ reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \ |
+ reinterpret_cast<base::AtomicWord>(value)); |
+#else |
+#define WRITE_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value) |
+#endif |
+ |
+#define RELEASE_WRITE_FIELD(p, offset, value) \ |
+ base::Release_Store( \ |
+ reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \ |
+ reinterpret_cast<base::AtomicWord>(value)); |
+ |
+#define NOBARRIER_WRITE_FIELD(p, offset, value) \ |
+ base::NoBarrier_Store( \ |
+ reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \ |
+ reinterpret_cast<base::AtomicWord>(value)); |
+ |
+#define WRITE_BARRIER(heap, object, offset, value) \ |
+ heap->incremental_marking()->RecordWrite( \ |
+ object, HeapObject::RawField(object, offset), value); \ |
+ heap->RecordWrite(object, offset, value); |
+ |
+#define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode) \ |
+ if (mode != SKIP_WRITE_BARRIER) { \ |
+ if (mode == UPDATE_WRITE_BARRIER) { \ |
+ heap->incremental_marking()->RecordWrite( \ |
+ object, HeapObject::RawField(object, offset), value); \ |
+ } \ |
+ heap->RecordWrite(object, offset, value); \ |
+ } |
+ |
+#define READ_DOUBLE_FIELD(p, offset) \ |
+ ReadDoubleValue(FIELD_ADDR_CONST(p, offset)) |
+ |
+#define WRITE_DOUBLE_FIELD(p, offset, value) \ |
+ WriteDoubleValue(FIELD_ADDR(p, offset), value) |
+ |
+#define READ_INT_FIELD(p, offset) \ |
+ (*reinterpret_cast<const int*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_INT_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_INTPTR_FIELD(p, offset) \ |
+ (*reinterpret_cast<const intptr_t*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_INTPTR_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_UINT8_FIELD(p, offset) \ |
+ (*reinterpret_cast<const uint8_t*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_UINT8_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<uint8_t*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_INT8_FIELD(p, offset) \ |
+ (*reinterpret_cast<const int8_t*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_INT8_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<int8_t*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_UINT16_FIELD(p, offset) \ |
+ (*reinterpret_cast<const uint16_t*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_UINT16_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_INT16_FIELD(p, offset) \ |
+ (*reinterpret_cast<const int16_t*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_INT16_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<int16_t*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_UINT32_FIELD(p, offset) \ |
+ (*reinterpret_cast<const uint32_t*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_UINT32_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_INT32_FIELD(p, offset) \ |
+ (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_INT32_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_FLOAT_FIELD(p, offset) \ |
+ (*reinterpret_cast<const float*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_FLOAT_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<float*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_UINT64_FIELD(p, offset) \ |
+ (*reinterpret_cast<const uint64_t*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_UINT64_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<uint64_t*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_INT64_FIELD(p, offset) \ |
+ (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define WRITE_INT64_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define READ_BYTE_FIELD(p, offset) \ |
+ (*reinterpret_cast<const byte*>(FIELD_ADDR_CONST(p, offset))) |
+ |
+#define NOBARRIER_READ_BYTE_FIELD(p, offset) \ |
+ static_cast<byte>(base::NoBarrier_Load( \ |
+ reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)))) |
+ |
+#define WRITE_BYTE_FIELD(p, offset, value) \ |
+ (*reinterpret_cast<byte*>(FIELD_ADDR(p, offset)) = value) |
+ |
+#define NOBARRIER_WRITE_BYTE_FIELD(p, offset, value) \ |
+ base::NoBarrier_Store( \ |
+ reinterpret_cast<base::Atomic8*>(FIELD_ADDR(p, offset)), \ |
+ static_cast<base::Atomic8>(value)); |
+ |
#ifdef VERIFY_HEAP |
#define DECLARE_VERIFIER(Name) void Name##Verify(); |
#else |