Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1301)

Unified Diff: src/objects-inl.h

Issue 227133007: Allow race-full access of map instance size when sweeping concurrently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 978704ac54286aff224e370390121e305cd45100..c4d8c88108dedaec68d5f6e99e78f1028e259ba6 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,16 @@ 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);
Jarin 2014/04/08 20:11:11 STATIC_ASSERT?
+ AtomicWord value = reinterpret_cast<AtomicWord>(
+ NO_BARRIER_READ_FIELD(this, kInstanceSizeOffset));
+ return (value & 0xff) << kPointerSizeLog2;
+}
+
+
void Map::set_inobject_properties(int value) {
ASSERT(0 <= value && value < 256);
WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value));
@@ -4289,6 +4299,36 @@ bool Map::CanOmitMapChecks() {
}
+void Map::Shrink(int slack) {
+ ASSERT(kInstanceSizeOffset % kPointerSize == 0);
Jarin 2014/04/08 20:11:11 STATIC_ASSERT? Tiny nit - since you are using Atom
+ ASSERT(kInstanceSizeOffset + kInObjectPropertiesByte ==
+ kInObjectPropertiesOffset);
+
+ // Our atomics API does not support byte accessors. Hence, we have to manually
+ // read out atomically the whole word, update the instance size and in object
+ // properties byte and write back the modified word.
+ Atomic32 first_word = NoBarrier_Load(reinterpret_cast<Atomic32*>(
+ FIELD_ADDR(this, kInstanceSizeOffset)));
+
+ // The first byte contains the instance size and the second byte (8 bits left)
+ // is the in object properties byte.
+ int difference = (slack << 8) + slack;
Michael Starzinger 2014/04/08 11:34:22 I don't even ... OMG.
Jarin 2014/04/08 20:11:11 Replace 8 with kInObjectPropertiesByte * kBitsPer
+ first_word -= difference;
+
+ ASSERT(0 <= (first_word & 0xff) && (first_word & 0xff) < 256);
+ ASSERT(0 <= ((first_word & 0xff00) >> 8) &&
+ ((first_word & 0xff00) >> 8) < 256);
Jarin 2014/04/08 20:11:11 The two assertions above do not seem to test any i
+
+ NoBarrier_Store(reinterpret_cast<Atomic32*>(
+ FIELD_ADDR(this, kInstanceSizeOffset)), first_word);
+
+ set_unused_property_fields(unused_property_fields() - slack);
+
+ // Visitor id might depend on the instance size, recalculate it.
+ set_visitor_id(StaticVisitorBase::GetVisitorId(this));
+}
+
+
int DependentCode::number_of_entries(DependencyGroup group) {
if (length() == 0) return 0;
return Smi::cast(get(group))->value();
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698