Enable Native Image Layers on Windows, macOS, and aarch64.#13018
Open
emberian wants to merge 2 commits intooracle:masterfrom
Open
Enable Native Image Layers on Windows, macOS, and aarch64.#13018emberian wants to merge 2 commits intooracle:masterfrom
emberian wants to merge 2 commits intooracle:masterfrom
Conversation
Previously, Native Image Layers were restricted to Linux AMD64. This change extends layer support to Darwin/AArch64 and Linux/AArch64 by: AArch64 backend: - Add forceIndirectCall() check to shouldEmitIndirectCall(), matching AMD64 - Handle cross-layer method calls in emitIndirectForeignCallAddress() via DynamicImageLayerInfo for both delayed and prior-layer methods - Implement createLoadMethodPointerConstant() for extension layers (previously threw VMError.unimplemented) - Add addend constructor to AArch64CGlobalDataLoadAddressOp for prior-layer method offset support - Skip cross-layer callees in trampoline calculation Darwin platform: - Extend DarwinImageHeapProvider with layered image heap initialization using vm_copy per layer section, with read-only page protection - Extract platform-independent patching code from LinuxImageHeapProvider into new LayeredImageHeapSupport class (shared by both platforms) - Update Darwin singleton annotations from Disallowed to their appropriate layered kinds (InitialLayerOnly/Independent) - Make IMAGE_LAYER file suffix format-aware (.dylib on macOS) - Add IMAGE_LAYER case to DarwinCCLinkerInvocation Tested end-to-end: base layer (shared library) + extension layer (thin executable) builds and runs correctly on macOS/aarch64. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
8176a76 to
8429a8d
Compare
8429a8d to
e5918a5
Compare
9df0f51 to
38b260d
Compare
|
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA). To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
7b2304e to
6aa7406
Compare
Extend native image layer support to Windows, completing coverage across all major platforms (Linux, macOS, Windows) for both AMD64 and AArch64. Key changes: Platform gate and singleton annotations: - Add WINDOWS_AMD64 and WINDOWS_AARCH64 to supportedPlatform() - Fix singleton annotations on 13 Windows files: change Disallowed to InitialLayerOnly with SingleLayer callbacks - Add firstImageBuild() guards to WindowsFeature and WindowsSystemPropertiesFeature WindowsImageHeapProvider - layered heap initialization: - Override initialize() for layered builds with per-layer heap copying - Add patchNextSectionPointers() to resolve NEXT_SECTION linked list at runtime via GetProcAddress (MSVC linker can't resolve forward refs) - Add resolveForwardSymbolReferences() to patch CGlobal slots before argument parsing reads them PE/COFF CGlobal fixup mechanism (.svm_fix section): - In NativeImage.java, build a fixup table mapping CGlobal slot offsets to symbol names for forward-reference CGlobals - At runtime, WindowsImageHeapProvider resolves each symbol via GetProcAddress on the extension layer's module - Add ImageHeapProvider.resolveForwardSymbolReferences() default method, called from CEntryPointSnippets.createIsolate() before argument parsing PE/COFF linker and object file fixes: - Handle IMAGE_LAYER output as .dll on PE/COFF - Suppress auto-exports to stay under PE/COFF 65535 export limit - Fix duplicate static libraries in linker command - Fix import library placement and library naming - Support unresolved forward references in shared layer DLLs - Fix cross-layer IAT (Import Address Table) symbol references Misc fixes: - Fix TimeZoneSupport singleton for layered builds - Skip file mapping optimization for layered heaps (must copy to preserve cross-layer patches) - Fix vtable symbols and codeSynchronization for Windows layers Testing: - Add mx layeredhelloworld command and gate task that builds base + extension layers and validates the output on all platforms - Remove outdated Darwin/AArch64 skip from layereddebuginfotest Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6aa7406 to
41aea63
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AArch64 backend changes
forceIndirectCall()toshouldEmitIndirectCall(), matching the AMD64 backendemitIndirectForeignCallAddress()viaDynamicImageLayerInfo(both delayed and prior-layer methods)createLoadMethodPointerConstant()for extension layers (previously threwVMError.unimplemented)AArch64CGlobalDataLoadAddressOpfor prior-layer method offset calculationLIRNativeImageCodeCache.addDirectCallTrampolines()Darwin platform changes
DarwinImageHeapProviderwith full layered image heap initialization usingvm_copy()per layer section, with read-only page protectionLinuxImageHeapProviderinto new sharedLayeredImageHeapSupportclassDisallowedto appropriate layered kinds (InitialLayerOnly/Independent)IMAGE_LAYERfile suffix format-aware (.dylibon macOS,.soon Linux)IMAGE_LAYERcase toDarwinCCLinkerInvocationPlatform gate
DARWIN_AARCH64andLINUX_AARCH64toHostedImageLayerBuildingSupport.supportedPlatform()Windows platform changes
WINDOWS_AMD64andWINDOWS_AARCH64to the layers platform gateWindowsImageHeapProvider, mirroring the Darwin implementation: reserves address space, iterates layer sections, copies each layer's heap viacommitAndCopyMemory(), protects read-only pages, and delegates toLayeredImageHeapSupport.patchLayeredImageHeap()for cross-layer patchingother = Disallowed.classwithlayeredInstallationKind = InitialLayerOnly.class(andNoLayeredCallbacks→SingleLayerwhere needed)firstImageBuild()guards toWindowsFeatureandWindowsSystemPropertiesFeatureto prevent double-registration in extension layersDisallowedfromWindowsCCompilerInvoker(matching Linux/Darwin)Test plan
mx native-image -H:LayerCreate=base,+module=java.base -o base Hello.javamx native-image -H:LayerUse=base -o hello Hello.javahello.exeto verify correct execution🤖 Generated with Claude Code