use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class HostedField method readValue.
@Override
public JavaConstant readValue(JavaConstant receiver) {
JavaConstant result;
if (location == LOC_CONSTANT_STATIC_FIELD) {
return getConstantValue();
} else {
JavaConstant wrappedReceiver;
if (receiver != null && SubstrateObjectConstant.asObject(receiver) instanceof Class) {
/* Manual object replacement from java.lang.Class to DynamicHub. */
wrappedReceiver = SubstrateObjectConstant.forObject(metaAccess.lookupJavaType((Class<?>) SubstrateObjectConstant.asObject(receiver)).getHub());
} else {
wrappedReceiver = receiver;
}
result = universe.lookup(universe.getConstantReflectionProvider().readFieldValue(wrapped, wrappedReceiver));
}
return result;
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class HostedMemoryAccessProvider method doRead.
/**
* Try to look up the original field from the given displacement, and read the field value.
*/
private JavaConstant doRead(JavaKind stackKind, JavaConstant base, long displacement) {
if (base.getJavaKind() != JavaKind.Object) {
return null;
}
HostedType type = (HostedType) metaAccess.lookupJavaType(base);
HostedField field = (HostedField) type.findInstanceFieldWithOffset(displacement, null);
if (field == null) {
return null;
}
assert field.getStorageKind().getStackKind() == stackKind;
JavaConstant result = field.readValue(base);
assert result.getJavaKind().getStackKind() == stackKind;
return result;
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class AheadOfTimeCompilationTest method testStringObjectCommon.
private void testStringObjectCommon(boolean compileAOT) {
StructuredGraph result = compile("getStringObject", compileAOT);
NodeIterable<ConstantNode> filter = getConstantNodes(result);
assertDeepEquals(1, filter.count());
JavaConstant c = filter.first().asJavaConstant();
Assert.assertEquals(getSnippetReflection().asObject(String.class, c), "test string");
assertDeepEquals(0, result.getNodes().filter(FloatingReadNode.class).count());
assertDeepEquals(0, result.getNodes().filter(ReadNode.class).count());
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class AheadOfTimeCompilationTest method testBoxedBoolean.
@Test
public void testBoxedBoolean() {
StructuredGraph result = compile("getBoxedBoolean", false);
assertDeepEquals(0, result.getNodes().filter(FloatingReadNode.class).count());
assertDeepEquals(0, result.getNodes(PiNode.TYPE).count());
assertDeepEquals(1, getConstantNodes(result).count());
ConstantNode constant = getConstantNodes(result).first();
assertDeepEquals(JavaKind.Object, constant.getStackKind());
JavaConstant c = constant.asJavaConstant();
Assert.assertEquals(getSnippetReflection().asObject(Boolean.class, c), Boolean.TRUE);
}
use of jdk.vm.ci.meta.JavaConstant in project graal by oracle.
the class AMD64HotSpotSafepointOp method emitGlobalPoll.
private static void emitGlobalPoll(CompilationResultBuilder crb, AMD64MacroAssembler asm, GraalHotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) {
assert !atReturn || state == null : "state is unneeded at return";
if (ImmutableCode.getValue(crb.getOptions())) {
JavaKind hostWordKind = JavaKind.Long;
int alignment = hostWordKind.getBitCount() / Byte.SIZE;
JavaConstant pollingPageAddress = JavaConstant.forIntegerKind(hostWordKind, config.safepointPollingAddress);
// co-located with the immutable code.
if (GeneratePIC.getValue(crb.getOptions())) {
asm.movq(scratch, asm.getPlaceholder(-1));
} else {
asm.movq(scratch, (AMD64Address) crb.recordDataReferenceInCode(pollingPageAddress, alignment));
}
final int pos = asm.position();
crb.recordMark(atReturn ? config.MARKID_POLL_RETURN_FAR : config.MARKID_POLL_FAR);
if (state != null) {
crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
}
asm.testl(rax, new AMD64Address(scratch));
} else if (isPollingPageFar(config)) {
asm.movq(scratch, config.safepointPollingAddress);
crb.recordMark(atReturn ? config.MARKID_POLL_RETURN_FAR : config.MARKID_POLL_FAR);
final int pos = asm.position();
if (state != null) {
crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
}
asm.testl(rax, new AMD64Address(scratch));
} else {
crb.recordMark(atReturn ? config.MARKID_POLL_RETURN_NEAR : config.MARKID_POLL_NEAR);
final int pos = asm.position();
if (state != null) {
crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
}
// The C++ code transforms the polling page offset into an RIP displacement
// to the real address at that offset in the polling page.
asm.testl(rax, new AMD64Address(rip, 0));
}
}
Aggregations