示例#1
0
void Execution_Tracer::check_it(Oop ents) {
  Object_p eo = ents.as_object();
  int wl = eo->fetchWordLength();
  int n = wl / e_N;

  for (int i = 0;  i < n;  ++i) {
    int x = -1;
    Oop rank = eo->fetchPointer(x   =   i * e_N  +  e_rank);
    assert_always( rank.is_int());
    switch (eo->fetchPointer(i * e_N  +  e_kind).integerValue()) {
        default: fatal();
      case k_bc: {
          Oop meth         = eo->fetchPointer(x   =   i * e_N  +  e_method); assert_always(meth.is_mem());
          Oop rcvr         = eo->fetchPointer(x   =   i * e_N  +  e_rcvr);
          Oop pc           = eo->fetchPointer(x   =   i * e_N  +  e_pc  );  assert_always(pc.is_int());
          Oop is_block     = eo->fetchPointer(x   =   i * e_N  +  e_is_block); assert_always(is_block == The_Squeak_Interpreter()->roots.trueObj || is_block == The_Squeak_Interpreter()->roots.falseObj);
          break;
      }
        case k_gc: {
          Oop gc           = eo->fetchPointer(x   =   i * e_N  +  e_gc      ); assert_always(gc.is_int());
        }
          break;
        case k_proc: {
          Oop process      = eo->fetchPointer(x   =   i * e_N  +  e_process); assert_always(process.is_mem());
        }
          break;
        case k_rcved_interp:
          break;
        case k_aux: break;
    }
  }
}
示例#2
0
void Profiling_Tracer::record_for_profile(Oop meth, Oop rcvr, bool is_block) {
  if (Logical_Core::num_cores > 1)
    return;

  static std::string lastSignature;
  std::map<std::string, int>* profile;
#warning Stefan: warning, not threadsafe
  get_profile(&profile);

  static char buff[2024];
  StringPrinter p(buff, 2023);

  Oop klass = rcvr.fetchClass();
  Oop sel, mclass;
  bool have_sel_and_mclass = klass.as_object()->selector_and_class_of_method_in_me_or_ancestors(meth, &sel, &mclass);
  if (!have_sel_and_mclass) return;
  if (mclass == The_Squeak_Interpreter()->roots.nilObj)
    mclass = rcvr.fetchClass();

  rcvr.print(&p);
  if (mclass != klass) {
    p.printf("(");
    bool is_meta;
    Oop mclassName = mclass.as_object()->name_of_class_or_metaclass(&is_meta);
    if (is_meta) p.printf("class ");
    mclassName.as_object()->print_bytes(&p);
    p.printf(")");
  }
  p.printf(">>");
  sel.as_object()->print_bytes(&p);
  if (is_block) p.printf("[]");

  buff[2023] = 0;
  std::string signature(buff);

  if (lastSignature != signature) {
    lastSignature = signature;
    ++(*profile)[lastSignature];
  }


  // STEFAN: a little hack to be able to get the printout during debugging, any better ways to do so?
  static bool print_profile = false;
  if (print_profile) {
    this->print_profile(debug_printer);
  }
}
示例#3
0
/** Inspired by:
 !Interpreter methodsFor: 'image save/restore' stamp: 'dtl 10/5/2010 23:54'!
 normalizeFloatOrderingInImage
 
 "Float objects were saved in platform word ordering. Reorder them into the
 traditional object format."
*/
void Squeak_Image_Reader::normalize_float_ordering_in_image() {
  Squeak_Interpreter* const interp = The_Squeak_Interpreter();
  Memory_System* const mem_sys = The_Memory_System();
  
  Oop cls = interp->splObj(Special_Indices::ClassFloat);
  for (Oop floatInstance = mem_sys->initialInstanceOf(cls);
       floatInstance != interp->roots.nilObj;
       floatInstance  = mem_sys->nextInstanceAfter(floatInstance) ) {
    /* Swap words within Float objects, taking them out of native platform ordering */
    floatInstance.as_object()->swapFloatParts_for_cog_compatibility();
  }
}
示例#4
0
文件: oop.cpp 项目: bhatti/RoarVM
bool Oop::isKindOf(char* className) {
  for (Oop klass = fetchClass();  klass != The_Squeak_Interpreter()->roots.nilObj;  klass = klass.as_object()->superclass())
    if (klass.as_object()->className().as_object()->equals_string(className))
      return true;
  return false;
}
示例#5
0
void Execution_Tracer::print_entries(Oop ents, Printer* p) {
  Object_p eo = ents.as_object();
  int n = eo->fetchWordLength()  /  e_N;
  int x;

  for (int i = 0;  i < n;  ++i) {
    int rank = eo->fetchPointer(x   =   i * e_N  +  e_rank).integerValue();
    p->printf("%3d on %2d: ", i - n, rank);

    switch (eo->fetchPointer(i * e_N  +  e_kind).integerValue()) {
        default: fatal(); break;
        case k_proc: {
          Oop process      = eo->fetchPointer(i * e_N  +  e_process); assert(process.is_mem());
          p->printf("switch to process 0x%x", process.as_untracked_object_ptr());
        }
          break;

      case k_aux: {
        int rank         = eo->fetchPointer(i * e_N  +  e_rank).integerValue();
        int aux1         = eo->fetchPointer(i * e_N  +  e_aux1).integerValue();
        //int aux2         = eo->fetchPointer(i * e_N  +  e_aux2).integerValue();
        int id           = eo->fetchPointer(i * e_N  +  e_id  ).integerValue();
        // p->printf("on %d: aux1 0x%x aux2 0x%x id %d", rank, aux1, aux2, id);
        p->printf("on %d: aux1 %s id %d", rank, aux1, id);
      }
        break;

        case k_gc:
          p->printf("gc: %d",  eo->fetchPointer(i * e_N  + e_gc).integerValue());
          break;

        case k_rcved_interp:
          p->printf("received interp");
          break;

        case k_bc: {
          Oop meth         = eo->fetchPointer(i * e_N  +  e_method); assert(meth.is_mem());
          Oop rcvr         = eo->fetchPointer(i * e_N  +  e_rcvr);
          int pc           = eo->fetchPointer(i * e_N  +  e_pc  ).integerValue();
          bool is_block    = eo->fetchPointer(i * e_N  +  e_is_block) == The_Squeak_Interpreter()->roots.trueObj;
          int aux1         = eo->fetchPointer(i * e_N  +  e_aux1).integerValue();
          int aux2         = eo->fetchPointer(i * e_N  +  e_aux2).integerValue();

          Oop klass = rcvr.fetchClass();
          Oop sel, mclass;
          bool have_sel_and_mclass = klass.as_object()->selector_and_class_of_method_in_me_or_ancestors(meth, &sel, &mclass);
          if (!have_sel_and_mclass) continue;
          if (mclass == The_Squeak_Interpreter()->roots.nilObj)
            mclass = rcvr.fetchClass();

          p->printf("rcvr: ");  rcvr.print(p);
          if (mclass != klass) {
            p->printf("(");
            bool is_meta;
            Oop mclassName = mclass.as_object()->name_of_class_or_metaclass(&is_meta);
            if (is_meta) p->printf("class ");
            mclassName.as_object()->print_bytes(p);
            p->printf(")");
          }
          p->printf("  >>  ");
          sel.as_object()->print_bytes(p);
          p->printf(is_block ? " [] " : "    ");
          p->printf(", pc: %d, ", pc);

          Object_p mo = meth.as_object();
          u_char bc = mo->first_byte_address()[pc];
          The_Squeak_Interpreter()->printBC(bc, p);

          p->printf(", bcCount %d", eo->fetchPointer(i * e_N  +  e_bcCount).integerValue());
          if (aux1)  p->printf(", aux1 = 0x%x", aux1);
          if (aux1)  p->printf(", aux1 = 0x%x", aux2);


        }
        break;
    }
    p->nl();
  }
}