size of generated machine code ?

Hi,

Is there a way to find out how much memory
some JIT'ed machine code uses ?

Simon.

lli -stats x.bc <args>

the -stats output will indicate the # bytes of machine code.

-Chris

This from the output:

   24620 x86-emitter - Number of machine instructions emitted

(i had to write a dummy main function to get this to work)

Is this really the number of bytes of machine code ?

thanks,

Simon.

Yes.

-Chris

To be specific, this is the number of bytes of machine code JIT'd. Thus, this only includes the stuff reachable from main, for example. To see specifically what functions it is compiling and how big they are, use:

lli -debug-only=jit foo.bc <args>

-Chris

This does not seem to be available in my build (1.7 release-asserts).

Another question: does lli actually run the program ?
I've cooked up a main function that would probably segfault it.
And what i'm seeing (with strace) is that something does segfault (a child thread?) and
lli is waiting on a futex:

access("dump.bc", F_OK) = 0
open("dump.bc", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0600, st_size=22744, ...}) = 0
mmap2(NULL, 24576, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7fe3000
mmap2(NULL, 16777216, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6d9c000
mmap2(0xb7d9c000, 1048576, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6c9c000
mmap2(0xb6d9c000, 1048576, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6b9c000
futex(0xb7fbb1b4, FUTEX_WAKE, 2147483647) = 0
brk(0) = 0x8562000
brk(0x8583000) = 0x8583000
brk(0) = 0x8583000
brk(0x85a4000) = 0x85a4000
brk(0) = 0x85a4000
brk(0x85c5000) = 0x85c5000
brk(0) = 0x85c5000
brk(0x85e6000) = 0x85e6000
brk(0) = 0x85e6000
brk(0x8609000) = 0x8609000
brk(0) = 0x8609000
brk(0x862b000) = 0x862b000
brk(0) = 0x862b000
brk(0x864c000) = 0x864c000
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
pipe([4, 5]) = 0
futex(0xb7ecf900, FUTEX_WAIT, 2, NULL
<unfinished ...>

dump.bc attached.

Simon.

dump.bc (22.2 KB)

To be specific, this is the number of bytes of machine code JIT'd. Thus,
this only includes the stuff reachable from main, for example. To see
specifically what functions it is compiling and how big they are, use:

lli -debug-only=jit foo.bc <args>

This does not seem to be available in my build (1.7 release-asserts).

Right, release-asserts builds have no debug stuff in them.

Another question: does lli actually run the program ?

Yup.

I've cooked up a main function that would probably segfault it.
And what i'm seeing (with strace) is that something does segfault (a child thread?) and
lli is waiting on a futex:

Right. lli is the JIT, which dynamically compiles code as it goes. If you're just curious about code size, why not use size on .o file?

-Chris

access("dump.bc", F_OK) = 0
open("dump.bc", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0600, st_size=22744, ...}) = 0
mmap2(NULL, 24576, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7fe3000
mmap2(NULL, 16777216, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6d9c000
mmap2(0xb7d9c000, 1048576, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6c9c000
mmap2(0xb6d9c000, 1048576, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6b9c000
futex(0xb7fbb1b4, FUTEX_WAKE, 2147483647) = 0
brk(0) = 0x8562000
brk(0x8583000) = 0x8583000
brk(0) = 0x8583000
brk(0x85a4000) = 0x85a4000
brk(0) = 0x85a4000
brk(0x85c5000) = 0x85c5000
brk(0) = 0x85c5000
brk(0x85e6000) = 0x85e6000
brk(0) = 0x85e6000
brk(0x8609000) = 0x8609000
brk(0) = 0x8609000
brk(0x862b000) = 0x862b000
brk(0) = 0x862b000
brk(0x864c000) = 0x864c000
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
pipe([4, 5]) = 0
futex(0xb7ecf900, FUTEX_WAIT, 2, NULL
<unfinished ...>

dump.bc attached.

Simon.

-Chris

I think i've fixed this now.

Simon.

Doh!! yes :slight_smile:

Simon.