Earlier quoted context omitted.
A class wrapping a long value with the pointer address in it.
How is the C memory modelled? One big Java array, or are there multiple data-structures? For instance, what happens when you call a function-pointer?
TruffleC: A C implementation on top of JVM (2014)
21–30 of 93 posts
Re: TruffleC: A C implementation on top of JVM (2014)
#22Way over my head here , but can someone perhaps explain the value and/or use-case of running c within a jvm?
Mostly migration of legacy programs probably, so companies can say they ported their stuff to java. It's stupid but companies do it.
Re: TruffleC: A C implementation on top of JVM (2014)
#23How are pointers implemented in a language that doesn't support them?
Re: TruffleC: A C implementation on top of JVM (2014)
#24OpenTV provided such a 'middleware' where the main language was C on such a VM, and was (possibly still is) widely used.
Re: TruffleC: A C implementation on top of JVM (2014)
#25How are pointers implemented in a language that doesn't support them?
The JVM is a specification which describes a pretend computer and its instruction set.
This TruffleC doesn't translate C to Java and run a Java program. This compiles C to bytecode which operates on the JVM.
Whatever Java does or doesn't support is irrelevant to this compiler. TruffleC has nothing to do with the Java programming language at all.
Just like you can compile C and get a memory address of a stack or heap location on any physical computer supported by a C compiler, likewise you can compile C with TruffleC and get a memory address within the stack or heap of the pretend computer called the JVM.
This must be how it works, unless the JVM itself has no concept of memory addresses, which seems very unlikely to me. Let me know if I am wrong?
Re: TruffleC: A C implementation on top of JVM (2014)
#26Earlier quoted context omitted.
A class wrapping a long value with the pointer address in it.
How is the C memory modelled? One big Java array, or are there multiple data-structures? For instance, what happens when you call a function-pointer?
Using a combination of native memory and JVM managed memory, depending on what the memory is needed for.
> For instance, what happens when you call a function-pointer?
This is a good example - because TruffleC can inline-cache a function-pointer, inlining the called function!
All this is in the linked paper, of course.
Re: TruffleC: A C implementation on top of JVM (2014)
#27Earlier quoted context omitted.
A class wrapping a long value with the pointer address in it.
Ha! Your paper is a "highly influential citation" https://www.semanticscholar.org/paper/TruffleC%3A-dynamic-ex...
Re: TruffleC: A C implementation on top of JVM (2014)
#28How are pointers implemented in a language that doesn't support them?
I don't think this is how it works. The JVM is a specification which describes a pretend computer and its instruction set. This TruffleC doesn't translate C to Java and run a Java program. This compiles C to bytecode which operates on the JVM. Whatever Java does or doesn't support is irrelevant to this compiler. TruffleC has nothing to do with the Java programming language at all. Just like you can compile C and get…
Re: TruffleC: A C implementation on top of JVM (2014)
#29Only 7% slower seems amazing. To me at least.
Re: TruffleC: A C implementation on top of JVM (2014)
#30Earlier quoted context omitted.
I don't think this is how it works. The JVM is a specification which describes a pretend computer and its instruction set. This TruffleC doesn't translate C to Java and run a Java program. This compiles C to bytecode which operates on the JVM. Whatever Java does or doesn't support is irrelevant to this compiler. TruffleC has nothing to do with the Java programming language at all. Just like you can compile C and get…
the JVM bytecode does not have any memory address type. Just various width integers & floats, and references to managed heap objects. Arbitrary pointers would have to be done with 'long's one way or another.