Path: blob/master/src/hotspot/cpu/arm/c1_FrameMap_arm.cpp
40930 views
/*1* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "c1/c1_FrameMap.hpp"26#include "c1/c1_LIR.hpp"27#include "runtime/sharedRuntime.hpp"28#include "vmreg_arm.inline.hpp"2930LIR_Opr FrameMap::R0_opr;31LIR_Opr FrameMap::R1_opr;32LIR_Opr FrameMap::R2_opr;33LIR_Opr FrameMap::R3_opr;34LIR_Opr FrameMap::R4_opr;35LIR_Opr FrameMap::R5_opr;3637LIR_Opr FrameMap::R0_oop_opr;38LIR_Opr FrameMap::R1_oop_opr;39LIR_Opr FrameMap::R2_oop_opr;40LIR_Opr FrameMap::R3_oop_opr;41LIR_Opr FrameMap::R4_oop_opr;42LIR_Opr FrameMap::R5_oop_opr;4344LIR_Opr FrameMap::R0_metadata_opr;45LIR_Opr FrameMap::R1_metadata_opr;46LIR_Opr FrameMap::R2_metadata_opr;47LIR_Opr FrameMap::R3_metadata_opr;48LIR_Opr FrameMap::R4_metadata_opr;49LIR_Opr FrameMap::R5_metadata_opr;505152LIR_Opr FrameMap::LR_opr;53LIR_Opr FrameMap::LR_oop_opr;54LIR_Opr FrameMap::LR_ptr_opr;55LIR_Opr FrameMap::FP_opr;56LIR_Opr FrameMap::SP_opr;57LIR_Opr FrameMap::Rthread_opr;5859LIR_Opr FrameMap::Int_result_opr;60LIR_Opr FrameMap::Long_result_opr;61LIR_Opr FrameMap::Object_result_opr;62LIR_Opr FrameMap::Float_result_opr;63LIR_Opr FrameMap::Double_result_opr;6465LIR_Opr FrameMap::Exception_oop_opr;66LIR_Opr FrameMap::Exception_pc_opr;6768LIR_Opr FrameMap::_caller_save_cpu_regs[] = { 0 };69LIR_Opr FrameMap::_caller_save_fpu_regs[]; // same as initialize to zero7071LIR_Opr FrameMap::map_to_opr(BasicType type, VMRegPair* reg, bool) {72LIR_Opr opr = LIR_OprFact::illegalOpr;73VMReg r_1 = reg->first();74VMReg r_2 = reg->second();75if (r_1->is_stack()) {76int st_off = (r_1->reg2stack() + SharedRuntime::out_preserve_stack_slots()) * VMRegImpl::stack_slot_size;77opr = LIR_OprFact::address(new LIR_Address(SP_opr, st_off, type));78} else if (r_1->is_Register()) {79Register reg = r_1->as_Register();80if (r_2->is_Register() && (type == T_LONG || type == T_DOUBLE)) {81opr = as_long_opr(reg, r_2->as_Register());82} else if (is_reference_type(type)) {83opr = as_oop_opr(reg);84} else if (type == T_METADATA) {85opr = as_metadata_opr(reg);86} else if (type == T_ADDRESS) {87opr = as_address_opr(reg);88} else {89// PreferInterpreterNativeStubs should ensure we never need to90// handle a long opr passed as R3+stack_slot91assert(! r_2->is_stack(), "missing support for ALIGN_WIDE_ARGUMENTS==0");92opr = as_opr(reg);93}94} else if (r_1->is_FloatRegister()) {95FloatRegister reg = r_1->as_FloatRegister();96opr = type == T_FLOAT ? as_float_opr(reg) : as_double_opr(reg);97} else {98ShouldNotReachHere();99}100return opr;101}102103104void FrameMap::initialize() {105if (_init_done) return;106107int i;108int rnum = 0;109110// Registers used for allocation111assert(Rthread == R10 && Rtemp == R12, "change the code here");112for (i = 0; i < 10; i++) {113map_register(rnum++, as_Register(i));114}115assert(rnum == pd_nof_cpu_regs_reg_alloc, "should be");116117// Registers not used for allocation118map_register(rnum++, LR); // LR register should be listed first, see c1_LinearScan_arm.hpp::is_processed_reg_num.119assert(rnum == pd_nof_cpu_regs_processed_in_linearscan, "should be");120121map_register(rnum++, Rtemp);122map_register(rnum++, Rthread);123map_register(rnum++, FP); // ARM32: R7 or R11124map_register(rnum++, SP);125map_register(rnum++, PC);126assert(rnum == pd_nof_cpu_regs_frame_map, "should be");127128_init_done = true;129130R0_opr = as_opr(R0); R0_oop_opr = as_oop_opr(R0); R0_metadata_opr = as_metadata_opr(R0);131R1_opr = as_opr(R1); R1_oop_opr = as_oop_opr(R1); R1_metadata_opr = as_metadata_opr(R1);132R2_opr = as_opr(R2); R2_oop_opr = as_oop_opr(R2); R2_metadata_opr = as_metadata_opr(R2);133R3_opr = as_opr(R3); R3_oop_opr = as_oop_opr(R3); R3_metadata_opr = as_metadata_opr(R3);134R4_opr = as_opr(R4); R4_oop_opr = as_oop_opr(R4); R4_metadata_opr = as_metadata_opr(R4);135R5_opr = as_opr(R5); R5_oop_opr = as_oop_opr(R5); R5_metadata_opr = as_metadata_opr(R5);136137138LR_opr = as_opr(LR);139LR_oop_opr = as_oop_opr(LR);140LR_ptr_opr = as_pointer_opr(LR);141FP_opr = as_pointer_opr(FP);142SP_opr = as_pointer_opr(SP);143Rthread_opr = as_pointer_opr(Rthread);144145// LIR operands for result146Int_result_opr = R0_opr;147Object_result_opr = R0_oop_opr;148Long_result_opr = as_long_opr(R0, R1);149#ifdef __ABI_HARD__150Float_result_opr = as_float_opr(S0);151Double_result_opr = as_double_opr(D0);152#else153Float_result_opr = LIR_OprFact::single_softfp(0);154Double_result_opr = LIR_OprFact::double_softfp(0, 1);155#endif // __ABI_HARD__156157Exception_oop_opr = as_oop_opr(Rexception_obj);158Exception_pc_opr = as_opr(Rexception_pc);159160for (i = 0; i < nof_caller_save_cpu_regs(); i++) {161_caller_save_cpu_regs[i] = LIR_OprFact::single_cpu(i);162}163for (i = 0; i < nof_caller_save_fpu_regs; i++) {164_caller_save_fpu_regs[i] = LIR_OprFact::single_fpu(i);165}166}167168169Address FrameMap::make_new_address(ByteSize sp_offset) const {170return Address(SP, sp_offset);171}172173LIR_Opr FrameMap::stack_pointer() {174return FrameMap::SP_opr;175}176177LIR_Opr FrameMap::method_handle_invoke_SP_save_opr() {178assert(Rmh_SP_save == FP, "Fix register used for saving SP for MethodHandle calls");179return FP_opr;180}181182bool FrameMap::validate_frame() {183int max_offset = in_bytes(framesize_in_bytes());184int java_index = 0;185for (int i = 0; i < _incoming_arguments->length(); i++) {186LIR_Opr opr = _incoming_arguments->at(i);187if (opr->is_stack()) {188int arg_offset = _argument_locations->at(java_index);189if (arg_offset > max_offset) {190max_offset = arg_offset;191}192}193java_index += type2size[opr->type()];194}195return max_offset < 4096;196}197198VMReg FrameMap::fpu_regname(int n) {199return as_FloatRegister(n)->as_VMReg();200}201202203