Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index 978704ac54286aff224e370390121e305cd45100..fbd7af2a036d13a6287ed4c14ae3a8e42ae9f5e0 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -4000,7 +4000,7 @@ int Map::GetInObjectPropertyOffset(int index) { |
int HeapObject::SizeFromMap(Map* map) { |
- int instance_size = map->instance_size(); |
+ int instance_size = map->nobarrier_instance_size(); |
if (instance_size != kVariableSizeSentinel) return instance_size; |
// Only inline the most frequent cases. |
int instance_type = static_cast<int>(map->instance_type()); |
@@ -4051,6 +4051,35 @@ void Map::set_instance_size(int value) { |
} |
+int Map::nobarrier_instance_size() { |
+ // Our atomics API does not support byte accessors. Hence, we have to manually |
+ // read out atomically the whole word and mask out the upper bytes. |
+ ASSERT(kInstanceSizeOffset % kPointerSize == 0); |
+ AtomicWord value = reinterpret_cast<AtomicWord>( |
+ NO_BARRIER_READ_FIELD(this, kInstanceSizeOffset)); |
+ return (value & 0xff) << kPointerSizeLog2; |
+} |
+ |
+ |
+void Map::nobarrier_set_instance_size(int value) { |
+ ASSERT_EQ(0, value & (kPointerSize - 1)); |
+ value >>= kPointerSizeLog2; |
+ ASSERT(0 <= value && value < 256); |
+ |
+ // Our atomics API does not support byte accessors. Hence, we have to manually |
+ // read out atomically the whole word, update the last byte and write back the |
+ // modified word. |
+ ASSERT(kInstanceSizeOffset % kPointerSize == 0); |
+ AtomicWord size_field = reinterpret_cast<AtomicWord>( |
+ NO_BARRIER_READ_FIELD(this, kInstanceSizeOffset)); |
+ size_field >>= 8; |
Hannes Payer (out of office)
2014/04/07 12:31:13
Do you prefer masking ifdef style?
|
+ size_field <<= 8; |
+ size_field |= value; |
+ NO_BARRIER_WRITE_FIELD( |
+ this, kInstanceSizeOffset, reinterpret_cast<Object*>(size_field)); |
+} |
+ |
+ |
void Map::set_inobject_properties(int value) { |
ASSERT(0 <= value && value < 256); |
WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value)); |