aoqi@1: /* aoqi@1: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@1: * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved. aoqi@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@1: * aoqi@1: * This code is free software; you can redistribute it and/or modify it aoqi@1: * under the terms of the GNU General Public License version 2 only, as aoqi@1: * published by the Free Software Foundation. aoqi@1: * aoqi@1: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@1: * version 2 for more details (a copy is included in the LICENSE file that aoqi@1: * accompanied this code). aoqi@1: * aoqi@1: * You should have received a copy of the GNU General Public License version aoqi@1: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@1: * aoqi@1: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@1: * or visit www.oracle.com if you need additional information or have any aoqi@1: * questions. aoqi@1: * aoqi@1: */ aoqi@1: aoqi@1: #include "precompiled.hpp" aoqi@1: #include "asm/macroAssembler.hpp" aoqi@1: #include "asm/macroAssembler.inline.hpp" aoqi@1: #include "code/icBuffer.hpp" aoqi@1: #include "gc_interface/collectedHeap.inline.hpp" aoqi@1: #include "interpreter/bytecodes.hpp" aoqi@1: #include "memory/resourceArea.hpp" aoqi@1: #include "nativeInst_mips.hpp" aoqi@1: #include "oops/oop.inline.hpp" aoqi@1: #include "oops/oop.inline2.hpp" aoqi@1: aoqi@1: int InlineCacheBuffer::ic_stub_code_size() { aoqi@1: return NativeMovConstReg::instruction_size + aoqi@1: NativeGeneralJump::instruction_size + aoqi@1: 1; aoqi@1: // so that code_end can be set in CodeBuffer aoqi@1: // 64bit 15 = 6 + 8 bytes + 1 byte aoqi@1: // 32bit 7 = 2 + 4 bytes + 1 byte aoqi@1: } aoqi@1: aoqi@1: aoqi@1: // we use T1 as cached oop(klass) now. this is the target of virtual call, aoqi@1: // when reach here, the receiver in T0 aoqi@1: // refer to shareRuntime_mips.cpp,gen_i2c2i_adapters aoqi@1: void InlineCacheBuffer::assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point) { aoqi@1: ResourceMark rm; aoqi@1: CodeBuffer code(code_begin, ic_stub_code_size()); aoqi@1: MacroAssembler* masm = new MacroAssembler(&code); aoqi@1: // note: even though the code contains an embedded oop, we do not need reloc info aoqi@1: // because aoqi@1: // (1) the oop is old (i.e., doesn't matter for scavenges) aoqi@1: // (2) these ICStubs are removed *before* a GC happens, so the roots disappear aoqi@1: // assert(cached_oop == NULL || cached_oop->is_perm(), "must be perm oop"); aoqi@1: #define __ masm-> aoqi@1: #ifndef _LP64 aoqi@1: __ lui(T1, Assembler::split_high((int)cached_value)); aoqi@1: __ addiu(T1, T1, Assembler::split_low((int)cached_value)); aoqi@1: aoqi@1: __ lui(T9, Assembler::split_high((int)entry_point)); aoqi@1: __ addiu(T9, T9, Assembler::split_low((int)entry_point)); aoqi@1: #else aoqi@1: __ li48(T1, (long)cached_value); aoqi@1: aoqi@1: __ li48(T9, (long)entry_point); aoqi@1: #endif aoqi@1: __ jr(T9); aoqi@1: __ delayed()->nop(); aoqi@1: __ flush(); aoqi@1: #undef __ aoqi@1: } aoqi@1: aoqi@1: aoqi@1: address InlineCacheBuffer::ic_buffer_entry_point(address code_begin) { aoqi@1: NativeMovConstReg* move = nativeMovConstReg_at(code_begin); // creation also verifies the object aoqi@1: //NativeJump* jump = nativeJump_at(move->next_instruction_address()); aoqi@1: NativeGeneralJump* jump = nativeGeneralJump_at(move->next_instruction_address()); aoqi@1: return jump->jump_destination(); aoqi@1: } aoqi@1: aoqi@1: void* InlineCacheBuffer::ic_buffer_cached_value(address code_begin) { aoqi@1: // creation also verifies the object aoqi@1: NativeMovConstReg* move = nativeMovConstReg_at(code_begin); aoqi@1: // Verifies the jump aoqi@1: //NativeJump* jump = nativeJump_at(move->next_instruction_address()); aoqi@1: NativeGeneralJump* jump = nativeGeneralJump_at(move->next_instruction_address()); aoqi@1: void* o= (void*)move->data(); aoqi@1: return o; aoqi@1: }