Re: [rvm-research] Inserting Assembly into Jikes

Jeremy Singer <[email protected]>
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
Hi Claire,

> > We literally want a faster equivalent of using JNI to insert C, 
> > which inserts assembly. 
> See org.jikesrvm.runtime.SysCall.java and follow the pattern that is there for the other sysCalls.

Just to make this explicit, which might be helpful for future hackers [ http://xkcd.com/979/ ]

1) add your C function foo (possibly containing inline assembler) in tools/bootImageRunner/sys.C

extern "C" void
foo(void) {
  // your code here
}

2) add an Address field for the runtime entry point to your C function in
rvm/src/org/jikesrvm/runtime/BootRecord.java

public Address fooIP;  // IP on end is required for correct code rewriting

Does this field need an @EntryPoint annotation?

3) add a method signature for the Java wrapper to your C function in 
rvm/src/org/jikesrvm/runtime/SysCall.java

@SysCallTemplate
public abstract void foo();

4) Invoke your code from somewhere in Jikes RVM (or your user application running on Jikes RVM) with:

import org.jikesrvm.runtime.SysCall;

…
SysCall.sysCall.foo();


Things get slightly more complicated when you try to map Java types onto C types, but you should be able to pass Addresses  and ints fairly easily - follow the existing code in sys.C I guess.

Best regards,
Jeremy

---
http://www.dcs.gla.ac.uk/~jsinger



------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.