|
25 | 25 | package com.oracle.svm.hosted.image;
|
26 | 26 |
|
27 | 27 | import static com.oracle.svm.core.SubstrateOptions.SpawnIsolates;
|
| 28 | +import static com.oracle.svm.core.SubstrateOptions.MremapImageHeap; |
28 | 29 | import static com.oracle.svm.core.SubstrateUtil.mangleName;
|
29 | 30 | import static com.oracle.svm.core.util.VMError.shouldNotReachHere;
|
30 | 31 |
|
@@ -489,9 +490,13 @@ public void build(String imageName, DebugContext debug) {
|
489 | 490 | // boundaries, so we take care of this ourselves in CommittedMemoryProvider, if we can.
|
490 | 491 | int alignment = pageSize;
|
491 | 492 |
|
492 |
| - // Manually add padding to the SVM_HEAP section, because when SpawnIsolates are disabled |
493 |
| - // we operate with mprotect on it with page size granularity. |
494 |
| - long paddedImageHeapSize = SpawnIsolates.getValue() ? imageHeapSize : NumUtil.roundUp(imageHeapSize, alignment); |
| 493 | + /* |
| 494 | + * Manually add padding to the SVM_HEAP section, because when SpawnIsolates are disabled |
| 495 | + * we operate with mprotect on it with page size granularity. Similarly, using mremap |
| 496 | + * aligns up the page boundary and may reset memory outside of the image heap. |
| 497 | + */ |
| 498 | + boolean padImageHeap = !SpawnIsolates.getValue() || MremapImageHeap.getValue(); |
| 499 | + long paddedImageHeapSize = padImageHeap ? NumUtil.roundUp(imageHeapSize, alignment) : imageHeapSize; |
495 | 500 | RelocatableBuffer heapSectionBuffer = new RelocatableBuffer(paddedImageHeapSize, objectFile.getByteOrder());
|
496 | 501 | ProgbitsSectionImpl heapSectionImpl = new BasicProgbitsSectionImpl(heapSectionBuffer.getBackingArray());
|
497 | 502 | // Note: On isolate startup the read only part of the heap will be set up as such.
|
|
0 commit comments