• Post Reply Bookmark Topic Watch Topic
  • New Topic

JNI - 80/128-bit Math, Object reference to void pointer  RSS feed

 
Louis Denning
Ranch Hand
Posts: 64
4
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whew, haven't been back here in a while.

Anyways, there's two things I'm experimenting with. I'm trying to implement extended precision floats (80-bit and 128-bit) for use in Java, so I thought maybe I could use the built in x87 functionality for 80-bit float math and libquadmath for 128-bit float math, all bridged over using JNI. The thing is, using the JNI functions to get object members seems a bit slow and clunky, so I was wondering if I could somehow convert a jobject to a raw pointer, if it isn't a pointer already, for quicker access to the float bits. If my memory serves me correctly, I expect my simple Java object of 10 (or 16) byte-sized (heheh) members to look something like the following, as a struct

I'm uncertain if the header size will change if UseCompressedOops is off, or whether I'm even thinking of the right thing, but I'm here to learn O:
If there's already a library for Java for extended floating point math, great; I just wanted to experiment with how to do it myself using what I've got here on this 64-bit toaster.

Oh, and the second thing I'm experimenting with is seeing how my specific JVM reorders object members for greater space efficiency. I had read an article on how member variables are rearranged, but I can't find the article anymore. Either way, I want to personally experiment and see how my JVM would reorder a class of [pseudo]randomly sized junk values like 0x33, 0xEEEE7777, 0xABCD, or whatever, so I access them via raw pointer (or struct pointer) in C-side code.

In case anything here is bad practice, let me know. I'll just treat it as experimental test code to see how things would work this way.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!