Skip to content
Browse files

Check CallFrames directly from their VM

  • Loading branch information...
1 parent 77a1c63 commit e9ef9915cb24d510a9c6dc2ab57e27b09c802197 Evan Phoenix committed
Showing with 58 additions and 74 deletions.
  1. +1 −1 .gdbinit
  2. +13 −8 vm/agent_components.cpp
  3. +9 −8 vm/builtin/channel.cpp
  4. +6 −8 vm/gc/baker.cpp
  5. +0 −14 vm/gc/gc.cpp
  6. +1 −8 vm/gc/gc.hpp
  7. +6 −10 vm/gc/immix.cpp
  8. +21 −8 vm/gc/walker.cpp
  9. +0 −2 vm/shared_state.cpp
  10. +0 −5 vm/shared_state.hpp
  11. +1 −2 vm/vm.cpp
View
2 .gdbinit
@@ -15,7 +15,7 @@ p __show_subtend__($arg0)
end
define validate
-p rubinius::VM::current_state()->om->validate_object($arg0)
+p rubinius::VM::current()->om->validate_object($arg0)
end
define refs
View
21 vm/agent_components.cpp
@@ -277,17 +277,22 @@ namespace agent {
shared_.interrupts.set_timer();
// GlobalLock::LockGuard guard(shared_.global_lock());
+ std::list<ManagedThread*>* threads = shared_.threads();
+
output.ok("value");
- output.e().write_tuple(shared_.call_frame_locations().size());
- for(CallFrameLocationList::iterator i = shared_.call_frame_locations().begin();
- i != shared_.call_frame_locations().end();
- i++) {
- CallFrame* loc = *(*i);
+ output.e().write_tuple(threads->size());
- std::ostringstream ss;
- loc->print_backtrace(state_, ss);
- output.e().write_binary(ss.str().c_str());
+ for(std::list<ManagedThread*>::iterator i = threads->begin();
+ i != threads->end();
+ i++) {
+ if(VM* vm = (*i)->as_vm()) {
+ std::ostringstream ss;
+ vm->saved_call_frame()->print_backtrace(state_, ss);
+ output.e().write_binary(ss.str().c_str());
+ } else {
+ output.e().write_binary("");
+ }
}
}
};
View
17 vm/builtin/channel.cpp
@@ -117,20 +117,21 @@ namespace rubinius {
waiters_++;
- state->set_call_frame(call_frame);
state->wait_on_channel(this);
for(;;) {
- GCIndependent gc_guard(state, call_frame);
-
- if(use_timed_wait) {
- if(condition_.wait_until(mutex_, &ts) == thread::cTimedOut) break;
- } else {
- condition_.wait(mutex_);
+ {
+ GCIndependent gc_guard(state, call_frame);
+
+ if(use_timed_wait) {
+ if(condition_.wait_until(mutex_, &ts) == thread::cTimedOut) break;
+ } else {
+ condition_.wait(mutex_);
+ }
}
// or there are values available.
- if(!value_->empty_p()) break;
+ if(!self->value()->empty_p()) break;
}
state->clear_waiter();
View
14 vm/gc/baker.cpp
@@ -178,6 +178,12 @@ namespace rubinius {
}
}
}
+
+ if(VM* vm = (*i)->as_vm()) {
+ if(CallFrame* cf = vm->saved_call_frame()) {
+ walk_call_frame(cf);
+ }
+ }
}
}
@@ -230,14 +236,6 @@ namespace rubinius {
}
}
- // Walk all the call frames
- for(CallFrameLocationList::iterator i = data.call_frames().begin();
- i != data.call_frames().end();
- i++) {
- CallFrame** loc = *i;
- walk_call_frame(*loc);
- }
-
// Handle all promotions to non-young space that occured.
handle_promotions();
View
14 vm/gc/gc.cpp
@@ -26,7 +26,6 @@ namespace rubinius {
GCData::GCData(STATE)
: roots_(state->globals().roots)
- , call_frames_(state->shared.call_frame_locations())
, variable_buffers_(*state->variable_buffers())
, handles_(state->shared.global_handles())
, cached_handles_(state->shared.cached_handles())
@@ -301,18 +300,6 @@ namespace rubinius {
}
}
- void GarbageCollector::visit_call_frames_list(CallFrameLocationList& call_frames,
- ObjectVisitor& visit) {
-
- // Walk all the call frames
- for(CallFrameLocationList::const_iterator i = call_frames.begin();
- i != call_frames.end();
- i++) {
- CallFrame** loc = *i;
- visit_call_frame(*loc, visit);
- }
- }
-
class UnmarkVisitor : public ObjectVisitor {
std::vector<Object*> stack_;
ObjectMemory* object_memory_;
@@ -372,7 +359,6 @@ namespace rubinius {
UnmarkVisitor visit(object_memory_);
visit_roots(data.roots(), visit);
- visit_call_frames_list(data.call_frames(), visit);
for(capi::Handles::Iterator i(*data.handles()); i.more(); i.advance()) {
visit.call(i->object());
View
9 vm/gc/gc.hpp
@@ -27,7 +27,6 @@ namespace rubinius {
class GCData {
Roots& roots_;
- CallFrameLocationList& call_frames_;
VariableRootBuffers& variable_buffers_;
capi::Handles* handles_;
capi::Handles* cached_handles_;
@@ -36,11 +35,10 @@ namespace rubinius {
public:
GCData(STATE);
- GCData(Roots& r, CallFrameLocationList& l, VariableRootBuffers& b,
+ GCData(Roots& r, VariableRootBuffers& b,
capi::Handles* handles = NULL, capi::Handles* cached_handles = NULL,
GlobalCache *cache = NULL, std::list<ManagedThread*>* ths = NULL)
: roots_(r)
- , call_frames_(l)
, variable_buffers_(b)
, handles_(handles)
, cached_handles_(cached_handles)
@@ -52,10 +50,6 @@ namespace rubinius {
return roots_;
}
- CallFrameLocationList& call_frames() {
- return call_frames_;
- }
-
std::list<ManagedThread*>* threads() {
return threads_;
}
@@ -110,7 +104,6 @@ namespace rubinius {
}
void visit_roots(Roots& roots, ObjectVisitor& visit);
- void visit_call_frames_list(CallFrameLocationList& call_frames, ObjectVisitor& visit);
void unmark_all(GCData& data);
void clean_weakrefs(bool check_forwards=false);
View
16 vm/gc/immix.cpp
@@ -128,7 +128,6 @@ namespace rubinius {
int via_handles_ = 0;
int via_roots = 0;
int via_stack = 0;
- int callframes = 0;
for(Roots::Iterator i(data.roots()); i.more(); i.advance()) {
tmp = i->get();
@@ -158,6 +157,12 @@ namespace rubinius {
}
}
}
+
+ if(VM* vm = (*i)->as_vm()) {
+ if(CallFrame* cf = vm->saved_call_frame()) {
+ walk_call_frame(cf);
+ }
+ }
}
}
@@ -189,15 +194,6 @@ namespace rubinius {
}
}
- // Walk all the call frames
- for(CallFrameLocationList::const_iterator i = data.call_frames().begin();
- i != data.call_frames().end();
- i++) {
- callframes++;
- CallFrame** loc = *i;
- walk_call_frame(*loc);
- }
-
gc_.process_mark_stack(allocator_);
// We've now finished marking the entire object graph.
View
29 vm/gc/walker.cpp
@@ -57,6 +57,27 @@ namespace rubinius {
for(Roots::Iterator ri((*i)->roots()); ri.more(); ri.advance()) {
saw_object(ri->get());
}
+
+ for(VariableRootBuffers::Iterator vi((*i)->root_buffers());
+ vi.more();
+ vi.advance())
+ {
+ Object*** buffer = vi->buffer();
+ for(int idx = 0; idx < vi->size(); idx++) {
+ Object** var = buffer[idx];
+ Object* tmp = *var;
+
+ if(tmp->reference_p() && tmp->young_object_p()) {
+ *var = saw_object(tmp);
+ }
+ }
+ }
+
+ if(VM* vm = (*i)->as_vm()) {
+ if(CallFrame* cf = vm->saved_call_frame()) {
+ walk_call_frame(cf);
+ }
+ }
}
}
@@ -78,14 +99,6 @@ namespace rubinius {
saw_object(tmp);
}
}
-
- // Walk all the call frames
- for(CallFrameLocationList::iterator i = data.call_frames().begin();
- i != data.call_frames().end();
- i++) {
- CallFrame** loc = *i;
- walk_call_frame(*loc);
- }
}
Object* ObjectWalker::next() {
View
2 vm/shared_state.cpp
@@ -93,7 +93,6 @@ namespace rubinius {
// field of ids, so we reuse ids.
VM* vm = new VM(id, *this);
- cf_locations_.push_back(vm->call_frame_location());
threads_.push_back(vm);
this->ref();
@@ -105,7 +104,6 @@ namespace rubinius {
void SharedState::remove_vm(VM* vm) {
SYNC(0);
- cf_locations_.remove(vm->call_frame_location());
threads_.remove(vm);
this->deref();
View
5 vm/shared_state.hpp
@@ -71,7 +71,6 @@ namespace rubinius {
private:
bool initialized_;
SignalHandler* signal_handler_;
- CallFrameLocationList cf_locations_;
VariableRootBuffers root_buffers_;
capi::Handles* global_handles_;
capi::Handles* cached_handles_;
@@ -139,10 +138,6 @@ namespace rubinius {
VM* new_vm();
void remove_vm(VM*);
- CallFrameLocationList& call_frame_locations() {
- return cf_locations_;
- }
-
std::list<ManagedThread*>* threads() {
return &threads_;
}
View
3 vm/vm.cpp
@@ -309,12 +309,11 @@ namespace rubinius {
}
bool VM::wakeup() {
+ SYNC(this);
if(interrupt_with_signal_) {
pthread_kill(os_thread_, SIGVTALRM);
return true;
} else {
- SYNC(this);
-
Channel* chan = waiting_channel_.get();
if(!chan->nil_p()) {

0 comments on commit e9ef991

Please sign in to comment.
Something went wrong with that request. Please try again.