Reviewers: Michael Starzinger, jarin,

Message:
There a two problems with that cl:
1) The instance size accessors are part of the objects API. We should remove
these accessors as soon as we have the proper abstractions on the GC side.
2) The atomic byte accessors are ugly, but we cannot make them part of the
atomics API since we took that code from chromium. If we have to access another atomic byte somewhere in the code, we should probably factor the accessors out.

Description:
Allow race-full access of map instance size when sweeping concurrently.

BUG=

Please review this at https://codereview.chromium.org/227133007/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+34, -1 lines):
  M src/objects.h
  M src/objects-inl.h


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;
+  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));
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index ff9f45721f1498a181015755bb9759b670f53aa1..a77e387167b9d03b145c5732781c7202ec4600c3 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -5986,6 +5986,10 @@ class Map: public HeapObject {
   inline int instance_size();
   inline void set_instance_size(int value);

+  // Get and set the instance size of a map using no barrier semantics.
+  inline int nobarrier_instance_size();
+  inline void nobarrier_set_instance_size(int value);
+
   // Count of properties allocated in the object.
   inline int inobject_properties();
   inline void set_inobject_properties(int value);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to