# HG changeset patch # User amurillo # Date 1455837579 28800 # Node ID b382ba2f07de13ff013d33c289f7fdf1bd1c76ad # Parent 1c076468bf7dad5b8f2ee5dcf66e2279caa3e208# Parent 65f01ec9666f179c70ba32a303222251dc634972 Merge diff -r 1c076468bf7d -r b382ba2f07de hotspot/.hgignore --- a/hotspot/.hgignore Wed Jul 05 21:22:47 2017 +0200 +++ b/hotspot/.hgignore Thu Feb 18 15:19:39 2016 -0800 @@ -10,7 +10,6 @@ .igv.log ^.hgtip .DS_Store -\.class$ ^\.mx.jvmci/env ^\.mx.jvmci/.*\.pyc ^\.mx.jvmci/eclipse-launches/.* diff -r 1c076468bf7d -r b382ba2f07de hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp --- a/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp Wed Jul 05 21:22:47 2017 +0200 +++ b/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp Thu Feb 18 15:19:39 2016 -0800 @@ -54,6 +54,7 @@ define_pd_global(intx, InteriorEntryAlignment, 16); define_pd_global(intx, NewSizeThreadIncrease, ScaleForWordSize(4*K)); define_pd_global(intx, LoopUnrollLimit, 60); +define_pd_global(intx, LoopPercentProfileLimit, 10); // InitialCodeCacheSize derived from specjbb2000 run. define_pd_global(intx, InitialCodeCacheSize, 2496*K); // Integral multiple of CodeCacheExpansionSize define_pd_global(intx, CodeCacheExpansionSize, 64*K); diff -r 1c076468bf7d -r b382ba2f07de hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp --- a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp Wed Jul 05 21:22:47 2017 +0200 +++ b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp Thu Feb 18 15:19:39 2016 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,7 +32,6 @@ // Sets the default values for platform dependent flags used by the runtime system. // (see globals.hpp) -define_pd_global(bool, ConvertSleepToYield, true); define_pd_global(bool, ShareVtableStubs, true); define_pd_global(bool, NeedsDeoptSuspend, false); // only register window machines need this diff -r 1c076468bf7d -r b382ba2f07de hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp --- a/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp Wed Jul 05 21:22:47 2017 +0200 +++ b/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp Thu Feb 18 15:19:39 2016 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -30,39 +30,151 @@ #include "vmreg_aarch64.inline.hpp" jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, Handle method, TRAPS) { - Unimplemented(); - return 0; + if (inst->is_call() || inst->is_jump() || inst->is_blr()) { + return pc_offset + NativeCall::instruction_size; + } else if (inst->is_general_jump()) { + return pc_offset + NativeGeneralJump::instruction_size; + } else { + JVMCI_ERROR_0("unsupported type of instruction for call site"); + } } void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) { - Unimplemented(); + address pc = _instructions->start() + pc_offset; + Handle obj = HotSpotObjectConstantImpl::object(constant); + jobject value = JNIHandles::make_local(obj()); + if (HotSpotObjectConstantImpl::compressed(constant)) { + int oop_index = _oop_recorder->find_index(value); + RelocationHolder rspec = oop_Relocation::spec(oop_index); + _instructions->relocate(pc, rspec, 1); + Unimplemented(); + } else { + NativeMovConstReg* move = nativeMovConstReg_at(pc); + move->set_data((intptr_t) value); + int oop_index = _oop_recorder->find_index(value); + RelocationHolder rspec = oop_Relocation::spec(oop_index); + _instructions->relocate(pc, rspec); + } } void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) { - Unimplemented(); + address pc = _instructions->start() + pc_offset; + if (HotSpotMetaspaceConstantImpl::compressed(constant)) { + narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK); + TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop); + Unimplemented(); + } else { + NativeMovConstReg* move = nativeMovConstReg_at(pc); + Metadata* reference = record_metadata_reference(constant, CHECK); + move->set_data((intptr_t) reference); + TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference)); + } } -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) { - Unimplemented(); +void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS) { + address pc = _instructions->start() + pc_offset; + NativeInstruction* inst = nativeInstruction_at(pc); + if (inst->is_adr_aligned()) { + address dest = _constants->start() + data_offset; + _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS)); + TRACE_jvmci_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset); + } else { + JVMCI_ERROR("unknown load or move instruction at " PTR_FORMAT, p2i(pc)); + } } void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS) { - Unimplemented(); + address pc = (address) inst; + if (inst->is_call()) { + NativeCall* call = nativeCall_at(pc); + call->set_destination((address) foreign_call_destination); + _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec()); + } else if (inst->is_jump()) { + NativeJump* jump = nativeJump_at(pc); + jump->set_jump_destination((address) foreign_call_destination); + _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); + } else if (inst->is_general_jump()) { + NativeGeneralJump* jump = nativeGeneralJump_at(pc); + jump->set_jump_destination((address) foreign_call_destination); + _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); + } else { + JVMCI_ERROR("unknown call or jump instruction at " PTR_FORMAT, p2i(pc)); + } + TRACE_jvmci_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst)); } void CodeInstaller::pd_relocate_JavaMethod(Handle hotspot_method, jint pc_offset, TRAPS) { - Unimplemented(); +#ifdef ASSERT + Method* method = NULL; + // we need to check, this might also be an unresolved method + if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) { + method = getMethodFromHotSpotMethod(hotspot_method()); + } +#endif + switch (_next_call_type) { + case INLINE_INVOKE: + break; + case INVOKEVIRTUAL: + case INVOKEINTERFACE: { + assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); + NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); + call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); + _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); + break; + } + case INVOKESTATIC: { + assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); + NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); + call->set_destination(SharedRuntime::get_resolve_static_call_stub()); + _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); + break; + } + case INVOKESPECIAL: { + assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); + NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); + call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); + _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); + break; + } + default: + JVMCI_ERROR("invalid _next_call_type value"); + break; + } } void CodeInstaller::pd_relocate_poll(address pc, jint mark, TRAPS) { - Unimplemented(); + switch (mark) { + case POLL_NEAR: + JVMCI_ERROR("unimplemented"); + break; + case POLL_FAR: + _instructions->relocate(pc, relocInfo::poll_type); + break; + case POLL_RETURN_NEAR: + JVMCI_ERROR("unimplemented"); + break; + case POLL_RETURN_FAR: + _instructions->relocate(pc, relocInfo::poll_return_type); + break; + default: + JVMCI_ERROR("invalid mark value"); + break; + } } // convert JVMCI register indices (as used in oop maps) to HotSpot registers VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, TRAPS) { - return NULL; + if (jvmci_reg < RegisterImpl::number_of_registers) { + return as_Register(jvmci_reg)->as_VMReg(); + } else { + jint floatRegisterNumber = jvmci_reg - RegisterImpl::number_of_registers; + if (floatRegisterNumber < FloatRegisterImpl::number_of_registers) { + return as_FloatRegister(floatRegisterNumber)->as_VMReg(); + } + JVMCI_ERROR_NULL("invalid register number: %d", jvmci_reg); + } } bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { - return false; + return !hotspotRegister->is_FloatRegister(); } diff -r 1c076468bf7d -r b382ba2f07de hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp --- a/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp Wed Jul 05 21:22:47 2017 +0200 +++ b/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp Thu Feb 18 15:19:39 2016 -0800 @@ -136,7 +136,7 @@ MacroAssembler::pd_patch_instruction(instruction_address(), (address)x); ICache::invalidate_range(instruction_address(), instruction_size); } -}; +} void NativeMovConstReg::print() { tty->print_cr(PTR_FORMAT ": mov reg, " INTPTR_FORMAT, @@ -208,6 +208,32 @@ //------------------------------------------------------------------- +address NativeGeneralJump::jump_destination() const { + NativeMovConstReg* move = nativeMovConstReg_at(instruction_address()); + address dest = (address) move->data(); + + // We use jump to self as the unresolved address which the inline + // cache code (and relocs) know about + + // return -1 if jump to self + dest = (dest == (address) this) ? (address) -1 : dest; + return dest; +} + +void NativeGeneralJump::set_jump_destination(address dest) { + NativeMovConstReg* move = nativeMovConstReg_at(instruction_address()); + + // We use jump to self as the unresolved address which the inline + // cache code (and relocs) know about + if (dest == (address) -1) { + dest = instruction_address(); + } + + move->set_data((uintptr_t) dest); +}; + +//------------------------------------------------------------------- + bool NativeInstruction::is_safepoint_poll() { // a safepoint_poll is implemented in two steps as either // @@ -249,6 +275,22 @@ Instruction_aarch64::extract(insn, 4, 0) == 0b11111); } +bool NativeInstruction::is_general_jump() { + if (is_movz()) { + NativeInstruction* inst1 = nativeInstruction_at(addr_at(instruction_size * 1)); + if (inst1->is_movk()) { + NativeInstruction* inst2 = nativeInstruction_at(addr_at(instruction_size * 2)); + if (inst2->is_movk()) { + NativeInstruction* inst3 = nativeInstruction_at(addr_at(instruction_size * 3)); + if (inst3->is_blr()) { + return true; + } + } + } + } + return false; +} + bool NativeInstruction::is_movz() { return Instruction_aarch64::extract(int_at(0), 30, 23) == 0b10100101; } diff -r 1c076468bf7d -r b382ba2f07de hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.hpp --- a/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.hpp Wed Jul 05 21:22:47 2017 +0200 +++ b/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.hpp Thu Feb 18 15:19:39 2016 -0800 @@ -54,11 +54,22 @@ friend class Relocation; friend bool is_NativeCallTrampolineStub_at(address); public: - enum { instruction_size = 4 }; + enum { + instruction_size = 4 + }; + + juint encoding() const { + return uint_at(0); + } + + bool is_blr() const { return (encoding() & 0xfffffc1f) == 0xd63f0000; } + bool is_adr_aligned() const { return (encoding() & 0xff000000) == 0x10000000; } // adr Xn,