From: jowenn Date: Sat, 6 Mar 2004 17:27:56 +0000 (+0000) Subject: retrieve line number information X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=7f63a2f27ffa94b61d4f968b3eb5db9d2cfd882f;p=cacao.git retrieve line number information --- diff --git a/global.h b/global.h index cd3d90bb1..d9cf9dd71 100644 --- a/global.h +++ b/global.h @@ -31,7 +31,7 @@ Philipp Tomsich Edwin Steiner - $Id: global.h 940 2004-03-06 14:04:15Z jowenn $ + $Id: global.h 941 2004-03-06 17:27:56Z jowenn $ */ @@ -195,6 +195,7 @@ typedef struct vftbl vftbl; typedef u1* methodptr; typedef struct fieldinfo fieldinfo; typedef struct methodinfo methodinfo; +typedef struct lineinfo lineinfo; typedef struct arraydescriptor arraydescriptor; @@ -545,6 +546,12 @@ typedef struct xtainfo { } xtainfo; +/* lineinfo *****************************************************************/ +struct lineinfo { + u2 start_pc; + u2 line_number; +}; + /* methodinfo *****************************************************************/ struct methodinfo { /* method structure */ @@ -566,11 +573,13 @@ struct methodinfo { /* method structure */ u1 *jcode; /* pointer to JavaVM code */ s4 exceptiontablelength;/* exceptiontable length */ - exceptiontable *exceptiontable; + exceptiontable *exceptiontable; /* the exceptiontable */ + + u2 thrownexceptionscount; /*number of exceptions declared to be thrown by a method*/ + classinfo **thrownexceptions; /*array of classinfos of declared exceptions*/ - u2 thrownexceptionscount; - classinfo **thrownexceptions; - /* the exceptiontable */ + u2 linenumbercount; /*number of linenumber attributes*/ + lineinfo *linenumbers; /*array of lineinfo items (start_pc,line_number)*/ u1 *stubroutine; /* stub for compiling or calling natives */ s4 mcodelength; /* legth of generated machine code */ diff --git a/jit/jit.c b/jit/jit.c index 12dd4bc12..47a42cafa 100644 --- a/jit/jit.c +++ b/jit/jit.c @@ -29,7 +29,7 @@ Changes: Edwin Steiner - $Id: jit.c 923 2004-02-24 13:28:08Z edwin $ + $Id: jit.c 941 2004-03-06 17:27:56Z jowenn $ */ @@ -153,6 +153,8 @@ int maxstack; /* maximal JavaVM stack size */ int maxlocals; /* maximal number of local JavaVM variables */ int jcodelength; /* length of JavaVM-codes */ u1 *jcode; /* pointer to start of JavaVM-code */ +lineinfo *jlinenumbers; /* line information array */ +u2 jlinenumbercount; /* number of entries in the linenumber array */ int exceptiontablelength; /* length of exception table */ xtable *extable; /* pointer to start of exception table */ exceptiontable *raw_extable; @@ -1517,6 +1519,8 @@ methodptr jit_compile(methodinfo *m) maxlocals = m->maxlocals; jcodelength = m->jcodelength; jcode = m->jcode; + jlinenumbers = m->linenumbers; + jlinenumbercount = m->linenumbercount; exceptiontablelength = m->exceptiontablelength; raw_extable = m->exceptiontable; regs_ok = false; diff --git a/jit/jit.h b/jit/jit.h index c59ba67ba..d72017db9 100644 --- a/jit/jit.h +++ b/jit/jit.h @@ -29,7 +29,7 @@ Changes: Christian Thalinger - $Id: jit.h 938 2004-03-06 00:56:43Z twisti $ + $Id: jit.h 941 2004-03-06 17:27:56Z jowenn $ */ @@ -110,9 +110,10 @@ struct instruction { u2 opc; /* opcode of intermediate code command */ s4 op1; /* first operand, usually variable number */ imm_union val; /* immediate constant */ - void *target; /* used for targets of branches and jumps */ - /* and as address for list of targets for */ - /* statements */ + void *target; /* used for targets of branches and jumps */ + /* and as address for list of targets for */ + /* statements */ + u2 line /* line number in source file */ }; @@ -895,6 +896,8 @@ extern int maxstack; /* maximal JavaVM stack size */ extern int maxlocals; /* maximal number of local JavaVM variables */ extern int jcodelength; /* length of JavaVM-codes */ extern u1 *jcode; /* pointer to start of JavaVM-code */ +lineinfo *jlinenumbers; /* line information array */ +u2 jlinenumbercount; /* number of entries in the linenumber array */ extern int exceptiontablelength;/* length of exception table */ extern xtable *extable; /* pointer to start of exception table */ extern exceptiontable *raw_extable; diff --git a/jit/parse.c b/jit/parse.c index 3f0687611..93cb649e9 100644 --- a/jit/parse.c +++ b/jit/parse.c @@ -29,7 +29,7 @@ Changes: Carolyn Oates Edwin Steiner - $Id: parse.c 893 2004-01-19 12:53:24Z edwin $ + $Id: parse.c 941 2004-03-06 17:27:56Z jowenn $ */ @@ -344,13 +344,13 @@ void descriptor2types(methodinfo *m) #define OP(o) iptr->opc=(o);/*iptr->op1=0*/;/*iptr->val.l=0*/;PINC #define OP1(o,o1) iptr->opc=(o);iptr->op1=(o1);/*iptr->val.l=(0)*/;PINC #define OP2I(o,o1,v) iptr->opc=(o);iptr->op1=(o1);iptr->val.i=(v);PINC -#define OP2A(o,o1,v) iptr->opc=(o);iptr->op1=(o1);iptr->val.a=(v);PINC -#define BUILTIN1(v,t) isleafmethod=false;iptr->opc=ICMD_BUILTIN1;iptr->op1=t;\ - iptr->val.a=(v);PINC -#define BUILTIN2(v,t) isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\ - iptr->val.a=(v);PINC -#define BUILTIN3(v,t) isleafmethod=false;iptr->opc=ICMD_BUILTIN3;iptr->op1=t;\ - iptr->val.a=(v);PINC +#define OP2A(o,o1,v,l) iptr->opc=(o);iptr->op1=(o1);iptr->val.a=(v);iptr->line=l;PINC +#define BUILTIN1(v,t,l) isleafmethod=false;iptr->opc=ICMD_BUILTIN1;iptr->op1=t;\ + iptr->val.a=(v);iptr->line=l;PINC +#define BUILTIN2(v,t,l) isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\ + iptr->val.a=(v);iptr->line=l;PINC +#define BUILTIN3(v,t,l) isleafmethod=false;iptr->opc=ICMD_BUILTIN3;iptr->op1=t;\ + iptr->val.a=(v);iptr->line=l;PINC /* We have to check local variables indices here because they are * used in stack.c to index the locals array. */ @@ -471,6 +471,10 @@ void parse() xtable* nextex; /* points next free entry in extable */ u1 *instructionstart; /* 1 for pcs which are valid instr. starts */ + u2 lineindex=0; + u2 currentline=0; + u2 linepcchange=0; + bool useinltmp; if (compileverbose) { @@ -588,14 +592,31 @@ void parse() #endif /* scan all java instructions */ + currentline=0; + linepcchange=0; + if (jlinenumbercount==0) { + lineindex=0; + } else { + linepcchange=jlinenumbers[0].start_pc; + } for (p = 0, gp = 0; p < jcodelength; gp += (nextp - p), p = nextp) { /* DEBUG */ /*printf("p:%d gp:%d ",p,gp);*/ /* mark this position as a valid instruction start */ - if (!iswide) + if (!iswide) { instructionstart[p] = 1; + if (linepcchange==p) { + if (jlinenumbercount>lineindex) { + currentline=jlinenumbers[lineindex].line_number; + lineindex++; + if (lineindexvftbl; - OP2A(opcode, v, arrayvftbl); + OP2A(opcode, v, arrayvftbl,currentline); } break; @@ -1038,7 +1059,7 @@ void parse() tablep = DMNEW(s4, num * 2 + 2); } - OP2A(opcode, 0, tablep); + OP2A(opcode, 0, tablep,currentline); /* default target */ @@ -1108,7 +1129,7 @@ void parse() tablep = DMNEW(s4, num + 1 + 3); } - OP2A(opcode, 0, tablep); + OP2A(opcode, 0, tablep,currentline); /* default target */ @@ -1160,7 +1181,7 @@ void parse() /* load and store of object fields *******************/ case JAVA_AASTORE: - BUILTIN3(BUILTIN_aastore, TYPE_VOID); + BUILTIN3(BUILTIN_aastore, TYPE_VOID,currentline); break; case JAVA_PUTSTATIC: @@ -1171,7 +1192,7 @@ void parse() fieldinfo *fi; fr = class_getconstant(class, i, CONSTANT_Fieldref); fi = class_findfield(fr->class, fr->name, fr->descriptor); - OP2A(opcode, fi->type, fi); + OP2A(opcode, fi->type, fi,currentline); if (!fi->class->initialized) { isleafmethod = false; } @@ -1186,7 +1207,7 @@ void parse() fieldinfo *fi; fr = class_getconstant (class, i, CONSTANT_Fieldref); fi = class_findfield (fr->class, fr->name, fr->descriptor); - OP2A(opcode, fi->type, fi); + OP2A(opcode, fi->type, fi,currentline); } break; @@ -1211,7 +1232,7 @@ void parse() descriptor2types(mi); isleafmethod=false; - OP2A(opcode, mi->paramcount, mi); + OP2A(opcode, mi->paramcount, mi,currentline); } break; @@ -1235,7 +1256,7 @@ void parse() panic ("Static/Nonstatic mismatch calling static method"); descriptor2types(mi); isleafmethod=false; - OP2A(opcode, mi->paramcount, mi); + OP2A(opcode, mi->paramcount, mi,currentline); } break; @@ -1251,7 +1272,7 @@ void parse() panic ("Static/Nonstatic mismatch calling static method"); descriptor2types(mi); isleafmethod=false; - OP2A(opcode, mi->paramcount, mi); + OP2A(opcode, mi->paramcount, mi,currentline); } break; @@ -1262,7 +1283,7 @@ void parse() LOADCONST_A_BUILTIN(class_getconstant(class, i, CONSTANT_Class)); s_count++; - BUILTIN1(BUILTIN_new, TYPE_ADR); + BUILTIN1(BUILTIN_new, TYPE_ADR,currentline); break; case JAVA_CHECKCAST: @@ -1276,15 +1297,15 @@ void parse() /* array type cast-check */ LOADCONST_A_BUILTIN(cls->vftbl); s_count++; - BUILTIN2(BUILTIN_checkarraycast, TYPE_ADR); + BUILTIN2(BUILTIN_checkarraycast, TYPE_ADR,currentline); } else { /* object type cast-check */ /* + LOADCONST_A_BUILTIN(class_getconstant(class, i, CONSTANT_Class)); + s_count++; -+ BUILTIN2(BUILTIN_checkcast, TYPE_ADR); ++ BUILTIN2(BUILTIN_checkcast, TYPE_ADR,currentline); + */ - OP2A(opcode, 1, cls); + OP2A(opcode, 1, cls,currentline); } } @@ -1302,15 +1323,15 @@ void parse() /* array type cast-check */ LOADCONST_A_BUILTIN(cls->vftbl); s_count++; - BUILTIN2(BUILTIN_arrayinstanceof, TYPE_INT); + BUILTIN2(BUILTIN_arrayinstanceof, TYPE_INT,currentline); } else { /* object type cast-check */ /* LOADCONST_A_BUILTIN(class_getconstant(class, i, CONSTANT_Class)); s_count++; - BUILTIN2(BUILTIN_instanceof, TYPE_INT); + BUILTIN2(BUILTIN_instanceof, TYPE_INT,currentline); + */ - OP2A(opcode, 1, cls); + OP2A(opcode, 1, cls,currentline); } } break; @@ -1318,7 +1339,7 @@ void parse() case JAVA_MONITORENTER: #ifdef USE_THREADS if (checksync) { - BUILTIN1(BUILTIN_monitorenter, TYPE_VOID); + BUILTIN1(BUILTIN_monitorenter, TYPE_VOID,currentline); } else #endif { @@ -1329,7 +1350,7 @@ void parse() case JAVA_MONITOREXIT: #ifdef USE_THREADS if (checksync) { - BUILTIN1(BUILTIN_monitorexit, TYPE_VOID); + BUILTIN1(BUILTIN_monitorexit, TYPE_VOID,currentline); } else #endif @@ -1360,7 +1381,7 @@ void parse() #if defined(__I386__) OP(opcode); #else - BUILTIN2(BUILTIN_frem, TYPE_FLOAT); + BUILTIN2(BUILTIN_frem, TYPE_FLOAT,currentline); #endif break; @@ -1368,14 +1389,14 @@ void parse() #if defined(__I386__) OP(opcode); #else - BUILTIN2(BUILTIN_drem, TYPE_DOUBLE); + BUILTIN2(BUILTIN_drem, TYPE_DOUBLE,currentline); #endif break; case JAVA_F2I: #if defined(__ALPHA__) if (!opt_noieee) { - BUILTIN1(BUILTIN_f2i, TYPE_INT); + BUILTIN1(BUILTIN_f2i, TYPE_INT,currentline); } else #endif { @@ -1386,7 +1407,7 @@ void parse() case JAVA_F2L: #if defined(__ALPHA__) if (!opt_noieee) { - BUILTIN1(BUILTIN_f2l, TYPE_LONG); + BUILTIN1(BUILTIN_f2l, TYPE_LONG,currentline); } else #endif { @@ -1397,7 +1418,7 @@ void parse() case JAVA_D2I: #if defined(__ALPHA__) if (!opt_noieee) { - BUILTIN1(BUILTIN_d2i, TYPE_INT); + BUILTIN1(BUILTIN_d2i, TYPE_INT,currentline); } else #endif { @@ -1408,7 +1429,7 @@ void parse() case JAVA_D2L: #if defined(__ALPHA__) if (!opt_noieee) { - BUILTIN1(BUILTIN_d2l, TYPE_LONG); + BUILTIN1(BUILTIN_d2l, TYPE_LONG,currentline); } else #endif { diff --git a/loader.c b/loader.c index fadb17cc2..a258a085f 100644 --- a/loader.c +++ b/loader.c @@ -30,7 +30,7 @@ Mark Probst Edwin Steiner - $Id: loader.c 940 2004-03-06 14:04:15Z jowenn $ + $Id: loader.c 941 2004-03-06 17:27:56Z jowenn $ */ @@ -86,6 +86,7 @@ static utf *utf_innerclasses; /* InnerClasses */ static utf *utf_constantvalue; /* ConstantValue */ static utf *utf_code; /* Code */ static utf *utf_exceptions; /* Exceptions */ +static utf *utf_linenumbertable; /* LineNumberTable */ static utf *utf_finalize; /* finalize */ static utf *utf_fidesc; /* ()V changed */ static utf *utf_init; /* */ @@ -1047,6 +1048,8 @@ static void method_load(methodinfo *m, classinfo *c) count_all_methods++; #endif m->thrownexceptionscount=0; + m->linenumbercount=0; + m->linenumbers=0; m->class = c; m->flags = suck_u2(); @@ -1183,8 +1186,28 @@ static void method_load(methodinfo *m, classinfo *c) class_getconstant(c, idx, CONSTANT_Class); } } - - skipattributes(suck_u2()); + { + u2 codeattrnum; + for (codeattrnum=suck_u2();codeattrnum>0;codeattrnum--) { + utf * caname = class_getconstant(c, suck_u2(), CONSTANT_Utf8); + if (caname==utf_linenumbertable) { + u2 lncid; + /*log_text("LineNumberTable found");*/ + suck_u4(); + m->linenumbercount=suck_u2(); + /*printf("length:%d\n",m->linenumbercount);*/ + m->linenumbers=MNEW(lineinfo,m->linenumbercount); + for (lncid=0;lncidlinenumbercount;lncid++) { + m->linenumbers[lncid].start_pc=suck_u2(); + m->linenumbers[lncid].line_number=suck_u2(); + } + codeattrnum--; + skipattributes(codeattrnum); + break; + } else skipattributebody(); + + } + } } } @@ -3755,6 +3778,7 @@ void loader_init(u1 *stackbottom) utf_constantvalue = utf_new_char("ConstantValue"); utf_code = utf_new_char("Code"); utf_exceptions = utf_new_char("Exceptions"); + utf_linenumbertable = utf_new_char("LineNumberTable"); utf_finalize = utf_new_char("finalize"); utf_fidesc = utf_new_char("()V"); utf_init = utf_new_char(""); diff --git a/src/vm/global.h b/src/vm/global.h index cd3d90bb1..d9cf9dd71 100644 --- a/src/vm/global.h +++ b/src/vm/global.h @@ -31,7 +31,7 @@ Philipp Tomsich Edwin Steiner - $Id: global.h 940 2004-03-06 14:04:15Z jowenn $ + $Id: global.h 941 2004-03-06 17:27:56Z jowenn $ */ @@ -195,6 +195,7 @@ typedef struct vftbl vftbl; typedef u1* methodptr; typedef struct fieldinfo fieldinfo; typedef struct methodinfo methodinfo; +typedef struct lineinfo lineinfo; typedef struct arraydescriptor arraydescriptor; @@ -545,6 +546,12 @@ typedef struct xtainfo { } xtainfo; +/* lineinfo *****************************************************************/ +struct lineinfo { + u2 start_pc; + u2 line_number; +}; + /* methodinfo *****************************************************************/ struct methodinfo { /* method structure */ @@ -566,11 +573,13 @@ struct methodinfo { /* method structure */ u1 *jcode; /* pointer to JavaVM code */ s4 exceptiontablelength;/* exceptiontable length */ - exceptiontable *exceptiontable; + exceptiontable *exceptiontable; /* the exceptiontable */ + + u2 thrownexceptionscount; /*number of exceptions declared to be thrown by a method*/ + classinfo **thrownexceptions; /*array of classinfos of declared exceptions*/ - u2 thrownexceptionscount; - classinfo **thrownexceptions; - /* the exceptiontable */ + u2 linenumbercount; /*number of linenumber attributes*/ + lineinfo *linenumbers; /*array of lineinfo items (start_pc,line_number)*/ u1 *stubroutine; /* stub for compiling or calling natives */ s4 mcodelength; /* legth of generated machine code */ diff --git a/src/vm/jit/jit.c b/src/vm/jit/jit.c index 12dd4bc12..47a42cafa 100644 --- a/src/vm/jit/jit.c +++ b/src/vm/jit/jit.c @@ -29,7 +29,7 @@ Changes: Edwin Steiner - $Id: jit.c 923 2004-02-24 13:28:08Z edwin $ + $Id: jit.c 941 2004-03-06 17:27:56Z jowenn $ */ @@ -153,6 +153,8 @@ int maxstack; /* maximal JavaVM stack size */ int maxlocals; /* maximal number of local JavaVM variables */ int jcodelength; /* length of JavaVM-codes */ u1 *jcode; /* pointer to start of JavaVM-code */ +lineinfo *jlinenumbers; /* line information array */ +u2 jlinenumbercount; /* number of entries in the linenumber array */ int exceptiontablelength; /* length of exception table */ xtable *extable; /* pointer to start of exception table */ exceptiontable *raw_extable; @@ -1517,6 +1519,8 @@ methodptr jit_compile(methodinfo *m) maxlocals = m->maxlocals; jcodelength = m->jcodelength; jcode = m->jcode; + jlinenumbers = m->linenumbers; + jlinenumbercount = m->linenumbercount; exceptiontablelength = m->exceptiontablelength; raw_extable = m->exceptiontable; regs_ok = false; diff --git a/src/vm/jit/jit.h b/src/vm/jit/jit.h index c59ba67ba..d72017db9 100644 --- a/src/vm/jit/jit.h +++ b/src/vm/jit/jit.h @@ -29,7 +29,7 @@ Changes: Christian Thalinger - $Id: jit.h 938 2004-03-06 00:56:43Z twisti $ + $Id: jit.h 941 2004-03-06 17:27:56Z jowenn $ */ @@ -110,9 +110,10 @@ struct instruction { u2 opc; /* opcode of intermediate code command */ s4 op1; /* first operand, usually variable number */ imm_union val; /* immediate constant */ - void *target; /* used for targets of branches and jumps */ - /* and as address for list of targets for */ - /* statements */ + void *target; /* used for targets of branches and jumps */ + /* and as address for list of targets for */ + /* statements */ + u2 line /* line number in source file */ }; @@ -895,6 +896,8 @@ extern int maxstack; /* maximal JavaVM stack size */ extern int maxlocals; /* maximal number of local JavaVM variables */ extern int jcodelength; /* length of JavaVM-codes */ extern u1 *jcode; /* pointer to start of JavaVM-code */ +lineinfo *jlinenumbers; /* line information array */ +u2 jlinenumbercount; /* number of entries in the linenumber array */ extern int exceptiontablelength;/* length of exception table */ extern xtable *extable; /* pointer to start of exception table */ extern exceptiontable *raw_extable; diff --git a/src/vm/jit/parse.c b/src/vm/jit/parse.c index 3f0687611..93cb649e9 100644 --- a/src/vm/jit/parse.c +++ b/src/vm/jit/parse.c @@ -29,7 +29,7 @@ Changes: Carolyn Oates Edwin Steiner - $Id: parse.c 893 2004-01-19 12:53:24Z edwin $ + $Id: parse.c 941 2004-03-06 17:27:56Z jowenn $ */ @@ -344,13 +344,13 @@ void descriptor2types(methodinfo *m) #define OP(o) iptr->opc=(o);/*iptr->op1=0*/;/*iptr->val.l=0*/;PINC #define OP1(o,o1) iptr->opc=(o);iptr->op1=(o1);/*iptr->val.l=(0)*/;PINC #define OP2I(o,o1,v) iptr->opc=(o);iptr->op1=(o1);iptr->val.i=(v);PINC -#define OP2A(o,o1,v) iptr->opc=(o);iptr->op1=(o1);iptr->val.a=(v);PINC -#define BUILTIN1(v,t) isleafmethod=false;iptr->opc=ICMD_BUILTIN1;iptr->op1=t;\ - iptr->val.a=(v);PINC -#define BUILTIN2(v,t) isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\ - iptr->val.a=(v);PINC -#define BUILTIN3(v,t) isleafmethod=false;iptr->opc=ICMD_BUILTIN3;iptr->op1=t;\ - iptr->val.a=(v);PINC +#define OP2A(o,o1,v,l) iptr->opc=(o);iptr->op1=(o1);iptr->val.a=(v);iptr->line=l;PINC +#define BUILTIN1(v,t,l) isleafmethod=false;iptr->opc=ICMD_BUILTIN1;iptr->op1=t;\ + iptr->val.a=(v);iptr->line=l;PINC +#define BUILTIN2(v,t,l) isleafmethod=false;iptr->opc=ICMD_BUILTIN2;iptr->op1=t;\ + iptr->val.a=(v);iptr->line=l;PINC +#define BUILTIN3(v,t,l) isleafmethod=false;iptr->opc=ICMD_BUILTIN3;iptr->op1=t;\ + iptr->val.a=(v);iptr->line=l;PINC /* We have to check local variables indices here because they are * used in stack.c to index the locals array. */ @@ -471,6 +471,10 @@ void parse() xtable* nextex; /* points next free entry in extable */ u1 *instructionstart; /* 1 for pcs which are valid instr. starts */ + u2 lineindex=0; + u2 currentline=0; + u2 linepcchange=0; + bool useinltmp; if (compileverbose) { @@ -588,14 +592,31 @@ void parse() #endif /* scan all java instructions */ + currentline=0; + linepcchange=0; + if (jlinenumbercount==0) { + lineindex=0; + } else { + linepcchange=jlinenumbers[0].start_pc; + } for (p = 0, gp = 0; p < jcodelength; gp += (nextp - p), p = nextp) { /* DEBUG */ /*printf("p:%d gp:%d ",p,gp);*/ /* mark this position as a valid instruction start */ - if (!iswide) + if (!iswide) { instructionstart[p] = 1; + if (linepcchange==p) { + if (jlinenumbercount>lineindex) { + currentline=jlinenumbers[lineindex].line_number; + lineindex++; + if (lineindexvftbl; - OP2A(opcode, v, arrayvftbl); + OP2A(opcode, v, arrayvftbl,currentline); } break; @@ -1038,7 +1059,7 @@ void parse() tablep = DMNEW(s4, num * 2 + 2); } - OP2A(opcode, 0, tablep); + OP2A(opcode, 0, tablep,currentline); /* default target */ @@ -1108,7 +1129,7 @@ void parse() tablep = DMNEW(s4, num + 1 + 3); } - OP2A(opcode, 0, tablep); + OP2A(opcode, 0, tablep,currentline); /* default target */ @@ -1160,7 +1181,7 @@ void parse() /* load and store of object fields *******************/ case JAVA_AASTORE: - BUILTIN3(BUILTIN_aastore, TYPE_VOID); + BUILTIN3(BUILTIN_aastore, TYPE_VOID,currentline); break; case JAVA_PUTSTATIC: @@ -1171,7 +1192,7 @@ void parse() fieldinfo *fi; fr = class_getconstant(class, i, CONSTANT_Fieldref); fi = class_findfield(fr->class, fr->name, fr->descriptor); - OP2A(opcode, fi->type, fi); + OP2A(opcode, fi->type, fi,currentline); if (!fi->class->initialized) { isleafmethod = false; } @@ -1186,7 +1207,7 @@ void parse() fieldinfo *fi; fr = class_getconstant (class, i, CONSTANT_Fieldref); fi = class_findfield (fr->class, fr->name, fr->descriptor); - OP2A(opcode, fi->type, fi); + OP2A(opcode, fi->type, fi,currentline); } break; @@ -1211,7 +1232,7 @@ void parse() descriptor2types(mi); isleafmethod=false; - OP2A(opcode, mi->paramcount, mi); + OP2A(opcode, mi->paramcount, mi,currentline); } break; @@ -1235,7 +1256,7 @@ void parse() panic ("Static/Nonstatic mismatch calling static method"); descriptor2types(mi); isleafmethod=false; - OP2A(opcode, mi->paramcount, mi); + OP2A(opcode, mi->paramcount, mi,currentline); } break; @@ -1251,7 +1272,7 @@ void parse() panic ("Static/Nonstatic mismatch calling static method"); descriptor2types(mi); isleafmethod=false; - OP2A(opcode, mi->paramcount, mi); + OP2A(opcode, mi->paramcount, mi,currentline); } break; @@ -1262,7 +1283,7 @@ void parse() LOADCONST_A_BUILTIN(class_getconstant(class, i, CONSTANT_Class)); s_count++; - BUILTIN1(BUILTIN_new, TYPE_ADR); + BUILTIN1(BUILTIN_new, TYPE_ADR,currentline); break; case JAVA_CHECKCAST: @@ -1276,15 +1297,15 @@ void parse() /* array type cast-check */ LOADCONST_A_BUILTIN(cls->vftbl); s_count++; - BUILTIN2(BUILTIN_checkarraycast, TYPE_ADR); + BUILTIN2(BUILTIN_checkarraycast, TYPE_ADR,currentline); } else { /* object type cast-check */ /* + LOADCONST_A_BUILTIN(class_getconstant(class, i, CONSTANT_Class)); + s_count++; -+ BUILTIN2(BUILTIN_checkcast, TYPE_ADR); ++ BUILTIN2(BUILTIN_checkcast, TYPE_ADR,currentline); + */ - OP2A(opcode, 1, cls); + OP2A(opcode, 1, cls,currentline); } } @@ -1302,15 +1323,15 @@ void parse() /* array type cast-check */ LOADCONST_A_BUILTIN(cls->vftbl); s_count++; - BUILTIN2(BUILTIN_arrayinstanceof, TYPE_INT); + BUILTIN2(BUILTIN_arrayinstanceof, TYPE_INT,currentline); } else { /* object type cast-check */ /* LOADCONST_A_BUILTIN(class_getconstant(class, i, CONSTANT_Class)); s_count++; - BUILTIN2(BUILTIN_instanceof, TYPE_INT); + BUILTIN2(BUILTIN_instanceof, TYPE_INT,currentline); + */ - OP2A(opcode, 1, cls); + OP2A(opcode, 1, cls,currentline); } } break; @@ -1318,7 +1339,7 @@ void parse() case JAVA_MONITORENTER: #ifdef USE_THREADS if (checksync) { - BUILTIN1(BUILTIN_monitorenter, TYPE_VOID); + BUILTIN1(BUILTIN_monitorenter, TYPE_VOID,currentline); } else #endif { @@ -1329,7 +1350,7 @@ void parse() case JAVA_MONITOREXIT: #ifdef USE_THREADS if (checksync) { - BUILTIN1(BUILTIN_monitorexit, TYPE_VOID); + BUILTIN1(BUILTIN_monitorexit, TYPE_VOID,currentline); } else #endif @@ -1360,7 +1381,7 @@ void parse() #if defined(__I386__) OP(opcode); #else - BUILTIN2(BUILTIN_frem, TYPE_FLOAT); + BUILTIN2(BUILTIN_frem, TYPE_FLOAT,currentline); #endif break; @@ -1368,14 +1389,14 @@ void parse() #if defined(__I386__) OP(opcode); #else - BUILTIN2(BUILTIN_drem, TYPE_DOUBLE); + BUILTIN2(BUILTIN_drem, TYPE_DOUBLE,currentline); #endif break; case JAVA_F2I: #if defined(__ALPHA__) if (!opt_noieee) { - BUILTIN1(BUILTIN_f2i, TYPE_INT); + BUILTIN1(BUILTIN_f2i, TYPE_INT,currentline); } else #endif { @@ -1386,7 +1407,7 @@ void parse() case JAVA_F2L: #if defined(__ALPHA__) if (!opt_noieee) { - BUILTIN1(BUILTIN_f2l, TYPE_LONG); + BUILTIN1(BUILTIN_f2l, TYPE_LONG,currentline); } else #endif { @@ -1397,7 +1418,7 @@ void parse() case JAVA_D2I: #if defined(__ALPHA__) if (!opt_noieee) { - BUILTIN1(BUILTIN_d2i, TYPE_INT); + BUILTIN1(BUILTIN_d2i, TYPE_INT,currentline); } else #endif { @@ -1408,7 +1429,7 @@ void parse() case JAVA_D2L: #if defined(__ALPHA__) if (!opt_noieee) { - BUILTIN1(BUILTIN_d2l, TYPE_LONG); + BUILTIN1(BUILTIN_d2l, TYPE_LONG,currentline); } else #endif { diff --git a/src/vm/loader.c b/src/vm/loader.c index fadb17cc2..a258a085f 100644 --- a/src/vm/loader.c +++ b/src/vm/loader.c @@ -30,7 +30,7 @@ Mark Probst Edwin Steiner - $Id: loader.c 940 2004-03-06 14:04:15Z jowenn $ + $Id: loader.c 941 2004-03-06 17:27:56Z jowenn $ */ @@ -86,6 +86,7 @@ static utf *utf_innerclasses; /* InnerClasses */ static utf *utf_constantvalue; /* ConstantValue */ static utf *utf_code; /* Code */ static utf *utf_exceptions; /* Exceptions */ +static utf *utf_linenumbertable; /* LineNumberTable */ static utf *utf_finalize; /* finalize */ static utf *utf_fidesc; /* ()V changed */ static utf *utf_init; /* */ @@ -1047,6 +1048,8 @@ static void method_load(methodinfo *m, classinfo *c) count_all_methods++; #endif m->thrownexceptionscount=0; + m->linenumbercount=0; + m->linenumbers=0; m->class = c; m->flags = suck_u2(); @@ -1183,8 +1186,28 @@ static void method_load(methodinfo *m, classinfo *c) class_getconstant(c, idx, CONSTANT_Class); } } - - skipattributes(suck_u2()); + { + u2 codeattrnum; + for (codeattrnum=suck_u2();codeattrnum>0;codeattrnum--) { + utf * caname = class_getconstant(c, suck_u2(), CONSTANT_Utf8); + if (caname==utf_linenumbertable) { + u2 lncid; + /*log_text("LineNumberTable found");*/ + suck_u4(); + m->linenumbercount=suck_u2(); + /*printf("length:%d\n",m->linenumbercount);*/ + m->linenumbers=MNEW(lineinfo,m->linenumbercount); + for (lncid=0;lncidlinenumbercount;lncid++) { + m->linenumbers[lncid].start_pc=suck_u2(); + m->linenumbers[lncid].line_number=suck_u2(); + } + codeattrnum--; + skipattributes(codeattrnum); + break; + } else skipattributebody(); + + } + } } } @@ -3755,6 +3778,7 @@ void loader_init(u1 *stackbottom) utf_constantvalue = utf_new_char("ConstantValue"); utf_code = utf_new_char("Code"); utf_exceptions = utf_new_char("Exceptions"); + utf_linenumbertable = utf_new_char("LineNumberTable"); utf_finalize = utf_new_char("finalize"); utf_fidesc = utf_new_char("()V"); utf_init = utf_new_char("");