8172310: [AOT] Fix unverified entry point

Fix AOT code for the unverified entry point

Reviewed-by: kvn
This commit is contained in:
Igor Veresov 2017-01-10 21:39:20 +03:00
parent 26a978276c
commit 5b9a2a728b
11 changed files with 50 additions and 17 deletions

View File

@ -397,6 +397,10 @@ public class BinaryContainer implements SymbolTable {
return "_aot_narrow_klass_base_address";
}
public String getNarrowOopBaseAddressSymbolName() {
return "_aot_narrow_oop_base_address";
}
public String getLogOfHeapRegionGrainBytesSymbolName() {
return "_aot_log_of_heap_region_grain_bytes";
}
@ -447,6 +451,7 @@ public class BinaryContainer implements SymbolTable {
createGotSymbol(getHeapTopAddressSymbolName());
createGotSymbol(getHeapEndAddressSymbolName());
createGotSymbol(getNarrowKlassBaseAddressSymbolName());
createGotSymbol(getNarrowOopBaseAddressSymbolName());
createGotSymbol(getPollingPageSymbolName());
createGotSymbol(getLogOfHeapRegionGrainBytesSymbolName());
createGotSymbol(getInlineContiguousAllocationSupportedSymbolName());

View File

@ -293,12 +293,18 @@ public class AOTCompiledClass {
// Record methods holder
methodInfo.addDependentKlassData(binaryContainer, resolvedJavaType);
// Record inlinee classes
for (ResolvedJavaMethod m : methodInfo.getCompilationResult().getMethods()) {
methodInfo.addDependentKlassData(binaryContainer, (HotSpotResolvedObjectType) m.getDeclaringClass());
ResolvedJavaMethod[] inlinees = methodInfo.getCompilationResult().getMethods();
if (inlinees != null) {
for (ResolvedJavaMethod m : inlinees) {
methodInfo.addDependentKlassData(binaryContainer, (HotSpotResolvedObjectType) m.getDeclaringClass());
}
}
// Record classes of fields that were accessed
for (ResolvedJavaField f : methodInfo.getCompilationResult().getFields()) {
methodInfo.addDependentKlassData(binaryContainer, (HotSpotResolvedObjectType) f.getDeclaringClass());
ResolvedJavaField[] fields = methodInfo.getCompilationResult().getFields();
if (fields != null) {
for (ResolvedJavaField f : fields) {
methodInfo.addDependentKlassData(binaryContainer, (HotSpotResolvedObjectType) f.getDeclaringClass());
}
}
}
}

View File

@ -48,6 +48,7 @@ enum MarkId {
HEAP_TOP_ADDRESS("CodeInstaller::HEAP_TOP_ADDRESS"),
HEAP_END_ADDRESS("CodeInstaller::HEAP_END_ADDRESS"),
NARROW_KLASS_BASE_ADDRESS("CodeInstaller::NARROW_KLASS_BASE_ADDRESS"),
NARROW_OOP_BASE_ADDRESS("CodeInstaller::NARROW_OOP_BASE_ADDRESS"),
CRC_TABLE_ADDRESS("CodeInstaller::CRC_TABLE_ADDRESS"),
LOG_OF_HEAP_REGION_GRAIN_BYTES("CodeInstaller::LOG_OF_HEAP_REGION_GRAIN_BYTES"),
INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED("CodeInstaller::INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED");

View File

@ -57,6 +57,7 @@ class MarkProcessor {
case HEAP_TOP_ADDRESS:
case HEAP_END_ADDRESS:
case NARROW_KLASS_BASE_ADDRESS:
case NARROW_OOP_BASE_ADDRESS:
case CRC_TABLE_ADDRESS:
case LOG_OF_HEAP_REGION_GRAIN_BYTES:
case INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED:
@ -78,6 +79,9 @@ class MarkProcessor {
case NARROW_KLASS_BASE_ADDRESS:
vmSymbolName = binaryContainer.getNarrowKlassBaseAddressSymbolName();
break;
case NARROW_OOP_BASE_ADDRESS:
vmSymbolName = binaryContainer.getNarrowOopBaseAddressSymbolName();
break;
case CRC_TABLE_ADDRESS:
vmSymbolName = binaryContainer.getCrcTableAddressSymbolName();
break;

View File

@ -267,10 +267,15 @@ public class AMD64HotSpotBackend extends HotSpotHostBackend {
if (config.useCompressedClassPointers) {
Register register = r10;
AMD64HotSpotMove.decodeKlassPointer(asm, register, providers.getRegisters().getHeapBaseRegister(), src, config.getKlassEncoding());
if (config.narrowKlassBase != 0) {
// The heap base register was destroyed above, so restore it
asm.movq(providers.getRegisters().getHeapBaseRegister(), config.narrowOopBase);
AMD64HotSpotMove.decodeKlassPointer(crb, asm, register, providers.getRegisters().getHeapBaseRegister(), src, config);
if (GeneratePIC.getValue()) {
asm.movq(providers.getRegisters().getHeapBaseRegister(), asm.getPlaceholder(-1));
crb.recordMark(config.MARKID_NARROW_OOP_BASE_ADDRESS);
} else {
if (config.narrowKlassBase != 0) {
// The heap base register was destroyed above, so restore it
asm.movq(providers.getRegisters().getHeapBaseRegister(), config.narrowOopBase);
}
}
asm.cmpq(inlineCacheKlass, register);
} else {

View File

@ -265,14 +265,21 @@ public class AMD64HotSpotMove {
}
}
public static void decodeKlassPointer(AMD64MacroAssembler masm, Register register, Register scratch, AMD64Address address, CompressEncoding encoding) {
public static void decodeKlassPointer(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register register, Register scratch, AMD64Address address, GraalHotSpotVMConfig config) {
CompressEncoding encoding = config.getKlassEncoding();
masm.movl(register, address);
if (encoding.shift != 0) {
assert encoding.alignment == encoding.shift : "Decode algorithm is wrong";
masm.shlq(register, encoding.alignment);
}
if (encoding.base != 0) {
masm.movq(scratch, encoding.base);
if (GeneratePIC.getValue() || encoding.base != 0) {
if (GeneratePIC.getValue()) {
masm.movq(scratch, masm.getPlaceholder(-1));
crb.recordMark(config.MARKID_NARROW_KLASS_BASE_ADDRESS);
} else {
assert encoding.base != 0;
masm.movq(scratch, encoding.base);
}
masm.addq(register, scratch);
}
}

View File

@ -773,9 +773,10 @@ public class GraalHotSpotVMConfig extends HotSpotVMConfigAccess {
public final int MARKID_HEAP_TOP_ADDRESS = getConstant("CodeInstaller::HEAP_TOP_ADDRESS", Integer.class, 17);
public final int MARKID_HEAP_END_ADDRESS = getConstant("CodeInstaller::HEAP_END_ADDRESS", Integer.class, 18);
public final int MARKID_NARROW_KLASS_BASE_ADDRESS = getConstant("CodeInstaller::NARROW_KLASS_BASE_ADDRESS", Integer.class, 19);
public final int MARKID_CRC_TABLE_ADDRESS = getConstant("CodeInstaller::CRC_TABLE_ADDRESS", Integer.class, 20);
public final int MARKID_LOG_OF_HEAP_REGION_GRAIN_BYTES = getConstant("CodeInstaller::LOG_OF_HEAP_REGION_GRAIN_BYTES", Integer.class, 21);
public final int MARKID_INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED = getConstant("CodeInstaller::INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED", Integer.class, 22);
public final int MARKID_NARROW_OOP_BASE_ADDRESS = getConstant("CodeInstaller::NARROW_OOP_BASE_ADDRESS", Integer.class, 20);
public final int MARKID_CRC_TABLE_ADDRESS = getConstant("CodeInstaller::CRC_TABLE_ADDRESS", Integer.class, 21);
public final int MARKID_LOG_OF_HEAP_REGION_GRAIN_BYTES = getConstant("CodeInstaller::LOG_OF_HEAP_REGION_GRAIN_BYTES", Integer.class, 22);
public final int MARKID_INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED = getConstant("CodeInstaller::INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED", Integer.class, 23);
// Checkstyle: resume

View File

@ -539,6 +539,7 @@ void AOTCodeHeap::link_global_lib_symbols() {
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_heap_end_address", address, (heap->supports_inline_contig_alloc() ? heap->end_addr() : NULL));
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_polling_page", address, os::get_polling_page());
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_narrow_klass_base_address", address, Universe::narrow_klass_base());
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_narrow_oop_base_address", address, Universe::narrow_oop_base());
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_log_of_heap_region_grain_bytes", int, HeapRegion::LogOfHRGrainBytes);
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_inline_contiguous_allocation_supported", bool, heap->supports_inline_contig_alloc());
link_shared_runtime_symbols();

View File

@ -1258,6 +1258,7 @@ void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, Handle site, T
case HEAP_TOP_ADDRESS:
case HEAP_END_ADDRESS:
case NARROW_KLASS_BASE_ADDRESS:
case NARROW_OOP_BASE_ADDRESS:
case CRC_TABLE_ADDRESS:
case LOG_OF_HEAP_REGION_GRAIN_BYTES:
case INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED:

View File

@ -133,9 +133,10 @@ private:
HEAP_TOP_ADDRESS = 17,
HEAP_END_ADDRESS = 18,
NARROW_KLASS_BASE_ADDRESS = 19,
CRC_TABLE_ADDRESS = 20,
LOG_OF_HEAP_REGION_GRAIN_BYTES = 21,
INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED = 22,
NARROW_OOP_BASE_ADDRESS = 20,
CRC_TABLE_ADDRESS = 21,
LOG_OF_HEAP_REGION_GRAIN_BYTES = 22,
INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED = 23,
INVOKE_INVALID = -1
};

View File

@ -429,6 +429,7 @@
declare_constant(CodeInstaller::HEAP_TOP_ADDRESS) \
declare_constant(CodeInstaller::HEAP_END_ADDRESS) \
declare_constant(CodeInstaller::NARROW_KLASS_BASE_ADDRESS) \
declare_constant(CodeInstaller::NARROW_OOP_BASE_ADDRESS) \
declare_constant(CodeInstaller::CRC_TABLE_ADDRESS) \
declare_constant(CodeInstaller::LOG_OF_HEAP_REGION_GRAIN_BYTES) \
declare_constant(CodeInstaller::INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED) \