├── JikesRVMProbes ├── .hgignore ├── Makefile ├── README ├── SpecApplication.java ├── bmadvice │ ├── _201_compress.ca │ ├── _201_compress.dc │ ├── _201_compress.ec │ ├── _202_jess.ca │ ├── _202_jess.dc │ ├── _202_jess.ec │ ├── _209_db.ca │ ├── _209_db.dc │ ├── _209_db.ec │ ├── _213_javac.ca │ ├── _213_javac.dc │ ├── _213_javac.ec │ ├── _222_mpegaudio.ca │ ├── _222_mpegaudio.dc │ ├── _222_mpegaudio.ec │ ├── _227_mtrt.ca │ ├── _227_mtrt.dc │ ├── _227_mtrt.ec │ ├── _228_jack.ca │ ├── _228_jack.dc │ ├── _228_jack.ec │ ├── antlr.ca │ ├── antlr.dc │ ├── antlr.ec │ ├── avrora.ca │ ├── avrora.dc │ ├── avrora.ec │ ├── bestadvice.log │ ├── bloat.ca │ ├── bloat.dc │ ├── bloat.ec │ ├── eclipse.ca │ ├── eclipse.dc │ ├── eclipse.ec │ ├── fop.ca │ ├── fop.dc │ ├── fop.ec │ ├── hsqldb.ca │ ├── hsqldb.dc │ ├── hsqldb.ec │ ├── jython.ca │ ├── jython.dc │ ├── jython.ec │ ├── luindex.ca │ ├── luindex.dc │ ├── luindex.ec │ ├── lusearch.ca │ ├── lusearch.dc │ ├── lusearch.ec │ ├── lusearch_fix.ca │ ├── lusearch_fix.dc │ ├── lusearch_fix.ec │ ├── pickadvice.py │ ├── pjbb2005.ca │ ├── pjbb2005.dc │ ├── pjbb2005.ec │ ├── pmd.ca │ ├── pmd.dc │ ├── pmd.ec │ ├── sunflow.ca │ ├── sunflow.dc │ ├── sunflow.ec │ ├── track.log │ ├── xalan.ca │ ├── xalan.dc │ └── xalan.ec ├── common.mk ├── moma │ ├── Disassemble.java │ ├── MoMaLogger.java │ ├── MoMaProfiler.java │ ├── MoMaSampling.java │ ├── MomaCallBack.java │ ├── MomaCmd.java │ ├── MomaThread.java │ ├── Util.java │ └── testrdpmc.java ├── native │ ├── hello_world │ │ ├── Makefile │ │ └── hello_world.c │ ├── perf_event │ │ ├── Makefile │ │ ├── m32_patch │ │ ├── perf_event_agent.c │ │ ├── perf_event_launcher.c │ │ ├── perf_event_launcher_jni.c │ │ ├── perf_event_reader_jni.c │ │ └── perf_event_shim.c │ ├── ptlsim │ │ ├── Makefile │ │ └── ptlsim.c │ └── valgrind │ │ ├── Makefile │ │ ├── cachegrind.h │ │ ├── probes-valgrind-3.5.0.patch │ │ ├── valgrind.c │ │ └── valgrind.h ├── probe │ ├── ApplicationPerfEventProbe.java │ ├── CompilerSamplesProbe.java │ ├── Dacapo2006Callback.java │ ├── DacapoBachCallback.java │ ├── HelloWorldNativeProbe.java │ ├── HelloWorldProbe.java │ ├── HooverProbe.java │ ├── JikesRVMPerfEventProbe.java │ ├── MMTkProbe.java │ ├── MomaProbe.java │ ├── PJBB2005Callback.java │ ├── PTLsimProbe.java │ ├── PerfEventLauncherProbe.java │ ├── PerfEventProbe.java │ ├── PerfEventReader.java │ ├── PowerProbe.java │ ├── Probe.java │ ├── ProbeMux.java │ ├── ReplayProbe.java │ ├── ScenarioProbe.java │ ├── ShellProbe.java │ ├── StopJITProbe.java │ ├── ThreadEventProbe.java │ └── ValgrindProbe.java ├── remotebuild.sh └── spec │ └── harness │ ├── ProgramRunner.java │ └── RunProgram.java ├── LICENSE ├── Makefile ├── README.md ├── example └── shim_example.c ├── papers └── ISCA-SHIM.pdf ├── ppid_module ├── Makefile ├── README ├── callback.patch ├── create_ppid_device.sh ├── ppid_map.c └── ppid_test.c ├── remotebuild.sh ├── shim.h └── shim_core.c /JikesRVMProbes/.hgignore: -------------------------------------------------------------------------------- 1 | .class 2 | libpfm4 3 | .o 4 | .so 5 | perf_event_launcher 6 | -------------------------------------------------------------------------------- /JikesRVMProbes/Makefile: -------------------------------------------------------------------------------- 1 | include common.mk 2 | #usage: make [OPTION=-m32]. If OPTION=-m32 is specified and the current machine is X86_64, 32bit version will be build. 3 | 4 | all: native-code probes.jar moma 5 | 6 | ## cd native/valgrind; $(MAKE) $(MFLAGS) all 7 | # cp -a native/valgrind/libvalgrind.so libvalgrind.so 8 | native-code: 9 | cd native/hello_world; $(MAKE) $(MFLAGS) all 10 | cp -a native/hello_world/libhello_world.so libhello_world.so 11 | cd native/perf_event; $(MAKE) $(MFLAGS) all 12 | cp -a native/perf_event/perf_event_launcher perf_event_launcher 13 | cp -a native/perf_event/libperf_event_launcher.so libperf_event_launcher.so 14 | cp -a native/perf_event/libperf_event_reader.so libperf_event_reader.so 15 | cp -a native/perf_event/libperf_event_shim.so libperf_event_shim.so 16 | cd native/ptlsim; $(MAKE) $(MFLAGS) all 17 | cp -a native/ptlsim/libptlsim.so libptlsim.so 18 | 19 | 20 | test: all 21 | $(JAVA) -Djava.library.path=`pwd` -Dprobes=HelloWorldNative -cp probes.jar:/usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar Harness -c probe.Dacapo2006Callback fop 22 | $(JAVA) -Dprobes=HelloWorld -cp probes.jar:/usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar Harness -c probe.Dacapo2006Callback fop 23 | $(JAVA) -Dprobes=Scenario -cp probes.jar:/usr/share/benchmarks/dacapo/dacapo-9.12-bach.jar Harness -c probe.DacapoBachCallback fop 24 | cd /usr/share/benchmarks/SPECjvm98; $(JAVA) -Dprobes=HelloWorld -cp $(CURDIR)/probes.jar:. SpecApplication -i1 _202_jess 25 | $(JAVA) -Xmx1G -Xms200M -Dprobes=HelloWorld -cp probes.jar:/usr/share/benchmarks/pjbb2005/jbb.jar:/usr/share/benchmarks/pjbb2005/check.jar spec.jbb.JBBmain -propfile SPECjbb-8x10000.props -c probe.PJBB2005Callback -n 1 26 | ./perf_event_launcher PERF_COUNT_HW_CPU_CYCLES $(JAVA) -Djava.library.path=`pwd` -Dprobes=PerfEventLauncher -cp probes.jar:/usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar Harness -c probe.Dacapo2006Callback fop 27 | $(JAVA) -Djava.library.path=`pwd` -Dprobes=PTLsim -cp probes.jar:/usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar Harness -c probe.Dacapo2006Callback fop 28 | $(JAVA) -Djava.library.path=`pwd` -Dprobes=Valgrind -cp probes.jar:/usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar Harness -c probe.Dacapo2006Callback fop 29 | $(JAVA) -Djava.library.path=`pwd` -Dprobes=StopJIT -Dprobe.stopjit.sleeptime=3 -Dprobe.stopjit.iteration=4 -cp probes.jar:/usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar Harness -c probe.Dacapo2006Callback -n 5 fop 30 | 31 | 32 | clean: 33 | rm -f *.so 34 | rm -f *.class 35 | rm -f *.jar 36 | rm -f spec/harness/*.class 37 | rm -f probe/*.class 38 | rm -f moma/*.class 39 | cd native/perf_event; $(MAKE) $(MFLAGS) clean 40 | cd native/hello_world; $(MAKE) $(MFLAGS) clean 41 | cd native/ptlsim; $(MAKE) $(MFLAGS) clean 42 | cd native/valgrind; $(MAKE) $(MFLAGS) clean 43 | 44 | probes.jar: probe/HelloWorldNativeProbe.class probe/ScenarioProbe.class probe/StopJITProbe.class probe/ValgrindProbe.class probe/PTLsimProbe.class probe/JikesRVMPerfEventProbe.class probe/MMTkProbe.class probe/ThreadEventProbe.class probe/PowerProbe.class probe/PerfEventProbe.class probe/PerfEventReader.class probe/PerfEventLauncherProbe.class probe/ApplicationPerfEventProbe.class probe/HelloWorldProbe.class probe/Probe.class probe/ProbeMux.class probe/PJBB2005Callback.class probe/Dacapo2006Callback.class probe/DacapoBachCallback.class spec/harness/ProgramRunner.class spec/harness/RunProgram.class SpecApplication.class probe/HooverProbe.class probe/ReplayProbe.class probe/CompilerSamplesProbe.class probe/MomaProbe.class moma/MomaThread.class moma/MomaCallBack.class moma/Util.class moma/Disassemble.class probe/ShellProbe.class moma/MomaCmd.class 45 | zip -r probes.jar *.class spec/harness/*.class probe/*.class moma/*.class 46 | 47 | SpecApplication.class: SpecApplication.java 48 | $(JAVAC) -implicit:none -cp .:/usr/share/benchmarks/SPECjvm98 -sourcepath . $< 49 | 50 | spec/%.class: spec/%.java 51 | $(JAVAC) -implicit:none -cp .:/usr/share/benchmarks/SPECjvm98 -sourcepath . $< 52 | 53 | moma/%.class: moma/%.java 54 | $(JAVAC) -cp .:$(JIKESRVMJAR) -sourcepath . $< 55 | probe/ReplayProbe.class:probe/ReplayProbe.java 56 | $(JAVAC) -cp .:$(JIKESRVMJAR) -sourcepath . $< 57 | probe/MMTkProbe.class:probe/MMTkProbe.java 58 | $(JAVAC) -cp .:$(JIKESRVMJAR) -sourcepath . $< 59 | probe/MomaProbe.class: probe/MomaProbe.java 60 | $(JAVAC) -cp .:$(JIKESRVMJAR) -sourcepath . $< 61 | probe/ShellProbe.class: probe/ShellProbe.java 62 | $(JAVAC) -cp .:$(JIKESRVMJAR) -sourcepath . $< 63 | 64 | %.class: %.java 65 | $(JAVAC) -cp . $< 66 | 67 | probe/Dacapo2006Callback.class: 68 | $(JAVAC) -cp .:/usr/share/benchmarks/dacapo/dacapo-2006-10-MR2.jar probe/Dacapo2006Callback.java 69 | 70 | probe/DacapoBachCallback.class: 71 | $(JAVAC) -cp .:/usr/share/benchmarks/dacapo/dacapo-9.12-bach.jar probe/DacapoBachCallback.java 72 | 73 | probe/PJBB2005Callback.class: 74 | $(JAVAC) -cp .:/usr/share/benchmarks/pjbb2005/jbb.jar probe/PJBB2005Callback.java 75 | -------------------------------------------------------------------------------- /JikesRVMProbes/README: -------------------------------------------------------------------------------- 1 | This directory contains many call back modules for Java workloads. 2 | "moma" is the module for profiling JikesRVM with SHIM. Here is 3 | the instruction to setup it up. 4 | 5 | * moma needs a special kernel and a kernel driver to tell you who is 6 | running at which hardware contexts. 7 | 8 | The kernel patch and the driver is in "../ppid_module" directory. 9 | Please follow "README" in the directory to setup the kernel. 10 | 11 | 12 | * moma needs a patched JikesRVM for generating signals. 13 | 14 | hg clone https://coderyang@bitbucket.org/coderyang/jikesrvmshim jikesrvmshim 15 | cd jikesrvmshim; 16 | #switch to moma branch 17 | hg update moma; 18 | #build JikesRVM 19 | #you need these packages to build the JikesRVM, 20 | #build-essential, gcc-multilib, g++-multilib, ant, bison, openjdk-7-jdk and mercurial 21 | #build the JikesRVM 22 | ./bin/build ./bin/buildit --with-perfevent localhost production -m shimIP 23 | #this build generates method ID, yieldpoint ID, GC phase signals 24 | 25 | * compile probes 26 | #setup parameters in "common.mk" based on where you put the JikesRVM 27 | #build the JikesRVM probes 28 | make OPTION=-m32 29 | 30 | * run experiments 31 | #download dacapo benchmark http://www.dacapobench.org 32 | #setup PROBEDIR 33 | PROBEDIR=`pwd` 34 | #On i7-4770 processor, this will bind JikesRVM process on CPU 7, SHIM thread on CPU 3 will observe 35 | #the application's behavior in the same core, and build a histogram about the average IPC of methods. 36 | sudo taskset 0x80 ../../jikesrvmshim/dist/production_shimIP_x86_64-linux/rvm -X:gc:threads=1 -Xms204M -X:gc:variableSizeHeap=false -Dprobes=Moma -X:vm:momaEvents=UNHALTED_CORE_CYCLES:u:k,INSTRUCTION_RETIRED:u:k:t,INSTRUCTION_RETIRED:u:k -X:gc:eagerMmapSpaces=true -X:availableProcessors=1 -X:vm:momaApproach=same,cmidHistogram,1,default -X:gc:fixedNursery=32M -Djava.library.path=$PROBEDIR -cp $PROBEDIR/probes.jar:/usr/share/benchmarks/dacapo/dacapo-9.12-bach.jar Harness -c probe.DacapoBachCallback -n 3 lusearch 37 | #if you want to control the compiler, you can do a warmup reply 38 | REPLAYDIR=`pwd`/bmadvice 39 | sudo taskset 0x80 ../../jikesrvmshim/dist/production_shimIP_x86_64-linux/rvm -X:gc:threads=1 -Xms204M -X:gc:variableSizeHeap=false -Dprobes=Replay,Moma -X:aos:initial_compiler=base -X:aos:enable_recompilation=false -X:aos:enable_bulk_compile=true -X:aos:cafi=$REPLAYDIR/lusearch.ca -X:aos:dcfi=$REPLAYDIR/lusearch.dc -X:vm:edgeCounterFile=$REPLAYDIR/lusearch.ec -X:vm:momaEvents=UNHALTED_CORE_CYCLES:u:k,INSTRUCTION_RETIRED:u:k:t,INSTRUCTION_RETIRED:u:k -X:gc:eagerMmapSpaces=true -X:availableProcessors=1 -X:vm:momaApproach=same,cmidHistogram,1,default -X:gc:fixedNursery=32M -Djava.library.path=$PROBEDIR -cp $PROBEDIR/probes.jar:/usr/share/benchmarks/dacapo/dacapo-9.12-bach.jar Harness -c probe.DacapoBachCallback -n 3 lusearch 40 | -------------------------------------------------------------------------------- /JikesRVMProbes/SpecApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)SpecApplication.java 1.28 06/17/98 3 | * 4 | * Copyright (c) 1998 Standard Performance Evaluation Corporation (SPEC) 5 | * All rights reserved. 6 | * Copyright (c) 1997,1998 Sun Microsystems, Inc. All rights reserved. 7 | * 8 | * This source code is provided as is, without any express or implied warranty. 9 | */ 10 | 11 | import java.awt.*; 12 | import java.applet.*; 13 | import spec.harness.*; 14 | 15 | /** 16 | This class is used for launching the SpecJVMClien98 as an application. This mode 17 | of operation is only for debugging purpose. The results from this mode can or 18 | can't reported to the Spec team depending on the final run rules 19 | */ 20 | 21 | public class SpecApplication { 22 | 23 | static boolean autogc = false; 24 | static int automin = 1; 25 | static int automax = 99; 26 | static int probeRun = 0; 27 | static int autodelay = 0; 28 | static int pct100; 29 | static boolean useThreads = false; // only use for stand alone option 30 | static java.util.Properties props = getBasicProperties(); 31 | 32 | // Main - creates a frame (SpecApplicationFrame) and set up applet to run 33 | // within that frame. 34 | 35 | /** 36 | Instance main method. This method parses all the command line options for 37 | SpecJVMClient and sets the run parameters accordingly. 38 | */ 39 | public static void main( String args[] ) { 40 | 41 | boolean runHarness = true; 42 | boolean autorun = false; 43 | 44 | Context.setCachedInputFlag( false ); 45 | 46 | for( int i = 0 ; i < args.length ; i++ ) { 47 | String s = args[i]; 48 | if( s.charAt( 0 ) == '-' ) { 49 | switch( s.charAt( 1 ) ) { 50 | 51 | case 'a': 52 | autorun = true; 53 | break; 54 | 55 | case 'b': 56 | // non-interactive, formerly known as batch 57 | // to generations of punch card programmers 58 | // in the days when men were men and 59 | // programming language was FORTRAN 60 | Context.setBatch(true); 61 | break; 62 | 63 | case 'c': 64 | ProgramRunner.createValidityCheckFiles = true; 65 | Context.out.println( "Will create validity check files" ); 66 | break; 67 | 68 | case 'd': 69 | autodelay = getarg (s,0); 70 | Context.out.println ("Will delay " + autodelay + 71 | " ms in between benchmarks"); 72 | break; 73 | 74 | case 'g': 75 | autogc = true; 76 | Context.out.println ("Will gc in between benchmarks" ); 77 | break; 78 | 79 | case 'i': 80 | probeRun = getarg (s,0); 81 | Context.out.println("Will use probeRun mode with " + probeRun + " iterations."); 82 | break; 83 | case 'm': 84 | automin = getarg (s,1); 85 | Context.out.println ("Will run each benchmark " + 86 | "at least " + automin + " times"); 87 | props.put ("spec.initial.automin", 88 | Integer.toString(automin)); 89 | break; 90 | 91 | case 'M': 92 | automax = getarg (s,99); 93 | Context.out.println ("Will run each benchmark " + 94 | "at most " + automax + " times"); 95 | props.put ("spec.initial.automax", 96 | Integer.toString(automax)); 97 | break; 98 | 99 | case 'n': 100 | Context.setCachedInputFlag( true ); 101 | break; 102 | 103 | case 'p': { 104 | char c = s.charAt( 2 ); 105 | ProgramRunner.ThreadPriority = (int)c - 0x30; 106 | Context.out.println( "ThreadPriority will be " + ProgramRunner.ThreadPriority ); 107 | break; 108 | } 109 | 110 | case 'P': { 111 | pct100 = getarg (s,300); 112 | double p = pct100/100.0; 113 | Context.out.println ("autorun threshhold is " 114 | + p + "%"); 115 | props.put ("spec.initial.percentTimes100", 116 | Integer.toString (pct100)); 117 | break; 118 | } 119 | 120 | case 's': { 121 | int val = 0; 122 | for( int j = 2 ; j < s.length() ; j++ ) { 123 | val *= 10; 124 | val += ((int)s.charAt( j )) - 0x30; 125 | } 126 | Context.setSpeed( val ); 127 | System.out.println( "Speed will be " + val ); 128 | break; 129 | } 130 | 131 | case 't': { 132 | useThreads = true; 133 | Context.out.println( "Will run using thread" ); 134 | break; 135 | } 136 | 137 | case 'u': { 138 | String userPropFile = s.substring(2); 139 | Context.out.println("User properties: " + userPropFile ); 140 | Context.setUserPropFile (userPropFile); 141 | break; 142 | } 143 | 144 | /* 145 | case 'v': { 146 | Context.setVerify(false); 147 | Context.out.println( "Will not verify" ); 148 | break; 149 | } 150 | */ 151 | 152 | default: { 153 | usage(); 154 | System.exit( 1 ); 155 | } 156 | } 157 | } else { 158 | runHarness = false; 159 | Context.setCommandLineMode (false); 160 | runBenchmark( s, autorun, probeRun ); 161 | } 162 | } 163 | 164 | if( runHarness ) { 165 | harness(); 166 | } 167 | 168 | if( !runHarness && !useThreads ) 169 | System.exit(0); // Should not be necessary but... 170 | 171 | } 172 | 173 | /** 174 | Parses the arguments 175 | */ 176 | private static int getarg (String s, int value){ 177 | if (s != null && s.length() > 2){ 178 | try{ 179 | value = Integer.parseInt (s.substring(2)); 180 | }catch (NumberFormatException e){} 181 | } 182 | return value; 183 | } 184 | 185 | /** 186 | The usage text is displayed, if the user runs the benchmark with wrong parameters 187 | */ 188 | private static void usage(){ 189 | Context.out.println ("Usage: java [JVMoptions] SpecApplication " + 190 | "[options] [_NNN_benchmark]\n" + 191 | "Options:\n" + 192 | "-a Perform autorun sequence on a single selected benchmark\n" + 193 | "-b Non-interactive execution controlled by parameter settings\n" + 194 | "-c Create new validity check files\n" + 195 | "-d Delay milliseconds between benchmark executions\n" + 196 | "-g Garbage collect in between benchmark executions\n" + 197 | "-i Use probe running mode for the number of iterations\n" + 198 | "-m Set minimum number of executions in autorun sequence\n" + 199 | "-M Set maximum number of executions in autorun sequence\n" + 200 | "-n Turn *ON* file input caching\n" + 201 | " >>note the sense of this switch changed in V20<<\n" + 202 | "-p Set thread priority to \n" + 203 | "-P Set autorun improvement threshhold (hundreths of a percent)\n" + 204 | "-s Set problem size to , 1, 10, or 100\n" + 205 | "-u Specify property file instead of props/user\n" 206 | ); 207 | } 208 | 209 | /** 210 | Brings up the harness window 211 | */ 212 | public static void harness() { 213 | 214 | // Create Toplevel Window to contain applet hello 215 | 216 | SpecApplicationFrame frame = new SpecApplicationFrame( "SPEC JVM Client98" ); 217 | 218 | // Must show Frame before we size it so insets() will return valid values 219 | 220 | frame.show(); 221 | frame.hide(); 222 | frame.resize(frame.insets().left + frame.insets().right + 530, 223 | frame.insets().top + frame.insets().bottom + 375); 224 | 225 | // The following code starts the applet running within the frame window. 226 | // It also calls GetParameters() to retrieve parameter values from the 227 | // command line, and sets m_fStandAlone to true to prevent init() from 228 | // trying to get them from the HTML page. 229 | 230 | SpecApplet applet = new SpecApplet(); 231 | 232 | frame.add("Center", applet); 233 | 234 | applet.applicationInit(); 235 | applet.start(); 236 | 237 | frame.show(); 238 | } 239 | 240 | /** 241 | Runs the selected benchmark 242 | */ 243 | public static void runBenchmark( String className, boolean autorun, int probeRun ) { 244 | Context.setCommandLineMode(true); 245 | RunProgram.run( 246 | className, 247 | autorun, 248 | probeRun, 249 | props, 250 | new SpecApplicationRunner() 251 | ); 252 | RunProgram.done(); 253 | } 254 | 255 | private static java.util.Properties getBasicProperties() { 256 | java.util.Properties props = new java.util.Properties(); 257 | try { 258 | java.io.FileInputStream fs = new java.io.FileInputStream("props/spec"); 259 | props.load(fs); 260 | fs.close(); 261 | } catch(java.io.IOException x) { 262 | Context.out.println("Error reading props/spec"+x); 263 | } 264 | return props; 265 | } 266 | } 267 | 268 | class SpecApplicationRunner implements spec.harness.BenchmarkDone { 269 | 270 | public void benchmarkDone(String className, java.util.Properties results) { 271 | boolean firstTime = true; 272 | for( java.util.Enumeration e = results.keys() ; e.hasMoreElements() ; ) { 273 | String key = (String)e.nextElement(); 274 | if( key.indexOf( "validity.error" ) != -1 ) { 275 | if (firstTime) { 276 | Context.out.println("Validity check errors:"); 277 | firstTime = false; 278 | } 279 | Context.out.println(key+"="+results.get(key)); 280 | } 281 | } 282 | } 283 | 284 | public void benchmarkPrint( String str ) { 285 | // just ignore 286 | } 287 | } 288 | 289 | 290 | class SpecApplicationFrame extends Frame { 291 | 292 | public SpecApplicationFrame( String str ) { 293 | super( str ); 294 | } 295 | 296 | public boolean handleEvent(Event evt) { 297 | switch( evt.id ) { 298 | case Event.WINDOW_DESTROY: 299 | System.exit(0); 300 | return true; 301 | default: 302 | return super.handleEvent(evt); 303 | } 304 | } 305 | } 306 | 307 | -------------------------------------------------------------------------------- /JikesRVMProbes/bmadvice/_201_compress.ca: -------------------------------------------------------------------------------- 1 | Ljava/lang/ClassLoader$StaticData; ()V 1 -1 2 | Lgnu/java/net/loader/JarURLLoader; (Ljava/net/URLClassLoader;Lgnu/java/net/loader/URLStreamHandlerCache;Ljava/net/URLStreamHandlerFactory;Ljava/net/URL;Ljava/net/URL;)V 1 -1 3 | Lgnu/java/net/loader/JarURLLoader; (Ljava/net/URLClassLoader;Lgnu/java/net/loader/URLStreamHandlerCache;Ljava/net/URLStreamHandlerFactory;Ljava/net/URL;Ljava/net/URL;Ljava/util/Set;)V 1 -1 4 | Lgnu/java/net/loader/URLLoader; (Ljava/net/URLClassLoader;Lgnu/java/net/loader/URLStreamHandlerCache;Ljava/net/URLStreamHandlerFactory;Ljava/net/URL;Ljava/net/URL;)V 1 -1 5 | Lgnu/java/net/loader/JarURLLoader; initialize ()V 1 -1 6 | Lgnu/java/net/IndexListParser; (Ljava/util/jar/JarFile;Ljava/net/URL;Ljava/net/URL;)V 1 -1 7 | Lgnu/java/net/IndexListParser; clearAll ()V 1 -1 8 | Lgnu/java/net/IndexListParser; getHeaders ()Ljava/util/LinkedHashMap; 1 -1 9 | Lgnu/java/net/loader/JarURLLoader; getClassPath ()Ljava/util/ArrayList; 1 -1 10 | Lgnu/java/net/loader/FileURLLoader; (Ljava/net/URLClassLoader;Lgnu/java/net/loader/URLStreamHandlerCache;Ljava/net/URLStreamHandlerFactory;Ljava/net/URL;Ljava/net/URL;)V 1 -1 11 | Lgnu/java/net/loader/URLLoader; getClassPath ()Ljava/util/ArrayList; 1 -1 12 | Ljava/lang/InheritableThreadLocal; newChildThread (Ljava/lang/Thread;)V 1 -1 13 | Lgnu/java/net/loader/URLLoader; getClass (Ljava/lang/String;)Ljava/lang/Class; 1 -1 14 | Lgnu/java/net/loader/JarURLLoader; getResource (Ljava/lang/String;)Lgnu/java/net/loader/Resource; 1 -1 15 | Lgnu/java/net/loader/JarURLResource; (Lgnu/java/net/loader/JarURLLoader;Ljava/lang/String;Ljava/util/jar/JarEntry;)V 1 -1 16 | Lgnu/java/net/loader/Resource; (Lgnu/java/net/loader/URLLoader;)V 1 -1 17 | Lgnu/java/net/loader/JarURLResource; getInputStream ()Ljava/io/InputStream; 1 -1 18 | Lgnu/java/net/loader/JarURLResource; getLength ()I 1 -1 19 | Lgnu/java/net/loader/Resource; getCodeSource ()Ljava/security/CodeSource; 1 -1 20 | Lgnu/java/net/loader/JarURLResource; getCertificates ()[Ljava/security/cert/Certificate; 1 -1 21 | LSpecApplication; ()V 1 -1 22 | LSpecApplication; getBasicProperties ()Ljava/util/Properties; 1 -1 23 | LSpecApplication; main ([Ljava/lang/String;)V 1 -1 24 | Lgnu/java/net/loader/Resource; getLoader ()Lgnu/java/net/loader/URLLoader; 1 -1 25 | Lgnu/java/net/loader/JarURLLoader; getManifest ()Ljava/util/jar/Manifest; 1 -1 26 | Lspec/harness/Context; ()V 1 -1 27 | Lspec/harness/Context; setCachedInputFlag (Z)V 1 -1 28 | LSpecApplication; getarg (Ljava/lang/String;I)I 1 -1 29 | Lspec/harness/Context; setCommandLineMode (Z)V 1 -1 30 | LSpecApplication; runBenchmark (Ljava/lang/String;ZI)V 1 -1 31 | Lgnu/java/net/loader/FileURLLoader; getResource (Ljava/lang/String;)Lgnu/java/net/loader/Resource; 1 -1 32 | Lgnu/java/net/loader/FileURLLoader; walkPathComponents (Ljava/lang/String;)Ljava/io/File; 1 -1 33 | Lgnu/java/net/loader/FileResource; (Lgnu/java/net/loader/FileURLLoader;Ljava/io/File;)V 1 -1 34 | Lgnu/java/net/loader/FileResource; getInputStream ()Ljava/io/InputStream; 1 -1 35 | Lgnu/java/net/loader/FileResource; getLength ()I 1 -1 36 | Lgnu/java/net/loader/Resource; getCertificates ()[Ljava/security/cert/Certificate; 1 -1 37 | LSpecApplicationRunner; ()V 1 -1 38 | Lspec/harness/RunProgram; run (Ljava/lang/String;ZILjava/util/Properties;Lspec/harness/BenchmarkDone;)V 1 -1 39 | Lspec/harness/RunProgram; getIntProp (Ljava/util/Properties;Ljava/lang/String;I)I 1 -1 40 | Lspec/harness/RunProgram; getBoolProp (Ljava/util/Properties;Ljava/lang/String;Z)Z 1 -1 41 | Lspec/harness/ProgramRunner; ()V 1 -1 42 | Lgnu/java/net/loader/URLLoader; getManifest ()Ljava/util/jar/Manifest; 1 -1 43 | Lspec/io/FileInputStream; ()V 1 -1 44 | Lspec/harness/ProgramRunner; (Ljava/lang/String;[Ljava/lang/String;ZILspec/harness/BenchmarkDone;CIIIIZZ)V 1 -1 45 | Lspec/harness/Context; getCommandLineMode ()Z 1 -1 46 | Lspec/harness/ProgramRunner; run ()V 1 -1 47 | Lspec/harness/ProgramRunner; runBenchmark ()V 1 -1 48 | Lspec/harness/ProgramRunner; runBenchmark2 ()Ljava/util/Properties; 1 -1 49 | Lspec/harness/Context; getSpeed ()I 1 -1 50 | Lspec/benchmarks/_201_compress/Main; ()V 1 -1 51 | Lspec/harness/Context; isCachedInput ()Z 1 -1 52 | Lprobe/ProbeMux; init ()V 1 -1 53 | Lprobe/MMTkProbe; ()V 1 -1 54 | Lprobe/MMTkProbe; init ()V 1 -1 55 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect3424; ()V 1 -1 56 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect3425; ()V 1 -1 57 | Lspec/harness/Context; setBenchmarkRelPath (Ljava/lang/String;)V 1 -1 58 | Lprobe/ProbeMux; begin (Ljava/lang/String;Z)V 1 -1 59 | Lprobe/MMTkProbe; begin (Ljava/lang/String;IZ)V 1 -1 60 | Lspec/harness/ProgramRunner; runOnce (Ljava/lang/Object;IJILjava/util/Properties;)Lspec/harness/BenchmarkTime; 1 -1 61 | Lspec/harness/Context; clearIOtime ()V 1 -1 62 | Lspec/harness/Context; setSpeed (I)V 1 -1 63 | Lspec/io/FileInputStream; clearIOStats ()V 1 -1 64 | Lspec/io/ValidityCheckOutputStream; (Ljava/lang/String;Ljava/lang/String;C)V 1 -1 65 | Lspec/io/ConsoleOutputStream; ()V 1 -1 66 | Lspec/io/ValidityCheckOutputStream; setValidityCheckValue (C)C 1 -1 67 | Lspec/io/PrintStream; (Ljava/io/OutputStream;)V 1 -1 68 | Lspec/io/FileOutputStream; ()V 1 -1 69 | Lspec/io/FileOutputStream; clearCount ()V 1 -1 70 | Lspec/benchmarks/_201_compress/Main; harnessMain ([Ljava/lang/String;)J 1 -1 71 | Lspec/benchmarks/_201_compress/Main; runBenchmark ([Ljava/lang/String;)J 1 -1 72 | Lspec/benchmarks/_201_compress/Harness; ()V 1 -1 73 | Lspec/benchmarks/_201_compress/Harness; inst_main ([Ljava/lang/String;)J 1 -1 74 | Lspec/benchmarks/_201_compress/Harness; run_compress ([Ljava/lang/String;)Z 1 -1 75 | Lspec/io/ConsoleOutputStream; write ([BII)V 1 -1 76 | Lspec/io/ValidityCheckOutputStream; write (I)V 1 -1 77 | Lspec/io/ConsoleOutputStream; write (I)V 1 -1 78 | Lspec/io/ConsoleOutputStream; flush ()V 1 -1 79 | Lspec/harness/Context; appendWindow (Ljava/lang/String;)V 1 -1 80 | Lspec/benchmarks/_201_compress/Harness; fill_text_buffer (Ljava/lang/String;)I 1 -1 81 | Lspec/io/FileInputStream; (Ljava/lang/String;)V 1 -1 82 | Lspec/io/FileInputStream; construct (Ljava/lang/String;)V 1 -1 83 | Lspec/harness/Context; getBasePath ()Ljava/lang/String; 1 -1 84 | Lspec/io/FileInputStream; makeGoodUrl (Ljava/lang/String;)Ljava/lang/String; 1 -1 85 | Lspec/io/FileInputStream; openStream ()V 1 -1 86 | Lspec/harness/Context; isNetworkAccess ()Z 1 -1 87 | Lspec/io/File; ()V 1 -1 88 | Lspec/io/TableOfExistingFiles; ()V 1 -1 89 | Lspec/io/File; (Ljava/lang/String;)V 1 -1 90 | Lspec/io/File; getPath ()Ljava/lang/String; 1 -1 91 | Lspec/io/File; length ()J 1 -1 92 | Lspec/harness/Context; addIOtime (J)V 1 -1 93 | Lspec/io/FileInputStream; getContentLength ()I 1 -1 94 | Lspec/io/FileInputStream; read ([BII)I 1 -1 95 | Lspec/io/FileInputStream; collectReadStats (I)V 1 -1 96 | Lspec/io/FileInputStream; close ()V 1 -1 97 | Lspec/benchmarks/_201_compress/Compress; ()V 1 -1 98 | Lspec/benchmarks/_201_compress/Compress; spec_select_action ([BII[B)I 1 -1 99 | Lspec/benchmarks/_201_compress/Input_Buffer; (I[B)V 1 -1 100 | Lspec/benchmarks/_201_compress/Output_Buffer; ([B)V 1 -1 101 | Lspec/benchmarks/_201_compress/Compressor; (Lspec/benchmarks/_201_compress/Input_Buffer;Lspec/benchmarks/_201_compress/Output_Buffer;)V 1 -1 102 | Lspec/benchmarks/_201_compress/Comp_Base; (Lspec/benchmarks/_201_compress/Input_Buffer;Lspec/benchmarks/_201_compress/Output_Buffer;)V 1 -1 103 | Lspec/benchmarks/_201_compress/Compressor$Hash_Table; (Lspec/benchmarks/_201_compress/Compressor;)V 1 -1 104 | Lspec/benchmarks/_201_compress/Code_Table; ()V 1 -1 105 | Lspec/benchmarks/_201_compress/Output_Buffer; putbyte (B)V 1 -1 106 | Lspec/benchmarks/_201_compress/Compressor; compress ()V 1 -1 107 | Lspec/benchmarks/_201_compress/Input_Buffer; getbyte ()I 1 -1 108 | Lspec/benchmarks/_201_compress/Compressor$Hash_Table; clear ()V 1 -1 109 | Lspec/benchmarks/_201_compress/Compressor; output (I)V 1 -1 110 | Lspec/benchmarks/_201_compress/Code_Table; set (II)V 1 -1 111 | Lspec/benchmarks/_201_compress/Code_Table; of (I)I 1 -1 112 | Lspec/benchmarks/_201_compress/Compressor; cl_block ()V 1 -1 113 | Lspec/benchmarks/_201_compress/Output_Buffer; writebytes ([BI)V 1 -1 114 | Lspec/benchmarks/_201_compress/Compressor; compress ()V 3 0 115 | Lspec/benchmarks/_201_compress/Input_Buffer; getbyte ()I 3 0 116 | Lspec/benchmarks/_201_compress/Code_Table; of (I)I 3 0 117 | Lspec/benchmarks/_201_compress/Compressor$Hash_Table; clear ()V 3 0 118 | Ljava/lang/reflect/Array; getLength (Ljava/lang/Object;)I 1 -1 119 | Lspec/benchmarks/_201_compress/Compressor; output (I)V 3 0 120 | Lspec/benchmarks/_201_compress/Output_Buffer; count ()I 1 -1 121 | Lspec/benchmarks/_201_compress/Decompressor; (Lspec/benchmarks/_201_compress/Input_Buffer;Lspec/benchmarks/_201_compress/Output_Buffer;)V 1 -1 122 | Lspec/benchmarks/_201_compress/Decompressor$Suffix_Table; (Lspec/benchmarks/_201_compress/Decompressor;)V 1 -1 123 | Lspec/benchmarks/_201_compress/Decompressor$De_Stack; (Lspec/benchmarks/_201_compress/Decompressor;)V 1 -1 124 | Lspec/benchmarks/_201_compress/Code_Table; clear (I)V 1 -1 125 | Lspec/benchmarks/_201_compress/Decompressor$Suffix_Table; init (I)V 1 -1 126 | Lspec/benchmarks/_201_compress/Decompressor; decompress ()V 1 -1 127 | Lspec/benchmarks/_201_compress/Decompressor; getcode ()I 1 -1 128 | Lspec/benchmarks/_201_compress/Input_Buffer; readbytes ([BI)I 1 -1 129 | Lspec/benchmarks/_201_compress/Decompressor; decompress ()V 3 0 130 | Lspec/benchmarks/_201_compress/Input_Buffer; readbytes ([BI)I 3 0 131 | Lspec/benchmarks/_201_compress/Output_Buffer; putbyte (B)V 3 0 132 | Lspec/benchmarks/_201_compress/Decompressor; getcode ()I 3 0 133 | Lspec/benchmarks/_201_compress/Compressor; compress ()V 3 2 134 | Lspec/benchmarks/_201_compress/Decompressor; decompress ()V 3 1 135 | Lspec/io/FileInputStream; finalize ()V 1 -1 136 | Lspec/benchmarks/_201_compress/Compressor; output (I)V 3 1 137 | Lspec/io/FileOutputStream; printCount (Z)V 1 -1 138 | Lspec/io/PrintStream; println (CLjava/lang/String;)V 1 -1 139 | Lspec/harness/BenchmarkTime; (J)V 1 -1 140 | Lspec/harness/ProgramRunner; getStatsString ()Ljava/lang/String; 1 -1 141 | Lspec/io/FileInputStream; getIOtime ()J 1 -1 142 | Lspec/io/FileInputStream; getNumUsedFiles ()I 1 -1 143 | Lspec/io/FileInputStream; getNumCacheByteReads ()I 1 -1 144 | Lspec/io/FileInputStream; getNumFileByteReads ()I 1 -1 145 | Lspec/io/FileInputStream; getNumUrlByteReads ()I 1 -1 146 | Lspec/io/FileInputStream; getNumCachedFiles ()I 1 -1 147 | Lspec/io/FileInputStream; getCachedDataSize ()I 1 -1 148 | Lspec/io/FileInputStream; getNumCacheHits ()I 1 -1 149 | Lspec/io/FileInputStream; getNumCacheMisses ()I 1 -1 150 | Lspec/io/FileInputStream; getTotalRetries ()I 1 -1 151 | Lspec/harness/Context; getVerify ()Z 1 -1 152 | Lspec/io/ValidityCheckOutputStream; validityCheck (Ljava/util/Properties;I)Z 1 -1 153 | Lspec/io/ValidityCheckOutputStream; validityCheck2 (Ljava/util/Properties;I)V 1 -1 154 | Ljava/io/LineNumberInputStream; (Ljava/io/InputStream;)V 1 -1 155 | Lspec/io/ValidityCheckOutputStream; getLineStartChar (Ljava/io/InputStream;)I 1 -1 156 | Ljava/io/LineNumberInputStream; read ()I 1 -1 157 | Lspec/io/FileInputStream; read ()I 1 -1 158 | Lspec/io/ValidityCheckOutputStream; strip (ILjava/io/InputStream;)Ljava/lang/String; 1 -1 159 | Lspec/io/ValidityCheckOutputStream; strip1 (Ljava/lang/StringBuffer;Ljava/io/InputStream;)V 1 -1 160 | Lprobe/ProbeMux; end (Z)V 1 -1 161 | Lprobe/MMTkProbe; end (Ljava/lang/String;IZ)V 1 -1 162 | Lprobe/MMTkProbe; report (Ljava/lang/String;IZ)V 1 -1 163 | Lspec/harness/BenchmarkTime; toLongString ()Ljava/lang/String; 1 -1 164 | Lspec/harness/BenchmarkTime; secs ()D 1 -1 165 | Lspec/harness/BenchmarkTime; toString ()Ljava/lang/String; 1 -1 166 | Lspec/harness/ProgramRunner; saveResults (Ljava/lang/String;Ljava/util/Properties;)V 1 -1 167 | Lspec/io/FileInputStream; getCachingtime ()J 1 -1 168 | Lspec/harness/ProgramRunner; tellParent (Ljava/lang/String;)V 1 -1 169 | LSpecApplicationRunner; benchmarkPrint (Ljava/lang/String;)V 1 -1 170 | Lspec/benchmarks/_201_compress/Compressor$Hash_Table; clear ()V 3 1 171 | Lspec/benchmarks/_201_compress/Decompressor; decompress ()V 3 2 172 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect3424; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 173 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect3425; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 174 | Lprobe/ProbeMux; cleanup ()V 1 -1 175 | Lprobe/MMTkProbe; cleanup ()V 1 -1 176 | Lspec/io/FileInputStream; clearCache ()V 1 -1 177 | Lspec/harness/ProgramRunner; pause (J)V 1 -1 178 | Lspec/io/FileInputStream; closeAll ()V 1 -1 179 | LSpecApplicationRunner; benchmarkDone (Ljava/lang/String;Ljava/util/Properties;)V 1 -1 180 | Lspec/harness/RunProgram; done ()V 1 -1 181 | Ljava/io/BufferedWriter; (Ljava/io/Writer;)V 1 -1 182 | Ljava/io/BufferedWriter; (Ljava/io/Writer;I)V 1 -1 183 | Ljava/io/BufferedWriter; write (Ljava/lang/String;II)V 1 -1 184 | Ljava/io/BufferedWriter; flush ()V 1 -1 185 | Ljava/io/BufferedWriter; localFlush ()V 1 -1 186 | -------------------------------------------------------------------------------- /JikesRVMProbes/bmadvice/_209_db.ca: -------------------------------------------------------------------------------- 1 | Ljava/lang/ClassLoader$StaticData; ()V 1 -1 2 | Lgnu/java/net/loader/JarURLLoader; (Ljava/net/URLClassLoader;Lgnu/java/net/loader/URLStreamHandlerCache;Ljava/net/URLStreamHandlerFactory;Ljava/net/URL;Ljava/net/URL;)V 1 -1 3 | Lgnu/java/net/loader/JarURLLoader; (Ljava/net/URLClassLoader;Lgnu/java/net/loader/URLStreamHandlerCache;Ljava/net/URLStreamHandlerFactory;Ljava/net/URL;Ljava/net/URL;Ljava/util/Set;)V 1 -1 4 | Lgnu/java/net/loader/URLLoader; (Ljava/net/URLClassLoader;Lgnu/java/net/loader/URLStreamHandlerCache;Ljava/net/URLStreamHandlerFactory;Ljava/net/URL;Ljava/net/URL;)V 1 -1 5 | Lgnu/java/net/loader/JarURLLoader; initialize ()V 1 -1 6 | Lgnu/java/net/IndexListParser; (Ljava/util/jar/JarFile;Ljava/net/URL;Ljava/net/URL;)V 1 -1 7 | Lgnu/java/net/IndexListParser; clearAll ()V 1 -1 8 | Lgnu/java/net/IndexListParser; getHeaders ()Ljava/util/LinkedHashMap; 1 -1 9 | Lgnu/java/net/loader/JarURLLoader; getClassPath ()Ljava/util/ArrayList; 1 -1 10 | Lgnu/java/net/loader/FileURLLoader; (Ljava/net/URLClassLoader;Lgnu/java/net/loader/URLStreamHandlerCache;Ljava/net/URLStreamHandlerFactory;Ljava/net/URL;Ljava/net/URL;)V 1 -1 11 | Lgnu/java/net/loader/URLLoader; getClassPath ()Ljava/util/ArrayList; 1 -1 12 | Ljava/lang/InheritableThreadLocal; newChildThread (Ljava/lang/Thread;)V 1 -1 13 | Lgnu/java/net/loader/URLLoader; getClass (Ljava/lang/String;)Ljava/lang/Class; 1 -1 14 | Lgnu/java/net/loader/JarURLLoader; getResource (Ljava/lang/String;)Lgnu/java/net/loader/Resource; 1 -1 15 | Lgnu/java/net/loader/JarURLResource; (Lgnu/java/net/loader/JarURLLoader;Ljava/lang/String;Ljava/util/jar/JarEntry;)V 1 -1 16 | Lgnu/java/net/loader/Resource; (Lgnu/java/net/loader/URLLoader;)V 1 -1 17 | Lgnu/java/net/loader/JarURLResource; getInputStream ()Ljava/io/InputStream; 1 -1 18 | Lgnu/java/net/loader/JarURLResource; getLength ()I 1 -1 19 | Lgnu/java/net/loader/Resource; getCodeSource ()Ljava/security/CodeSource; 1 -1 20 | Lgnu/java/net/loader/JarURLResource; getCertificates ()[Ljava/security/cert/Certificate; 1 -1 21 | LSpecApplication; ()V 1 -1 22 | LSpecApplication; getBasicProperties ()Ljava/util/Properties; 1 -1 23 | LSpecApplication; main ([Ljava/lang/String;)V 1 -1 24 | Lgnu/java/net/loader/Resource; getLoader ()Lgnu/java/net/loader/URLLoader; 1 -1 25 | Lgnu/java/net/loader/JarURLLoader; getManifest ()Ljava/util/jar/Manifest; 1 -1 26 | Lspec/harness/Context; ()V 1 -1 27 | Lspec/harness/Context; setCachedInputFlag (Z)V 1 -1 28 | LSpecApplication; getarg (Ljava/lang/String;I)I 1 -1 29 | Lspec/harness/Context; setCommandLineMode (Z)V 1 -1 30 | LSpecApplication; runBenchmark (Ljava/lang/String;ZI)V 1 -1 31 | Lgnu/java/net/loader/FileURLLoader; getResource (Ljava/lang/String;)Lgnu/java/net/loader/Resource; 1 -1 32 | Lgnu/java/net/loader/FileURLLoader; walkPathComponents (Ljava/lang/String;)Ljava/io/File; 1 -1 33 | Lgnu/java/net/loader/FileResource; (Lgnu/java/net/loader/FileURLLoader;Ljava/io/File;)V 1 -1 34 | Lgnu/java/net/loader/FileResource; getInputStream ()Ljava/io/InputStream; 1 -1 35 | Lgnu/java/net/loader/FileResource; getLength ()I 1 -1 36 | Lgnu/java/net/loader/Resource; getCertificates ()[Ljava/security/cert/Certificate; 1 -1 37 | LSpecApplicationRunner; ()V 1 -1 38 | Lspec/harness/RunProgram; run (Ljava/lang/String;ZILjava/util/Properties;Lspec/harness/BenchmarkDone;)V 1 -1 39 | Lspec/harness/RunProgram; getIntProp (Ljava/util/Properties;Ljava/lang/String;I)I 1 -1 40 | Lspec/harness/RunProgram; getBoolProp (Ljava/util/Properties;Ljava/lang/String;Z)Z 1 -1 41 | Lspec/harness/ProgramRunner; ()V 1 -1 42 | Lgnu/java/net/loader/URLLoader; getManifest ()Ljava/util/jar/Manifest; 1 -1 43 | Lspec/io/FileInputStream; ()V 1 -1 44 | Lspec/harness/ProgramRunner; (Ljava/lang/String;[Ljava/lang/String;ZILspec/harness/BenchmarkDone;CIIIIZZ)V 1 -1 45 | Lspec/harness/Context; getCommandLineMode ()Z 1 -1 46 | Lspec/harness/ProgramRunner; run ()V 1 -1 47 | Lspec/harness/ProgramRunner; runBenchmark ()V 1 -1 48 | Lspec/harness/ProgramRunner; runBenchmark2 ()Ljava/util/Properties; 1 -1 49 | Lspec/harness/Context; getSpeed ()I 1 -1 50 | Lspec/benchmarks/_209_db/Main; ()V 1 -1 51 | Lspec/harness/Context; isCachedInput ()Z 1 -1 52 | Lprobe/ProbeMux; init ()V 1 -1 53 | Lprobe/MMTkProbe; ()V 1 -1 54 | Lprobe/MMTkProbe; init ()V 1 -1 55 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect3424; ()V 1 -1 56 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect3425; ()V 1 -1 57 | Lspec/harness/Context; setBenchmarkRelPath (Ljava/lang/String;)V 1 -1 58 | Lprobe/ProbeMux; begin (Ljava/lang/String;Z)V 1 -1 59 | Lprobe/MMTkProbe; begin (Ljava/lang/String;IZ)V 1 -1 60 | Lspec/harness/ProgramRunner; runOnce (Ljava/lang/Object;IJILjava/util/Properties;)Lspec/harness/BenchmarkTime; 1 -1 61 | Lspec/harness/Context; clearIOtime ()V 1 -1 62 | Lspec/harness/Context; setSpeed (I)V 1 -1 63 | Lspec/io/FileInputStream; clearIOStats ()V 1 -1 64 | Lspec/io/ValidityCheckOutputStream; (Ljava/lang/String;Ljava/lang/String;C)V 1 -1 65 | Lspec/io/ConsoleOutputStream; ()V 1 -1 66 | Lspec/io/ValidityCheckOutputStream; setValidityCheckValue (C)C 1 -1 67 | Lspec/io/PrintStream; (Ljava/io/OutputStream;)V 1 -1 68 | Lspec/io/FileOutputStream; ()V 1 -1 69 | Lspec/io/FileOutputStream; clearCount ()V 1 -1 70 | Lspec/benchmarks/_209_db/Main; harnessMain ([Ljava/lang/String;)J 1 -1 71 | Lspec/benchmarks/_209_db/Main; runBenchmark ([Ljava/lang/String;)J 1 -1 72 | Lspec/benchmarks/_209_db/Database; ()V 1 -1 73 | Lspec/benchmarks/_209_db/Main; inst_main ([Ljava/lang/String;)J 1 -1 74 | Lspec/io/ConsoleOutputStream; write ([BII)V 1 -1 75 | Lspec/io/ValidityCheckOutputStream; write (I)V 1 -1 76 | Lspec/io/ConsoleOutputStream; write (I)V 1 -1 77 | Lspec/io/ConsoleOutputStream; flush ()V 1 -1 78 | Lspec/harness/Context; appendWindow (Ljava/lang/String;)V 1 -1 79 | Lspec/benchmarks/_209_db/Main; run ([Ljava/lang/String;)V 1 -1 80 | Lspec/io/FileInputStream; (Ljava/lang/String;)V 1 -1 81 | Lspec/io/FileInputStream; construct (Ljava/lang/String;)V 1 -1 82 | Lspec/harness/Context; getBasePath ()Ljava/lang/String; 1 -1 83 | Lspec/io/FileInputStream; makeGoodUrl (Ljava/lang/String;)Ljava/lang/String; 1 -1 84 | Lspec/io/FileInputStream; openStream ()V 1 -1 85 | Lspec/harness/Context; isNetworkAccess ()Z 1 -1 86 | Lspec/io/File; ()V 1 -1 87 | Lspec/io/TableOfExistingFiles; ()V 1 -1 88 | Lspec/io/File; (Ljava/lang/String;)V 1 -1 89 | Lspec/io/File; getPath ()Ljava/lang/String; 1 -1 90 | Lspec/io/File; length ()J 1 -1 91 | Lspec/harness/Context; addIOtime (J)V 1 -1 92 | Lspec/benchmarks/_209_db/Database; (Ljava/lang/String;)V 1 -1 93 | Lspec/benchmarks/_209_db/Database; read_fmt (Ljava/lang/String;)V 1 -1 94 | Lspec/io/FileInputStream; read ([B)I 1 -1 95 | Lspec/io/FileInputStream; collectReadStats (I)V 1 -1 96 | Lspec/io/FileInputStream; close ()V 1 -1 97 | Lspec/benchmarks/_209_db/Database; read_db (Ljava/lang/String;)V 1 -1 98 | Lspec/io/FileInputStream; getContentLength ()I 1 -1 99 | Lspec/io/FileInputStream; read ([BII)I 1 -1 100 | Lspec/benchmarks/_209_db/Entry; ()V 1 -1 101 | Lspec/benchmarks/_209_db/Database; add (Lspec/benchmarks/_209_db/Entry;)V 1 -1 102 | Lspec/io/FileInputStream; read ()I 1 -1 103 | Lspec/benchmarks/_209_db/Database; getEntry (Ljava/io/DataInputStream;)Lspec/benchmarks/_209_db/Entry; 1 -1 104 | Lspec/benchmarks/_209_db/Database; sort (Ljava/io/DataInputStream;)V 1 -1 105 | Lspec/benchmarks/_209_db/Database; getfield (Ljava/io/DataInputStream;)I 1 -1 106 | Lspec/benchmarks/_209_db/Database; set_index ()V 1 -1 107 | Lspec/benchmarks/_209_db/Database; shell_sort (I)V 1 -1 108 | Lspec/benchmarks/_209_db/Database; find (Ljava/io/DataInputStream;)V 1 -1 109 | Lspec/benchmarks/_209_db/Database; lookup (Ljava/lang/String;I)I 1 -1 110 | Lspec/benchmarks/_209_db/Database; gotoRec (I)V 1 -1 111 | Lspec/benchmarks/_209_db/Database; printRec ()V 1 -1 112 | Lspec/benchmarks/_209_db/Database; remove ()V 1 -1 113 | Lspec/benchmarks/_209_db/Entry; equals (Ljava/lang/Object;)Z 1 -1 114 | Ljava/lang/reflect/VMProxy; ()V 1 -1 115 | Ljava/lang/reflect/Modifier; isPublic (I)Z 1 -1 116 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1383; ()V 1 -1 117 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect16537; ()V 1 -1 118 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect16538; ()V 1 -1 119 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect16539; ()V 1 -1 120 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect5111; ()V 1 -1 121 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect5111; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 122 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39158; ()V 1 -1 123 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39158; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 124 | L$Proxy0; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 125 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect576; ()V 1 -1 126 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect577; ()V 1 -1 127 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39170; ()V 1 -1 128 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39170; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 129 | L$Proxy1; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 130 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39180; ()V 1 -1 131 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39180; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 132 | L$Proxy2; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 133 | Lspec/benchmarks/_209_db/Database; shell_sort (I)V 3 0 134 | Lspec/benchmarks/_209_db/Database; set_index ()V 3 0 135 | L$Proxy1; value ()Lorg/vmmagic/pragma/Inline$When; 1 -1 136 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect4139; ()V 1 -1 137 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39190; ()V 1 -1 138 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39190; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 139 | L$Proxy3; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 140 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39199; ()V 1 -1 141 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39199; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 142 | L$Proxy4; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 143 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect3322; ()V 1 -1 144 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39209; ()V 1 -1 145 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39209; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 146 | L$Proxy5; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 147 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1274; ()V 1 -1 148 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39220; ()V 1 -1 149 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39220; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 150 | L$Proxy6; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 151 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1149; ()V 1 -1 152 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39231; ()V 1 -1 153 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39231; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 154 | L$Proxy7; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 155 | Lspec/benchmarks/_209_db/Database; read_db (Ljava/lang/String;)V 3 0 156 | Lspec/benchmarks/_209_db/Database; modify (Ljava/io/DataInputStream;)V 1 -1 157 | Lspec/benchmarks/_209_db/Entry; equals (Ljava/lang/Object;)Z 3 0 158 | Lspec/io/FileInputStream; finalize ()V 1 -1 159 | Lspec/benchmarks/_209_db/Database; list ()V 1 -1 160 | Lspec/benchmarks/_209_db/Database; end ()V 1 -1 161 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39240; ()V 1 -1 162 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39240; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 163 | L$Proxy8; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 164 | Lspec/benchmarks/_209_db/Database; shell_sort (I)V 3 2 165 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39248; ()V 1 -1 166 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39248; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 167 | L$Proxy9; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 168 | Lspec/benchmarks/_209_db/Database; set_index ()V 3 2 169 | Lspec/benchmarks/_209_db/Entry; equals (Ljava/lang/Object;)Z 3 1 170 | Lspec/benchmarks/_209_db/Database; next ()V 1 -1 171 | Lspec/benchmarks/_209_db/Database; previous ()V 1 -1 172 | Lspec/io/FileOutputStream; printCount (Z)V 1 -1 173 | Lspec/io/PrintStream; println (CLjava/lang/String;)V 1 -1 174 | Lspec/harness/BenchmarkTime; (J)V 1 -1 175 | Lspec/harness/ProgramRunner; getStatsString ()Ljava/lang/String; 1 -1 176 | Lspec/io/FileInputStream; getIOtime ()J 1 -1 177 | Lspec/io/FileInputStream; getNumUsedFiles ()I 1 -1 178 | Lspec/io/FileInputStream; getNumCacheByteReads ()I 1 -1 179 | Lspec/io/FileInputStream; getNumFileByteReads ()I 1 -1 180 | Lspec/io/FileInputStream; getNumUrlByteReads ()I 1 -1 181 | Lspec/io/FileInputStream; getNumCachedFiles ()I 1 -1 182 | Lspec/io/FileInputStream; getCachedDataSize ()I 1 -1 183 | Lspec/io/FileInputStream; getNumCacheHits ()I 1 -1 184 | Lspec/io/FileInputStream; getNumCacheMisses ()I 1 -1 185 | Lspec/io/FileInputStream; getTotalRetries ()I 1 -1 186 | Lspec/harness/Context; getVerify ()Z 1 -1 187 | Lspec/io/ValidityCheckOutputStream; validityCheck (Ljava/util/Properties;I)Z 1 -1 188 | Lspec/io/ValidityCheckOutputStream; validityCheck2 (Ljava/util/Properties;I)V 1 -1 189 | Ljava/io/LineNumberInputStream; (Ljava/io/InputStream;)V 1 -1 190 | Lspec/io/ValidityCheckOutputStream; getLineStartChar (Ljava/io/InputStream;)I 1 -1 191 | Ljava/io/LineNumberInputStream; read ()I 1 -1 192 | Lspec/io/ValidityCheckOutputStream; strip (ILjava/io/InputStream;)Ljava/lang/String; 1 -1 193 | Lspec/io/ValidityCheckOutputStream; strip1 (Ljava/lang/StringBuffer;Ljava/io/InputStream;)V 1 -1 194 | Lprobe/ProbeMux; end (Z)V 1 -1 195 | Lprobe/MMTkProbe; end (Ljava/lang/String;IZ)V 1 -1 196 | Lprobe/MMTkProbe; report (Ljava/lang/String;IZ)V 1 -1 197 | Lspec/harness/BenchmarkTime; toLongString ()Ljava/lang/String; 1 -1 198 | Lspec/harness/BenchmarkTime; secs ()D 1 -1 199 | Lspec/harness/BenchmarkTime; toString ()Ljava/lang/String; 1 -1 200 | Lspec/harness/ProgramRunner; saveResults (Ljava/lang/String;Ljava/util/Properties;)V 1 -1 201 | Lspec/io/FileInputStream; getCachingtime ()J 1 -1 202 | Lspec/harness/ProgramRunner; tellParent (Ljava/lang/String;)V 1 -1 203 | LSpecApplicationRunner; benchmarkPrint (Ljava/lang/String;)V 1 -1 204 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39269; ()V 1 -1 205 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39269; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 206 | L$Proxy10; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 207 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39277; ()V 1 -1 208 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39277; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 209 | L$Proxy11; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 210 | Lspec/io/FileInputStream; read ()I 3 0 211 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39285; ()V 1 -1 212 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39285; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 213 | L$Proxy12; (Ljava/lang/reflect/InvocationHandler;)V 1 -1 214 | L$Proxy1; arguments ()[I 1 -1 215 | Lspec/io/FileInputStream; read ()I 3 1 216 | Lspec/benchmarks/_209_db/Database; read_db (Ljava/lang/String;)V 3 1 217 | Lspec/benchmarks/_209_db/Database; getEntry (Ljava/io/DataInputStream;)Lspec/benchmarks/_209_db/Entry; 3 0 218 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect3424; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 219 | Lorg/jikesrvm/classloader/ReflectionBase$$Reflect3425; invokeInternal (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; 1 -1 220 | Lprobe/ProbeMux; cleanup ()V 1 -1 221 | Lprobe/MMTkProbe; cleanup ()V 1 -1 222 | Lspec/io/FileInputStream; clearCache ()V 1 -1 223 | Lspec/harness/ProgramRunner; pause (J)V 1 -1 224 | Lspec/io/FileInputStream; closeAll ()V 1 -1 225 | LSpecApplicationRunner; benchmarkDone (Ljava/lang/String;Ljava/util/Properties;)V 1 -1 226 | Lspec/harness/RunProgram; done ()V 1 -1 227 | Ljava/io/BufferedWriter; (Ljava/io/Writer;)V 1 -1 228 | Ljava/io/BufferedWriter; (Ljava/io/Writer;I)V 1 -1 229 | Ljava/io/BufferedWriter; write (Ljava/lang/String;II)V 1 -1 230 | Ljava/io/BufferedWriter; flush ()V 1 -1 231 | Ljava/io/BufferedWriter; localFlush ()V 1 -1 232 | -------------------------------------------------------------------------------- /JikesRVMProbes/bmadvice/bestadvice.log: -------------------------------------------------------------------------------- 1 | _201_compress 19 1754.41 2 | _201_compress 4 1755.57 3 | _201_compress 9 1755.65 4 | _201_compress 16 1757.21 5 | _201_compress 17 1759.18 6 | _201_compress 11 1769.33 7 | _201_compress 14 1769.6 8 | _201_compress 1 1771.0 9 | _201_compress 8 1771.79 10 | _201_compress 5 1772.12 11 | _201_compress 7 1772.42 12 | _201_compress 12 1772.63 13 | _201_compress 0 1774.1 14 | _201_compress 15 1774.15 15 | _201_compress 10 1775.01 16 | _201_compress 18 1775.35 17 | _201_compress 6 1775.74 18 | _201_compress 2 1775.99 19 | _201_compress 13 1780.98 20 | _201_compress 3 1789.05 21 | _202_jess 9 315.22 22 | _202_jess 1 317.57 23 | _202_jess 7 319.12 24 | _202_jess 15 320.97 25 | _202_jess 16 321.63 26 | _202_jess 5 322.8 27 | _202_jess 11 323.62 28 | _202_jess 12 324.66 29 | _202_jess 3 326.76 30 | _202_jess 4 326.8 31 | _202_jess 13 326.85 32 | _202_jess 8 327.54 33 | _202_jess 17 327.67 34 | _202_jess 6 328.49 35 | _202_jess 10 330.67 36 | _202_jess 2 331.4 37 | _202_jess 18 331.94 38 | _202_jess 14 333.98 39 | _202_jess 19 334.57 40 | _202_jess 0 337.94 41 | _209_db 3 1178.36 42 | _209_db 5 1179.12 43 | _209_db 8 1180.03 44 | _209_db 1 1180.33 45 | _209_db 17 1180.99 46 | _209_db 19 1181.61 47 | _209_db 16 1182.29 48 | _209_db 10 1182.65 49 | _209_db 12 1183.93 50 | _209_db 18 1185.43 51 | _209_db 6 1188.71 52 | _209_db 2 1189.9 53 | _209_db 15 1191.04 54 | _209_db 0 1191.21 55 | _209_db 7 1193.15 56 | _209_db 9 1193.85 57 | _209_db 4 1196.01 58 | _209_db 14 1197.78 59 | _209_db 13 1203.05 60 | _209_db 11 1204.6 61 | _213_javac 9 716.7 62 | _213_javac 3 722.13 63 | _213_javac 6 722.25 64 | _213_javac 19 724.99 65 | _213_javac 5 725.07 66 | _213_javac 7 726.28 67 | _213_javac 10 733.14 68 | _213_javac 18 734.43 69 | _213_javac 11 737.59 70 | _213_javac 0 737.91 71 | _213_javac 4 739.33 72 | _213_javac 14 741.72 73 | _213_javac 16 741.94 74 | _213_javac 15 747.01 75 | _213_javac 2 748.9 76 | _213_javac 1 752.25 77 | _213_javac 17 754.9 78 | _213_javac 8 757.3 79 | _213_javac 12 762.79 80 | _213_javac 13 778.59 81 | _222_mpegaudio 19 1049.38 82 | _222_mpegaudio 18 1051.76 83 | _222_mpegaudio 6 1053.65 84 | _222_mpegaudio 8 1053.83 85 | _222_mpegaudio 4 1053.95 86 | _222_mpegaudio 5 1054.17 87 | _222_mpegaudio 14 1054.41 88 | _222_mpegaudio 9 1056.25 89 | _222_mpegaudio 15 1056.26 90 | _222_mpegaudio 16 1058.21 91 | _222_mpegaudio 12 1059.26 92 | _222_mpegaudio 11 1059.65 93 | _222_mpegaudio 17 1060.24 94 | _222_mpegaudio 13 1063.8 95 | _222_mpegaudio 10 1070.21 96 | _222_mpegaudio 2 1071.79 97 | _222_mpegaudio 0 1074.36 98 | _222_mpegaudio 7 1080.42 99 | _222_mpegaudio 1 1083.81 100 | _222_mpegaudio 3 1095.08 101 | _227_mtrt 8 230.9 102 | _227_mtrt 11 231.26 103 | _227_mtrt 4 231.64 104 | _227_mtrt 12 232.56 105 | _227_mtrt 6 234.49 106 | _227_mtrt 15 242.02 107 | _227_mtrt 13 242.84 108 | _227_mtrt 16 243.65 109 | _227_mtrt 9 243.92 110 | _227_mtrt 18 244.05 111 | _227_mtrt 14 245.2 112 | _227_mtrt 5 245.24 113 | _227_mtrt 3 245.29 114 | _227_mtrt 2 246.35 115 | _227_mtrt 0 246.88 116 | _227_mtrt 1 248.42 117 | _227_mtrt 7 251.44 118 | _227_mtrt 19 253.73 119 | _227_mtrt 17 260.67 120 | _227_mtrt 10 274.76 121 | _228_jack 16 450.42 122 | _228_jack 14 451.91 123 | _228_jack 12 452.44 124 | _228_jack 18 452.81 125 | _228_jack 13 453.11 126 | _228_jack 5 454.39 127 | _228_jack 7 454.94 128 | _228_jack 2 454.95 129 | _228_jack 8 455.2 130 | _228_jack 1 455.39 131 | _228_jack 0 455.94 132 | _228_jack 15 456.1 133 | _228_jack 4 457.03 134 | _228_jack 11 457.82 135 | _228_jack 17 461.0 136 | _228_jack 9 461.68 137 | _228_jack 3 461.71 138 | _228_jack 19 464.46 139 | _228_jack 10 465.18 140 | _228_jack 6 513.76 141 | antlr 18 554.27 142 | antlr 13 556.0 143 | antlr 5 561.79 144 | antlr 9 563.77 145 | antlr 17 569.47 146 | antlr 0 571.65 147 | antlr 14 575.66 148 | antlr 2 580.97 149 | antlr 12 581.54 150 | antlr 3 582.05 151 | antlr 16 587.42 152 | antlr 15 587.9 153 | antlr 11 592.26 154 | antlr 6 596.82 155 | antlr 7 598.56 156 | antlr 8 599.97 157 | antlr 1 600.17 158 | antlr 4 603.22 159 | antlr 10 607.06 160 | antlr 19 636.69 161 | avrora 5 2213.02 162 | avrora 6 2229.35 163 | avrora 8 2230.5 164 | avrora 13 2231.99 165 | avrora 0 2232.49 166 | avrora 14 2233.92 167 | avrora 11 2233.93 168 | avrora 4 2234.29 169 | avrora 17 2235.56 170 | avrora 3 2238.14 171 | avrora 10 2240.58 172 | avrora 9 2244.68 173 | avrora 1 2245.38 174 | avrora 12 2247.49 175 | avrora 2 2247.5 176 | avrora 7 2250.74 177 | avrora 19 2254.46 178 | avrora 15 2256.07 179 | avrora 18 2266.15 180 | avrora 16 2282.55 181 | bloat 15 1861.57 182 | bloat 17 1864.59 183 | bloat 12 1875.97 184 | bloat 8 1895.66 185 | bloat 4 1911.08 186 | bloat 11 1916.36 187 | bloat 2 1919.01 188 | bloat 16 1926.03 189 | bloat 14 1933.11 190 | bloat 9 1936.23 191 | bloat 3 1942.06 192 | bloat 10 1942.19 193 | bloat 1 1947.8 194 | bloat 18 1959.94 195 | bloat 19 1970.35 196 | bloat 7 1973.69 197 | bloat 0 1974.78 198 | bloat 6 1993.34 199 | bloat 13 2020.38 200 | bloat 5 2078.21 201 | eclipse 2 10888.63 202 | eclipse 19 10906.0 203 | eclipse 1 10921.67 204 | eclipse 15 10931.12 205 | eclipse 13 10931.58 206 | eclipse 4 10947.6 207 | eclipse 14 10957.69 208 | eclipse 9 10969.82 209 | eclipse 18 10985.8 210 | eclipse 5 10986.62 211 | eclipse 12 11016.01 212 | eclipse 16 11028.07 213 | eclipse 17 11039.56 214 | eclipse 7 11049.27 215 | eclipse 10 11064.18 216 | eclipse 8 11089.69 217 | eclipse 6 11192.54 218 | eclipse 3 11203.12 219 | eclipse 0 11258.83 220 | eclipse 11 11278.97 221 | fop 14 570.03 222 | fop 11 571.79 223 | fop 7 577.09 224 | fop 6 579.02 225 | fop 3 580.3 226 | fop 15 580.55 227 | fop 0 581.36 228 | fop 16 582.19 229 | fop 19 583.62 230 | fop 12 583.71 231 | fop 2 586.84 232 | fop 18 588.09 233 | fop 4 591.79 234 | fop 8 592.2 235 | fop 10 594.32 236 | fop 17 595.5 237 | fop 1 609.83 238 | fop 5 609.88 239 | fop 13 624.31 240 | fop 9 626.5 241 | hsqldb 3 689.91 242 | hsqldb 19 695.81 243 | hsqldb 1 698.78 244 | hsqldb 12 698.79 245 | hsqldb 8 699.89 246 | hsqldb 13 705.24 247 | hsqldb 6 707.49 248 | hsqldb 15 708.78 249 | hsqldb 2 710.55 250 | hsqldb 16 711.51 251 | hsqldb 9 712.87 252 | hsqldb 17 713.49 253 | hsqldb 18 717.96 254 | hsqldb 4 723.92 255 | hsqldb 11 725.13 256 | hsqldb 7 737.85 257 | hsqldb 14 746.61 258 | hsqldb 5 754.67 259 | hsqldb 0 759.73 260 | hsqldb 10 771.91 261 | jython 13 1988.81 262 | jython 5 2013.16 263 | jython 17 2020.56 264 | jython 10 2034.28 265 | jython 4 2034.9 266 | jython 6 2044.95 267 | jython 0 2048.33 268 | jython 7 2051.1 269 | jython 16 2057.57 270 | jython 15 2062.23 271 | jython 2 2062.74 272 | jython 8 2070.19 273 | jython 1 2075.98 274 | jython 9 2082.53 275 | jython 12 2083.3 276 | jython 18 2086.35 277 | jython 11 2089.93 278 | jython 19 2091.55 279 | jython 3 2095.23 280 | jython 14 2121.91 281 | luindex 17 579.43 282 | luindex 6 583.8 283 | luindex 12 586.88 284 | luindex 16 590.44 285 | luindex 8 593.96 286 | luindex 1 600.03 287 | luindex 2 600.45 288 | luindex 10 600.78 289 | luindex 18 608.26 290 | luindex 14 608.62 291 | luindex 7 609.14 292 | luindex 4 609.2 293 | luindex 13 613.05 294 | luindex 3 616.42 295 | luindex 0 617.38 296 | luindex 19 619.04 297 | luindex 11 620.03 298 | luindex 5 623.95 299 | luindex 9 625.0 300 | luindex 15 630.09 301 | lusearch 12 810.05 302 | lusearch 19 810.21 303 | lusearch 4 822.19 304 | lusearch 13 822.93 305 | lusearch 6 824.09 306 | lusearch 3 824.73 307 | lusearch 15 827.46 308 | lusearch 2 827.98 309 | lusearch 7 828.03 310 | lusearch 9 828.36 311 | lusearch 1 830.58 312 | lusearch 18 831.53 313 | lusearch 14 834.95 314 | lusearch 17 836.75 315 | lusearch 11 843.25 316 | lusearch 8 843.43 317 | lusearch 10 847.43 318 | lusearch 0 853.15 319 | lusearch 5 853.35 320 | lusearch 16 868.83 321 | lusearch_fix 11 497.83 322 | lusearch_fix 3 501.38 323 | lusearch_fix 1 504.64 324 | lusearch_fix 9 511.16 325 | lusearch_fix 17 511.59 326 | lusearch_fix 13 512.51 327 | lusearch_fix 6 513.71 328 | lusearch_fix 18 514.93 329 | lusearch_fix 19 515.14 330 | lusearch_fix 12 516.85 331 | lusearch_fix 14 517.13 332 | lusearch_fix 2 518.71 333 | lusearch_fix 15 524.56 334 | lusearch_fix 0 526.85 335 | lusearch_fix 8 527.29 336 | lusearch_fix 10 527.45 337 | lusearch_fix 7 530.29 338 | lusearch_fix 5 531.92 339 | lusearch_fix 16 534.25 340 | lusearch_fix 4 544.32 341 | pjbb2005 10 2797.92 342 | pjbb2005 19 2808.86 343 | pjbb2005 16 2811.1 344 | pjbb2005 14 2848.3 345 | pjbb2005 2 2856.2 346 | pjbb2005 0 2862.96 347 | pjbb2005 8 2867.55 348 | pjbb2005 6 2872.94 349 | pjbb2005 4 2873.3 350 | pjbb2005 11 2880.07 351 | pjbb2005 15 2882.86 352 | pjbb2005 7 2886.31 353 | pjbb2005 12 2894.1 354 | pjbb2005 5 2894.48 355 | pjbb2005 18 2898.74 356 | pjbb2005 3 2911.89 357 | pjbb2005 9 2917.0 358 | pjbb2005 17 2918.88 359 | pjbb2005 1 2936.98 360 | pjbb2005 13 2943.78 361 | pmd 4 574.16 362 | pmd 1 576.96 363 | pmd 19 579.43 364 | pmd 3 579.61 365 | pmd 0 580.34 366 | pmd 18 582.25 367 | pmd 7 582.76 368 | pmd 13 582.8 369 | pmd 8 588.73 370 | pmd 16 590.69 371 | pmd 5 591.07 372 | pmd 17 592.24 373 | pmd 15 592.99 374 | pmd 10 594.38 375 | pmd 11 595.7 376 | pmd 6 598.74 377 | pmd 14 601.24 378 | pmd 2 604.0 379 | pmd 9 604.33 380 | pmd 12 612.72 381 | sunflow 4 1688.95 382 | sunflow 10 1699.83 383 | sunflow 15 1706.68 384 | sunflow 9 1709.81 385 | sunflow 8 1718.29 386 | sunflow 7 1720.94 387 | sunflow 18 1723.2 388 | sunflow 17 1743.03 389 | sunflow 19 1743.81 390 | sunflow 13 1750.06 391 | sunflow 11 1750.44 392 | sunflow 0 1752.9 393 | sunflow 6 1763.67 394 | sunflow 14 1766.88 395 | sunflow 1 1774.77 396 | sunflow 16 1776.4 397 | sunflow 3 1785.12 398 | sunflow 5 1799.83 399 | sunflow 12 1807.33 400 | sunflow 2 1824.83 401 | xalan 14 638.11 402 | xalan 1 639.17 403 | xalan 17 639.18 404 | xalan 8 640.55 405 | xalan 9 642.21 406 | xalan 5 644.94 407 | xalan 13 646.59 408 | xalan 6 651.63 409 | xalan 15 652.82 410 | xalan 2 653.9 411 | xalan 4 658.46 412 | xalan 18 658.84 413 | xalan 19 658.97 414 | xalan 11 659.31 415 | xalan 0 660.82 416 | xalan 12 661.63 417 | xalan 7 661.86 418 | xalan 10 666.05 419 | xalan 16 672.47 420 | xalan 3 677.93 421 | -------------------------------------------------------------------------------- /JikesRVMProbes/bmadvice/pickadvice.py: -------------------------------------------------------------------------------- 1 | #!/bin/python 2 | import os,sys,re 3 | import sys 4 | import subprocess 5 | 6 | usage= "python bestadvice.log logdir bestadvice.log in format as [benchmarkname invocation time], and time is in asecending order" 7 | 8 | #affix in .ec 9 | def copyfile(bname, invoc, targetdir,affix): 10 | command="find " + targetdir + " -name " + "\'" + bname + "*." + invoc + affix + "\'"; 11 | p = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE) 12 | filename = p.stdout.readline().rstrip('\n'); 13 | print "copy " + filename + " to current directory" 14 | copycommand= "cp " + filename + " ./" + bname + affix; 15 | subprocess.call(copycommand,shell=True); 16 | 17 | 18 | def main(argv): 19 | if len(argv) != 3: 20 | print usage 21 | bestfilename = argv[1] 22 | bestf = open(bestfilename,'r'); 23 | lastbenchmarkname="none" 24 | l = bestf.readline(); 25 | 26 | while(l): 27 | benchname = l.split('\t')[0] 28 | invocation = l.split('\t')[-2] 29 | 30 | if (benchname != lastbenchmarkname): 31 | print "invocation " + invocation + " is best for " + benchname 32 | lastbenchmarkname = benchname 33 | copyfile(benchname, invocation, argv[2], ".ca"); 34 | copyfile(benchname, invocation, argv[2], ".dc"); 35 | copyfile(benchname, invocation, argv[2], ".ec"); 36 | 37 | l = bestf.readline(); 38 | 39 | 40 | 41 | 42 | if __name__ == "__main__": 43 | print sys.argv 44 | main(sys.argv) 45 | -------------------------------------------------------------------------------- /JikesRVMProbes/bmadvice/track.log: -------------------------------------------------------------------------------- 1 | ['./pickadvice.py', './bestadvice.log', '/home/yangxi/plotty/ftlb/log/rat-advicefile/'] 2 | invocation 19 is best for _201_compress 3 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_201_compress.6000.114.production.fn-32M.p-all.19.ca to current directory 4 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_201_compress.6000.114.production.fn-32M.p-all.19.dc to current directory 5 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_201_compress.6000.114.production.fn-32M.p-all.19.ec to current directory 6 | invocation 9 is best for _202_jess 7 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_202_jess.6000.114.production.fn-32M.p-all.9.ca to current directory 8 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_202_jess.6000.114.production.fn-32M.p-all.9.dc to current directory 9 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_202_jess.6000.114.production.fn-32M.p-all.9.ec to current directory 10 | invocation 3 is best for _209_db 11 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_209_db.6000.114.production.fn-32M.p-all.3.ca to current directory 12 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_209_db.6000.114.production.fn-32M.p-all.3.dc to current directory 13 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_209_db.6000.114.production.fn-32M.p-all.3.ec to current directory 14 | invocation 9 is best for _213_javac 15 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_213_javac.6000.198.production.fn-32M.p-all.9.ca to current directory 16 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_213_javac.6000.198.production.fn-32M.p-all.9.dc to current directory 17 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_213_javac.6000.198.production.fn-32M.p-all.9.ec to current directory 18 | invocation 19 is best for _222_mpegaudio 19 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_222_mpegaudio.6000.78.production.fn-32M.p-all.19.ca to current directory 20 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_222_mpegaudio.6000.78.production.fn-32M.p-all.19.dc to current directory 21 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_222_mpegaudio.6000.78.production.fn-32M.p-all.19.ec to current directory 22 | invocation 8 is best for _227_mtrt 23 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_227_mtrt.6000.120.production.fn-32M.p-all.8.ca to current directory 24 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_227_mtrt.6000.120.production.fn-32M.p-all.8.dc to current directory 25 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_227_mtrt.6000.120.production.fn-32M.p-all.8.ec to current directory 26 | invocation 16 is best for _228_jack 27 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_228_jack.6000.102.production.fn-32M.p-all.16.ca to current directory 28 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_228_jack.6000.102.production.fn-32M.p-all.16.dc to current directory 29 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/_228_jack.6000.102.production.fn-32M.p-all.16.ec to current directory 30 | invocation 18 is best for antlr 31 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/antlr.6000.144.production.fn-32M.p-all.18.ca to current directory 32 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/antlr.6000.144.production.fn-32M.p-all.18.dc to current directory 33 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/antlr.6000.144.production.fn-32M.p-all.18.ec to current directory 34 | invocation 5 is best for avrora 35 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/avrora.6000.300.production.fn-32M.p-all.5.ca to current directory 36 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/avrora.6000.300.production.fn-32M.p-all.5.dc to current directory 37 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/avrora.6000.300.production.fn-32M.p-all.5.ec to current directory 38 | invocation 15 is best for bloat 39 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/bloat.6000.198.production.fn-32M.p-all.15.ca to current directory 40 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/bloat.6000.198.production.fn-32M.p-all.15.dc to current directory 41 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/bloat.6000.198.production.fn-32M.p-all.15.ec to current directory 42 | invocation 2 is best for eclipse 43 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/eclipse.6000.480.production.fn-32M.p-all.2.ca to current directory 44 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/eclipse.6000.480.production.fn-32M.p-all.2.dc to current directory 45 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/eclipse.6000.480.production.fn-32M.p-all.2.ec to current directory 46 | invocation 14 is best for fop 47 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/fop.6000.240.production.fn-32M.p-all.14.ca to current directory 48 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/fop.6000.240.production.fn-32M.p-all.14.dc to current directory 49 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/fop.6000.240.production.fn-32M.p-all.14.ec to current directory 50 | invocation 3 is best for hsqldb 51 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/hsqldb.6000.762.production.fn-32M.p-all.3.ca to current directory 52 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/hsqldb.6000.762.production.fn-32M.p-all.3.dc to current directory 53 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/hsqldb.6000.762.production.fn-32M.p-all.3.ec to current directory 54 | invocation 13 is best for jython 55 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/jython.6000.240.production.fn-32M.p-all.13.ca to current directory 56 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/jython.6000.240.production.fn-32M.p-all.13.dc to current directory 57 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/jython.6000.240.production.fn-32M.p-all.13.ec to current directory 58 | invocation 17 is best for luindex 59 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/luindex.6000.132.production.fn-32M.p-all.17.ca to current directory 60 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/luindex.6000.132.production.fn-32M.p-all.17.dc to current directory 61 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/luindex.6000.132.production.fn-32M.p-all.17.ec to current directory 62 | invocation 12 is best for lusearch 63 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/lusearch.6000.204.production.fn-32M.p-all.12.ca to current directory 64 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/lusearch.6000.204.production.fn-32M.p-all.12.dc to current directory 65 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/lusearch.6000.204.production.fn-32M.p-all.12.ec to current directory 66 | invocation 11 is best for lusearch_fix 67 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/lusearch_fix.6000.204.production.fn-32M.p-all.11.ca to current directory 68 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/lusearch_fix.6000.204.production.fn-32M.p-all.11.dc to current directory 69 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/lusearch_fix.6000.204.production.fn-32M.p-all.11.ec to current directory 70 | invocation 10 is best for pjbb2005 71 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/pjbb2005.6000.1200.production.fn-32M.p-all.10.ca to current directory 72 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/pjbb2005.6000.1200.production.fn-32M.p-all.10.dc to current directory 73 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/pjbb2005.6000.1200.production.fn-32M.p-all.10.ec to current directory 74 | invocation 4 is best for pmd 75 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/pmd.6000.294.production.fn-32M.p-all.4.ca to current directory 76 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/pmd.6000.294.production.fn-32M.p-all.4.dc to current directory 77 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/pmd.6000.294.production.fn-32M.p-all.4.ec to current directory 78 | invocation 4 is best for sunflow 79 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/sunflow.6000.324.production.fn-32M.p-all.4.ca to current directory 80 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/sunflow.6000.324.production.fn-32M.p-all.4.dc to current directory 81 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/sunflow.6000.324.production.fn-32M.p-all.4.ec to current directory 82 | invocation 14 is best for xalan 83 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/xalan.6000.324.production.fn-32M.p-all.14.ca to current directory 84 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/xalan.6000.324.production.fn-32M.p-all.14.dc to current directory 85 | copy /home/yangxi/plotty/ftlb/log/rat-advicefile/xalan.6000.324.production.fn-32M.p-all.14.ec to current directory 86 | -------------------------------------------------------------------------------- /JikesRVMProbes/common.mk: -------------------------------------------------------------------------------- 1 | #put your JDK path here 2 | JDK=/opt/jdk1.6.0 3 | #put your JikesRVMSHIM shimIP jar path here 4 | JIKESRVMJAR=../../jikesrvmshim/dist/production_shimIP_x86_64-linux/jksvm.jar 5 | JAVAC=$(JDK)/bin/javac 6 | JAVA=$(JDK)/bin/java 7 | #put your Dacapo benchmark directory here 8 | BENCHMARKS=/usr/share/benchmarks 9 | CFLAGS=-O2 -g -D_GNU_SOURCE -fPIC 10 | ifeq (-m32,$(findstring -m32,$(OPTION))) 11 | M32_FLAG = y 12 | CFLAGS += -m32 13 | endif 14 | -------------------------------------------------------------------------------- /JikesRVMProbes/moma/Disassemble.java: -------------------------------------------------------------------------------- 1 | package moma; 2 | 3 | import java.io.*; 4 | import java.util.ArrayList; 5 | 6 | import org.jikesrvm.ArchitectureSpecific; 7 | import org.jikesrvm.adaptive.util.CompilerAdviceAttribute; 8 | import org.jikesrvm.adaptive.util.CompilerAdviceInfoReader; 9 | import org.jikesrvm.classloader.RVMClass; 10 | import org.jikesrvm.classloader.RVMClassLoader; 11 | import org.jikesrvm.classloader.RVMMethod; 12 | import org.jikesrvm.classloader.TypeReference; 13 | import org.vmmagic.unboxed.Address; 14 | import org.vmmagic.unboxed.ObjectReference; 15 | 16 | /** 17 | * Created by xiyang on 16/10/2014. 18 | * Disassemble codearry to instructions, and print them out 19 | */ 20 | public class Disassemble implements MomaCallBack{ 21 | 22 | public void invoke(String target){ 23 | System.out.println("Disassemble method:" + target); 24 | String[] code = disassemble(target); 25 | for(String l : code){ 26 | System.out.println(l); 27 | } 28 | } 29 | 30 | public static String[] disassemble(String target){ 31 | 32 | CompilerAdviceAttribute attr = CompilerAdviceInfoReader.readOneAttributeFromString(target); 33 | 34 | if (attr == null) 35 | return null; 36 | 37 | // find class loader from get 38 | ClassLoader cl = RVMClassLoader.findWorkableClassloader(attr.getClassName()); 39 | if (cl == null){ 40 | System.out.println("Disassembler could not find classloader of class " + attr.getClassName()); 41 | return null; 42 | } 43 | 44 | TypeReference tRef = TypeReference.findOrCreate(cl, attr.getClassName()); 45 | 46 | if (tRef == null){ 47 | System.out.println("Disassembler could not find class " + attr.getClassName()); 48 | return null; 49 | } 50 | 51 | RVMClass cls = (RVMClass) tRef.peekType(); 52 | RVMMethod method = cls.findDeclaredMethod(attr.getMethodName(), attr.getMethodSig()); 53 | if (method == null){ 54 | System.out.println("Disassembler could not find method " + attr.getMethodSig() + " " + attr.getMethodName() + " in class " + attr.getClassName()); 55 | return null; 56 | } 57 | 58 | ArchitectureSpecific.CodeArray ca = method.getCurrentCompiledMethod().getEntryCodeArray(); 59 | Address address = ObjectReference.fromObject(ca).toAddress(); 60 | int length = ca.length(); 61 | final Address end = address.plus(length); 62 | 63 | System.err.println("Disassemble code in address range [" + Util.addressToHexString(address) + ", " + 64 | Util.addressToHexString(end) + "[ (" + length + " bytes)"); 65 | OutputStream os = null; 66 | try { 67 | // create a temporary file containing the code 68 | final File file = File.createTempFile("jikesrdb-binary-for-disassembly", ".bin"); 69 | System.err.println(" Generating binary file with code: " + file); 70 | os = new BufferedOutputStream(new FileOutputStream(file)); 71 | Address current = address; 72 | while (current.LT(end)) { 73 | os.write(current.loadByte()); 74 | current = current.plus(1); 75 | } 76 | os.close(); 77 | // launch ndisasm 78 | System.err.print(" Lanuching ndisasm to disassemble the generated file \""); 79 | final String[] commandLineWords = new String[]{"/usr/bin/ndisasm", "-b", "32", "-o", "0x" + Util.addressToHexString(address), 80 | file.getPath()}; 81 | 82 | final StringBuffer commandLine = new StringBuffer(); 83 | for (final String word : commandLineWords) { 84 | commandLine.append(word); 85 | commandLine.append(' '); 86 | System.err.print(" " + word); 87 | 88 | } 89 | System.err.println("\""); 90 | // final Process ndisasm = Runtime.getRuntime().exec(commandLine); 91 | final ProcessBuilder builder = new ProcessBuilder(commandLineWords); 92 | builder.redirectErrorStream(true); 93 | final Process ndisasm = builder.start(); 94 | // parse ndisasm output or error 95 | System.err.println(" Draining ndisasm's stdout/stderr"); 96 | final ArrayList stringList = new ArrayList(); 97 | final BufferedReader br = new BufferedReader(new InputStreamReader(ndisasm.getInputStream())); 98 | String line; 99 | while ((line = br.readLine()) != null) { 100 | stringList.add(line); 101 | System.out.println(line); 102 | } 103 | // delete temporary file 104 | //file.delete(); 105 | // wait for ndisasm (should not block, given that we wait above for its 106 | // stdout to be drained) 107 | final int exitCode = ndisasm.waitFor(); 108 | if (exitCode != 0) { 109 | stringList.add(0, "ERROR"); 110 | stringList.add(1, commandLine.toString()); 111 | stringList.add(2, "Exit code: " + exitCode); 112 | } 113 | // return 114 | return stringList.toArray(new String[stringList.size()]); 115 | } catch (final IOException ex) { 116 | ex.printStackTrace(); 117 | return new String[]{ex.getMessage()}; 118 | } catch (final InterruptedException ex) { 119 | ex.printStackTrace(); 120 | return null; 121 | } finally { 122 | if (os != null) { 123 | try { 124 | os.close(); 125 | } catch (final IOException ex) { 126 | // ignore 127 | } 128 | } 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /JikesRVMProbes/moma/MoMaLogger.java: -------------------------------------------------------------------------------- 1 | package moma; 2 | 3 | 4 | import org.jikesrvm.Options; 5 | 6 | import static org.jikesrvm.runtime.SysCall.sysCall; 7 | 8 | import org.jikesrvm.VM; 9 | import org.jikesrvm.classloader.Atom; 10 | import org.jikesrvm.classloader.RVMMethod; 11 | import org.jikesrvm.compilers.common.CompiledMethod; 12 | import org.jikesrvm.compilers.common.CompiledMethods; 13 | import org.jikesrvm.runtime.Magic; 14 | import org.jikesrvm.scheduler.RVMThread; 15 | import org.vmmagic.unboxed.Word; 16 | 17 | import java.io.FileOutputStream; 18 | import java.io.PrintStream; 19 | import java.io.PrintWriter; 20 | import java.text.DateFormat; 21 | import java.text.SimpleDateFormat; 22 | import java.util.Date; 23 | 24 | /** 25 | * Created by xiyang on 3/09/2014. 26 | */ 27 | public class MoMaLogger extends MoMaProfiler { 28 | 29 | public static final int BUFSIZE = 1024*1024; 30 | 31 | //counters[SIZE][NumberofEvents + 1] 32 | 33 | private long tempCounter[]; 34 | private long momaCounters[][]; 35 | private long dumpLines = 0; 36 | private int numberItems; 37 | 38 | //index key for reading perf counters cheaply in userlevel 39 | private int eventIndexes[]; 40 | private int numberPerfEvent; 41 | private String eventNames[]; 42 | 43 | 44 | private RVMThread targetThread; 45 | private PrintStream dumpFile; 46 | 47 | 48 | private void reportThreadName() { 49 | for (RVMThread t : RVMThread.threads) { 50 | if (t != null) 51 | System.out.println(" Thread" + t.getId() + t.getName()); 52 | } 53 | } 54 | 55 | 56 | public void init() { 57 | System.out.println("haha, moma profiler thread is here."); 58 | if (Options.MomaEvents == null) { 59 | System.out.println("MomaEvents is not set."); 60 | return; 61 | } 62 | 63 | //setup counters 64 | eventNames = Options.MomaEvents.split(","); 65 | numberPerfEvent = eventNames.length; 66 | sysCall.sysMomaEventInit(numberPerfEvent); 67 | eventIndexes = new int[numberPerfEvent]; 68 | 69 | // new buffer 70 | tempCounter = new long[numberPerfEvent + 1]; 71 | momaCounters = new long[BUFSIZE][numberPerfEvent + 1]; 72 | 73 | for (RVMThread t : RVMThread.threads) { 74 | if (t != null && t.getName().equals("MainThread")) { 75 | targetThread = t; 76 | System.out.println("Pin MainThread to 0x1, pin myself to 0x10"); 77 | sysCall.sysCall.sysThreadBind(t.pthread_id, 0x2); 78 | System.out.println("Mainthread's mask is " + sysCall.sysCall.sysGetThreadBindSet(t.pthread_id)); 79 | sysCall.sysCall.sysThreadBind(Magic.getThreadRegister().pthread_id, 0x20); 80 | System.out.println("myself mask is " + sysCall.sysCall.sysGetThreadBindSet(Magic.getThreadRegister().pthread_id)); 81 | 82 | } 83 | } 84 | 85 | for (int i = 0; i < numberPerfEvent; i++) { 86 | eventIndexes[i] = sysCall.sysMomaEventCreate(i, eventNames[i].concat("\0").getBytes()); 87 | VM.sysWriteln("Creat counter", eventNames[i], "at index", eventIndexes[i]); 88 | } 89 | 90 | try { 91 | dumpFile = new PrintStream("/tmp/momaDump"); 92 | } catch (Exception e) { 93 | System.out.println("Can't create /tmp/momaDump"); 94 | } 95 | 96 | DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); 97 | Date date = new Date(); 98 | 99 | dumpFile.println("{\n \"date\":\"" + dateFormat.format(date) + "\","); 100 | 101 | for (int i =0; i < numberPerfEvent; i++){ 102 | dumpFile.println("\"event" + i + "\":\"" + eventNames[i] + "\","); 103 | } 104 | } 105 | 106 | private void logCounters(long counters[], long tag) { 107 | for (int i = 0; i < numberPerfEvent; i++) { 108 | counters[i] = Magic.getPerformanceCounter(eventIndexes[i]); 109 | } 110 | counters[numberPerfEvent] = tag; 111 | } 112 | 113 | 114 | public void profile() { 115 | //System.out.println("moma profile"); 116 | int i = 0; 117 | logCounters(momaCounters[i], (long)targetThread.momaAppEvent); 118 | long lastTag = (int)momaCounters[i++][numberPerfEvent]; 119 | 120 | while (true) { 121 | long now = targetThread.momaAppEvent; 122 | if (now != lastTag) { 123 | logCounters(momaCounters[i++], now); 124 | lastTag = now; 125 | if (i == BUFSIZE || enabled == false) { 126 | numberItems = i; 127 | break; 128 | } 129 | } 130 | } 131 | } 132 | 133 | public void beginProfile() { 134 | dumpFile.print("\"items\":[\n"); 135 | 136 | } 137 | 138 | public void endProfile() { 139 | dumpFile.println("]}\n"); 140 | } 141 | 142 | 143 | //return jason style 144 | //{"seqId":global,"bufId":bufid,"package":"packagename", "method":"methodName", "cmid", cmid, "event0":counters,... "eventn":} 145 | public String formatEventsToString(long counters[], int bufId) 146 | { 147 | int tag = (int)counters[numberPerfEvent]; 148 | int cmid = tag; 149 | 150 | if (tag < 0) { 151 | cmid = -tag; 152 | } 153 | 154 | dumpLines++; 155 | 156 | RVMMethod method; 157 | String className = "XXXX"; 158 | String methodName = "XXXX"; 159 | if (cmid > 0 && cmid <= CompiledMethods.currentCompiledMethodId) { 160 | method = CompiledMethods.getCompiledMethod(cmid).method; 161 | if (method != null) { 162 | className = method.getDeclaringClass().toString(); 163 | methodName = method.getName().toString(); 164 | } 165 | } 166 | 167 | //dump message to dumpFile; 168 | String formatString; 169 | 170 | if (dumpLines == 1) 171 | formatString = "{"; 172 | else 173 | formatString = ",\n{"; 174 | 175 | formatString += "\"seqId\":" + dumpLines + "," + "\"bufId\":" + bufId + "," + "\"cmid\":" + tag + "," + "\"className\":\"" + className + "\"," + "\"methodName\":\"" + methodName + "\""; 176 | for (int j = 0; j < numberPerfEvent; j++) { 177 | formatString += ",\"event" + j + "\":" + counters[j]; 178 | } 179 | formatString += "}"; 180 | return formatString; 181 | } 182 | 183 | public void process() { 184 | dumpFile.print(formatEventsToString(momaCounters[0], 0)); 185 | 186 | for (int i = 1; i < numberItems; i++) { 187 | for (int j=0;j 3000) { 127 | i++; 128 | if (i == BUFSIZE || enabled == false) { 129 | numberItems = i; 130 | break; 131 | } 132 | } 133 | } 134 | } 135 | 136 | public void beginProfile() { 137 | dumpFile.print("\"items\":[\n"); 138 | 139 | } 140 | 141 | public void endProfile() { 142 | dumpFile.println("]}\n"); 143 | } 144 | 145 | 146 | //return jason style 147 | //{"seqId":global,"bufId":bufid,"package":"packagename", "method":"methodName", "cmid", cmid, "event0":counters,... "eventn":} 148 | public String formatEventsToString(long counters[], int bufId) 149 | { 150 | int tag = (int)counters[numberPerfEvent]; 151 | int cmid = tag; 152 | 153 | if (tag < 0) { 154 | cmid = -tag; 155 | } 156 | 157 | dumpLines++; 158 | 159 | RVMMethod method; 160 | String className = "XXXX"; 161 | String methodName = "XXXX"; 162 | if (cmid > 0 && cmid <= CompiledMethods.currentCompiledMethodId) { 163 | method = CompiledMethods.getCompiledMethod(cmid).method; 164 | if (method != null) { 165 | className = method.getDeclaringClass().toString(); 166 | methodName = method.getName().toString(); 167 | } 168 | } 169 | 170 | //dump message to dumpFile; 171 | String formatString; 172 | 173 | if (dumpLines == 1) 174 | formatString = "{"; 175 | else 176 | formatString = ",\n{"; 177 | 178 | formatString += "\"seqId\":" + dumpLines + "," + "\"bufId\":" + bufId + "," + "\"cmid\":" + tag + "," + "\"className\":\"" + className + "\"," + "\"methodName\":\"" + methodName + "\""; 179 | for (int j = 0; j < numberPerfEvent; j++) { 180 | formatString += ",\"event" + j + "\":" + counters[j]; 181 | } 182 | formatString += "}"; 183 | return formatString; 184 | } 185 | 186 | public void process() { 187 | 188 | dumpFile.print(formatEventsToString(momaCounters[0], 0)); 189 | 190 | for (int i = 1; i < numberItems; i++) { 191 | for (int j=0;j]*>", "").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&"); 34 | } 35 | 36 | public static String escapeHtml(final String s) { 37 | // the order is important, otherwise '<' is replaced with '<' and 38 | // then later '&' is replaced with '&' so '<' becomes '&lt;' 39 | return s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">"); 40 | } 41 | 42 | /** 43 | * Given a type name like "I" or "[C" or "Ljava/lang/String;" or 44 | * "[[Ljava/lang/String;", return a shorter version without package names. 45 | */ 46 | public static String shortenTypeName(final String name) { 47 | if (name.contains("/")) { 48 | return name.replaceFirst("L.*/", "").replace(";", ""); 49 | } else { 50 | return name; 51 | } 52 | } 53 | 54 | /** 55 | * Given a type name like "[C" or "Ljava/lang/String;" or 56 | * "[[Ljava/lang/String;", return a human readable version 57 | * like "char[]" or "java.lang.String" or "java.lang.String[][]". 58 | */ 59 | public static String humanizeTypeName(final String name) { 60 | return humanizeTypeName(name, false, false); 61 | } 62 | 63 | public static String humanizeTypeName(final String name, final boolean htmlize, final boolean abbreviate) { 64 | String h = name; 65 | while (h.startsWith("[")) { 66 | h = h.replaceFirst("\\[", "") + "[]"; 67 | } 68 | if (h.startsWith("L")) { 69 | h = h.replaceFirst("L", "").replace(";", ""); 70 | if (abbreviate) { 71 | h = h.replaceFirst("org/jikesrvm", "~"); // abbreviate org.jikesrvm as ~ 72 | } 73 | final int startOfUnqualifiedName = h.contains("/") ? h.lastIndexOf('/') + 1 : 0; 74 | h = h.replace("/", "."); 75 | if (htmlize) { 76 | h = h.substring(0, startOfUnqualifiedName)+""+h.substring(startOfUnqualifiedName)+""; 77 | } 78 | return h; 79 | } 80 | if (h.matches("B(\\[\\])*")) { 81 | h = h.replaceFirst("B", "byte"); 82 | } else if (h.matches("Z(\\[\\])*")) { 83 | h = h.replaceFirst("Z", "boolean"); 84 | } else if (h.matches("C(\\[\\])*")) { 85 | h = h.replaceFirst("C", "char"); 86 | } else if (h.matches("S(\\[\\])*")) { 87 | h = h.replaceFirst("S", "short"); 88 | } else if (h.matches("I(\\[\\])*")) { 89 | h = h.replaceFirst("I", "int"); 90 | } else if (h.matches("J(\\[\\])*")) { 91 | h = h.replaceFirst("J", "long"); 92 | } else if (h.matches("F(\\[\\])*")) { 93 | h = h.replaceFirst("F", "float"); 94 | } else if (h.matches("D(\\[\\])*")) { 95 | h = h.replaceFirst("D", "double"); 96 | } else if (h.matches("V")) { 97 | h = h.replaceFirst("V", "void"); 98 | } 99 | if (htmlize) { 100 | return ""+h+""; 101 | } else { 102 | return h; 103 | } 104 | } 105 | 106 | /** 107 | * Given a method descriptor like "()Z" or "(II)Ljava/lang/String;" 108 | * return a human readable version 109 | * like "():boolean" or "(int, int):java.lang.String". 110 | */ 111 | public static String humanizeMethodDescriptor(final String name) { 112 | final Pattern p = Pattern.compile("\\((.*)\\)(.*)"); 113 | final Matcher m = p.matcher(name); 114 | final boolean b = m.matches(); 115 | if (b) { 116 | return "(" + parseArguments(m.group(1)) + "): " + humanizeTypeName(m.group(2), false, true); 117 | } 118 | return name; 119 | } 120 | 121 | public static String humanizeMemberDescriptor(final String descriptor) { 122 | if (descriptor.startsWith("(")) { 123 | return Util.humanizeMethodDescriptor(descriptor); 124 | } 125 | return Util.humanizeTypeName(descriptor, false, true); 126 | } 127 | 128 | private static String parseArguments(final String args) { 129 | final Pattern p = Pattern.compile("(\\[*(B|Z|C|S|I|J|F|D|(L[^;]+;)))(.*)"); 130 | final Matcher m = p.matcher(args); 131 | final boolean b = m.matches(); 132 | if (b) { 133 | final String x = humanizeTypeName(m.group(1), false, true); 134 | final String xs = parseArguments(m.group(4)); 135 | if (xs.equals("")) return x; 136 | return x + ", " + xs; 137 | } 138 | return args; 139 | } 140 | 141 | public static String shorten(final String contents, final int maxLength) { 142 | if (contents.length() > maxLength) { 143 | return contents.substring(0, maxLength - 3) + "..."; 144 | } else { 145 | return contents; 146 | } 147 | } 148 | 149 | public static String addressToHexString(final Address address) { 150 | if (address == null) return "?"; 151 | System.out.println("ToHexString " + address.toInt()); 152 | if (VM.BuildFor32Addr) return String.format("%8x", address.toInt()); 153 | return String.format("%16x", address.toLong()); 154 | } 155 | 156 | public static Address fromHex(final String addressAsHexString) { 157 | if (VM.BuildFor32Addr) { 158 | // parseInt does not work for negative integers like BFFFF3B0 159 | // because it expects negative integers to be like -40000C50 160 | // (this is 2's complement of BFFFF3B0 and a sign) 161 | // FIXME find something better or error on invalid hex strings 162 | int value = 0; 163 | for (final char c : addressAsHexString.toUpperCase().toCharArray()) { 164 | value = ((value << 4) & 0xfffffff0) | (0xf & (('0' <= c && c <= '9') ? c - '0' : c - '7')); 165 | } 166 | return Address.fromIntZeroExtend(value); 167 | // return Address.fromIntZeroExtend(Integer.parseInt(addressAsHexString, 16)); 168 | } 169 | long value = 0; 170 | for (final char c : addressAsHexString.toUpperCase().toCharArray()) { 171 | value = ((value << 4) & 0xfffffffffffffff0L) | (0xfL & (('0' <= c && c <= '9') ? c - '0' : c - '7')); 172 | } 173 | return Address.fromLong(value); 174 | // return Address.fromLong(Long.parseLong(addressAsHexString, 16)); 175 | } 176 | 177 | public static String wordToHexString(final Word word) { 178 | if (word == null) { 179 | return "?"; 180 | } else if (VM.BuildFor32Addr) { 181 | final int intValue = word.toInt(); 182 | return String.format("%08x", intValue); 183 | } else { 184 | final long longValue = word.toLong(); 185 | return String.format("%016x", longValue); 186 | } 187 | } 188 | 189 | public static String offsetToDecString(final Offset offset) { 190 | if (offset == null) { 191 | return "?"; 192 | } else if (VM.BuildFor32Addr) { 193 | final int intValue = offset.toInt(); 194 | return "" + intValue; 195 | } else { 196 | final long longValue = offset.toLong(); 197 | return "" + longValue; 198 | } 199 | } 200 | 201 | public static String offsetToHexString(final Offset offset) { 202 | if (offset == null) { 203 | return "?"; 204 | } else if (VM.BuildFor32Addr) { 205 | final int intValue = offset.toInt(); 206 | return String.format("%08x", intValue); 207 | } else { 208 | final long longValue = offset.toLong(); 209 | return String.format("%016x", longValue); 210 | } 211 | } 212 | 213 | public static String offsetToPlusMinusHexString(final Offset offset) { 214 | if (offset == null) { 215 | return "?"; 216 | } else if (VM.BuildFor32Addr) { 217 | final int intValue = offset.toInt(); 218 | return intValue<0?String.format("-%x", -intValue):String.format("+%x", intValue); 219 | } else { 220 | final long longValue = offset.toLong(); 221 | return longValue<0?String.format("-%x", -longValue):String.format("+%x", longValue); 222 | } 223 | } 224 | 225 | public static String offsetToNothingMinusHexString(final Offset offset) { 226 | if (offset == null) { 227 | return "?"; 228 | } else if (VM.BuildFor32Addr) { 229 | final int intValue = offset.toInt(); 230 | return intValue<0?String.format("-%x", -intValue):String.format("%x", intValue); 231 | } else { 232 | final long longValue = offset.toLong(); 233 | return longValue<0?String.format("-%x", -longValue):String.format("%x", longValue); 234 | } 235 | } 236 | 237 | public static String extentToDecString(final Extent extent) { 238 | if (extent == null) { 239 | return "?"; 240 | } else if (VM.BuildFor32Addr) { 241 | final int intValue = extent.toInt(); 242 | return "" + intValue; 243 | } else { 244 | final long longValue = extent.toLong(); 245 | return "" + longValue; 246 | } 247 | } 248 | 249 | public static String extentToHexString(final Extent extent) { 250 | if (extent == null) { 251 | return "?"; 252 | } else if (VM.BuildFor32Addr) { 253 | final int intValue = extent.toInt(); 254 | return String.format("%08x", intValue); 255 | } else { 256 | final long longValue = extent.toLong(); 257 | return String.format("%016x", longValue); 258 | } 259 | } 260 | 261 | /** 262 | * 263 | * @param value 264 | * @param sizeInBits 265 | * @param blockSize number of bits in a block, blocks separated by spaces, 266 | * e.g 0111 0010 with blockSize equal 4, can't be less than 4. 267 | * @return string of 0s and 1s representing value as a binary number 268 | */ 269 | public static String toBinaryString(final long value, final int sizeInBits, final int blockSize) { 270 | final StringBuffer sb = new StringBuffer(); 271 | final int size = ceilingPower2(sizeInBits); 272 | final int block = ceilingPower2(blockSize); 273 | int remainder = block; 274 | for (int i = size - 4; i >= 0; i -= 4) { 275 | if (block > 0 && remainder == 0) { 276 | remainder = block; 277 | sb.append(' '); 278 | } 279 | final int index = (0xf & (int)(value >> i)); 280 | sb.append(BITS[index]); 281 | remainder -= 4; 282 | } 283 | return sb.toString(); 284 | } 285 | 286 | public static int ceilingPower2(final int x) { 287 | int r = x - 1; 288 | r = r | (r >> 1); 289 | r = r | (r >> 2); 290 | r = r | (r >> 4); 291 | r = r | (r >> 8); 292 | r = r | (r >> 16); 293 | return r + 1; 294 | } 295 | } 296 | -------------------------------------------------------------------------------- /JikesRVMProbes/moma/testrdpmc.java: -------------------------------------------------------------------------------- 1 | package moma; 2 | 3 | import org.jikesrvm.Options; 4 | import static org.jikesrvm.runtime.SysCall.sysCall; 5 | import org.jikesrvm.VM; 6 | import org.jikesrvm.runtime.Magic; 7 | import org.jikesrvm.runtime.SysCall; 8 | 9 | /** 10 | * Created by xiyang on 11/08/2014. 11 | */ 12 | public class testrdpmc { 13 | 14 | public static boolean enable; 15 | 16 | 17 | private static int indexes[]; 18 | private static int numberEvents; 19 | private static String eventNames[]; 20 | 21 | private static void init() { 22 | eventNames = Options.MomaEvents.split(","); 23 | numberEvents = eventNames.length; 24 | sysCall.sysMomaEventInit(numberEvents); 25 | indexes = new int[numberEvents]; 26 | for (int i = 0; i < numberEvents; i++) { 27 | indexes[i] = sysCall.sysMomaEventCreate(i, eventNames[i].concat("\0").getBytes()); 28 | VM.sysWriteln("Creat counter", eventNames[i], "at index", indexes[i]); 29 | } 30 | } 31 | 32 | public static long test() 33 | { 34 | 35 | long v1 = 0; 36 | long v2 = 0; 37 | for(int i=0;i<100000;i=i+1){ 38 | v1 = Magic.getPerformanceCounter(indexes[0]); 39 | v2 = Magic.getPerformanceCounter(indexes[0]); 40 | } 41 | return v2 - v1; 42 | 43 | } 44 | 45 | public static void main(String args[]) { 46 | //start profiling now, checking Options. 47 | init(); 48 | long cpumask = sysCall.sysGetThreadBindSet(sysCall.sysGetThreadId()); 49 | VM.sysWriteln("cpumask is ", cpumask); 50 | long count = 0; 51 | for(int i=0;i<1000000;i=i+1) 52 | count += test(); 53 | System.out.println("count is " + count); 54 | 55 | 56 | 57 | /*while(true) { 58 | for (int i = 0; i < 8; i++) { 59 | long whichcpu = 1 << i; 60 | sysCall.sysCall.sysThreadBind(sysCall.sysGetThreadId(), whichcpu); 61 | //wait for 100k instructions 62 | VM.sysWriteln("Moving to CPU ", i); 63 | long base = Magic.getPerformanceCounter(indexes[0]); 64 | while (Magic.getPerformanceCounter(indexes[0]) < base + 100000) 65 | ; 66 | }*/ 67 | 68 | 69 | 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/hello_world/Makefile: -------------------------------------------------------------------------------- 1 | include ../../common.mk 2 | 3 | all: libhello_world.so 4 | 5 | libhello_world.so: hello_world.o 6 | gcc $(CFLAGS) -pthread -shared -o libhello_world.so hello_world.o -lc 7 | 8 | hello_world.o: hello_world.c 9 | gcc $(CFLAGS) -pthread -c hello_world.c -I$(JDK)/include -I$(JDK)/include/linux/ 10 | 11 | 12 | clean: 13 | rm -rf *.o *.so 14 | 15 | test: default 16 | $(JAVA) -Djava.library.path=`pwd`/hello_world -cp .:$(BENCHMARKS)/dacapo/dacapo-9.12-bach.jar Harness -c callback.DacapoBachCallback avrora 17 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/hello_world/hello_world.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* JNI Functions */ 5 | JNIEXPORT void JNICALL Java_probe_HelloWorldNativeProbe_begin 6 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 7 | jboolean iscopy; 8 | const char *bm = (*env)->GetStringUTFChars(env, benchmark, &iscopy); 9 | printf("HelloWorldNativeProbe_begin.(benchmark = %s, iteration = %d, warmup = %d)\n", bm, iteration, warmup); 10 | } 11 | JNIEXPORT void JNICALL Java_probe_HelloWorldNativeProbe_end 12 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 13 | jboolean iscopy; 14 | const char *bm = (*env)->GetStringUTFChars(env, benchmark, &iscopy); 15 | printf("HelloWorldNativeProbe_end.(benchmark = %s, iteration = %d, warmup = %d)\n", bm, iteration, warmup); 16 | } 17 | JNIEXPORT void JNICALL Java_probe_HelloWorldNativeProbe_report 18 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 19 | jboolean iscopy; 20 | const char *bm = (*env)->GetStringUTFChars(env, benchmark, &iscopy); 21 | printf("HelloWorldNativeProbe_report.(benchmark = %s, iteration = %d, warmup = %d)\n", bm, iteration, warmup); 22 | } 23 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/perf_event/Makefile: -------------------------------------------------------------------------------- 1 | include ../../common.mk 2 | 3 | objs = perf_event_launcher libperf_event_launcher.so libperf_event_reader.so libperf_event_shim.so shim_core.o 4 | 5 | all: $(objs) 6 | 7 | perf_event_launcher: perf_event_launcher.c 8 | g++ $(CFLAGS) -fPIC perf_event_launcher.c -o perf_event_launcher -pthread -lpfm 9 | 10 | libperf_event_launcher.so:perf_event_launcher_jni.c 11 | gcc $(CFLAGS) -std=c99 -fPIC -lpfm -shared perf_event_launcher_jni.c -o libperf_event_launcher.so -I$(JDK)/include -I$(JDK)/include/linux/ 12 | 13 | libperf_event_reader.so:perf_event_reader_jni.c 14 | gcc $(CFLAGS) -shared -std=c99 -fPIC perf_event_reader_jni.c -o libperf_event_reader.so -I$(JDK)/include -I$(JDK)/include/linux/ -lpfm 15 | 16 | shim_core.o: ../../../shim_core.c 17 | gcc $(CFLAGS) -c $< -o $@ -pthread -lpfm -lrt 18 | 19 | libperf_event_shim.so:perf_event_shim.c shim_core.o 20 | gcc $(CFLAGS) -shared -std=c99 -fPIC perf_event_shim.c ./shim_core.o -o $@ -I$(JDK)/include -I$(JDK)/include/linux/ -I../../../ -lpfm -lrt -pthread 21 | # gcc $(CFLAGS) -shared -std=c99 -fPIC perf_event_shim.c -o $@ -I$(JDK)/include -I$(JDK)/include/linux/ -I../../../ -lpfm -lrt -pthread 22 | 23 | 24 | .PHONY: clean 25 | clean: 26 | -rm $(objs) 27 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/perf_event/m32_patch: -------------------------------------------------------------------------------- 1 | diff --git a/config.mk b/config.mk 2 | index 522c585..646b73c 100644 3 | --- a/config.mk 4 | +++ b/config.mk 5 | @@ -172,8 +172,8 @@ INSTALL=install 6 | LN?=ln -sf 7 | PFMINCDIR=$(TOPDIR)/include 8 | PFMLIBDIR=$(TOPDIR)/lib 9 | -DBG?=-g -Wall -Werror 10 | -CFLAGS+=$(OPTIM) $(DBG) -I$(SYSINCDIR) -I$(PFMINCDIR) 11 | +DBG?=-g -Wall 12 | +CFLAGS+=$(OPTIM) $(DBG) -I$(SYSINCDIR) -I$(PFMINCDIR) -fPIC 13 | MKDEP=makedepend 14 | PFMLIB=$(PFMLIBDIR)/libpfm.a 15 | 16 | @@ -183,6 +183,13 @@ LDFLAGS+= -m64 17 | LIBDIR=$(DESTDIR)/lib64 18 | endif 19 | 20 | +ifeq ($(CONFIG_PFMLIB_ARCH_X86),y) 21 | +ifeq (-m32,$(findstring -m32,$(OPTION))) 22 | +CFLAGS += -m32 23 | +CONFIG_PFMLIB_NOPYTHON=y 24 | +endif 25 | +endif 26 | + 27 | ifeq ($(CONFIG_PFMLIB_DEBUG),y) 28 | CFLAGS += -DCONFIG_PFMLIB_DEBUG 29 | endif 30 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/perf_event/perf_event_agent.c: -------------------------------------------------------------------------------- 1 | /* 2 | * self.c - example of a simple self monitoring task 3 | * 4 | * Copyright (c) 2009 Google, Inc 5 | * Contributed by Stephane Eranian 6 | * 7 | * Based on: 8 | * Copyright (c) 2002-2007 Hewlett-Packard Development Company, L.P. 9 | * Contributed by Stephane Eranian 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 15 | * of the Software, and to permit persons to whom the Software is furnished to do so, 16 | * subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 22 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 23 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 25 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 26 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | * 28 | * This file is part of libpfm, a performance monitoring support library for 29 | * applications on Linux. 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include 47 | #include "perf_util.h" 48 | 49 | #include "jvmti.h" 50 | #include "jni.h" 51 | 52 | 53 | /*static const char *gen_events[]={ 54 | "PERF_COUNT_HW_CPU_CYCLES", 55 | "PERF_COUNT_HW_INSTRUCTIONS", 56 | NULL 57 | };*/ 58 | 59 | static perf_event_desc_t* perfevent_fds = NULL; 60 | static int perfevent_num_fds = 0; 61 | static char* perfevent_events = NULL; 62 | 63 | 64 | void perfevent_initialize(char*events) { 65 | int i, ret; 66 | perfevent_events = strdup(events); 67 | 68 | /* 69 | * Initialize pfm library (required before we can use it) 70 | */ 71 | ret = pfm_initialize(); 72 | if (ret != PFM_SUCCESS) 73 | errx(1, "Cannot initialize library: %s", pfm_strerror(ret)); 74 | 75 | ret = perf_setup_list_events(events, &perfevent_fds, &perfevent_num_fds); 76 | if (ret || !perfevent_num_fds) 77 | errx(1, "cannot setup events"); 78 | 79 | perfevent_fds[0].fd = -1; 80 | for(i=0; i < perfevent_num_fds; i++) { 81 | /* request timing information necessary for scaling */ 82 | perfevent_fds[i].hw.read_format = PERF_FORMAT_SCALE; 83 | 84 | perfevent_fds[i].hw.disabled = (i == 0); /* do not start now */ 85 | perfevent_fds[i].hw.inherit = 1; /* pass on to child threads */ 86 | 87 | /* each event is in an independent group (multiplexing likely) */ 88 | perfevent_fds[i].fd = perf_event_open(&perfevent_fds[i].hw, 0, -1, perfevent_fds[0].fd, 0); 89 | if (perfevent_fds[i].fd == -1) 90 | err(1, "cannot open event %d", i); 91 | } 92 | } 93 | void perfevent_enable() { 94 | int ret; 95 | /* 96 | * start counting now 97 | */ 98 | ret = ioctl(perfevent_fds[0].fd, PERF_EVENT_IOC_ENABLE, 0); 99 | if (ret) 100 | err(1, "ioctl(enable) failed"); 101 | } 102 | void perfevent_disable() { 103 | int ret; 104 | /* 105 | * stop counting 106 | */ 107 | ret = ioctl(perfevent_fds[0].fd, PERF_EVENT_IOC_DISABLE, 0); 108 | if (ret) 109 | err(1, "ioctl(disable) failed"); 110 | } 111 | void perfevent_reset() { 112 | int i, ret; 113 | /* 114 | * stop counting 115 | */ 116 | for(i=0; i < perfevent_num_fds; i++) { 117 | ret = ioctl(perfevent_fds[i].fd, PERF_EVENT_IOC_RESET, 0); 118 | if (ret) 119 | err(1, "ioctl(reset) failed"); 120 | } 121 | } 122 | 123 | void perfevent_read() { 124 | int i, ret; 125 | uint64_t values[3]; 126 | /* 127 | * now read the results. We use pfp_event_count because 128 | * libpfm guarantees that counters for the events always 129 | * come first. 130 | */ 131 | memset(values, 0, sizeof(values)); 132 | 133 | fprintf(stderr, "============================ Tabulate Statistics ============================\n"); 134 | for (i=0; i < perfevent_num_fds; i++) { 135 | fprintf(stderr, "%s ", perfevent_fds[i].name); 136 | } 137 | fprintf(stderr, "\n"); 138 | for (i=0; i < perfevent_num_fds; i++) { 139 | uint64_t val; 140 | double ratio; 141 | 142 | ret = read(perfevent_fds[i].fd, values, sizeof(values)); 143 | if (ret < sizeof(values)) { 144 | if (ret == -1) 145 | err(1, "cannot read results: %s", strerror(errno)); 146 | else 147 | warnx("could not read event%d", i); 148 | } 149 | /* 150 | * scaling is systematic because we may be sharing the PMU and 151 | * thus may be multiplexed 152 | */ 153 | val = perf_scale(values); 154 | ratio = perf_scale_ratio(values); 155 | 156 | if (ratio == 1.0) 157 | fprintf(stderr, "%lld ", (long long int) val); 158 | else 159 | if (ratio == 0.0) 160 | fprintf(stderr, "NO_VALUE "); 161 | else 162 | fprintf(stderr, "%lld-SCALED-%.2f%% ", (long long int) val, ratio*100.0); 163 | } 164 | fprintf(stderr, "\n=============================================================================\n"); 165 | } 166 | void perfevent_cleanup() { 167 | int i; 168 | for (i=0; i < perfevent_num_fds; i++) { 169 | close(perfevent_fds[i].fd); 170 | } 171 | free(perfevent_fds); 172 | perfevent_fds = NULL; 173 | perfevent_num_fds = 0; 174 | } 175 | 176 | /* JVMTI Functions */ 177 | JNIEXPORT jint JNICALL 178 | Agent_OnLoad(JavaVM *vm, char *options, void *reserved) { 179 | perfevent_initialize(options); 180 | return JNI_OK; 181 | } 182 | JNIEXPORT void JNICALL 183 | Agent_OnUnload(JavaVM *vm) { 184 | perfevent_cleanup(); 185 | } 186 | 187 | /* JNI Functions */ 188 | JNIEXPORT void JNICALL Java_probe_PerfEventProbe_begin 189 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 190 | perfevent_enable(); 191 | } 192 | JNIEXPORT void JNICALL Java_probe_PerfEventProbe_end 193 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 194 | perfevent_disable(); 195 | } 196 | JNIEXPORT void JNICALL Java_probe_PerfEventProbe_report 197 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 198 | perfevent_read(); 199 | perfevent_reset(); 200 | } 201 | JNIEXPORT void JNICALL Java_probe_PerfEventProbe_reinitialize 202 | (JNIEnv *env, jobject o) { 203 | perfevent_cleanup(); 204 | perfevent_initialize(perfevent_events); 205 | } 206 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/perf_event/perf_event_launcher.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int DEBUG = 1; 13 | 14 | #define debug_printf(fmt, ...) \ 15 | do { if (DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0) 16 | 17 | int create_counter(const char *name, struct perf_event_attr *attr, int cpu, int task) 18 | { 19 | // int ret = pfm_get_perf_event_encoding(name, PFM_PLM3, attr, NULL, NULL); 20 | pfm_perf_encode_arg_t raw; 21 | memset(&raw, 0, sizeof(pfm_perf_encode_arg_t)); 22 | memset(attr, 0, sizeof(struct perf_event_attr)); 23 | raw.attr = attr; 24 | raw.size = sizeof(pfm_perf_encode_arg_t); 25 | int ret = pfm_get_os_event_encoding(name, PFM_PLM3, PFM_OS_PERF_EVENT, &raw); 26 | if (ret != PFM_SUCCESS) { 27 | errx(1, "error when translating name to attr '%s': %s\n", name, pfm_strerror(ret)); 28 | } 29 | 30 | attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING; 31 | attr->disabled = 1; 32 | attr->inherit = 1; 33 | 34 | int fd = perf_event_open(attr, task, cpu, -1, 0); 35 | if (fd == -1) { 36 | err(1, "error in perf_event_open for event %s on task %d on cpu %d", name, task, cpu); 37 | } 38 | 39 | debug_printf("create_counter: %s, on cpu %d, on task %d as fd %d\n", name, cpu, task, fd); 40 | 41 | return fd; 42 | } 43 | 44 | int main(int argc, char* argv[]) { 45 | int nr_cpus = 1; 46 | int nr_events = 1; 47 | char *events; 48 | 49 | struct perf_event_attr *attrs; 50 | char **names; 51 | int *fds; 52 | 53 | int percpu = 0; 54 | int pincpu = 0; 55 | 56 | char *event_list = NULL; 57 | int len_list = 100; 58 | 59 | 60 | if (argc <= 2) 61 | printf( "perf_event_launcher [COMMAND] EVENT1,EVENT2,...,EVENTN program ...\n" 62 | "Default COMMAND is creating counters for the program process\n" 63 | "commands are:\n" 64 | " percpu: create counters for each CPU for the program process\n" 65 | " pincpu: create counters on each CPU\n"); 66 | 67 | 68 | //process COMMAND 69 | if (strcmp(argv[1],"percpu") == 0){ 70 | events = argv[2]; 71 | percpu = 1; 72 | } 73 | else if (strcmp(argv[1],"pincpu") == 0){ 74 | percpu = 1; 75 | pincpu = 1; 76 | events = argv[2]; 77 | } 78 | else { 79 | events = argv[1]; 80 | } 81 | 82 | 83 | nr_cpus = get_nprocs(); 84 | 85 | for (char *c = events; *c!='\0'; c++) 86 | if (*c == ',') 87 | nr_events++; 88 | 89 | debug_printf("Setup %d events on %d cpus: %s\n ", nr_events,nr_cpus,events); 90 | 91 | int ret = pfm_initialize(); 92 | if (ret != PFM_SUCCESS) 93 | errx(1, "Cannot initialize library: %s", pfm_strerror(ret)); 94 | 95 | /*allocate attrs,etc. based on nr_events*/ 96 | attrs = (struct perf_event_attr *)calloc(nr_events,sizeof(struct perf_event_attr)); 97 | if (attrs == NULL) 98 | errx(1, "Cannot allocate space for attrs"); 99 | 100 | names = (char **)malloc(sizeof(char*) * nr_events); 101 | if (names == NULL) 102 | errx(1, "Cannot allocate space for event_name"); 103 | 104 | fds = (int *)malloc(sizeof(int) * nr_events * nr_cpus); 105 | if (fds == NULL) 106 | errx(1, "Cannot allocate space for fds"); 107 | 108 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | JNIEXPORT void JNICALL 13 | Java_probe_PerfEventLauncherProbe_enable(JNIEnv *env, jclass cls, jint fd) 14 | { 15 | if (ioctl( fd, PERF_EVENT_IOC_ENABLE) == -1) 16 | err(1, "error in prctl(PR_TASK_PERF_EVENTS_ENABLE)"); 17 | } 18 | 19 | JNIEXPORT void JNICALL 20 | Java_probe_PerfEventLauncherProbe_disable(JNIEnv *env, jclass cls, jint fd) 21 | { 22 | if (ioctl( fd, PERF_EVENT_IOC_DISABLE) == -1) 23 | err(1, "error in prctl(PR_TASK_PERF_EVENTS_ENABLE)"); 24 | } 25 | 26 | JNIEXPORT void JNICALL 27 | Java_probe_PerfEventLauncherProbe_reset(JNIEnv *env, jclass cls, jint fd) 28 | { 29 | if (ioctl( fd, PERF_EVENT_IOC_RESET) == -1) 30 | err(1, "error in prctl(PR_TASK_PERF_EVENTS_ENABLE)"); 31 | } 32 | 33 | JNIEXPORT void JNICALL 34 | Java_probe_PerfEventLauncherProbe_read(JNIEnv *env, jclass cls, jint fd, jlongArray result) 35 | { 36 | uint64_t buf[3]; 37 | size_t expectedBytes = 3 * sizeof(uint64_t); 38 | 39 | int ret = read(fd, buf, expectedBytes); 40 | if (ret < 0) { 41 | err(1, "error reading event: %s", strerror(errno)); 42 | } 43 | if (ret != expectedBytes) { 44 | errx(1, "read of perf event did not return 3 64-bit values"); 45 | } 46 | 47 | jlong* r = (*env)->GetLongArrayElements(env,result, NULL); 48 | 49 | for (int i=0; i<3; i++) 50 | r[i] = buf[i]; 51 | 52 | (*env)->ReleaseLongArrayElements(env,result, r, 0); 53 | } 54 | 55 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/perf_event/perf_event_reader_jni.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | //RAPL 15 | #define RAPL_ENERGY_UNIT_MASK 0x1F00 16 | #define RAPL_ENERGY_UNIT_OFFSET 0x08 17 | #define RAPL_POWER_UNIT 0x606 18 | #define RAPL_PACKAGE_ENERGY 0x611 19 | #define RAPL_CORE_ENERGY 0x639 20 | #define RAPL_UNCORE_ENERGY 0x641 21 | #define RAPL_DRAM_ENERGY 0x619 22 | 23 | static int msr_fd; 24 | 25 | static jlong readRAPL(unsigned int reg){ 26 | jlong data; 27 | if (msr_fd != -1) 28 | if (lseek(msr_fd, reg, SEEK_SET) == reg) 29 | if (read(msr_fd, &data, sizeof(data)) == sizeof(data)) 30 | return data; 31 | 32 | return 0; 33 | } 34 | 35 | JNIEXPORT jlong JNICALL 36 | Java_probe_PerfEventReader_raplInit(JNIEnv *env, jobject obj) 37 | { 38 | jlong mask; 39 | msr_fd = open("/dev/cpu/0/msr", O_RDONLY); 40 | 41 | if(msr_fd != -1) 42 | if (lseek(msr_fd, RAPL_POWER_UNIT, SEEK_SET) == RAPL_POWER_UNIT) 43 | if (read(msr_fd,&mask,sizeof(mask)) == sizeof(mask)) 44 | return 1<< ((mask & RAPL_ENERGY_UNIT_MASK) >> RAPL_ENERGY_UNIT_OFFSET); 45 | 46 | return 0; 47 | } 48 | 49 | JNIEXPORT jlong JNICALL 50 | Java_probe_PerfEventReader_raplPackage(JNIEnv *env, jobject obj) 51 | { 52 | return readRAPL(RAPL_PACKAGE_ENERGY); 53 | } 54 | 55 | JNIEXPORT jlong JNICALL 56 | Java_probe_PerfEventReader_raplCore(JNIEnv *env, jobject obj) 57 | { 58 | return readRAPL(RAPL_CORE_ENERGY); 59 | } 60 | 61 | JNIEXPORT jlong JNICALL 62 | Java_probe_PerfEventReader_raplUncore(JNIEnv *env, jobject obj) 63 | { 64 | return readRAPL(RAPL_UNCORE_ENERGY); 65 | } 66 | 67 | JNIEXPORT jlong JNICALL 68 | Java_probe_PerfEventReader_raplDram(JNIEnv *env, jobject obj) 69 | { 70 | return readRAPL(RAPL_DRAM_ENERGY); 71 | } 72 | 73 | 74 | 75 | JNIEXPORT void JNICALL 76 | Java_probe_PerfEventReader_init(JNIEnv *env, jobject obj) 77 | { 78 | int ret = pfm_initialize(); 79 | if (ret != PFM_SUCCESS) { 80 | errx(1, "error in pfm_initialize: %s", pfm_strerror(ret)); 81 | } 82 | } 83 | 84 | JNIEXPORT jint JNICALL 85 | Java_probe_PerfEventReader_create(JNIEnv * env, jobject obj, jstring jeventName) 86 | { 87 | pfm_perf_encode_arg_t raw; 88 | struct perf_event_attr peattr; 89 | struct perf_event_attr *pe = &peattr; 90 | memset(&raw, 0, sizeof(pfm_perf_encode_arg_t)); 91 | memset(pe, 0, sizeof(struct perf_event_attr)); 92 | raw.attr = pe; 93 | raw.size = sizeof(pfm_perf_encode_arg_t); 94 | const char * eventName = (*env)->GetStringUTFChars(env, jeventName, 0); 95 | int ret = pfm_get_os_event_encoding(eventName, PFM_PLM3, PFM_OS_PERF_EVENT, &raw); 96 | if (ret != PFM_SUCCESS) { 97 | errx(1, "error creating event '%s': %s\n", eventName, pfm_strerror(ret)); 98 | } 99 | pe->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | PERF_FORMAT_TOTAL_TIME_RUNNING; 100 | pe->disabled = 0; 101 | pe->inherit = 1; 102 | int fd = perf_event_open(pe, 0, -1, -1, 0); 103 | if (fd == -1) { 104 | err(1, "error in perf_event_open for event %d '%s'", fd, eventName); 105 | } 106 | (*env)->ReleaseStringUTFChars(env,jeventName, eventName); 107 | return fd; 108 | } 109 | 110 | JNIEXPORT jlong JNICALL 111 | Java_probe_PerfEventReader_read(JNIEnv * envint , jobject obj, jint jfd){ 112 | int fd = jfd; 113 | size_t expectedBytes = 3 * sizeof(long long); 114 | long long values[3]; 115 | int ret = read(fd, values, expectedBytes); 116 | if (ret < 0) { 117 | err(1, "error reading event: %s", strerror(errno)); 118 | } 119 | if (ret != expectedBytes) { 120 | errx(1, "read of perf event did not return 3 64-bit values"); 121 | } 122 | return (jlong)(values[0]); 123 | } 124 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/ptlsim/Makefile: -------------------------------------------------------------------------------- 1 | include ../../common.mk 2 | 3 | all: libptlsim.so 4 | 5 | libptlsim.so: ptlsim.o 6 | gcc $(CFLAGS) -pthread -shared -o libptlsim.so ptlsim.o -lc 7 | 8 | ptlsim.o: ptlsim.c 9 | gcc $(CFLAGS) -pthread -c ptlsim.c -I$(JDK)/include -I$(JDK)/include/linux/ 10 | 11 | clean: 12 | rm -rf *.o *.so 13 | 14 | test: default 15 | $(JAVA) -Djava.library.path=`pwd`/ptlsim -cp .:$(BENCHMARKS)/dacapo/dacapo-9.12-bach.jar Harness -c callback.DacapoBachCallback avrora 16 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/ptlsim/ptlsim.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* JNI Functions */ 5 | JNIEXPORT void JNICALL Java_probe_PTLsimProbe_begin 6 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 7 | jboolean iscopy; 8 | const char *bm = (*env)->GetStringUTFChars(env, benchmark, &iscopy); 9 | printf("We would call switch to sim now (benchmark: %s, iteration: %d, warmup %d)\n", bm, iteration, warmup); 10 | } 11 | JNIEXPORT void JNICALL Java_probe_PTLsimProbe_end 12 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 13 | jboolean iscopy; 14 | const char *bm = (*env)->GetStringUTFChars(env, benchmark, &iscopy); 15 | printf("We would call switch to native now (benchmark: %s, iteration: %d, warmup %d)\n", bm, iteration, warmup); 16 | } 17 | JNIEXPORT void JNICALL Java_probe_PTLsimProbe_report 18 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 19 | jboolean iscopy; 20 | const char *bm = (*env)->GetStringUTFChars(env, benchmark, &iscopy); 21 | printf("We could print results now (benchmark: %s, iteration: %d, warmup %d)\n", bm, iteration, warmup); 22 | } 23 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/valgrind/Makefile: -------------------------------------------------------------------------------- 1 | include ../../common.mk 2 | 3 | all: libvalgrind.so 4 | 5 | libvalgrind.so: valgrind.o 6 | gcc $(CFLAGS) -pthread -shared -o libvalgrind.so valgrind.o -lc 7 | 8 | valgrind.o: valgrind.c 9 | gcc $(CFLAGS) -pthread -c valgrind.c -I$(JDK)/include -I$(JDK)/include/linux/ 10 | 11 | clean: 12 | rm -rf *.o *.so 13 | 14 | test: default 15 | $(JAVA) -Djava.library.path=`pwd`/valgrind -cp .:$(BENCHMARKS)/dacapo/dacapo-9.12-bach.jar Harness -c callback.DacapoBachCallback avrora 16 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/valgrind/cachegrind.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ---------------------------------------------------------------- 4 | 5 | Notice that the following BSD-style license applies to this one 6 | file (callgrind.h) only. The rest of Valgrind is licensed under the 7 | terms of the GNU General Public License, version 2, unless 8 | otherwise indicated. See the COPYING file in the source 9 | distribution for details. 10 | 11 | ---------------------------------------------------------------- 12 | 13 | This file is part of callgrind, a valgrind tool for cache simulation 14 | and call tree tracing. 15 | 16 | Copyright (C) 2003-2009 Josef Weidendorfer. All rights reserved. 17 | 18 | Redistribution and use in source and binary forms, with or without 19 | modification, are permitted provided that the following conditions 20 | are met: 21 | 22 | 1. Redistributions of source code must retain the above copyright 23 | notice, this list of conditions and the following disclaimer. 24 | 25 | 2. The origin of this software must not be misrepresented; you must 26 | not claim that you wrote the original software. If you use this 27 | software in a product, an acknowledgment in the product 28 | documentation would be appreciated but is not required. 29 | 30 | 3. Altered source versions must be plainly marked as such, and must 31 | not be misrepresented as being the original software. 32 | 33 | 4. The name of the author may not be used to endorse or promote 34 | products derived from this software without specific prior written 35 | permission. 36 | 37 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 38 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 39 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 40 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 41 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 42 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 43 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 44 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 45 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 46 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 47 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | 49 | ---------------------------------------------------------------- 50 | 51 | Notice that the above BSD-style license applies to this one file 52 | (callgrind.h) only. The entire rest of Valgrind is licensed under 53 | the terms of the GNU General Public License, version 2. See the 54 | COPYING file in the source distribution for details. 55 | 56 | ---------------------------------------------------------------- 57 | */ 58 | 59 | #ifndef __CACHEGRIND_H 60 | #define __CACHEGRIND_H 61 | 62 | #include "valgrind.h" 63 | 64 | /* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! 65 | This enum comprises an ABI exported by Valgrind to programs 66 | which use client requests. DO NOT CHANGE THE ORDER OF THESE 67 | ENTRIES, NOR DELETE ANY -- add new ones at the end. 68 | */ 69 | 70 | typedef 71 | enum { 72 | VG_USERREQ__PROBE_BEGIN = VG_USERREQ_TOOL_BASE('C','G'), 73 | VG_USERREQ__PROBE_END, 74 | VG_USERREQ__PROBE_REPORT 75 | } Vg_CachegrindClientRequest; 76 | 77 | /* Start of a benchmark iteration via the probe API */ 78 | #define CACHEGRIND_PROBE_BEGIN(_qzz_itr,_qzz_warmup) \ 79 | {unsigned int _qzz_res; \ 80 | VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ 81 | VG_USERREQ__PROBE_BEGIN, \ 82 | _qzz_itr, _qzz_warmup, 0, 0, 0); \ 83 | } 84 | 85 | /* End of a benchmark iteration via the probe API */ 86 | #define CACHEGRIND_PROBE_END(_qzz_itr,_qzz_warmup) \ 87 | {unsigned int _qzz_res; \ 88 | VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ 89 | VG_USERREQ__PROBE_END, \ 90 | _qzz_itr, _qzz_warmup, 0, 0, 0); \ 91 | } 92 | 93 | /* End of a benchmark iteration via the probe API */ 94 | #define CACHEGRIND_PROBE_REPORT(_qzz_itr,_qzz_warmup) \ 95 | {unsigned int _qzz_res; \ 96 | VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ 97 | VG_USERREQ__PROBE_REPORT, \ 98 | _qzz_itr, _qzz_warmup, 0, 0, 0); \ 99 | } 100 | 101 | 102 | #endif /* __CACHEGRIND_H */ 103 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/valgrind/probes-valgrind-3.5.0.patch: -------------------------------------------------------------------------------- 1 | diff -uNr valgrind-3.5.0-clean/cachegrind/cachegrind.h valgrind-3.5.0/cachegrind/cachegrind.h 2 | --- valgrind-3.5.0-clean/cachegrind/cachegrind.h 1970-01-01 10:00:00.000000000 +1000 3 | +++ valgrind-3.5.0/cachegrind/cachegrind.h 2010-05-28 22:13:21.000000000 +1000 4 | @@ -0,0 +1,102 @@ 5 | + 6 | +/* 7 | + ---------------------------------------------------------------- 8 | + 9 | + Notice that the following BSD-style license applies to this one 10 | + file (callgrind.h) only. The rest of Valgrind is licensed under the 11 | + terms of the GNU General Public License, version 2, unless 12 | + otherwise indicated. See the COPYING file in the source 13 | + distribution for details. 14 | + 15 | + ---------------------------------------------------------------- 16 | + 17 | + This file is part of callgrind, a valgrind tool for cache simulation 18 | + and call tree tracing. 19 | + 20 | + Copyright (C) 2003-2009 Josef Weidendorfer. All rights reserved. 21 | + 22 | + Redistribution and use in source and binary forms, with or without 23 | + modification, are permitted provided that the following conditions 24 | + are met: 25 | + 26 | + 1. Redistributions of source code must retain the above copyright 27 | + notice, this list of conditions and the following disclaimer. 28 | + 29 | + 2. The origin of this software must not be misrepresented; you must 30 | + not claim that you wrote the original software. If you use this 31 | + software in a product, an acknowledgment in the product 32 | + documentation would be appreciated but is not required. 33 | + 34 | + 3. Altered source versions must be plainly marked as such, and must 35 | + not be misrepresented as being the original software. 36 | + 37 | + 4. The name of the author may not be used to endorse or promote 38 | + products derived from this software without specific prior written 39 | + permission. 40 | + 41 | + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 42 | + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 43 | + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 45 | + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 47 | + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 48 | + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 49 | + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 50 | + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 51 | + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 52 | + 53 | + ---------------------------------------------------------------- 54 | + 55 | + Notice that the above BSD-style license applies to this one file 56 | + (callgrind.h) only. The entire rest of Valgrind is licensed under 57 | + the terms of the GNU General Public License, version 2. See the 58 | + COPYING file in the source distribution for details. 59 | + 60 | + ---------------------------------------------------------------- 61 | +*/ 62 | + 63 | +#ifndef __CACHEGRIND_H 64 | +#define __CACHEGRIND_H 65 | + 66 | +#include "valgrind.h" 67 | + 68 | +/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! 69 | + This enum comprises an ABI exported by Valgrind to programs 70 | + which use client requests. DO NOT CHANGE THE ORDER OF THESE 71 | + ENTRIES, NOR DELETE ANY -- add new ones at the end. 72 | + */ 73 | + 74 | +typedef 75 | + enum { 76 | + VG_USERREQ__PROBE_BEGIN = VG_USERREQ_TOOL_BASE('C','G'), 77 | + VG_USERREQ__PROBE_END, 78 | + VG_USERREQ__PROBE_REPORT 79 | + } Vg_CachegrindClientRequest; 80 | + 81 | +/* Start of a benchmark iteration via the probe API */ 82 | +#define CACHEGRIND_PROBE_BEGIN(_qzz_itr,_qzz_warmup) \ 83 | + {unsigned int _qzz_res; \ 84 | + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ 85 | + VG_USERREQ__PROBE_BEGIN, \ 86 | + _qzz_itr, _qzz_warmup, 0, 0, 0); \ 87 | + } 88 | + 89 | +/* End of a benchmark iteration via the probe API */ 90 | +#define CACHEGRIND_PROBE_END(_qzz_itr,_qzz_warmup) \ 91 | + {unsigned int _qzz_res; \ 92 | + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ 93 | + VG_USERREQ__PROBE_END, \ 94 | + _qzz_itr, _qzz_warmup, 0, 0, 0); \ 95 | + } 96 | + 97 | +/* End of a benchmark iteration via the probe API */ 98 | +#define CACHEGRIND_PROBE_REPORT(_qzz_itr,_qzz_warmup) \ 99 | + {unsigned int _qzz_res; \ 100 | + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ 101 | + VG_USERREQ__PROBE_REPORT, \ 102 | + _qzz_itr, _qzz_warmup, 0, 0, 0); \ 103 | + } 104 | + 105 | + 106 | +#endif /* __CACHEGRIND_H */ 107 | diff -uNr valgrind-3.5.0-clean/cachegrind/cg_main.c valgrind-3.5.0/cachegrind/cg_main.c 108 | --- valgrind-3.5.0-clean/cachegrind/cg_main.c 2009-08-19 23:37:09.000000000 +1000 109 | +++ valgrind-3.5.0/cachegrind/cg_main.c 2010-05-28 22:23:28.000000000 +1000 110 | @@ -46,6 +46,7 @@ 111 | #include "pub_tool_clientstate.h" 112 | #include "pub_tool_machine.h" // VG_(fnptr_to_fnentry) 113 | 114 | +#include "cachegrind.h" 115 | #include "cg_arch.h" 116 | #include "cg_sim.c" 117 | #include "cg_branchpred.c" 118 | @@ -1723,6 +1724,75 @@ 119 | ); 120 | } 121 | 122 | + 123 | +/*------------------------------------------------------------*/ 124 | +/*--- Client requests ---*/ 125 | +/*------------------------------------------------------------*/ 126 | + 127 | +void probe_begin ( int iteration, Bool warmup ) 128 | +{ 129 | + VG_(printf) ("probe begin(%d %d)", iteration, warmup); 130 | +} 131 | + 132 | +void probe_end ( int iteration, Bool warmup ) 133 | +{ 134 | + VG_(printf) ("probe end(%d %d)", iteration, warmup); 135 | +} 136 | + 137 | +void probe_report ( int iteration, Bool warmup ) 138 | +{ 139 | + VG_(printf) ("probe report(%d %d)", iteration, warmup); 140 | +} 141 | + 142 | +static Bool cg_handle_client_request ( ThreadId tid, UWord* arg, UWord* ret ) 143 | +{ 144 | + 145 | + if (!VG_IS_TOOL_USERREQ('C','G',arg[0])) { 146 | + VG_(message)( 147 | + Vg_UserMsg, 148 | + Vg_UserMsg, 149 | + "Warning: non match %llx\n", 150 | + (ULong)arg[0] 151 | + ); 152 | + return False; 153 | + } 154 | + 155 | + switch (arg[0]) { 156 | + 157 | + case VG_USERREQ__PROBE_BEGIN: 158 | + { 159 | + probe_begin ( (int) arg[1], (int) arg[2] ); 160 | + *ret = -1; 161 | + break; 162 | + } 163 | + 164 | + case VG_USERREQ__PROBE_END: 165 | + { 166 | + probe_end ( (int) arg[1], (int) arg[2] ); 167 | + *ret = -1; 168 | + break; 169 | + } 170 | + 171 | + case VG_USERREQ__PROBE_REPORT: 172 | + { 173 | + probe_report ( (int) arg[1], (int) arg[2] ); 174 | + *ret = -1; 175 | + break; 176 | + } 177 | + 178 | + default: 179 | + VG_(message)( 180 | + Vg_UserMsg, 181 | + Vg_UserMsg, 182 | + "Warning: unknown cachegrind client request code %llx\n", 183 | + (ULong)arg[0] 184 | + ); 185 | + return False; 186 | + } 187 | + return True; 188 | +} 189 | + 190 | + 191 | /*--------------------------------------------------------------------*/ 192 | /*--- Setup ---*/ 193 | /*--------------------------------------------------------------------*/ 194 | @@ -1747,6 +1817,7 @@ 195 | VG_(needs_command_line_options)(cg_process_cmd_line_option, 196 | cg_print_usage, 197 | cg_print_debug_usage); 198 | + VG_(needs_client_requests) (cg_handle_client_request); 199 | } 200 | 201 | static void cg_post_clo_init(void) 202 | -------------------------------------------------------------------------------- /JikesRVMProbes/native/valgrind/valgrind.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "cachegrind.h" 4 | 5 | /* JNI Functions */ 6 | JNIEXPORT void JNICALL Java_probe_ValgrindProbe_begin 7 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 8 | jboolean iscopy; 9 | const char *bm = (*env)->GetStringUTFChars(env, benchmark, &iscopy); 10 | printf("ValgrindProbe_begin(benchmark = %s, iteration = %d, warmup = %d)\n", bm, iteration, warmup); 11 | CACHEGRIND_PROBE_BEGIN(iteration, warmup); 12 | } 13 | JNIEXPORT void JNICALL Java_probe_ValgrindProbe_end 14 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 15 | jboolean iscopy; 16 | const char *bm = (*env)->GetStringUTFChars(env, benchmark, &iscopy); 17 | printf("ValgrindProbe_end(benchmark = %s, iteration = %d, warmup = %d)\n", bm, iteration, warmup); 18 | CACHEGRIND_PROBE_END(iteration, warmup); 19 | } 20 | JNIEXPORT void JNICALL Java_probe_ValgrindProbe_report 21 | (JNIEnv *env, jobject o, jstring benchmark, jint iteration, jboolean warmup) { 22 | jboolean iscopy; 23 | const char *bm = (*env)->GetStringUTFChars(env, benchmark, &iscopy); 24 | printf("ValgrindProbe_report(benchmark = %s, iteration = %d, warmup = %d)\n", bm, iteration, warmup); 25 | CACHEGRIND_PROBE_REPORT(iteration, warmup); 26 | } 27 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/ApplicationPerfEventProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | public class ApplicationPerfEventProbe extends PerfEventProbe { 4 | 5 | private boolean reinitialized = false; 6 | 7 | public void begin(String benchmark, int iteration, boolean warmup) { 8 | if (!reinitialized) { 9 | /* We restart/reinitialize the counters here so they only deal with application threads */ 10 | super.reinitialize(); 11 | reinitialized = true; 12 | } 13 | super.begin(benchmark, iteration, warmup); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/CompilerSamplesProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import java.lang.reflect.*; 4 | 5 | public class CompilerSamplesProbe implements Probe { 6 | private Method startMethod; 7 | private Method endMethod; 8 | 9 | public void init() { 10 | try { 11 | Class harnessClass = Class.forName("org.jikesrvm.adaptive.controller.Controller"); 12 | startMethod = harnessClass.getMethod("startCompilationSamples"); 13 | endMethod = harnessClass.getMethod("endCompilationSamples"); 14 | } catch (Exception e) { 15 | throw new RuntimeException("Unable to find callback methods", e); 16 | } 17 | } 18 | 19 | public void cleanup() { 20 | // Nothing to do 21 | } 22 | 23 | public void begin(String benchmark, int iteration, boolean warmup) { 24 | try { 25 | startMethod.invoke(null); 26 | } catch (Exception e) { 27 | throw new RuntimeException("Error running update compilation sample method", e); 28 | } 29 | } 30 | 31 | public void end(String benchmark, int iteration, boolean warmup) { 32 | try { 33 | endMethod.invoke(null); 34 | } catch (Exception e) { 35 | throw new RuntimeException("Error running update or dump methods", e); 36 | } 37 | } 38 | 39 | public void report(String benchmark, int iteration, boolean warmup) { 40 | // Done within end. 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/Dacapo2006Callback.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | import dacapo.Callback; 3 | 4 | public class Dacapo2006Callback extends Callback { 5 | public Dacapo2006Callback() { 6 | super(); 7 | ProbeMux.init(); 8 | } 9 | 10 | public void startWarmup(String benchmark) { 11 | ProbeMux.begin(benchmark, true); 12 | super.startWarmup(benchmark); 13 | }; 14 | 15 | public void stopWarmup() { 16 | super.stopWarmup(); 17 | ProbeMux.end(true); 18 | } 19 | public void start(String benchmark) { 20 | ProbeMux.begin(benchmark, false); 21 | super.start(benchmark); 22 | }; 23 | 24 | public void stop() { 25 | super.stop(); 26 | ProbeMux.end(false); 27 | ProbeMux.cleanup(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/DacapoBachCallback.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import org.dacapo.harness.Callback; 4 | import org.dacapo.harness.CommandLineArgs; 5 | 6 | public class DacapoBachCallback extends Callback { 7 | public DacapoBachCallback(CommandLineArgs cla) { 8 | super(cla); 9 | ProbeMux.init(); 10 | } 11 | 12 | public void start(String benchmark) { 13 | ProbeMux.begin(benchmark, isWarmup()); 14 | super.start(benchmark); 15 | }; 16 | 17 | /* Immediately after the end of the benchmark */ 18 | public void stop() { 19 | super.stop(); 20 | ProbeMux.end(isWarmup()); 21 | if (!isWarmup()) { 22 | ProbeMux.cleanup(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/HelloWorldNativeProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | public class HelloWorldNativeProbe implements Probe { 4 | static { 5 | System.loadLibrary("hello_world"); 6 | } 7 | 8 | public void init() { 9 | // Nothing to do 10 | } 11 | 12 | public void cleanup() { 13 | // Nothing to do 14 | } 15 | 16 | public native void begin(String benchmark, int iteration, boolean warmup); 17 | public native void end(String benchmark, int iteration, boolean warmup); 18 | public native void report(String benchmark, int iteration, boolean warmup); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/HelloWorldProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | public class HelloWorldProbe implements Probe { 4 | public void init() { 5 | System.err.println("HelloWorldProbe.init()"); 6 | } 7 | public void cleanup() { 8 | System.err.println("HelloWorldProbe.cleanup()"); 9 | } 10 | 11 | public void begin(String benchmark, int iteration, boolean warmup) { 12 | System.err.println("HelloWorldProbe.begin(benchmark = " + benchmark + ", iteration = " + iteration + ", warmup = " + warmup + ")"); 13 | } 14 | 15 | public void end(String benchmark, int iteration, boolean warmup) { 16 | System.err.println("HelloWorldProbe.end(benchmark = " + benchmark + ", iteration = " + iteration + ", warmup = " + warmup + ")"); 17 | } 18 | 19 | public void report(String benchmark, int iteration, boolean warmup) { 20 | System.err.println("HelloWorldProbe.report(benchmark = " + benchmark + ", iteration = " + iteration + ", warmup = " + warmup + ")"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/HooverProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import java.lang.reflect.*; 4 | 5 | public class HooverProbe implements Probe { 6 | private Method beginMethod; 7 | private Method endMethod; 8 | 9 | public void init() { 10 | try { 11 | Class harnessClass = Class.forName("org.mmtk.utility.PTGProfiler"); 12 | beginMethod = harnessClass.getMethod("harnessBegin"); 13 | endMethod = harnessClass.getMethod("harnessEnd"); 14 | } catch (Exception e) { 15 | throw new RuntimeException("Unable to find MMTk org.mmtk.utility.PTGProfiler.harnessBegin and/or org.mmtk.utility.PTGProfiler.harnessBegin", e); 16 | } 17 | } 18 | public void cleanup() {} 19 | 20 | public void begin(String benchmark, int iteration, boolean warmup) { 21 | if (warmup) return; 22 | try { 23 | beginMethod.invoke(null); 24 | } catch (Exception e) { 25 | throw new RuntimeException("Error running PTGProfiler.harnessBegin", e); 26 | } 27 | } 28 | 29 | public void end(String benchmark, int iteration, boolean warmup) { 30 | if (warmup) return; 31 | try { 32 | endMethod.invoke(null); 33 | } catch (Exception e) { 34 | throw new RuntimeException("Error running PTGProfiler.harnessEnd", e); 35 | } 36 | } 37 | 38 | public void report(String benchmark, int iteration, boolean warmup) {} 39 | } -------------------------------------------------------------------------------- /JikesRVMProbes/probe/JikesRVMPerfEventProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import java.lang.reflect.*; 4 | 5 | public class JikesRVMPerfEventProbe implements Probe { 6 | private Method beginMethod; 7 | private Method endMethod; 8 | 9 | public void init() { 10 | try { 11 | Class harnessClass = Class.forName("org.jikesrvm.scheduler.RVMThread"); 12 | beginMethod = harnessClass.getMethod("perfEventEnable"); 13 | endMethod = harnessClass.getMethod("perfEventDisable"); 14 | } catch (Exception e) { 15 | throw new RuntimeException("Unable to find RVMThread.perfEventEnable or RVMThread.perfEventDisable", e); 16 | } 17 | } 18 | 19 | public void cleanup() { 20 | // Nothing to do 21 | } 22 | 23 | public void begin(String benchmark, int iteration, boolean warmup) { 24 | if (warmup) return; 25 | try { 26 | beginMethod.invoke(null); 27 | } catch (Exception e) { 28 | throw new RuntimeException("Error running RVMThread.perfEventEnable", e); 29 | } 30 | } 31 | 32 | public void end(String benchmark, int iteration, boolean warmup) { 33 | if (warmup) return; 34 | try { 35 | endMethod.invoke(null); 36 | } catch (Exception e) { 37 | throw new RuntimeException("Error running RVMThread.perfEventDisable", e); 38 | } 39 | } 40 | 41 | public void report(String benchmark, int iteration, boolean warmup) { 42 | // Done within end. 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/MMTkProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import org.mmtk.utility.options.Options; 4 | import org.mmtk.vm.VM; 5 | 6 | import java.lang.reflect.*; 7 | 8 | public class MMTkProbe implements Probe { 9 | private Method beginMethod; 10 | private Method endMethod; 11 | 12 | public void init() { 13 | try { 14 | Class harnessClass = Class.forName("org.mmtk.plan.Plan"); 15 | beginMethod = harnessClass.getMethod("harnessBegin"); 16 | endMethod = harnessClass.getMethod("harnessEnd"); 17 | } catch (Exception e) { 18 | throw new RuntimeException("Unable to find MMTk Plan.harnessBegin and/or Plan.harnessEnd", e); 19 | } 20 | } 21 | 22 | public void cleanup() { 23 | // Nothing to do 24 | } 25 | 26 | public void begin(String benchmark, int iteration, boolean warmup) { 27 | if (warmup) return; 28 | try { 29 | beginMethod.invoke(null); 30 | } catch (Exception e) { 31 | throw new RuntimeException("Error running MMTk Plan.harnessBegin", e); 32 | } 33 | } 34 | 35 | public void end(String benchmark, int iteration, boolean warmup) { 36 | if (iteration == 1) 37 | VM.statistics.perfEventInit(Options.perfEvents.getValue()); 38 | 39 | if (warmup) return; 40 | try { 41 | endMethod.invoke(null); 42 | } catch (Exception e) { 43 | throw new RuntimeException("Error running MMTk Plan.harnessEnd", e); 44 | } 45 | } 46 | 47 | public void report(String benchmark, int iteration, boolean warmup) { 48 | // Done within end. 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/MomaProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import moma.MomaCmd; 4 | import moma.MomaThread; 5 | import org.jikesrvm.Options; 6 | import org.jikesrvm.VM; 7 | import org.jikesrvm.runtime.Magic; 8 | import org.jikesrvm.scheduler.RVMThread; 9 | 10 | import static org.jikesrvm.runtime.SysCall.sysCall; 11 | import static moma.MomaCmd.ProfilingApproach.*; 12 | import static moma.MomaCmd.ProfilingPosition.*; 13 | 14 | public class MomaProbe implements Probe { 15 | public static final int StartIteration = 3; 16 | //Create SHIM thread for each core 17 | public static final int maxCoreNumber = 4; 18 | //each core has one corresponding shim working thread 19 | public static MomaThread[] shims; 20 | public static MomaCmd[] cmds; 21 | public static MomaThread profiler; 22 | public static int samplingRate = 1; 23 | //which CPU JikesRVM process are bind on 24 | public static int runningCPU = 4; 25 | 26 | 27 | 28 | 29 | public void init(){ 30 | cmds = MomaCmd.parseShimCommand(); 31 | long cpumask = sysCall.sysCall.sysGetThreadBindSet(Magic.getThreadRegister().pthread_id); 32 | for (int i=0; i<64; i++) { 33 | if ((cpumask & (1 << i)) != 0) { 34 | runningCPU = i; 35 | break; 36 | } 37 | } 38 | shims = new MomaThread[maxCoreNumber]; 39 | for (int i = 0; i < maxCoreNumber; i++) { 40 | int targetCPU = i + maxCoreNumber; 41 | if (cmds[0].shimWhere == REMOTECORE) 42 | targetCPU = maxCoreNumber * 2 - i; 43 | 44 | shims[i] = new MomaThread(i, i, targetCPU); 45 | shims[i].setName("shim" + i); 46 | shims[i].start(); 47 | if (targetCPU == runningCPU) 48 | profiler = shims[i]; 49 | } 50 | System.out.println("Benchmark is running at CPU " + runningCPU + " target SHIM thread is " + profiler.toString()); 51 | } 52 | 53 | private void waitForShims(){ 54 | try { 55 | for (MomaThread t : shims) { 56 | //suspend the shim thread if it is running. 57 | if (t.state == t.MOMA_RUNNING) { 58 | t.suspendMoma(); 59 | while (t.state == t.MOMA_RUNNING) 60 | ; 61 | t.resetControlFlag(); 62 | } 63 | } 64 | }catch (Exception e){ 65 | System.out.println("Exception is happened while asking shim threads to stop e:" + e); 66 | } 67 | } 68 | 69 | public void cleanup() { 70 | System.err.println("MomaProbe.cleanup()"); 71 | } 72 | 73 | public void begin(String benchmark, int iteration, boolean warmup) { 74 | System.out.println("MomaProbe.begin(benchmark = " + benchmark + ", iteration = " + iteration + ", warmup = " + warmup + ")"); 75 | if (iteration < StartIteration) 76 | return; 77 | 78 | int cmdindex = (iteration - StartIteration)%cmds.length; 79 | System.out.println("Using " + cmdindex + "th command"); 80 | profiler.curCmd = cmds[cmdindex]; 81 | 82 | synchronized (profiler) { 83 | profiler.notifyAll(); 84 | } 85 | } 86 | 87 | public void end(String benchmark, int iteration, boolean warmup) { 88 | System.out.println("MomaProbe.end(benchmark = " + benchmark + ", iteration = " + iteration + ", warmup = " + warmup + ")"); 89 | if (iteration < StartIteration) 90 | return; 91 | waitForShims(); 92 | } 93 | 94 | public void report(String benchmark, int iteration, boolean warmup) { 95 | System.out.println("MomaProbe.report(benchmark = " + benchmark + ", iteration = " + iteration + ", warmup = " + warmup + ")"); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/PJBB2005Callback.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import harness.Callback; 4 | 5 | public class PJBB2005Callback extends Callback { 6 | 7 | public PJBB2005Callback() { 8 | super(); 9 | ProbeMux.init(); 10 | } 11 | 12 | public void begin(int iteration, boolean warmup) { 13 | ProbeMux.begin("pjbb2005", warmup); 14 | super.begin(iteration, warmup); 15 | }; 16 | 17 | public void end(int iteration, boolean warmup) { 18 | super.end(iteration, warmup); 19 | ProbeMux.end(warmup); 20 | if (!warmup) ProbeMux.cleanup(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/PTLsimProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | public class PTLsimProbe implements Probe { 4 | static { 5 | System.loadLibrary("ptlsim"); 6 | } 7 | 8 | public void init() { 9 | // Nothing to do 10 | } 11 | 12 | public void cleanup() { 13 | // Nothing to do 14 | } 15 | 16 | public native void begin(String benchmark, int iteration, boolean warmup); 17 | public native void end(String benchmark, int iteration, boolean warmup); 18 | public native void report(String benchmark, int iteration, boolean warmup); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/PerfEventLauncherProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | 4 | //PERF_EVENT_NAMES is set to EVENT1,fd0,fd1,...fdn;EVENT2,fd0,fd1,.... 5 | 6 | public class PerfEventLauncherProbe implements Probe { 7 | 8 | private static String[] eventNames; 9 | private static int[][] eventFds; 10 | 11 | private static native void enable(int fd); 12 | private static native void disable(int fd); 13 | private static native void reset(int fd); 14 | private static native void read(int fd, long[] result); 15 | 16 | static { 17 | System.loadLibrary("perf_event_launcher"); 18 | } 19 | 20 | public void init() 21 | { 22 | System.out.println("PERF_EVENT_NAMES is " + System.getenv("PERF_EVENT_NAMES")); 23 | 24 | String[] events = System.getenv("PERF_EVENT_NAMES").split(";"); 25 | System.out.println(events.length); 26 | eventNames = new String[events.length]; 27 | eventFds = new int[events.length][]; 28 | for (int i=0; i< events.length; i++){ 29 | String[] str = events[i].split(","); 30 | eventNames[i] = str[0]; 31 | eventFds[i] = new int[str.length-1]; 32 | for (int j=1;j=0){ 63 | val[i] = read(fids[i]); 64 | } else { 65 | if (fids[i] == -3) 66 | val[i] = raplPackage(); 67 | else if (fids[i] == -4) 68 | val[i] = raplCore(); 69 | else if (fids[i] == -5) 70 | val[i] = raplUncore(); 71 | else if (fids[i] == -6) 72 | val[i] = raplDram(); 73 | else 74 | System.out.println("fd should not be this val " + val[i]); 75 | } 76 | } 77 | } 78 | 79 | public void update(){ 80 | read(this.values); 81 | } 82 | 83 | public void report(){ 84 | System.out.println("=======events begin ======="); 85 | for (int i = 0; i< fids.length; i++){ 86 | System.out.print(names[i] + ":" + values[i] + " "); 87 | } 88 | System.out.println(""); 89 | System.out.println("=======events end======="); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/PowerProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | import java.io.*; 3 | 4 | public class PowerProbe implements Probe { 5 | private static String powerDevice = System.getProperty("probe.power.device", "/dev/ttyACM0"); 6 | private static double powerMultiplier = Double.parseDouble(System.getProperty("probe.power.multiplier", "-28.45")); 7 | private static double powerIntercept = Double.parseDouble(System.getProperty("probe.power.intercept", "14591.1")); 8 | private Process child; 9 | private BufferedReader in; 10 | private StringBuilder current; 11 | 12 | public void init() { 13 | try { 14 | child = Runtime.getRuntime().exec("cat " + powerDevice); 15 | BufferedReader err = new BufferedReader(new InputStreamReader(child.getErrorStream(), "UTF-8")); 16 | in = new BufferedReader(new InputStreamReader(child.getInputStream(), "UTF-8")); 17 | if (in.readLine() == null) { 18 | String errorString = ""; 19 | while (err.ready()) errorString += err.readLine(); 20 | int result = child.waitFor(); 21 | throw new RuntimeException("Child process died: " + errorString); 22 | } 23 | } catch (Exception e) { 24 | throw new RuntimeException("Error opening power device '" + powerDevice + "', try setting with -Dprobe.power.device=X", e); 25 | } 26 | } 27 | 28 | public void cleanup() { 29 | try { 30 | in.close(); 31 | child.destroy(); 32 | } catch (IOException e) { 33 | throw new RuntimeException("Error closing power device", e); 34 | } 35 | } 36 | 37 | public void begin(String benchmark, int iteration, boolean warmup) { 38 | try { 39 | // Flush all data 40 | while(in.ready()) in.readLine(); 41 | } catch (IOException e) { 42 | throw new RuntimeException("Error reading power device", e); 43 | } 44 | }; 45 | 46 | public void end(String benchmark, int iteration, boolean warmup) { 47 | current = new StringBuilder(); 48 | try { 49 | while(in.ready()) current.append(" " + in.readLine()); 50 | } catch (IOException e) { 51 | throw new RuntimeException("Error reading power device", e); 52 | } 53 | } 54 | 55 | public void report(String benchmark, int iteration, boolean warmup) { 56 | String[] values = current.toString().split("[^0-9]+"); 57 | long x = 0; 58 | int n = 0; 59 | for(String v: values) { 60 | if (!v.equals("")) { 61 | x += Integer.parseInt(v); 62 | n++; 63 | } 64 | } 65 | double avg = (double)x / (double)n; 66 | double watts = (powerMultiplier * avg + powerIntercept) * 12 / 1000; 67 | System.err.println("============================ Tabulate Statistics ============================"); 68 | System.err.println("power.n power.sum power.avg power.watts"); 69 | System.err.println(n + " " + x + " " + avg + " " + watts); 70 | System.err.println("============================================================================="); 71 | current = null; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/Probe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | public interface Probe { 4 | public void init(); 5 | public void begin(String benchmark, int iteration, boolean warmup); 6 | public void end(String benchmark, int iteration, boolean warmup); 7 | public void report(String benchmark, int iteration, boolean warmup); 8 | public void cleanup(); 9 | } 10 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/ProbeMux.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | 6 | public class ProbeMux { 7 | private static Probe[] probes; 8 | private static int iteration; 9 | private static String benchmark; 10 | 11 | public static void init() { 12 | String probesProperty = System.getProperty("probes"); 13 | if (probesProperty == null) { 14 | System.err.println("WARNING: No probes configured, pass -Dprobes=Probe1,Probe2,..."); 15 | probes = new Probe[0]; 16 | return; 17 | } 18 | String[] probeNames = probesProperty.split(","); 19 | probes = new Probe[probeNames.length]; 20 | int i = 0; 21 | for(String probeName: probeNames) { 22 | Class probeClass; 23 | String probeClassName = "probe." + probeName + "Probe"; 24 | try { 25 | probeClass = Class.forName(probeClassName).asSubclass(Probe.class); 26 | } catch (ClassNotFoundException cnfe) { 27 | throw new RuntimeException("Could not find probe class '" + probeClassName + "'", cnfe); 28 | } 29 | try { 30 | probes[i++] = probeClass.newInstance(); 31 | } catch (Exception e) { 32 | throw new RuntimeException("Could not instantiate probe class '" + probeClassName + "'", e); 33 | } 34 | } 35 | for(i=0; i < probes.length; i++) { 36 | probes[i].init(); 37 | } 38 | } 39 | 40 | public static void begin(String bm, boolean warmup) { 41 | benchmark = bm; 42 | iteration++; 43 | for(int i=0; i < probes.length; i++) { 44 | probes[i].begin(benchmark, iteration, warmup); 45 | } 46 | } 47 | 48 | public static void end(boolean warmup) { 49 | for(int i=probes.length-1; i>=0 ;i--) { 50 | probes[i].end(benchmark, iteration, warmup); 51 | } 52 | for(int i=probes.length-1; i>=0 ;i--) { 53 | probes[i].report(benchmark, iteration, warmup); 54 | } 55 | } 56 | 57 | public static void cleanup() { 58 | for(int i=0; i < probes.length; i++) { 59 | probes[i].cleanup(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/ReplayProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import org.jikesrvm.compilers.common.CompiledMethods; 4 | 5 | import java.lang.reflect.*; 6 | 7 | public class ReplayProbe implements Probe { 8 | private Method compileAll; 9 | private static final String PRECOMPILE_CLASS = "org.jikesrvm.adaptive.recompilation.BulkCompile"; 10 | private static final String PRECOMPILE_METHOD = "compileAllMethods"; 11 | 12 | public void init() { 13 | try { 14 | Class preCompile = Class.forName(PRECOMPILE_CLASS); 15 | compileAll = preCompile.getMethod(PRECOMPILE_METHOD); 16 | } catch (Exception e) { 17 | throw new RuntimeException("Unable to find "+PRECOMPILE_CLASS+"."+PRECOMPILE_METHOD+"()", e); 18 | } 19 | } 20 | public void cleanup() {} 21 | 22 | public void begin(String benchmark, int iteration, boolean warmup) { 23 | } 24 | 25 | public void end(String benchmark, int iteration, boolean warmup) { 26 | if (iteration != 1) return; 27 | try { 28 | System.out.println("Replay probe end(), iteration "+iteration+" about to recompile..."); 29 | compileAll.invoke(null); 30 | } catch (Exception e) { 31 | throw new RuntimeException("Error running ReplayProbe.end()", e); 32 | } 33 | System.out.println("Max current CMID " + CompiledMethods.currentCompiledMethodId + " yp:" + CompiledMethods.maxYieldPoint); 34 | } 35 | 36 | public void report(String benchmark, int iteration, boolean warmup) {} 37 | } -------------------------------------------------------------------------------- /JikesRVMProbes/probe/ScenarioProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | public class ScenarioProbe implements Probe { 4 | public void init() {} 5 | public void cleanup() {} 6 | 7 | public void begin(String benchmark, int iteration, boolean warmup) { 8 | System.err.print("====> Scenario iteration=");System.err.println(iteration); 9 | } 10 | 11 | public void end(String benchmark, int iteration, boolean warmup) {} 12 | public void report(String benchmark, int iteration, boolean warmup) {} 13 | } 14 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/ShellProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | /* 4 | * 5 | */ 6 | import moma.MomaCallBack; 7 | import org.jikesrvm.classloader.RVMMethod; 8 | import org.jikesrvm.compilers.common.CompiledMethod; 9 | import org.jikesrvm.compilers.common.CompiledMethods; 10 | 11 | import java.io.BufferedReader; 12 | import java.io.IOException; 13 | import java.io.InputStreamReader; 14 | 15 | public class ShellProbe implements Probe { 16 | public void init() { 17 | System.err.println("ShellProbe.init()"); 18 | } 19 | public void cleanup() { 20 | System.err.println("ShellProbe.cleanup()"); 21 | } 22 | 23 | public void begin(String benchmark, int iteration, boolean warmup) { 24 | System.err.println("ShellProbe.begin(benchmark = " + benchmark + ", iteration = " + iteration + ", warmup = " + warmup + ")"); 25 | } 26 | 27 | public void end(String benchmark, int iteration, boolean warmup) { 28 | System.err.println("Shell.end(benchmark = " + benchmark + ", iteration = " + iteration + ", warmup = " + warmup + ")"); 29 | if (warmup) 30 | return; 31 | 32 | //now we want to receive command from standinput, and execute that java file with command. 33 | //read command line like "pprint hello world". pprint is the name of class, hello world are two parameters 34 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 35 | while (true){ 36 | 37 | String cmd = null; 38 | try { 39 | cmd = br.readLine(); 40 | }catch (IOException ioe) { 41 | System.out.println("IO error while reading cmd from stdin"); 42 | System.exit(1); 43 | } 44 | System.out.println("Shell: receive command " + cmd); 45 | 46 | String[] cmds = cmd.split(":"); 47 | int cmid = 0; 48 | 49 | try { 50 | cmid = Integer.parseInt(cmds[0]); 51 | CompiledMethod cm = CompiledMethods.getCompiledMethodUnchecked(cmid); 52 | RVMMethod m = CompiledMethods.getCompiledMethodUnchecked(cmid).getMethod(); 53 | System.out.println(m.getName() + ":" + m.getDeclaringClass() + ":" + m.getSignature() + ":" + m.getDescriptor()+ ":" + cm.getEntryCodeArray().length()); 54 | continue; 55 | }catch (Exception e){ 56 | System.out.println("not a number " + cmds[0]); 57 | } 58 | 59 | Class momaClass; 60 | String probeClassName = "moma." + cmds[0]; 61 | try { 62 | momaClass = Class.forName(probeClassName).asSubclass(MomaCallBack.class); 63 | } catch (ClassNotFoundException cnfe) { 64 | throw new RuntimeException("Could not find probe class '" + probeClassName + "'", cnfe); 65 | } 66 | 67 | MomaCallBack cb; 68 | try { 69 | cb = momaClass.newInstance(); 70 | } catch (Exception e) { 71 | throw new RuntimeException("Could not instantiate probe class '" + probeClassName + "'", e); 72 | } 73 | cb.invoke(cmds[1]); 74 | } 75 | } 76 | 77 | public void report(String benchmark, int iteration, boolean warmup) { 78 | System.err.println("HelloWorldProbe.report(benchmark = " + benchmark + ", iteration = " + iteration + ", warmup = " + warmup + ")"); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/StopJITProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | public class StopJITProbe implements Probe { 4 | private static int stoppingIteration = Integer.parseInt(System.getProperty("probe.stopjit.iteration", "2")); 5 | private static int sleepSeconds = Integer.parseInt(System.getProperty("probe.stopjit.sleeptime", "0")); 6 | 7 | public void init() {} 8 | public void cleanup() {} 9 | public void begin(String benchmark, int iteration, boolean warmup) {} 10 | public void end(String benchmark, int iteration, boolean warmup) { 11 | if (iteration == stoppingIteration) { 12 | System.out.println("========== JIT DISABLED (via java.lang.Compiler.disable()"+((sleepSeconds > 0) ? ", sleeping for " + sleepSeconds + " seconds" : "") +") =========="); 13 | java.lang.Compiler.disable(); 14 | try { 15 | Thread.currentThread().sleep(1000*sleepSeconds); 16 | } catch (java.lang.InterruptedException ie) {} 17 | } 18 | } 19 | public void report(String benchmark, int iteration, boolean warmup) {} 20 | } 21 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/ThreadEventProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | import java.lang.reflect.*; 4 | 5 | public class ThreadEventProbe implements Probe { 6 | private Method beginMethod; 7 | private Method endMethod; 8 | 9 | public void init() { 10 | try { 11 | Class harnessClass = Class.forName("org.jikesrvm.scheduler.RVMThread"); 12 | beginMethod = harnessClass.getMethod("perfEventStart"); 13 | endMethod = harnessClass.getMethod("perfEventStop"); 14 | } catch (Exception e) { 15 | throw new RuntimeException("Unable to find RVMThread.perfEventStart and/or perfEventStop", e); 16 | } 17 | } 18 | 19 | public void cleanup() { 20 | // Nothing to do 21 | } 22 | 23 | public void begin(String benchmark, int iteration, boolean warmup) { 24 | if (warmup) return; 25 | try { 26 | beginMethod.invoke(null); 27 | } catch (Exception e) { 28 | throw new RuntimeException("Error running perfEventStart", e); 29 | } 30 | } 31 | 32 | public void end(String benchmark, int iteration, boolean warmup) { 33 | if (warmup) return; 34 | try { 35 | endMethod.invoke(null); 36 | } catch (Exception e) { 37 | throw new RuntimeException("Error running perfEventStop", e); 38 | } 39 | } 40 | 41 | public void report(String benchmark, int iteration, boolean warmup) { 42 | // Done within end. 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /JikesRVMProbes/probe/ValgrindProbe.java: -------------------------------------------------------------------------------- 1 | package probe; 2 | 3 | public class ValgrindProbe implements Probe { 4 | static { 5 | System.loadLibrary("valgrind"); 6 | } 7 | 8 | public void init() { 9 | // Nothing to do 10 | } 11 | 12 | public void cleanup() { 13 | // Nothing to do 14 | } 15 | 16 | public native void begin(String benchmark, int iteration, boolean warmup); 17 | public native void end(String benchmark, int iteration, boolean warmup); 18 | public native void report(String benchmark, int iteration, boolean warmup); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /JikesRVMProbes/remotebuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #usage ./remotebuild.sh rat.moma /home/yangxi/probes "make OPTIONS=-m32" 3 | #sync the directory 4 | echo "syncing direcoty from `pwd` to $1" 5 | echo "rsync -avz ./ $1:$2" 6 | rsync -avz ./ $1:$2 7 | echo "exec $2 in the remote directory $1" 8 | echo "ssh $1 bash -c \"cd $2; $3\"" 9 | ssh $1 bash -c "'cd $2; $3'" 10 | 11 | -------------------------------------------------------------------------------- /JikesRVMProbes/spec/harness/RunProgram.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)RunProgram.java 1.7 06/17/98 3 | * 4 | * Copyright (c) 1998 Standard Performance Evaluation Corporation (SPEC) 5 | * All rights reserved. 6 | * Copyright (c) 1997,1998 Sun Microsystems, Inc. All rights reserved. 7 | * 8 | * This source code is provided as is, without any express or implied warranty. 9 | */ 10 | 11 | package spec.harness; 12 | import java.util.Properties; 13 | 14 | public class RunProgram{ 15 | 16 | public static ProgramRunner runner; 17 | 18 | public static void done(){ 19 | runner = null; 20 | } 21 | 22 | public static void run (String className, boolean autoRun, int probeRun, Properties props, 23 | BenchmarkDone parent) 24 | { 25 | if (runner != null){ 26 | Context.out.println ("Cannot start " + className + 27 | " because " + runner.className + " is running"); 28 | return; 29 | } 30 | char defaultValidityValue = '0'; 31 | String validityString = (String) props.get( "spec.validity."+className ); 32 | if (validityString != null) { 33 | defaultValidityValue = validityString.charAt(0); 34 | } 35 | int automin = getIntProp (props, "spec.initial.automin", 1); 36 | int automax = getIntProp (props, "spec.initial.automax", 20); 37 | int autodelay = getIntProp (props, "spec.initial.autodelay", 0); 38 | int autodelaymax = getIntProp (props, "spec.initial.autodelaymax", 39 | Integer.MAX_VALUE); 40 | if (autodelay > autodelaymax) 41 | autodelay = autodelaymax; 42 | boolean autogc = getBoolProp (props, "spec.initial.autogc", true); 43 | int pct = getIntProp (props, "spec.initial.percentTimes100",-99); 44 | boolean doChecksum = getBoolProp (props, 45 | "spec.validity.checksum."+className, true); 46 | runner = new ProgramRunner ( 47 | className, 48 | new String[0], 49 | autoRun, 50 | probeRun, 51 | parent, 52 | defaultValidityValue, 53 | pct, 54 | automin, 55 | automax, 56 | autodelay, 57 | autogc, 58 | doChecksum 59 | ); 60 | if (Context.getCommandLineMode()) 61 | runner.run(); // only one thread for run from command line 62 | else 63 | runner.start(); // multi-threaded from harness 64 | } 65 | 66 | public static void stop(){ 67 | if (runner == null){ 68 | Context.out.println ("Cannot stop. No benchmark is running."); 69 | return; 70 | } 71 | runner.stopBenchmark(); 72 | Context.out.println(" manually stopped"); 73 | done(); 74 | } 75 | 76 | private static boolean getBoolProp (Properties props, String key, boolean value){ 77 | if (props != null){ 78 | String s = (String) props.get (key); 79 | if (s != null){ 80 | if (s.equalsIgnoreCase("true")) 81 | return true; 82 | if (s.equalsIgnoreCase("false")) 83 | return false; 84 | } 85 | } 86 | return value; 87 | } 88 | 89 | private static int getIntProp (Properties props, String key, int value){ 90 | if (props != null){ 91 | String s = (String) props.get (key); 92 | if (s != null) 93 | try{ 94 | value = Integer.parseInt (s); 95 | }catch (NumberFormatException e){} // keep default value 96 | } 97 | return value; 98 | } 99 | 100 | }//end class 101 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all:JikesProbes 2 | 3 | JikesProbes: 4 | cd ./JikesRVMProbes; make OPTION=-m32 5 | 6 | clean: 7 | cd ./JikesRVMProbes; make clean 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SHIM is a high frequency profiler. The design and implementation of SHIM 2 | is discussed in this paper (./papers/ISCA-SHIM.pdf) X. Yang, S. M. Blackburn, 3 | and K. S. McKinley, ”Computer Performance Microscopy with SHIM”, appeared in Proceedings of 4 | the 42nd International Symposium on Computer Architecture (ISCA 2015) , 5 | Portland, OR, June 13-17, 2015. 6 | 7 | Core data structures and functions of SHIM is in "shim.h" and "shim_core.c". Applications could 8 | build different profilers based on them. JikesRVMProbes has an example for profiling JikesRVM. 9 | Please have a look ./JikesRVMProbes/README.md for how to profile JikesRVM with SHIM. 10 | -------------------------------------------------------------------------------- /example/shim_example.c: -------------------------------------------------------------------------------- 1 | #include "shim.h" 2 | #define MAX_HW_COUNTERS (10) 3 | #define INDEX_HW_COUNTERS (2) 4 | int 5 | main(int argc, char **argv) 6 | { 7 | int i; 8 | int trustable; 9 | 10 | shim_init(); 11 | shim * my = (shim *)calloc(1, sizeof(shim)); 12 | shim_thread_init(my, 0, argc-1, argv+1); 13 | 14 | uint64_t begin[MAX_HW_COUNTERS]; 15 | uint64_t end[MAX_HW_COUNTERS]; 16 | 17 | shim_read_counters(begin, my); 18 | printf("hello world\n"); 19 | shim_read_counters(end, my); 20 | 21 | trustable = shim_trustable_sample(begin, end, 99, 101); 22 | 23 | printf("Trustable samples:\n"); 24 | for (i=0; inr_hw_events; i++){ 25 | printf("%s, end: %lld, begin: %lld, diff: %lld\n", 26 | my->hw_events[i].name, 27 | (unsigned long long)end[INDEX_HW_COUNTERS + i], 28 | (unsigned long long)begin[INDEX_HW_COUNTERS + i], 29 | (unsigned long long)end[INDEX_HW_COUNTERS + i] - (unsigned long long)begin[INDEX_HW_COUNTERS + i]); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /papers/ISCA-SHIM.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShimProfiler/SHIM/606f20722c31e05830d31ef14cb2829adb37b63f/papers/ISCA-SHIM.pdf -------------------------------------------------------------------------------- /ppid_module/Makefile: -------------------------------------------------------------------------------- 1 | default: ppid_map 2 | KERNELDIR ?= /lib/modules/`uname -r`/build 3 | PWD = `pwd` 4 | 5 | ifeq ($(KERNELRELEASE),) 6 | 7 | .PHONY: clean. 8 | clean: 9 | rm -rf *.o *.~ *.ko *.mod.c 10 | 11 | ppid_map: 12 | $(MAKE) -C $(KERNELDIR) M=$(PWD) modules 13 | 14 | else 15 | obj-m:= ppid_map.o 16 | endif 17 | -------------------------------------------------------------------------------- /ppid_module/README: -------------------------------------------------------------------------------- 1 | How to load the module & create the device file 2 | 3 | Before you load the module, you need to patch your kernel with "callback.path". 4 | 5 | sudo insmod ./ppid_map.ko 6 | sudo ./create_ppid_device.sh 7 | 8 | /dev/ppid_map provides information about who is running on which processors 9 | by exposing a map to user level mmap requests. 10 | 11 | Start from the base address of the map, each processor has one cacheline size slot (64 bytes for intel x86). 12 | For each slot, the first 32bit shows the pid of the thread running on that processor, the second 32bit shows 13 | the the tgid (process id) of the thread. 14 | 15 | Here is an example to get the map: 16 | 17 | if ((fd=open("/dev/ppid_map", O_RDWR|O_SYNC)) < 0) { 18 | perror("open") 19 | exit(-1); 20 | } 21 | kadr = mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED| MAP_LOCKED, 22 | fd, 0); 23 | if (kadr == MAP_FAILED) { 24 | perror("mmap"); 25 | exit(-1); 26 | } 27 | pid_signal_buf = (char *)kadr; 28 | -------------------------------------------------------------------------------- /ppid_module/callback.patch: -------------------------------------------------------------------------------- 1 | diff --git a/kernel/sched/core.c b/kernel/sched/core.c 2 | index 649c9f8..e5a02fd 100644 3 | --- a/kernel/sched/core.c 4 | +++ b/kernel/sched/core.c 5 | @@ -3365,6 +3365,9 @@ pick_next_task(struct rq *rq) 6 | BUG(); /* the idle class will always have a runnable task */ 7 | } 8 | 9 | +void (*switchCallBack)(struct task_struct *prev,struct task_struct *next) = NULL; 10 | +EXPORT_SYMBOL(switchCallBack); 11 | + 12 | /* 13 | * __schedule() is the main scheduler function. 14 | */ 15 | @@ -3445,6 +3448,9 @@ need_resched: 16 | sched_preempt_enable_no_resched(); 17 | if (need_resched()) 18 | goto need_resched; 19 | + 20 | + if (switchCallBack) 21 | + switchCallBack(prev,next); 22 | } 23 | 24 | static inline void sched_submit_work(struct task_struct *tsk) 25 | -------------------------------------------------------------------------------- /ppid_module/create_ppid_device.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -a /dev/ppid_map ] 3 | then 4 | echo "/dev/ppid_map is exist already." 5 | exit 6 | fi 7 | 8 | deviceID=`cat /proc/devices | grep ppid | grep -o [0-9]*` 9 | echo $deviceID 10 | mknod /dev/ppid_map c $deviceID 0 11 | ls -lh /dev/ppid_map 12 | -------------------------------------------------------------------------------- /ppid_module/ppid_map.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #ifdef MODVERSIONS 12 | # include 13 | #endif 14 | #include 15 | 16 | /* 17 | * ppid_map.ko driver provides a memory map that shows which software threads 18 | * are running on which hardware threads at any given time. 19 | * This driver is based on the mmap_alloc driver written by Claudio Scordino, Bruno Morelli. 20 | * https://github.com/claudioscordino/mmap_alloc 21 | * 22 | * Author: Xi Yang 23 | */ 24 | 25 | /* character device structures */ 26 | static dev_t mmap_dev; 27 | static struct cdev mmap_cdev; 28 | 29 | /* methods of the character device */ 30 | static int mmap_open(struct inode *inode, struct file *filp); 31 | static int mmap_release(struct inode *inode, struct file *filp); 32 | static int mmap_mmap(struct file *filp, struct vm_area_struct *vma); 33 | 34 | /* the file operations, i.e. all character device methods */ 35 | static struct file_operations mmap_fops = { 36 | .open = mmap_open, 37 | .release = mmap_release, 38 | .mmap = mmap_mmap, 39 | .owner = THIS_MODULE, 40 | }; 41 | 42 | // length of the two memory areas 43 | #define NPAGES 1 44 | #define CACHELINESIZE 64 45 | // original pointer for allocated area 46 | static char *alloc_ptr; 47 | dma_addr_t dma_handle; 48 | 49 | extern void (*switchCallBack)(struct task_struct *prev,struct task_struct *next); 50 | 51 | static void momaCallBack(struct task_struct *prev,struct task_struct *next) 52 | { 53 | int cpu = smp_processor_id(); 54 | int pid_index = cpu * CACHELINESIZE; 55 | unsigned long long *ptr = (unsigned long long *)(alloc_ptr + pid_index); 56 | unsigned long long val = (unsigned long long)task_pid_nr(next) | ((unsigned long long)task_tgid_nr(next)<<32); 57 | *ptr = val; 58 | } 59 | 60 | /* character device open method */ 61 | static int mmap_open(struct inode *inode, struct file *filp) 62 | { 63 | printk(KERN_INFO "ppid_map: device open\n"); 64 | return 0; 65 | } 66 | /* character device last close method */ 67 | static int mmap_release(struct inode *inode, struct file *filp) 68 | { 69 | printk(KERN_INFO "ppid_map: device is being released\n"); 70 | return 0; 71 | } 72 | 73 | // helper function, mmap's the allocated area which is physically contiguous 74 | int mmap_kmem(struct file *filp, struct vm_area_struct *vma) 75 | { 76 | int ret; 77 | long length = vma->vm_end - vma->vm_start; 78 | 79 | /* check length - do not allow larger mappings than the number of 80 | pages allocated */ 81 | if (length > NPAGES * PAGE_SIZE) 82 | return -EIO; 83 | /* #ifdef ARCH_HAS_DMA_MMAP_COHERENT */ 84 | if (vma->vm_pgoff == 0) { 85 | printk(KERN_INFO "Using dma_mmap_coherent\n"); 86 | ret = dma_mmap_coherent(NULL, vma, alloc_ptr, 87 | dma_handle, length); 88 | } else 89 | /* #else */ 90 | { 91 | printk(KERN_INFO "Using remap_pfn_range\n"); 92 | printk(KERN_INFO "off=%ld\n", vma->vm_pgoff); 93 | ret = remap_pfn_range(vma, vma->vm_start, 94 | PFN_DOWN(virt_to_phys(bus_to_virt(dma_handle))) + 95 | vma->vm_pgoff, length, vma->vm_page_prot); 96 | } 97 | /* #endif */ 98 | /* map the whole physically contiguous area in one piece */ 99 | if (ret < 0) { 100 | printk(KERN_ERR "ppid_map: remap failed (%d)\n", ret); 101 | return ret; 102 | } 103 | 104 | return 0; 105 | } 106 | 107 | /* character device mmap method */ 108 | static int mmap_mmap(struct file *filp, struct vm_area_struct *vma) 109 | { 110 | printk(KERN_INFO "ppid_map: device is being mapped\n"); 111 | return mmap_kmem(filp, vma); 112 | } 113 | 114 | /* module initialization - called at module load time */ 115 | static int __init ppid_map_init(void) 116 | { 117 | int ret = 0; 118 | int i; 119 | int *alloc_area; 120 | 121 | /* Allocate not-cached memory area with dma_map_coherent. */ 122 | printk(KERN_INFO "Use dma_alloc_coherent\n"); 123 | alloc_ptr = dma_alloc_coherent (NULL, (NPAGES + 2) * PAGE_SIZE, 124 | &dma_handle, GFP_KERNEL); 125 | 126 | if (!alloc_ptr) { 127 | printk(KERN_ERR 128 | "ppid_map: dma_alloc_coherent error\n"); 129 | ret = -ENOMEM; 130 | goto out; 131 | } 132 | printk(KERN_INFO "ppid_map: physical address is %llx\n", 133 | dma_handle); 134 | printk(KERN_INFO "ppid_map: bus_to_virt %llx\n", 135 | virt_to_phys(bus_to_virt(dma_handle))); 136 | 137 | /* get the major number of the character device */ 138 | if ((ret = alloc_chrdev_region(&mmap_dev, 0, 1, "ppid_map")) < 0) { 139 | printk(KERN_ERR 140 | "ppid_map: could not allocate major number for mmap\n"); 141 | goto out_vfree; 142 | } 143 | 144 | /* initialize the device structure and register the device with the 145 | * kernel */ 146 | cdev_init(&mmap_cdev, &mmap_fops); 147 | if ((ret = cdev_add(&mmap_cdev, mmap_dev, 1)) < 0) { 148 | printk(KERN_ERR 149 | "ppid_map: could not allocate chrdev for mmap\n"); 150 | goto out_unalloc_region; 151 | } 152 | 153 | /* store a pattern in the memory. 154 | * the test application will check for it */ 155 | alloc_area = (int *) alloc_ptr; 156 | for (i = 0; i < (NPAGES * PAGE_SIZE / sizeof(int)); i += 2) { 157 | alloc_area[i] = -1; 158 | alloc_area[i + 1] = -1; 159 | } 160 | 161 | switchCallBack = momaCallBack; 162 | 163 | return ret; 164 | 165 | out_unalloc_region: 166 | unregister_chrdev_region(mmap_dev, 1); 167 | out_vfree: 168 | dma_free_coherent (NULL, (NPAGES + 2) * PAGE_SIZE, alloc_ptr, 169 | dma_handle); 170 | out: 171 | return ret; 172 | } 173 | 174 | /* module unload */ 175 | static void __exit ppid_map_exit(void) 176 | { 177 | 178 | switchCallBack = NULL; 179 | /* remove the character deivce */ 180 | cdev_del(&mmap_cdev); 181 | unregister_chrdev_region(mmap_dev, 1); 182 | 183 | /* free the memory areas */ 184 | dma_free_coherent (NULL, (NPAGES + 2) * PAGE_SIZE, alloc_ptr, 185 | dma_handle); 186 | } 187 | 188 | module_init(ppid_map_init); 189 | module_exit(ppid_map_exit); 190 | MODULE_DESCRIPTION("ppid_map driver"); 191 | MODULE_AUTHOR("Xi Yang"); 192 | MODULE_LICENSE("GPL"); 193 | 194 | -------------------------------------------------------------------------------- /ppid_module/ppid_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define NPAGES 1 10 | 11 | 12 | int main(void) 13 | { 14 | int fd; 15 | int *kadr; 16 | 17 | int len = NPAGES * getpagesize(); 18 | 19 | if ((fd=open("/dev/ppid_map", O_RDWR|O_SYNC)) < 0) { 20 | perror("open"); 21 | exit(-1); 22 | } 23 | fprintf(stderr, "/dev/ppid_map: open OK\n"); 24 | 25 | kadr = mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED| MAP_LOCKED, 26 | fd, 0); 27 | 28 | if (kadr == MAP_FAILED) { 29 | perror("Could not mmap /dev/ppid_map"); 30 | exit(-1); 31 | } 32 | fprintf(stderr, "ppid_map: mmap OK\n"); 33 | 34 | int cpu = 0; 35 | while(1){ 36 | for (cpu=0; cpu<8; cpu++){ 37 | int *buf = kadr + cpu * (64/sizeof(int)); 38 | printf("CPU%d: tgid %d pid %d\n", cpu, buf[0], buf[1]); 39 | } 40 | sleep(1); 41 | } 42 | close(fd); 43 | return(0); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /remotebuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #usage ./remotebuild.sh rat.moma /home/yangxi/shim "make" 3 | #sync the directory 4 | echo "syncing direcoty from `pwd` to $1" 5 | echo "rsync -avz ./ $1:$2" 6 | rsync -avz ./ $1:$2 7 | echo "exec $2 in the remote directory $1" 8 | echo "ssh $1 bash -c \"cd $2; $3\"" 9 | ssh $1 bash -c "'cd $2; $3'" 10 | -------------------------------------------------------------------------------- /shim.h: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE /* See feature_test_macros(7) */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | struct shim_hardware_event { 21 | int index; 22 | int fd; 23 | struct perf_event_attr perf_attr; 24 | struct perf_event_mmap_page *buf; 25 | char * name; 26 | }; 27 | 28 | typedef struct shim_worker_struct shim; 29 | 30 | struct shim_worker_struct{ 31 | int cpuid; 32 | int nr_hw_events; 33 | struct shim_hardware_event *hw_events; 34 | int (*probe_other_events)(uint64_t *buf, shim *myshim); 35 | int (*probe_tags)(uint64_t *buf, shim * myshim); 36 | }; 37 | 38 | #define DEBUG 1 39 | 40 | #define debug_print(fmt, ...) \ 41 | do { if (DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0) 42 | 43 | 44 | static void __inline__ relax_cpu() 45 | { 46 | __asm__ volatile("rep; nop\n\t"::: "memory"); 47 | } 48 | 49 | static uint64_t __inline__ rdtsc(void) 50 | { 51 | unsigned int tickl, tickh; 52 | __asm__ __volatile__("rdtscp":"=a"(tickl),"=d"(tickh)::"%ecx"); 53 | return ((uint64_t)tickh << 32)|tickl; 54 | } 55 | 56 | static int __inline__ get_cpuid() 57 | { 58 | cpu_set_t cpuset; 59 | int j; 60 | CPU_ZERO(&cpuset); 61 | pthread_getaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); 62 | assert(CPU_COUNT(&cpuset) == 1); 63 | for (j = 0; j < CPU_SETSIZE; j++) 64 | if (CPU_ISSET(j, &cpuset)) 65 | return j; 66 | return -1; 67 | } 68 | 69 | static shim __inline__ *get_myshim(shim *shims) 70 | { 71 | int cpuid = get_cpuid(); 72 | shim *my = shims + cpuid; 73 | return my; 74 | } 75 | 76 | void shim_init(); 77 | char *ppid_init(); 78 | void shim_thread_init(shim *myshim, int cpuid, int nr_hw_events, const char **hw_event_names); 79 | int shim_read_counters(uint64_t *buf, shim *myshim); 80 | int shim_trustable_sample(uint64_t *start, uint64_t *end, int lowpass, int highpass); 81 | -------------------------------------------------------------------------------- /shim_core.c: -------------------------------------------------------------------------------- 1 | #include "shim.h" 2 | 3 | #define PAGESIZE (4096) 4 | static void shim_create_hw_event(char *name, int id, shim *myshim); 5 | 6 | //help functions 7 | static char *copy_name(char *name) 8 | { 9 | char *dst = (char *)malloc(strlen(name) + 1); 10 | strncpy(dst, name, strlen(name) + 1); 11 | return dst; 12 | } 13 | 14 | static void bind_processor(int cpu) 15 | { 16 | cpu_set_t cpuset; 17 | CPU_ZERO(&cpuset); 18 | CPU_SET(cpu, &cpuset); 19 | pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); 20 | } 21 | 22 | char *ppid_init() 23 | { 24 | char *kadr; 25 | int fd; 26 | 27 | if ((fd=open("/dev/ppid_map", O_RDWR|O_SYNC)) < 0) { 28 | err(1,"Can't open /dev/ppid_map"); 29 | exit(-1); 30 | } 31 | 32 | kadr = mmap(0, PAGESIZE, PROT_READ|PROT_WRITE, MAP_SHARED| MAP_LOCKED, fd, 0); 33 | if (kadr == MAP_FAILED) { 34 | perror("mmap"); 35 | exit(-1); 36 | } 37 | return kadr; 38 | } 39 | 40 | void shim_init() 41 | { 42 | //from libpfm library man page, http://perfmon2.sourceforge.net/manv4/pfm_initialize.html 43 | //This is the first function that a program must call otherwise the library will not function at all. 44 | //This function probes the underlying hardware looking for valid PMUs event tables to activate. 45 | //Multiple distinct PMU tables may be activated at the same time.The function must be called only once. 46 | int ret = pfm_initialize(); 47 | if (ret != PFM_SUCCESS) { 48 | err(1,"pfm_initialize() is failed!"); 49 | exit(-1); 50 | } 51 | } 52 | 53 | void shim_thread_init(shim *my, int cpuid, int nr_hw_events, const char **hw_event_names) 54 | { 55 | int i; 56 | debug_print("init shim thread at cpu %d\n", cpuid); 57 | bind_processor(cpuid); 58 | my->cpuid = cpuid; 59 | my->nr_hw_events = nr_hw_events; 60 | my->hw_events = (struct shim_hardware_event *)calloc(nr_hw_events, sizeof(struct shim_hardware_event)); 61 | // assert(my->hw_events != NULL); 62 | for (i=0; ihw_events + i; 67 | debug_print("updateindex event %s, fd %d, index %x\n", e->name, e->fd, e->buf->index - 1); 68 | e->index = e->buf->index - 1; 69 | 70 | } 71 | my->probe_other_events = NULL; 72 | my->probe_tags = NULL; 73 | } 74 | 75 | static void shim_create_hw_event(char *name, int id, shim *myshim) 76 | { 77 | struct shim_hardware_event * event = myshim->hw_events + id; 78 | struct perf_event_attr *pe = &(event->perf_attr); 79 | int ret = pfm_get_perf_event_encoding(name, PFM_PLM3, pe, NULL, NULL); 80 | if (ret != PFM_SUCCESS) { 81 | errx(1, "error creating event %d '%s': %s\n", id, name, pfm_strerror(ret)); 82 | } 83 | pe->sample_type = PERF_SAMPLE_READ; 84 | event->fd = perf_event_open(pe, 0, -1, -1, 0); 85 | if (event->fd == -1) { 86 | err(1, "error in perf_event_open for event %d '%s'", id, name); 87 | } 88 | //mmap the fd to get the raw index 89 | event->buf = (struct perf_event_mmap_page *)mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ, MAP_SHARED, event->fd, 0); 90 | if (event->buf == MAP_FAILED) { 91 | err(1,"mmap on perf fd"); 92 | } 93 | 94 | event->name = copy_name(name); 95 | 96 | event->index = event->buf->index - 1; 97 | debug_print("SHIM %d:creat %d hardware event name:%s, fd:%d, index:%x\n", 98 | myshim->cpuid, 99 | id, 100 | name, 101 | event->fd, 102 | event->index); 103 | } 104 | 105 | 106 | int shim_read_counters(uint64_t *buf, shim *myshim) 107 | { 108 | //[0] and [1] are start timestamp and end timestamp 109 | int index = 2; 110 | int i = 0; 111 | //start timestamp 112 | buf[0] = rdtsc(); 113 | //hardware counters 114 | for (i=0; inr_hw_events; i++){ 115 | rdtsc(); 116 | buf[index++] = __builtin_ia32_rdpmc(myshim->hw_events[i].index); 117 | } 118 | //call back probe_other_events is happened between getting two timestamps 119 | if (myshim->probe_other_events != NULL) 120 | index += myshim->probe_other_events(buf + index, myshim); 121 | //end timestamp 122 | buf[1] = rdtsc(); 123 | //call back probe_other_tags is happend after reading two timestamps 124 | if (myshim->probe_tags != NULL) 125 | index += myshim->probe_tags(buf + index, myshim); 126 | return index; 127 | } 128 | 129 | //test whether the error is in [lowpass, highpass], for example [99,101] means acceptiong +-%1 error 130 | int shim_trustable_sample(uint64_t *start, uint64_t *end, int lowpass, int highpass) 131 | { 132 | int cycle_begin_index = 0; 133 | int cycle_end_index = 1; 134 | uint64_t cycle_begin_diff = end[cycle_begin_index] - start[cycle_begin_index]; 135 | uint64_t cycle_end_diff = end[cycle_end_index] - start[cycle_end_index]; 136 | int cpc = (cycle_end_diff * 100 ) / cycle_begin_diff; 137 | if (cpc < lowpass || cpc > highpass){ 138 | // debug_print("cpc is %d\n", cpc); 139 | return 0; 140 | } 141 | return 1; 142 | } 143 | --------------------------------------------------------------------------------