Mercurial > hg > graal-jvmci-8
changeset 18177:89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 27 Oct 2014 14:24:02 +0100 |
parents | c2270ad35f57 |
children | b9f31ed0643b |
files | src/share/vm/code/relocInfo.cpp src/share/vm/code/relocInfo.hpp src/share/vm/graal/graalCodeInstaller.cpp |
diffstat | 3 files changed, 41 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/code/relocInfo.cpp Mon Oct 27 14:07:49 2014 +0100 +++ b/src/share/vm/code/relocInfo.cpp Mon Oct 27 14:24:02 2014 +0100 @@ -30,6 +30,7 @@ #include "memory/resourceArea.hpp" #include "runtime/stubCodeGenerator.hpp" #include "utilities/copy.hpp" +#include "oops/oop.inline.hpp" PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC @@ -424,6 +425,30 @@ ShouldNotReachHere(); } +void Relocation::const_set_data_value(address x) { +#ifdef _LP64 + if (format() == relocInfo::narrow_oop_in_const) { + *(narrowOop*)addr() = oopDesc::encode_heap_oop((oop) x); + } else { +#endif + *(address*)addr() = x; +#ifdef _LP64 + } +#endif +} + +void Relocation::const_verify_data_value(address x) { +#ifdef _LP64 + if (format() == relocInfo::narrow_oop_in_const) { + assert(*(narrowOop*)addr() == oopDesc::encode_heap_oop((oop) x), "must agree"); + } else { +#endif + assert(*(address*)addr() == x, "must agree"); +#ifdef _LP64 + } +#endif +} + RelocationHolder Relocation::spec_simple(relocInfo::relocType rtype) { if (rtype == relocInfo::none) return RelocationHolder::none;
--- a/src/share/vm/code/relocInfo.hpp Mon Oct 27 14:07:49 2014 +0100 +++ b/src/share/vm/code/relocInfo.hpp Mon Oct 27 14:24:02 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, 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 @@ -446,6 +446,11 @@ }; public: enum { +#ifdef _LP64 + // for use in format + // format_width must be at least 1 on _LP64 + narrow_oop_in_const = 1, +#endif // Conservatively large estimate of maximum length (in shorts) // of any relocation record. // Extended format is length prefix, data words, and tag/offset suffix. @@ -765,6 +770,9 @@ } protected: + // platform-independent utility for patching constant section + void const_set_data_value (address x); + void const_verify_data_value (address x); // platform-dependent utilities for decoding and patching instructions void pd_set_data_value (address x, intptr_t off, bool verify_only = false); // a set or mem-ref void pd_verify_data_value (address x, intptr_t off) { pd_set_data_value(x, off, true); } @@ -875,13 +883,13 @@ void set_value(address x) { set_value(x, offset()); } void set_value(address x, intptr_t o) { if (addr_in_const()) - *(address*)addr() = x; + const_set_data_value(x); else pd_set_data_value(x, o); } void verify_value(address x) { if (addr_in_const()) - assert(*(address*)addr() == x, "must agree"); + const_verify_data_value(x); else pd_verify_data_value(x, offset()); }
--- a/src/share/vm/graal/graalCodeInstaller.cpp Mon Oct 27 14:07:49 2014 +0100 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Mon Oct 27 14:24:02 2014 +0100 @@ -580,7 +580,11 @@ address dest = _constants->start() + CompilationResult_Site::pcOffset(patch); if (HotSpotObjectConstant::compressed(constant)) { - fatal("unexpected compressed oop in data section"); +#ifdef _LP64 + _constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); +#else + fatal("unexpected compressed oop in 32-bit mode"); +#endif } else { _constants->relocate(dest, oop_Relocation::spec(oop_index)); }