Example #1
0
  void GarbageCollector::clean_weakrefs(bool check_forwards) {
    if(!weak_refs_) return;

    for(ObjectArray::iterator i = weak_refs_->begin();
        i != weak_refs_->end();
        ++i) {
      if(!*i) continue; // Object was removed during young gc.
      WeakRef* ref = try_as<WeakRef>(*i);
      if(!ref) continue; // Other type for some reason?

      Object* obj = ref->object();
      if(!obj->reference_p()) continue;

      if(check_forwards) {
        if(obj->young_object_p()) {
          if(!obj->forwarded_p()) {
            ref->set_object(object_memory_, cNil);
          } else {
            ref->set_object(object_memory_, obj->forward());
          }
        }
      } else if(!obj->marked_p(object_memory_->mark())) {
        ref->set_object(object_memory_, cNil);
      }
    }

    delete weak_refs_;
    weak_refs_ = NULL;
  }
Example #2
0
  void GarbageCollector::clean_weakrefs(bool check_forwards) {
    if(!weak_refs_) return;

    for(ObjectArray::iterator i = weak_refs_->begin();
        i != weak_refs_->end();
        i++) {
      WeakRef* ref = try_as<WeakRef>(*i);
      if(!ref) continue; // WTF.

      Object* obj = ref->object();
      if(!obj->reference_p()) continue;

      if(check_forwards) {
        if(obj->young_object_p()) {
          if(!obj->forwarded_p()) {
            ref->set_object(object_memory_, Qnil);
          } else {
            ref->set_object(object_memory_, obj->forward());
          }
        }
      } else if(!obj->marked_p(object_memory_->mark())) {
        ref->set_object(object_memory_, Qnil);
      }
    }

    delete weak_refs_;
    weak_refs_ = NULL;
  }
Example #3
0
 Object* Module::reset_method_cache(STATE, Symbol* name) {
   if(Class* self = try_as<Class>(this)) {
     self->increment_serial();
   }
   if(!name->nil_p()) {
     if(MethodTableBucket* b = method_table_->find_entry(state, name)) {
       Executable* exec = b->method();
       if(!exec->nil_p()) {
         exec->clear_inliners(state);
       }
     }
   }
   if(!hierarchy_subclasses_->nil_p()) {
     for(native_int i = 0; i < hierarchy_subclasses_->size(); ++i) {
       WeakRef* ref = try_as<WeakRef>(hierarchy_subclasses_->get(state, i));
       if(ref && ref->alive_p()) {
         Module* mod = as<Module>(ref->object());
         mod->reset_method_cache(state, name);
       }
     }
   }
   return cNil;
 }