Path: blob/master/src/hotspot/cpu/ppc/interp_masm_ppc.hpp
40930 views
/*1* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2012, 2021 SAP SE. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef CPU_PPC_INTERP_MASM_PPC_HPP26#define CPU_PPC_INTERP_MASM_PPC_HPP2728#include "asm/macroAssembler.hpp"29#include "interpreter/invocationCounter.hpp"3031// This file specializes the assembler with interpreter-specific macros.323334class InterpreterMacroAssembler: public MacroAssembler {3536public:37InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {}3839void null_check_throw(Register a, int offset, Register temp_reg);4041void jump_to_entry(address entry, Register Rscratch);4243// Handy address generation macros.44#define thread_(field_name) in_bytes(JavaThread::field_name ## _offset()), R16_thread45#define method_(field_name) in_bytes(Method::field_name ## _offset()), R19_method4647virtual void check_and_handle_popframe(Register scratch_reg);48virtual void check_and_handle_earlyret(Register scratch_reg);4950// Base routine for all dispatches.51void dispatch_base(TosState state, address* table);5253void load_earlyret_value(TosState state, Register Rscratch1);5455static const Address l_tmp;56static const Address d_tmp;5758// dispatch routines59void dispatch_next(TosState state, int step = 0, bool generate_poll = false);60void dispatch_via (TosState state, address* table);61void load_dispatch_table(Register dst, address* table);62void dispatch_Lbyte_code(TosState state, Register bytecode, address* table, bool generate_poll = false);6364// Called by shared interpreter generator.65void dispatch_prolog(TosState state, int step = 0);66void dispatch_epilog(TosState state, int step = 0);6768// Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls.69void super_call_VM_leaf(Register thread_cache, address entry_point, Register arg_1);70void super_call_VM(Register thread_cache, Register oop_result, Register last_java_sp,71address entry_point, Register arg_1, Register arg_2, bool check_exception = true);7273// Generate a subtype check: branch to ok_is_subtype if sub_klass is74// a subtype of super_klass. Blows registers tmp1, tmp2 and tmp3.75void gen_subtype_check(Register sub_klass, Register super_klass,76Register tmp1, Register tmp2, Register tmp3, Label &ok_is_subtype);7778// Load object from cpool->resolved_references(index).79void load_resolved_reference_at_index(Register result, Register index, Register tmp1, Register tmp2,80Label *L_handle_null = NULL);8182// load cpool->resolved_klass_at(index)83void load_resolved_klass_at_offset(Register Rcpool, Register Roffset, Register Rklass);8485void load_resolved_method_at_index(int byte_no, Register cache, Register method);8687void load_receiver(Register Rparam_count, Register Rrecv_dst);8889// helpers for expression stack90void pop_i( Register r = R17_tos);91void pop_ptr( Register r = R17_tos);92void pop_l( Register r = R17_tos);93void pop_f(FloatRegister f = F15_ftos);94void pop_d(FloatRegister f = F15_ftos );9596void push_i( Register r = R17_tos);97void push_ptr( Register r = R17_tos);98void push_l( Register r = R17_tos);99void push_f(FloatRegister f = F15_ftos );100void push_d(FloatRegister f = F15_ftos);101102void push_2ptrs(Register first, Register second);103104void move_l_to_d(Register l = R17_tos, FloatRegister d = F15_ftos);105void move_d_to_l(FloatRegister d = F15_ftos, Register l = R17_tos);106107void pop (TosState state); // transition vtos -> state108void push(TosState state); // transition state -> vtos109void empty_expression_stack(); // Resets both Lesp and SP.110111public:112// Load values from bytecode stream:113114enum signedOrNot { Signed, Unsigned };115enum setCCOrNot { set_CC, dont_set_CC };116117void get_2_byte_integer_at_bcp(int bcp_offset,118Register Rdst,119signedOrNot is_signed);120121void get_4_byte_integer_at_bcp(int bcp_offset,122Register Rdst,123signedOrNot is_signed = Unsigned);124125void get_cache_index_at_bcp(Register Rdst, int bcp_offset, size_t index_size);126127void get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size = sizeof(u2));128129void get_u4(Register Rdst, Register Rsrc, int offset, signedOrNot is_signed);130131// common code132133void field_offset_at(int n, Register tmp, Register dest, Register base);134int field_offset_at(Register object, address bcp, int offset);135void fast_iaaccess(int n, address bcp);136void fast_iaputfield(address bcp, bool do_store_check);137138void index_check(Register array, Register index, int index_shift, Register tmp, Register res);139void index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res);140141void get_const(Register Rdst);142void get_constant_pool(Register Rdst);143void get_constant_pool_cache(Register Rdst);144void get_cpool_and_tags(Register Rcpool, Register Rtags);145void is_a(Label& L);146147void narrow(Register result);148149// Java Call Helpers150void call_from_interpreter(Register Rtarget_method, Register Rret_addr, Register Rscratch1, Register Rscratch2);151152// --------------------------------------------------153154void unlock_if_synchronized_method(TosState state, bool throw_monitor_exception = true,155bool install_monitor_exception = true);156157// Removes the current activation (incl. unlocking of monitors).158// Additionally this code is used for earlyReturn in which case we159// want to skip throwing an exception and installing an exception.160void remove_activation(TosState state,161bool throw_monitor_exception = true,162bool install_monitor_exception = true);163void merge_frames(Register Rtop_frame_sp, Register return_pc, Register Rscratch1, Register Rscratch2); // merge top frames164165void add_monitor_to_stack(bool stack_is_empty, Register Rtemp1, Register Rtemp2);166167// Local variable access helpers168void load_local_int(Register Rdst_value, Register Rdst_address, Register Rindex);169void load_local_long(Register Rdst_value, Register Rdst_address, Register Rindex);170void load_local_ptr(Register Rdst_value, Register Rdst_address, Register Rindex);171void load_local_float(FloatRegister Rdst_value, Register Rdst_address, Register Rindex);172void load_local_double(FloatRegister Rdst_value, Register Rdst_address, Register Rindex);173void store_local_int(Register Rvalue, Register Rindex);174void store_local_long(Register Rvalue, Register Rindex);175void store_local_ptr(Register Rvalue, Register Rindex);176void store_local_float(FloatRegister Rvalue, Register Rindex);177void store_local_double(FloatRegister Rvalue, Register Rindex);178179// Call VM for std frames180// Special call VM versions that check for exceptions and forward exception181// via short cut (not via expensive forward exception stub).182void check_and_forward_exception(Register Rscratch1, Register Rscratch2);183void call_VM(Register oop_result, address entry_point, bool check_exceptions = true);184void call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions = true);185void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions = true);186void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions = true);187// Should not be used:188void call_VM(Register oop_result, Register last_java_sp, address entry_point, bool check_exceptions = true) {ShouldNotReachHere();}189void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, bool check_exceptions = true) {ShouldNotReachHere();}190void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, bool check_exceptions = true) {ShouldNotReachHere();}191void call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions = true) {ShouldNotReachHere();}192193Address first_local_in_stack();194195enum LoadOrStore { load, store };196void static_iload_or_store(int which_local, LoadOrStore direction, Register Rtmp);197void static_aload_or_store(int which_local, LoadOrStore direction, Register Rtmp);198void static_dload_or_store(int which_local, LoadOrStore direction);199200void save_interpreter_state(Register scratch);201void restore_interpreter_state(Register scratch, bool bcp_and_mdx_only = false);202203void increment_backedge_counter(const Register Rcounters, Register Rtmp, Register Rtmp2, Register Rscratch);204205void record_static_call_in_profile(Register Rentry, Register Rtmp);206void record_receiver_call_in_profile(Register Rklass, Register Rentry, Register Rtmp);207208void get_method_counters(Register method, Register Rcounters, Label& skip);209void increment_invocation_counter(Register iv_be_count, Register Rtmp1, Register Rtmp2_r0);210211// Object locking212void lock_object (Register lock_reg, Register obj_reg);213void unlock_object(Register lock_reg);214215// Interpreter profiling operations216void set_method_data_pointer_for_bcp();217void test_method_data_pointer(Label& zero_continue);218void verify_method_data_pointer();219220void set_mdp_data_at(int constant, Register value);221222void increment_mdp_data_at(int constant, Register counter_addr, Register Rbumped_count, bool decrement = false);223224void increment_mdp_data_at(Register counter_addr, Register Rbumped_count, bool decrement = false);225void increment_mdp_data_at(Register reg, int constant, Register scratch, Register Rbumped_count, bool decrement = false);226227void set_mdp_flag_at(int flag_constant, Register scratch);228void test_mdp_data_at(int offset, Register value, Label& not_equal_continue, Register test_out);229230void update_mdp_by_offset(int offset_of_disp, Register scratch);231void update_mdp_by_offset(Register reg, int offset_of_disp,232Register scratch);233void update_mdp_by_constant(int constant);234void update_mdp_for_ret(TosState state, Register return_bci);235236void profile_taken_branch(Register scratch, Register bumped_count);237void profile_not_taken_branch(Register scratch1, Register scratch2);238void profile_call(Register scratch1, Register scratch2);239void profile_final_call(Register scratch1, Register scratch2);240void profile_virtual_call(Register Rreceiver, Register Rscratch1, Register Rscratch2, bool receiver_can_be_null);241void profile_typecheck(Register Rklass, Register Rscratch1, Register Rscratch2);242void profile_typecheck_failed(Register Rscratch1, Register Rscratch2);243void profile_ret(TosState state, Register return_bci, Register scratch1, Register scratch2);244void profile_switch_default(Register scratch1, Register scratch2);245void profile_switch_case(Register index, Register scratch1,Register scratch2, Register scratch3);246void profile_null_seen(Register Rscratch1, Register Rscratch2);247void record_klass_in_profile(Register receiver, Register scratch1, Register scratch2, bool is_virtual_call);248void record_klass_in_profile_helper(Register receiver, Register scratch1, Register scratch2, int start_row, Label& done, bool is_virtual_call);249250// Argument and return type profiling.251void profile_obj_type(Register obj, Register mdo_addr_base, RegisterOrConstant mdo_addr_offs, Register tmp, Register tmp2);252void profile_arguments_type(Register callee, Register tmp1, Register tmp2, bool is_virtual);253void profile_return_type(Register ret, Register tmp1, Register tmp2);254void profile_parameters_type(Register tmp1, Register tmp2, Register tmp3, Register tmp4);255256// Debugging257void verify_oop(Register reg, TosState state = atos); // only if +VerifyOops && state == atos258void verify_oop_or_return_address(Register reg, Register rtmp); // for astore259void verify_FPU(int stack_depth, TosState state = ftos);260261typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;262263// Support for jvmdi/jvmpi.264void notify_method_entry();265void notify_method_exit(bool is_native_method, TosState state,266NotifyMethodExitMode mode, bool check_exceptions);267};268269#endif // CPU_PPC_INTERP_MASM_PPC_HPP270271272