[Mono-list] One Bug, Many questions

tom berger t.berger@ucl.ac.uk
27 Aug 2002 14:24:49 +0100


--=-XgXGpdlfsMFMN22HKQJr
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Tue, 2002-08-27 at 12:50, Dietmar Maurer wrote:
> This is maybe a jit bug. Maybe you can extract a small test case to
> reproduce that bug. The IL code for the function which produces the bug
> would help.

OK, here is the problematic function.

I don't have the sources online. I can send them, but they are rather
messy (undocumented and not very well organised).

Tom



b.t.w sorry for the double-post, I used the wrong email, at first.

--=-XgXGpdlfsMFMN22HKQJr
Content-Disposition: attachment; filename=scm_jit_bug_example.txt
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=scm_jit_bug_example.txt; charset=ISO-8859-1

public static void ILGenerate(object exp, Env env, ILGenerator ilg, ModuleB=
uilder rtmodule, bool tail) {
  if (exp is Pair) {
    Pair sexp =3D (Pair) exp;
    if (sexp.Car is string && env[(string)sexp.Car] is Syntax) {
      List args =3D (List)sexp.Cdr;
      //HERE THE JIT WILL DIE
      ((Syntax)env[(string)sexp.Car]).ILGenerate(args, env, ilg, rtmodule);
    } else {
      //HERE THE JIT WILL DIE
      ILGenerate(sexp.Car, env, ilg, rtmodule);
      ilg.Emit(OpCodes.Isinst, typeof(Procedure));
      int ArgsLength =3D ((List)sexp.Cdr).Count;
      if (ArgsLength > 3) {
        ilg.Emit(OpCodes.Ldc_I4, ArgsLength);
        ilg.Emit(OpCodes.Newarr, typeof(object));
        int i =3D 0;
        foreach (object obj in (List)sexp.Cdr) {
          ilg.Emit(OpCodes.Dup);
          ilg.Emit(OpCodes.Ldc_I4, i);
          //HERE THE JIT WILL DIE
          ILGenerate(obj, env, ilg, rtmodule);
          ilg.Emit(OpCodes.Stelem_Ref);
          i++;
        }
      } else {
        foreach (object obj in (List)sexp.Cdr) {
          //HERE THE JIT WILL DIE
          ILGenerate(obj, env, ilg, rtmodule);
        }
      }
      if (tail) {
        ilg.Emit(OpCodes.Tailcall);
      }
      Type[] ApplyTypes;
      if (ArgsLength > 3) {
        ApplyTypes =3D new Type[1]{typeof(object[])};
      } else {
        ApplyTypes =3D new Type[ArgsLength];
        for (int i =3D 0; i < ArgsLength; i++) {
          ApplyTypes[i] =3D typeof(object);
        }
      }
      ilg.Emit(OpCodes.Callvirt, typeof(Procedure).GetMethod("Apply", Apply=
Types));
    }
  } else if (exp is string) {
    ilg.Emit(OpCodes.Ldloc_0);
    ilg.Emit(OpCodes.Ldstr, (string) exp);
    ilg.Emit(OpCodes.Call, typeof(Env).GetMethod("ItemOrError"));
  } else {
    //HERE THE JIT WILL DIE
    Quote.CSILGenerate(new Pair(exp, List.Empty), env, ilg);
  }
}

--=-XgXGpdlfsMFMN22HKQJr--