Permalink
Browse files

Track the root fiber properly. Fixes #1568

  • Loading branch information...
1 parent 865e778 commit c98174bfa13f4b8263405ead075bb6eb9a878568 @evanphx evanphx committed Feb 23, 2012
Showing with 14 additions and 9 deletions.
  1. +1 −1 vm/builtin/data.cpp
  2. +1 −1 vm/builtin/fiber.cpp
  3. +2 −1 vm/builtin/fiber.hpp
  4. +5 −1 vm/fiber_data.hpp
  5. +2 −2 vm/fiber_stack.cpp
  6. +1 −1 vm/fiber_stack.hpp
  7. +2 −2 vm/vm.hpp
View
@@ -94,7 +94,7 @@ namespace rubinius {
}
void Data::Info::mark(Object* t, ObjectMark& mark) {
- // auto_mark(t, mark);
+ auto_mark(t, mark);
Data* data = force_as<Data>(t);
View
@@ -44,7 +44,7 @@ namespace rubinius {
fib->root_ = true;
fib->status_ = Fiber::eRunning;
- fib->data_ = new FiberData(state->vm(), true);
+ fib->data_ = state->vm()->new_fiber_data(true);
state->memory()->needs_finalization(fib, (FinalizerFunction)&Fiber::finalize);
View
@@ -46,7 +46,8 @@ namespace rubinius {
}
void sleep(CallFrame* cf) {
- if(data_) data_->set_call_frame(cf);
+ if(cf && !data_) rubinius::bug("bad fiber");
+ data_->set_call_frame(cf);
status_ = eSleeping;
}
View
@@ -38,6 +38,7 @@ namespace rubinius {
#endif
class FiberStack;
+ class FiberStacks;
class FiberData {
fiber_context_t machine_;
@@ -61,7 +62,7 @@ namespace rubinius {
CallFrame* call_frame_;
- public:
+ // Private constructor so only FiberStack can use it.
FiberData(VM* thread, bool root=false)
: status_(root ? eOnStack : eInitial)
@@ -73,6 +74,9 @@ namespace rubinius {
, call_frame_(0)
{}
+ friend class FiberStacks;
+
+ public:
~FiberData();
bool dead_p() {
View
@@ -88,8 +88,8 @@ namespace rubinius {
}
}
- FiberData* FiberStacks::new_data() {
- FiberData* data = new FiberData(thread_);
+ FiberData* FiberStacks::new_data(bool root) {
+ FiberData* data = new FiberData(thread_, root);
datas_.push_back(data);
return data;
View
@@ -86,7 +86,7 @@ namespace rubinius {
datas_.remove(data);
}
- FiberData* new_data();
+ FiberData* new_data(bool root=false);
void* trampoline();
View
@@ -280,8 +280,8 @@ namespace rubinius {
return fiber_stacks_.trampoline();
}
- FiberData* new_fiber_data() {
- return fiber_stacks_.new_data();
+ FiberData* new_fiber_data(bool root=false) {
+ return fiber_stacks_.new_data(root);
}
void remove_fiber_data(FiberData* data) {

0 comments on commit c98174b

Please sign in to comment.