From 06299adb2121ff3ee27a8ecb5fb2312bdf8080a2 Mon Sep 17 00:00:00 2001 From: never Date: Tue, 5 Apr 2011 00:31:09 -0700 Subject: [PATCH] 6777083: assert(target != __null,"must not be null") Reviewed-by: iveresov, kvn --- src/cpu/x86/vm/assembler_x86.hpp | 12 ++++++++++-- src/share/vm/code/relocInfo.cpp | 18 ++++++------------ src/share/vm/code/relocInfo.hpp | 10 ++++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/cpu/x86/vm/assembler_x86.hpp b/src/cpu/x86/vm/assembler_x86.hpp index 6ef01cbb4..2457f18bd 100644 --- a/src/cpu/x86/vm/assembler_x86.hpp +++ b/src/cpu/x86/vm/assembler_x86.hpp @@ -385,10 +385,18 @@ class OopAddress: public AddressLiteral { }; class ExternalAddress: public AddressLiteral { + private: + static relocInfo::relocType reloc_for_target(address target) { + // Sometimes ExternalAddress is used for values which aren't + // exactly addresses, like the card table base. + // external_word_type can't be used for values in the first page + // so just skip the reloc in that case. + return external_word_Relocation::can_be_relocated(target) ? relocInfo::external_word_type : relocInfo::none; + } - public: + public: - ExternalAddress(address target) : AddressLiteral(target, relocInfo::external_word_type){} + ExternalAddress(address target) : AddressLiteral(target, reloc_for_target(target)) {} }; diff --git a/src/share/vm/code/relocInfo.cpp b/src/share/vm/code/relocInfo.cpp index 0264f2060..7015dbc87 100644 --- a/src/share/vm/code/relocInfo.cpp +++ b/src/share/vm/code/relocInfo.cpp @@ -472,20 +472,14 @@ RelocationHolder Relocation::spec_simple(relocInfo::relocType rtype) { return itr._rh; } - -static inline bool is_index(intptr_t index) { - return 0 < index && index < os::vm_page_size(); -} - - int32_t Relocation::runtime_address_to_index(address runtime_address) { - assert(!is_index((intptr_t)runtime_address), "must not look like an index"); + assert(!is_reloc_index((intptr_t)runtime_address), "must not look like an index"); if (runtime_address == NULL) return 0; StubCodeDesc* p = StubCodeDesc::desc_for(runtime_address); if (p != NULL && p->begin() == runtime_address) { - assert(is_index(p->index()), "there must not be too many stubs"); + assert(is_reloc_index(p->index()), "there must not be too many stubs"); return (int32_t)p->index(); } else { // Known "miscellaneous" non-stub pointers: @@ -506,7 +500,7 @@ int32_t Relocation::runtime_address_to_index(address runtime_address) { address Relocation::index_to_runtime_address(int32_t index) { if (index == 0) return NULL; - if (is_index(index)) { + if (is_reloc_index(index)) { StubCodeDesc* p = StubCodeDesc::desc_for_index(index); assert(p != NULL, "there must be a stub for this index"); return p->begin(); @@ -634,7 +628,7 @@ void external_word_Relocation::pack_data_to(CodeSection* dest) { #ifndef _LP64 p = pack_1_int_to(p, index); #else - if (is_index(index)) { + if (is_reloc_index(index)) { p = pack_2_ints_to(p, index, 0); } else { jlong t = (jlong) _target; @@ -642,7 +636,7 @@ void external_word_Relocation::pack_data_to(CodeSection* dest) { int32_t hi = high(t); p = pack_2_ints_to(p, lo, hi); DEBUG_ONLY(jlong t1 = jlong_from(hi, lo)); - assert(!is_index(t1) && (address) t1 == _target, "not symmetric"); + assert(!is_reloc_index(t1) && (address) t1 == _target, "not symmetric"); } #endif /* _LP64 */ dest->set_locs_end((relocInfo*) p); @@ -656,7 +650,7 @@ void external_word_Relocation::unpack_data() { int32_t lo, hi; unpack_2_ints(lo, hi); jlong t = jlong_from(hi, lo);; - if (is_index(t)) { + if (is_reloc_index(t)) { _target = index_to_runtime_address(t); } else { _target = (address) t; diff --git a/src/share/vm/code/relocInfo.hpp b/src/share/vm/code/relocInfo.hpp index 7dc11fee0..013a4e61c 100644 --- a/src/share/vm/code/relocInfo.hpp +++ b/src/share/vm/code/relocInfo.hpp @@ -703,6 +703,10 @@ class Relocation VALUE_OBJ_CLASS_SPEC { assert(datalen()==0 || type()==relocInfo::none, "no data here"); } + static bool is_reloc_index(intptr_t index) { + return 0 < index && index < os::vm_page_size(); + } + protected: // Helper functions for pack_data_to() and unpack_data(). @@ -1127,6 +1131,12 @@ class external_word_Relocation : public DataRelocation { return rh; } + // Some address looking values aren't safe to treat as relocations + // and should just be treated as constants. + static bool can_be_relocated(address target) { + return target != NULL && !is_reloc_index((intptr_t)target); + } + private: address _target; // address in runtime -- GitLab