Beispiel #1
0
int SourceAssembler::find_gp_offset(const char *name) {
#if !ENABLE_THUMB_GP_TABLE
  int offset = 256 * sizeof(OopDesc*); // skip the bytecode table
  if (ENABLE_DISPATCH_TABLE_PADDING) {
    offset += 8 * sizeof(OopDesc*);    // 8 extra bytecodes.
  }
#else
  int offset = 1 * sizeof(OopDesc*); // skip the nop bytecode
#endif

  static const GPTemplate gp_templates[] = {
    GP_SYMBOLS_DO(DEFINE_GP_POINTER, DEFINE_GP_VALUE)
    {NULL, 0, 0, 0}
  };

  for (const GPTemplate* tmpl = gp_templates; tmpl->name; tmpl++) {
    if (jvm_strcmp(name, tmpl->name) == 0) {
      return offset;
    }
    offset += tmpl->size;
    GUARANTEE((offset % 4) == 0, "must be word aligned");
  }

  SHOULD_NOT_REACH_HERE();
  return 0;
}
void GPTableGenerator::generate_constants_table() {
  int i;

  bind("gp_constants");

  static const GPTemplate gp_templates[] = {
    GP_SYMBOLS_DO(DEFINE_GP_POINTER, DEFINE_GP_VALUE)
    {NULL, 0, 0, 0}
  };

  for (const GPTemplate* tmpl = gp_templates; tmpl->name; tmpl++) {
    if (tmpl->is_pointer) {
      char buff[120];
      jvm_sprintf(buff, "gp_%s_ptr", tmpl->name);
      bind(buff);

      Label L(tmpl->name);
      if (!tmpl->is_asm) {
        import(L);
      }
      define_long(L);
    } else {
      if (jvm_strcmp(tmpl->name, "current_thread") == 0) {
         bind("jvm_fast_globals");
      }
      char buff[120];
      jvm_sprintf(buff, "_%s", tmpl->name);
      bind(buff);
      if (jvm_strcmp(tmpl->name, "bit_selector") == 0) {
        // IMPL_NOTE: create a common framework to define initial values
        define_long(0x80808080);
      } else {
        define_zeros(tmpl->size);
      }
    }
  }

  if (!GenerateGPTableOnly) {
    // Some constants to check we've linked with the right ROM
    Label L1(XSTR(_ROM_LINKCHECK_HLE));
    import(L1);
    define_long(L1);

    Label L2(XSTR(_ROM_LINKCHECK_MFFD));
    import(L2);
    define_long(L2);

    Label L3(XSTR(_ROM_LINKCHECK_MFFL));
    import(L3);
    define_long(L3);
  }

  if (ENABLE_THUMB_GP_TABLE && GenerateGPTableOnly) {
    // These symbols are necessary to link romgen.
    // We define a long for each entry, since they 
    // should be bound to different addresses.
    bind("jvm_ladd");
    define_long(0);
    bind("jvm_lsub");
    define_long(0);
    bind("jvm_land");
    define_long(0);
    bind("jvm_lor");
    define_long(0);
    bind("jvm_lxor");
    define_long(0);
    bind("jvm_lcmp");
    define_long(0);
    bind("jvm_lmin");
    define_long(0);
    bind("jvm_lmax");
    define_long(0);
    bind("jvm_lmul");
    define_long(0);
    bind("jvm_lshl");
    define_long(0);
    bind("jvm_lshr");
    define_long(0);
    bind("jvm_lushr");
    define_long(0);
  }

  bind("gp_constants_end");
}