Exemplo n.º 1
0
    Class* dominating_class() {
      int seen = classes_seen();
      switch(seen) {
      case 0:
        return NULL;
      case 1:
        return seen_classes_[0].klass();
      /*
       *  These are disabled because they hurt performance.
      case 2: {
        int h1 = seen_classes_[0].hits();
        int h2 = seen_classes_[1].hits();
        if(h2 * 10 < h1) return seen_classes_[0].klass();
        if(h1 * 10 < h2) return seen_classes_[1].klass();
        return NULL;
      }

      case 3: {
        int h1 = seen_classes_[0].hits();
        int h2 = seen_classes_[1].hits();
        int h3 = seen_classes_[2].hits();

        if(h2 * 10 < h1 && h3 * 10 < h1) return seen_classes_[0].klass();
        if(h1 * 10 < h2 && h3 * 10 < h2) return seen_classes_[1].klass();
        if(h1 * 10 < h3 && h2 * 10 < h3) return seen_classes_[2].klass();

        return NULL;
      }
      */
      default:
        return NULL;
      }
    }
Exemplo n.º 2
0
  void PolyInlineCache::print(STATE, std::ostream& stream) {
    stream << "name: " << name()->debug_str(state) << "\n"
           << "seen classes: " << classes_seen() << "\n"
           << "overflows: " << seen_classes_overflow() << "\n"
           << "classes:\n";

    for(int i = 0; i < cTrackedICHits; i++) {
      if(entries_[i]) {
        Module* mod = entries_[i]->receiver_class();
        if(mod) {
          if(SingletonClass* sc = try_as<SingletonClass>(mod)) {
            if(Module* inner = try_as<Module>(sc->singleton())) {
              stream << "  SingletonClass:" << inner->debug_str(state);
            } else {
              stream << "  SingletonClass:" << sc->singleton()->class_object(state)->debug_str(state);
            }
          } else {
            stream << "  " << mod->debug_str(state);
          }

          stream << "\n";
        }
      }
    }
  }
Exemplo n.º 3
0
  void InlineCache::print(STATE, std::ostream& stream) {
    stream << "name: " << name->c_str(state) << "\n"
           << "seen classes: " << classes_seen() << "\n"
           << "total hits: " << total_hits() << "\n"
           << "overflows: " << seen_classes_overflow_ << "\n"
           << "classes:\n";

    for(int i = 0; i < cTrackedICHits; i++) {
      Module* mod = seen_classes_[i].klass();
      if(mod) {
        if(SingletonClass* sc = try_as<SingletonClass>(mod)) {
          if(Module* inner = try_as<Module>(sc->attached_instance())) {
            stream << "  SingletonClass:" << inner->name()->c_str(state);
          } else {
            stream << "  SingletonClass:" << sc->attached_instance()->class_object(state)->name()->c_str(state);
          }
        } else {
          stream << "  " << mod->name()->c_str(state);
        }

        stream << " " << seen_classes_[i].hits() << "\n";
      }
    }
  }