comparison graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCompare.java @ 18662:c9d57a5fb655

Added PIC support for metaspace access
author adlertz
date Thu, 11 Dec 2014 19:35:25 +0100
parents 7acff34abbf7
children 8fc336a04d77
comparison
equal deleted inserted replaced
18661:aa4f2e3629ca 18662:c9d57a5fb655
23 package com.oracle.graal.hotspot.amd64; 23 package com.oracle.graal.hotspot.amd64;
24 24
25 import static com.oracle.graal.api.code.ValueUtil.*; 25 import static com.oracle.graal.api.code.ValueUtil.*;
26 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; 26 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
27 27
28 import com.oracle.graal.hotspot.HotSpotGraalRuntime;
28 import com.oracle.graal.api.meta.*; 29 import com.oracle.graal.api.meta.*;
29 import com.oracle.graal.asm.*; 30 import com.oracle.graal.asm.*;
30 import com.oracle.graal.asm.amd64.*; 31 import com.oracle.graal.asm.amd64.*;
31 import com.oracle.graal.compiler.common.*; 32 import com.oracle.graal.compiler.common.*;
32 import com.oracle.graal.hotspot.meta.*; 33 import com.oracle.graal.hotspot.meta.*;
64 // uncompressed oop 65 // uncompressed oop
65 AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(y, 8); 66 AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(y, 8);
66 masm.cmpq(asRegister(x), patch); 67 masm.cmpq(asRegister(x), patch);
67 } 68 }
68 } else if (y instanceof HotSpotMetaspaceConstant) { 69 } else if (y instanceof HotSpotMetaspaceConstant) {
70 boolean isImmutable = GraalOptions.ImmutableCode.getValue();
71 boolean generatePIC = GraalOptions.GeneratePIC.getValue();
69 if (y.getKind() == Kind.Int) { 72 if (y.getKind() == Kind.Int) {
70 // compressed metaspace pointer 73 // compressed metaspace pointer
71 crb.recordInlineDataInCode(y); 74 crb.recordInlineDataInCode(y);
72 masm.cmpl(asRegister(x), y.asInt()); 75 if (isImmutable && generatePIC) {
76 Kind hostWordKind = HotSpotGraalRuntime.getHostWordKind();
77 int alignment = hostWordKind.getBitCount() / Byte.SIZE;
78 // recordDataReferenceInCode forces the mov to be rip-relative
79 masm.cmpl(asRegister(x), (AMD64Address) crb.recordDataReferenceInCode(JavaConstant.INT_0, alignment));
80 } else {
81 masm.cmpl(asRegister(x), y.asInt());
82 }
73 } else { 83 } else {
74 // uncompressed metaspace pointer 84 // uncompressed metaspace pointer
75 AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(y, 8); 85 if (isImmutable && generatePIC) {
76 masm.cmpq(asRegister(x), patch); 86 crb.recordInlineDataInCode(y);
87 Kind hostWordKind = HotSpotGraalRuntime.getHostWordKind();
88 int alignment = hostWordKind.getBitCount() / Byte.SIZE;
89 // recordDataReferenceInCode forces the mov to be rip-relative
90 masm.cmpq(asRegister(x), (AMD64Address) crb.recordDataReferenceInCode(JavaConstant.INT_0, alignment));
91 } else {
92 AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(y, 8);
93 masm.cmpq(asRegister(x), patch);
94 }
77 } 95 }
78 } else { 96 } else {
79 throw GraalInternalError.shouldNotReachHere(); 97 throw GraalInternalError.shouldNotReachHere();
80 } 98 }
81 } 99 }