Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Windows support to the native part of MaxineVM #21

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

mihalis341
Copy link

@mihalis341 mihalis341 commented Jul 8, 2020

Added Windows code to com.oracle.max.vm.native while the already existing code for other OSes remains functional. You can check the description of my last commit for additional info. Also, all the additions made regard x86_64 (amd64) ISA only.

…relies exclusively on existing native Windows Libraries, no dependency required)
…e (code relies exclusively on existing native Windows Libraries, no dependency required)"

This reverts commit 8d7ca09.
Added code for the creation of the following shared libraries/executables on Windows:
jvm.dll (substrate), javatest.dll, hosted.dll, maxvm.exe (launch)
-Only tele.dll excluded

Code depends entirely on native Windows DLLs- no other dependencies required to compile and run)

The only thing left unimplemented (besides Tele) is the sending of signals to different threds/processes (ie. kill() ) as Windows do not support that functionality. Windows Signals can only be raised from within the same process that receives them (like Exceptions).
Added code for the creation of the following executables and shared libraries on Windows:
jvm.dll (substrate), javatest.dll, maxvm.exe (launch), hosted.dll
-Only tele.dll excluded

The code depends entirely on native Windows Libraries available in any Windows OS after (including) Windows Vista. No additional dependency (like .Cygwin, pthread libraries etc) is required to compile and run it.

Only thing left unimplemented (besides Tele) is the ability to send signals to different threads/ procs (ie. kill () ) as Windows do not support such functionality. Windows signals can only be raised from within the same process that receives them (like Exceptions). One could probably emulate the functionality of UNIX signals using something like Windows message posting but that requires each thread to explicitly receive a message using function like GetMessage(). For now, it is left unimplemented.
@kotselidis
Copy link
Member

Hi Mihali, thanks for the PR.
With this PR does MaxineVM work on Windows or just the native part is compiled?

@mihalis341
Copy link
Author

Hi. Unfortunately, I have still some issues with boot image creation on Windows so i cannot completely test Maxine VM. However, the code added is tested using my own tests and appears to work correctly. Also, maxvm.exe correctly loads maxine function from jvm.dll and attempts to find the boot image in the same directory. I was prompted by @zakkak to make this PR in case someone wants to continue the development for Windows.

@kotselidis
Copy link
Member

Great, thanks Mihali.
Could you please also add the README files with platform compatibility to reflect the state?
Also, would it make sense to include your tests also?

mihalis341 and others added 12 commits July 14, 2020 21:26
Fixed com.sun.max.config.jdk.Package constructor. We avoid resetting any field in java.lang.UNIXProcess when running on Windows. Attempting to load java.lang.UNIX on Windows caused NoClassDefFoundError when we tried to load com.sun.max.config.jdk.Package class during image generation. As a result problematic classed were not added to Compilation Blacklist and many unexplainable compilation errors were emerging
-makefile omits Tele build on Windows
-launch.mk uses "maxvm.exe" instead of bare "maxvm" (some cp (copy) implementations for Windows need the extension while others do not).
-javatest.mk uses more source files for javatest.dll on Windows because Windows do not allow undefined references in DLLs. However, if not on Windows, we use the default source files
-platform.mk we assign OS = windows when uname returns not only "WindowsNT" but if it also includes "MINGW" inside it.
…page size + better reading of image file on Windows
@mihalis341
Copy link
Author

mihalis341 commented Nov 16, 2020

Hi.
Sorry for the delay but I had some other responsibilities and eventually forgot about it. I added one more commit with updated Status.srt. I also attach an updated version of a report I wrote for @zakkak course 4 months ago. It includes all the steps one should follow in order to reproduce my work (ie. build Maxine VM + image in Windows and run what is runnable). In my last response I mentioned that an image cannot be created yet in Windows, however, this has been resolved in a July commit
. I fixed some things in Java code and now a working image gets created successfully.
In my report some things get explained regarding the native C code for Windows, however, it is in no way a complete documentation! I suggest someone who wants to continue developing for Windows better inspect my code and read my comments contained in it. The part of the report which describes the current stage is the last 3 pages which describe where a crash happens during the execution of the image file Java code from C (specifically, inside the VMRun() Entry Point) code with no apparent cause. I suspect that maybe some new interceptions are needed to prevent such crashes but I have no clue how to go about it. Regarding the tests I mentioned, I meant that I tested all the Win32 API code I used for the native code (ie. Mutexes, Critical Sections, Threads, Threads Local Storage, Conditions, Memory Mapping etc) completely using C Code. The reason I had to test them is that it was actually my very first time using Win32 API and I needed to know how things work. Unfortunately, I have no Java tests that use my native code.

Regards,
Michael

report.pdf

@mihalis341 mihalis341 closed this Nov 18, 2020
@mihalis341 mihalis341 reopened this Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants