comparison src/main/gov/nasa/jpf/vm/MJIEnv.java @ 23:db918c531e6d

streamlined class init, which was a mixed case of registerClass()/initializeClass() and pushRequiredClinits(). Now it is a single initializeClass(ti) method which combines the previous initializeClass(), pushRequiredClinits() and pushClinit() methods. The reason for combining these is the forthcoming replacement of separately locked clinits from different DirectCallStackFrames with a single synthetic frame that calls clinits from nested synchronized blocks. This is required to model hotspot, which does cause deadlocks with concurrent init of classes that cause subclass init during their clinit executions.
author Peter Mehlitz <Peter.C.Mehlitz@nasa.gov>
date Wed, 15 Apr 2015 22:40:21 -0700
parents caa0924e093d
children 6774e2e08d37
comparison
equal deleted inserted replaced
22:cd7880ab73c7 23:db918c531e6d
1036 1036
1037 return heap.newArray(elementClsName, size, ti).getObjectRef(); 1037 return heap.newArray(elementClsName, size, ti).getObjectRef();
1038 } 1038 }
1039 1039
1040 public ElementInfo newElementInfo (ClassInfo ci){ 1040 public ElementInfo newElementInfo (ClassInfo ci){
1041 if (ci.pushRequiredClinits(ti)){ 1041 if (ci.initializeClass(ti)){
1042 throw new ClinitRequired(ci); 1042 throw new ClinitRequired(ci);
1043 } 1043 }
1044 1044
1045 return heap.newObject(ci, ti); 1045 return heap.newObject(ci, ti);
1046 } 1046 }
1289 /** 1289 /**
1290 * use this whenever a peer performs an operation on a class that might not be initialized yet 1290 * use this whenever a peer performs an operation on a class that might not be initialized yet
1291 * Do a repeatInvocation() in this case 1291 * Do a repeatInvocation() in this case
1292 */ 1292 */
1293 public boolean requiresClinitExecution(ClassInfo ci) { 1293 public boolean requiresClinitExecution(ClassInfo ci) {
1294 return ci.pushRequiredClinits(ti); 1294 return ci.initializeClass(ti);
1295 } 1295 }
1296 1296
1297 /** 1297 /**
1298 * repeat execution of the instruction that caused a native method call 1298 * repeat execution of the instruction that caused a native method call
1299 * NOTE - this does NOT mean it's the NEXT executed insn, since the native method 1299 * NOTE - this does NOT mean it's the NEXT executed insn, since the native method
1742 ThreadInfo ti = getThreadInfo(); 1742 ThreadInfo ti = getThreadInfo();
1743 1743
1744 // NOTE: we have to repeat no matter what, since this is called from 1744 // NOTE: we have to repeat no matter what, since this is called from
1745 // a handler context (if we only had to create a class object w/o 1745 // a handler context (if we only had to create a class object w/o
1746 // calling clinit, we can't just go on) 1746 // calling clinit, we can't just go on)
1747 ci.pushRequiredClinits(ti); 1747 ci.initializeClass(ti);
1748 repeatInvocation(); 1748 repeatInvocation();
1749 } 1749 }
1750 1750
1751 public StackFrame getCallerStackFrame() { 1751 public StackFrame getCallerStackFrame() {
1752 // since native methods are now executed within their own stack frames 1752 // since native methods are now executed within their own stack frames