Permalink
Browse files

Wrap up all access to flag manipulation in methods

  • Loading branch information...
1 parent 297239a commit 6872d8b2c22779a703399b38cc997c3451b31669 @dbussink dbussink committed Oct 5, 2012
Showing with 21 additions and 9 deletions.
  1. +2 −2 vm/gc/immix.cpp
  2. +2 −2 vm/gc/marksweep.cpp
  3. +2 −2 vm/objectmemory.cpp
  4. +3 −3 vm/oop.cpp
  5. +12 −0 vm/oop.hpp
View
@@ -95,8 +95,8 @@ namespace rubinius {
obj->inflated_header()->set_object(obj);
}
- obj->flags().zone = MatureObjectZone;
- obj->flags().age = 0;
+ obj->set_zone(MatureObjectZone);
+ obj->set_age(0);
obj->set_in_immix();
View
@@ -100,8 +100,8 @@ namespace rubinius {
obj->inflated_header()->set_object(obj);
}
- obj->flags().zone = MatureObjectZone;
- obj->flags().age = 0;
+ obj->set_zone(MatureObjectZone);
+ obj->set_age(0);
orig->set_forward(obj);
View
@@ -400,14 +400,14 @@ namespace rubinius {
break;
}
- ih->flags().LockContended = 0;
-
new_val.all_flags = ih;
new_val.f.inflated = 1;
// Try it all over again if it fails.
if(!obj->header.atomic_set(orig, new_val)) continue;
+ obj->clear_lock_contended();
+
if(cDebugThreading) {
std::cerr << "[LOCK " << state->vm()->thread_id() << " inflated lock for contention.]" << std::endl;
}
View
@@ -28,17 +28,17 @@ namespace rubinius {
HeaderWord orig = header;
ih->reset_object(this);
- if(!ih->update(state, header)) return false;
+ if(!ih->update(state, orig)) return false;
- HeaderWord new_val = header;
+ HeaderWord new_val = orig;
new_val.all_flags = ih;
new_val.f.inflated = 1;
// Do a spin update so if someone else is trying to update it at the same time
// we catch that and keep trying until we get our version in.
while(!header.atomic_set(orig, new_val)) {
orig = header;
- if(!ih->update(state, header)) return false;
+ if(!ih->update(state, orig)) return false;
}
return true;
View
@@ -312,6 +312,10 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
void unlock_mutex_for_terminate(STATE, GCToken gct);
void wakeup();
+
+ private:
+
+
};
class ObjectHeader {
@@ -590,6 +594,14 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
flags().Remember = 0;
}
+ void set_lock_contended() {
+ flags().LockContended = 1;
+ }
+
+ void clear_lock_contended() {
+ flags().LockContended = 0;
+ }
+
bool is_frozen_p() const {
return flags().Frozen == 1;
}

0 comments on commit 6872d8b

Please sign in to comment.