[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Jilc-dev] Fw: IL Structs
From: |
Gaurav Vaish |
Subject: |
[Jilc-dev] Fw: IL Structs |
Date: |
Mon, 11 Mar 2002 12:42:29 +0530 |
Hello,
Here's a relevant portion of a mail from Rhys Weatherly (man behind dotGNU)
where I recently discussed with him about how to emit il code.
Cheers,
Gaurav Vaish
http://home.iitk.ac.in/student/gvaish
http://calendar.yahoo.com/mastergaurav
---------------------------------
----- Original Message -----
From: "Rhys Weatherley" <address@hidden>
To: "Gaurav Vaish" <address@hidden>
Sent: Monday, March 11, 2002 07:11
Subject: Re: IL Structs
: Gaurav Vaish wrote:
:
: > Besides, I have one more query - I am still a little confused about how
to
: > do label management (IL_xxxx) while converting. Reading from a PE file and
: > dumping it in il file is easy, but when converting from java code, the
labels
: > will not remain same and I need to keep track of the labels, esp those that
are
: > pointed by "br.s" and conditional jumps.
:
: If you are outputting IL source, to be fed into ilasm, then
: you can cheat a little. Generate a label based on the
: offset within the Java method. Then, whenever you see
: a Java branch, you use the Java offset to generate the
: label name. e.g. consider this code to determine if an
: integer variable is non-zero or not (var != 0).
:
: 0000: iload var
: 0002: ifne 0008
: 0005: iconst_0
: 0006: goto 000A
: 0009: iconst_1
: 000A:
:
: When you generate the IL, you'll do this:
:
: L0000: ldloc var'
: L0002: brtrue.s L0008
: L0005: ldc.i4.0
: L0006: br.s L000A
: L0009: ldc.i4.1
: L000A:
:
: Note: the "brtrue.s" instruction is actually 2 bytes long,
: not 3. But it doesn't matter because the assembler treats
: the labels as symbolic: it generates the real offsets itself.
:
: Knowing the exact IL offsets is only a problem if you want
: to generate IL bytecode directly, rather than through an
: assembler. In that case, you will need to keep a table
: that maps Java offsets to IL offsets, and back-patch
: any opcodes that refer to later instructions.
:
: Cheers,
:
: Rhys.
:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Jilc-dev] Fw: IL Structs,
Gaurav Vaish <=