Skip to content

Commit

Permalink
Adjust inline cache check size for forced 4-byte displacements
Browse files Browse the repository at this point in the history
  • Loading branch information
gergo- committed Mar 7, 2024
1 parent 8433868 commit c7abc29
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -50,6 +50,8 @@
import static jdk.vm.ci.amd64.AMD64.rbp;
import static jdk.vm.ci.amd64.AMD64.rsp;

import java.util.EnumSet;

import org.graalvm.collections.EconomicSet;

import jdk.graal.compiler.asm.Assembler;
Expand All @@ -63,8 +65,6 @@
import jdk.vm.ci.code.TargetDescription;
import jdk.vm.ci.meta.PlatformKind;

import java.util.EnumSet;

/**
* This class implements an assembler that can encode most X86 instructions.
*/
Expand Down Expand Up @@ -285,6 +285,14 @@ public void setForce4ByteNonZeroDisplacements(boolean force4ByteNonZeroDisplacem
this.force4ByteNonZeroDisplacements = force4ByteNonZeroDisplacements;
}

/**
* Returns {@code true}} if this assembler is configured to emit all non-zero displacements in
* addresses as 4 bytes even if they would fit into a byte.
*/
public boolean force4ByteNonZeroDisplacements() {
return force4ByteNonZeroDisplacements;
}

protected void annotatePatchingImmediate(int operandOffset, int operandSize) {
if (codePatchingAnnotationConsumer != null) {
int pos = position();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -360,6 +360,13 @@ public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, CompilationRes

// Size of IC check sequence checked with a guarantee below.
int inlineCacheCheckSize = 14;
if (asm.force4ByteNonZeroDisplacements()) {
/*
* The mov and cmp below each contain a 1-byte displacement that is emitted as 4
* bytes instead, thus we have 3 extra bytes for each of these instructions.
*/
inlineCacheCheckSize += 3 + 3;
}
asm.align(config.codeEntryAlignment, asm.position() + inlineCacheCheckSize);

int startICCheck = asm.position();
Expand Down

0 comments on commit c7abc29

Please sign in to comment.