• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Ranch Hand
Posts: 64
4
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic