RFR: two small patches to fix AArch64
Andrew Dinn
adinn at redhat.com
Wed Apr 12 11:13:42 UTC 2017
I have been testing my fix for address lowering on AArch64 Graal by
running netbeans and found several errors which crash the JVM. It seems
the AArch64 port of Graal is already bust without my changes when it
comes to running a large program like this.
I am still investigating some remaining problems but I wanted to propose
these two small fixes in the backend code generation for inclusion
before I propose my full patch.
Since these are tiny changes I am simply posting a git diff. Can someone
in the project team apply them and push them to the main repo? Or do I
have to provide a git PR?
regards,
Andrew Dinn
-----------
Problem 1) Scaled displacement Address verify rule is incorrect
This first problem is innocuous until it gets uncovered by my changes
but only because no hand-coded scaled displacement instructions happen
to have used a large enough offset. Scaled offsets need to allow up to
12 unsigned bits.
--- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -----
git diff
graal/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64Address.java
diff --git
a/graal/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64Address.java
b/graal/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64Address.java
index 8a48c42..b86b2c4 100644
---
a/graal/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64Address.java
+++
b/graal/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64Address.java
@@ -286,7 +286,7 @@ public final class AArch64Address extends
AbstractAddress {
return immediate & NumUtil.getNbitNumberInt(9);
case IMMEDIATE_SCALED:
// Unsigned value can be returned as-is.
- assert NumUtil.isUnsignedNbit(9, immediate);
+ assert NumUtil.isUnsignedNbit(12, immediate);
return immediate;
case PC_LITERAL:
// 21-bit signed value, but lower 2 bits are always 0
and are shifted out.
--- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -----
Problem 1) Stack-bang shadow region size is waaay over-size
The second patch fixes a problem in the stack-banging code generation.
On AArch64 page size is normally 64K. The current code to compute the
stack bang offset ends up using an offset of 20 * 64K (25 * 64K in dev
builds) which is obviously ludicrous. It causes almost immediate stack
overflows on any reasonably large program. The following generic change
assumes a 4K shadow page unit then rounds up to the resulting stack bang
offset to a multiple of the actual page size.
n.b. this change merely updates Graal to relect what happens in the
latest jdk9/hotspot generic source (see os::init_before_ergo in
hotspot/src/share/vm/runtime/os.cpp).
--- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -----
diff --git
a/graal/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotHostBackend.java
b/graal/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotHostBackend.java
index f58232f..7af446d 100644
---
a/graal/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotHostBackend.java
+++
b/graal/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotHostBackend.java
@@ -22,9 +22,11 @@
*/
package org.graalvm.compiler.hotspot;
+import static jdk.vm.ci.code.CodeUtil.K;
import static jdk.vm.ci.code.CodeUtil.getCallingConvention;
import static jdk.vm.ci.common.InitTimer.timer;
+import org.graalvm.compiler.core.common.NumUtil;
import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
import org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider;
import org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider;
@@ -109,7 +111,7 @@ public abstract class HotSpotHostBackend extends
HotSpotBackend {
// is greater than a page.
int pageSize = config.vmPageSize;
- int bangEnd = config.stackShadowPages * pageSize;
+ int bangEnd = NumUtil.roundUp(config.stackShadowPages * 4 *
K, pageSize);
// This is how far the previous frame's stack banging extended.
int bangEndSafe = bangEnd;
--- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -----
More information about the graal-dev
mailing list