hotspot Zero for iOS
Johan Vos
johan.vos at gluonhq.com
Mon Dec 16 08:06:38 UTC 2024
Hi Julian,
See inline.
On Mon, Dec 16, 2024 at 7:23 AM Julian Waters <tanksherman27 at gmail.com>
wrote:
> Hi,
>
> I'm a little puzzled, mobile has a Pull Request for iOS at
> https://github.com/openjdk/mobile/pull/30 which uses the minimal
> variant. How is minimal possible on iOS since it includes C1 and the
> assembly based Interpreter? Or has that one been dropped in favour of
> Zero on iOS instead, as the current post seems to imply?
>
Correct, PR-30 isn't relevant anymore (I closed it). I had this PR so that
others could follow my work, and comment on it, which is why it was
prefixed with [WIP]
> On the topic of Android, I also remember hearing that all Android
> applications, even ones written in C or C++, are actually Android
> Runtime apps and all run in the same Android Java VM (Native C and C++
> code simply becomes a shared library that is loaded through JNI). I
> don't know how true that is since my knowledge of mobile operating
> systems, including Android, is rather spotty, but if there really
> isn't a way to run an application as a fully native and standalone one
> on Android and everything is actually in a Java VM under the hood, how
> would the JDK fit on an Android device? Sounds to me like the Java
> executables and HotSpot itself would end up ironically running inside
> a Java VM, which would probably destroy performance to an epic degree,
> among a host of other issues that will likely be present as a result
> of this.
>
Performance is actually pretty good on Android. We use this approach
already (at Gluon), with images compiled with GraalVM native-image and
SubstrateVM (hence not hotspot). In this approach, we start an Android
Activity and invoke a native method immediately which starts the
non-Android JVM. So there is little overhead in execution time. The
appsize is bigger though, as we bundle a JVM while native Android apps
don't do that, as they leverage the pre-installed Android (J)VM on the
devices.
In a next step, I want to use hotspot as the JVM, but the flow would
probably still be the same as we do now. I don't see performance as an
issue, but rather apk size and appstore specific things (permission
management etc). The latter is something we can't avoid, but the rules
there are the same for all Android developers (idem for iOS).
> Lastly, how can the mobile port be compiled? What environment is
> required? Since iOS seems to be the only working one at the moment,
> I'm guessing Xcode? There's no instructions in building.md for either
> iOS or Android, and I would submit an enhancement to include
> instructions for both, but currently I myself am not sure where to
> start even compiling the JDK for mobile devices. It might be helpful
> to share that information in the docs files.
>
I absolutely agree. Keep in mind that this is spare-time, volunteer project
at this moment, but even then docs are crucial. Hence, as I said I plan to
update the OpenJDK Mobile wiki (or I would be happy of course if someone
else does it). The PR itself (https://github.com/openjdk/mobile/pull/32)
has information on how to configure/compile -- I'll copy my own configure
below, hope that helps.
sh configure \
--with-conf-name=zero-ios-aarch64 \
--disable-warnings-as-errors \
--openjdk-target=aarch64-macos-ios \
--with-build-jdk=/opt/jdk-25-jv.jdk \
--with-boot-jdk=/opt/jdk-24.jdk/Contents/Home \
--with-jvm-variants=zero \
--with-libffi-include=/Users/johan/libffi/exp/t2/libffi-3.4.5/build_iphoneos-arm64/include
\
--with-libffi-lib=/Users/johan/libffi/exp/t2/libffi-3.4.5/build_iphoneos-arm64/.libs
\
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
\
--with-cups-include=../support/cups-2.3.6
- Johan
>
> best regards,
> Julian
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/mobile-dev/attachments/20241216/3ad2bd13/attachment-0001.htm>
More information about the mobile-dev
mailing list