2424 */
2525package org .graalvm .compiler .hotspot .amd64 ;
2626
27- import static jdk .vm .ci .amd64 .AMD64 .k0 ;
28- import static jdk .vm .ci .amd64 .AMD64 .k1 ;
29- import static jdk .vm .ci .amd64 .AMD64 .k2 ;
30- import static jdk .vm .ci .amd64 .AMD64 .k3 ;
31- import static jdk .vm .ci .amd64 .AMD64 .k4 ;
32- import static jdk .vm .ci .amd64 .AMD64 .k5 ;
33- import static jdk .vm .ci .amd64 .AMD64 .k6 ;
34- import static jdk .vm .ci .amd64 .AMD64 .k7 ;
3527import static jdk .vm .ci .amd64 .AMD64 .rax ;
36- import static jdk .vm .ci .amd64 .AMD64 .rip ;
37- import static org .graalvm .compiler .core .common .NumUtil .isInt ;
3828
3929import java .util .EnumSet ;
4030
5646import jdk .vm .ci .code .RegisterValue ;
5747import jdk .vm .ci .code .site .InfopointReason ;
5848import jdk .vm .ci .meta .AllocatableValue ;
59- import jdk .vm .ci .meta .Value ;
6049
6150/**
6251 * Emits a safepoint poll.
@@ -72,19 +61,12 @@ public final class AMD64HotSpotSafepointOp extends AMD64LIRInstruction {
7261 private final GraalHotSpotVMConfig config ;
7362 private final Register thread ;
7463
75- private static final AllocatableValue [] MASK_REGISTERS = new AllocatableValue []{k0 .asValue (), k1 .asValue (), k2 .asValue (), k3 .asValue (), k4 .asValue (), k5 .asValue (), k6 .asValue (), k7 .asValue ()};
76-
7764 public AMD64HotSpotSafepointOp (LIRFrameState state , GraalHotSpotVMConfig config , NodeLIRBuilderTool tool , Register thread ) {
7865 super (TYPE );
7966 this .state = state ;
8067 this .config = config ;
8168 this .thread = thread ;
82- if (config .useThreadLocalPolling || isPollingPageFar (config )) {
83- temp = tool .getLIRGeneratorTool ().newVariable (LIRKind .value (tool .getLIRGeneratorTool ().target ().arch .getWordKind ()));
84- } else {
85- // Don't waste a register if it's unneeded
86- temp = Value .ILLEGAL ;
87- }
69+ temp = tool .getLIRGeneratorTool ().newVariable (LIRKind .value (tool .getLIRGeneratorTool ().target ().arch .getWordKind ()));
8870 EnumSet <CPUFeature > features = ((AMD64 ) tool .getLIRGeneratorTool ().target ().arch ).getFeatures ();
8971 killedMaskRegisters = AllocatableValue .NONE ;
9072 }
@@ -95,46 +77,6 @@ public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) {
9577 }
9678
9779 public static void emitCode (CompilationResultBuilder crb , AMD64MacroAssembler asm , GraalHotSpotVMConfig config , boolean atReturn , LIRFrameState state , Register thread , Register scratch ) {
98- if (config .useThreadLocalPolling ) {
99- emitThreadLocalPoll (crb , asm , config , atReturn , state , thread , scratch );
100- } else {
101- emitGlobalPoll (crb , asm , config , atReturn , state , scratch );
102- }
103- }
104-
105- /**
106- * Tests if the polling page address can be reached from the code cache with 32-bit
107- * displacements.
108- */
109- private static boolean isPollingPageFar (GraalHotSpotVMConfig config ) {
110- final long pollingPageAddress = config .safepointPollingAddress ;
111- return config .forceUnreachable || !isInt (pollingPageAddress - config .codeCacheLowBound ) || !isInt (pollingPageAddress - config .codeCacheHighBound );
112- }
113-
114- private static void emitGlobalPoll (CompilationResultBuilder crb , AMD64MacroAssembler asm , GraalHotSpotVMConfig config , boolean atReturn , LIRFrameState state , Register scratch ) {
115- assert !atReturn || state == null : "state is unneeded at return" ;
116- if (isPollingPageFar (config )) {
117- asm .movq (scratch , config .safepointPollingAddress );
118- crb .recordMark (atReturn ? HotSpotMarkId .POLL_RETURN_FAR : HotSpotMarkId .POLL_FAR );
119- final int pos = asm .position ();
120- if (state != null ) {
121- crb .recordInfopoint (pos , state , InfopointReason .SAFEPOINT );
122- }
123- asm .testl (rax , new AMD64Address (scratch ));
124- } else {
125- crb .recordMark (atReturn ? HotSpotMarkId .POLL_RETURN_NEAR : HotSpotMarkId .POLL_NEAR );
126- final int pos = asm .position ();
127- if (state != null ) {
128- crb .recordInfopoint (pos , state , InfopointReason .SAFEPOINT );
129- }
130- // The C++ code transforms the polling page offset into an RIP displacement
131- // to the real address at that offset in the polling page.
132- asm .testl (rax , new AMD64Address (rip , 0 ));
133- }
134- }
135-
136- private static void emitThreadLocalPoll (CompilationResultBuilder crb , AMD64MacroAssembler asm , GraalHotSpotVMConfig config , boolean atReturn , LIRFrameState state , Register thread ,
137- Register scratch ) {
13880 assert !atReturn || state == null : "state is unneeded at return" ;
13981
14082 assert config .threadPollingPageOffset >= 0 ;
0 commit comments