Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ffd3943b8bcd
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7d071f0cfe85
Choose a head ref
  • 3 commits
  • 6 files changed
  • 1 contributor

Commits on Mar 28, 2016

  1. Copy the full SHA
    bc2c1cf View commit details
  2. Added GC cycle to object header.

    This is a temporary mechanism to help identify when objects are being created.
    It will be removed when the memory regions are reworked.
    brixen committed Mar 28, 2016
    Copy the full SHA
    a5fa2d8 View commit details
  3. Finish running finalizers before halting the machine.

    During the halting process, when running finalizers, since finalizers may be
    Ruby objects and may run Ruby methods, we need to ensure the system is still
    fully operational.
    
    During the finalizer finish process, no new finalizers may be created.
    brixen committed Mar 28, 2016

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7d071f0 View commit details
Showing with 38 additions and 8 deletions.
  1. +2 −2 machine/environment.cpp
  2. +9 −4 machine/memory.cpp
  3. +9 −0 machine/memory.hpp
  4. +2 −0 machine/memory/finalizer.cpp
  5. +1 −0 machine/memory/mark_sweep.cpp
  6. +15 −2 machine/oop.hpp
4 changes: 2 additions & 2 deletions machine/environment.cpp
Original file line number Diff line number Diff line change
@@ -585,6 +585,8 @@ namespace rubinius {

logger::write("exit process: %s %d", shared->pid.c_str(), exit_code);

shared->finalizer_handler()->finish(state);

state->shared().tool_broker()->shutdown(state);

if(Memory* om = state->memory()) {
@@ -602,8 +604,6 @@ namespace rubinius {

shared->thread_nexus()->wait_till_alone(state->vm());

shared->finalizer_handler()->finish(state);

NativeMethod::cleanup_thread(state);

state->shared().signals()->stop(state);
13 changes: 9 additions & 4 deletions machine/memory.cpp
Original file line number Diff line number Diff line change
@@ -68,6 +68,7 @@ namespace rubinius {
, inflated_headers_(new memory::InflatedHeaders)
, capi_handles_(new capi::Handles)
, code_manager_(&vm->shared)
, cycle_(0)
, mark_(2)
, allow_gc_(true)
, mature_mark_concurrent_(shared.config.gc_immix_concurrent)
@@ -470,10 +471,14 @@ namespace rubinius {
} else if(obj->young_object_p()) {
return false; /* young_->validate_object(obj) == cValid; */
} else if(obj->mature_object_p()) {
if(immix_->validate_object(obj) == cInImmix) {
return true;
} else if(mark_sweep_->validate_object(obj) == cMatureObject) {
return true;
if(obj->in_immix_p()) {
if(immix_->validate_object(obj) == cInImmix) {
return true;
}
} else if(obj->large_object_p()) {
if(mark_sweep_->validate_object(obj) == cMatureObject) {
return true;
}
}
}

9 changes: 9 additions & 0 deletions machine/memory.hpp
Original file line number Diff line number Diff line change
@@ -103,6 +103,9 @@ namespace rubinius {
/// Garbage collector for CodeResource objects.
memory::CodeManager code_manager_;

/// The number of GC cycles that have run
unsigned int cycle_;

/// The current mark value used when marking objects.
unsigned int mark_;

@@ -163,6 +166,10 @@ namespace rubinius {
return this;
}

unsigned int cycle() {
return cycle_;
}

unsigned int mark() const {
return mark_;
}
@@ -328,6 +335,8 @@ namespace rubinius {
write_barrier(obj, klass);
}

obj->set_cycle(cycle_);

return obj;
}

2 changes: 2 additions & 0 deletions machine/memory/finalizer.cpp
Original file line number Diff line number Diff line change
@@ -277,6 +277,8 @@ namespace memory {

void FinalizerThread::finish(STATE) {
finishing_ = true;
atomic::memory_barrier();

if(process_list_ || !lists_->empty() || !live_list_->empty()) {
while(true) {
if(!process_list_) {
1 change: 1 addition & 0 deletions machine/memory/mark_sweep.cpp
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@ namespace memory {
}

obj->init_header(MatureObjectZone, InvalidType);
obj->set_in_large();

return obj;
}
17 changes: 15 additions & 2 deletions machine/oop.hpp
Original file line number Diff line number Diff line change
@@ -156,21 +156,21 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
struct ObjectFlags {
object_type obj_type : 8;
gc_zone zone : 2;
unsigned int age : 4;
unsigned int age : 7;
aux_meaning meaning : 3;

unsigned int Forwarded : 1;
unsigned int Remember : 1;
unsigned int Marked : 3;

unsigned int InImmix : 1;
unsigned int InLarge : 1;
unsigned int Pinned : 1;

unsigned int Frozen : 1;
unsigned int Tainted : 1;
unsigned int Untrusted : 1;
unsigned int LockContended : 1;
unsigned int unused : 4;

uint32_t aux_word;
};
@@ -359,6 +359,10 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
return ++header.f.age;
}

void set_cycle(unsigned int cycle) {
header.f.age = cycle;
}

void set_age(unsigned int age);

/*
@@ -451,6 +455,10 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
return zone() == MatureObjectZone;
}

bool large_object_p() const {
return flags().InLarge == 1;
}

bool forwarded_p() const {
return flags().Forwarded == 1;
}
@@ -527,6 +535,11 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
header.f.InImmix = 1;
}

// Only called in non contended scenario's
void set_in_large() {
header.f.InLarge = 1;
}

bool remembered_p() const {
return flags().Remember == 1;
}