From: jzhou Date: Thu, 31 May 2012 00:17:54 +0000 (+0000) Subject: Fix bugs: 1) reorder the initialization of static fields and the execution of static... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=bb567462fe31ae45b904c2f3236b456a782137b5 Fix bugs: 1) reorder the initialization of static fields and the execution of static blocks to make sure that a class' static fields/blocks are initialized/executed after those of its super classes' 2) fix compile problem of FileInputStream.nativeOpen() --- diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 59ee3e07..c18d65f2 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -331,23 +331,57 @@ public class BuildCode { // execute all the static blocks and all the static field initializations SymbolTable sctbl = this.state.getSClassSymbolTable(); Iterator it_sclasses = sctbl.getDescriptorsIterator(); - if(it_sclasses.hasNext()) { - while(it_sclasses.hasNext()) { - ClassDescriptor t_cd = (ClassDescriptor)it_sclasses.next(); - MethodDescriptor t_md = (MethodDescriptor)t_cd.getMethodTable().get("staticblocks"); - - if(t_md != null&&callgraph.isInit(t_cd)) { - outmethod.println(" {"); - if ((GENERATEPRECISEGC) || state.MULTICOREGC||state.PMC) { - outmethod.print(" struct "+t_cd.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"_params __parameterlist__={"); - outmethod.println("0, NULL};"); - outmethod.println(" "+t_cd.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"(& __parameterlist__);"); - } else { - outmethod.println(" "+t_cd.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();"); - } - outmethod.println(" }"); - } - } + Vector tooutput = new Vector(); + Queue toprocess=new LinkedList(); + Vector outputs = new Vector(); + while(it_sclasses.hasNext()) { + ClassDescriptor t_cd = (ClassDescriptor)it_sclasses.next(); + if(!outputs.contains(t_cd)) { + tooutput.clear(); + tooutput.add(t_cd); + toprocess.clear(); + toprocess.add(t_cd); + while(!toprocess.isEmpty()) { + ClassDescriptor pcd = toprocess.poll(); + // check super interfaces + Iterator it_sinterfaces = pcd.getSuperInterfaces(); + while(it_sinterfaces.hasNext()) { + ClassDescriptor sint = (ClassDescriptor)it_sinterfaces.next(); + if(!outputs.contains(sint)) { + toprocess.add(sint); + if(sctbl.contains(sint.getClassName())) { + tooutput.add(sint); + } + } + } + // check super classes + ClassDescriptor supercd = pcd.getSuperDesc(); + if(supercd!=null && !outputs.contains(supercd)) { + toprocess.add(supercd); + if(sctbl.contains(supercd.getClassName())) { + tooutput.add(supercd); + } + } + } + + for(int i = tooutput.size()-1; i>=0; i--) { + ClassDescriptor output = tooutput.elementAt(i); + MethodDescriptor t_md = (MethodDescriptor)output.getMethodTable().get("staticblocks"); + + if(t_md != null&&callgraph.isInit(output)) { + outmethod.println(" {"); + if ((GENERATEPRECISEGC) || state.MULTICOREGC||state.PMC) { + outmethod.print(" struct "+output.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"_params __parameterlist__={"); + outmethod.println("0, NULL};"); + outmethod.println(" "+output.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"(& __parameterlist__);"); + } else { + outmethod.println(" "+output.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();"); + } + outmethod.println(" }"); + } + outputs.add(output); + } + } } } diff --git a/Robust/src/Runtime/file.c b/Robust/src/Runtime/file.c index f9401e84..20763a9d 100644 --- a/Robust/src/Runtime/file.c +++ b/Robust/src/Runtime/file.c @@ -84,8 +84,6 @@ int CALL01(___FileInputStream______nativeOpen_____AR_B, struct ArrayObject * ___ return 0; #endif #else - int length=VAR(___filename___)->___length___; - char* filename= (((char *)&VAR(___filename___)->___length___)+sizeof(int)); int fd; if ((fd=open(filename, O_RDONLY, 0)) < 0) { printf(">>>\n");