Path: blob/master/src/hotspot/cpu/s390/interp_masm_s390.hpp
40930 views
/*1* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2016, 2017 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_S390_INTERP_MASM_S390_HPP26#define CPU_S390_INTERP_MASM_S390_HPP2728#include "asm/macroAssembler.hpp"29#include "interpreter/invocationCounter.hpp"3031// This file specializes the assember with interpreter-specific macros.3233class InterpreterMacroAssembler: public MacroAssembler {3435protected:36// Interpreter specific version of call_VM_base().37virtual void call_VM_leaf_base(address entry_point);38virtual void call_VM_leaf_base(address entry_point, bool allow_relocation);3940virtual void call_VM_base(Register oop_result,41Register last_java_sp,42address entry_point,43bool check_exceptions);44virtual void call_VM_base(Register oop_result,45Register last_java_sp,46address entry_point,47bool allow_relocation,48bool check_exceptions);4950// Base routine for all dispatches.51void dispatch_base(TosState state, address* table, bool generate_poll = false);5253public:54InterpreterMacroAssembler(CodeBuffer* c)55: MacroAssembler(c) {}5657virtual void check_and_handle_popframe(Register java_thread);58virtual void check_and_handle_earlyret(Register java_thread);5960void jump_to_entry(address entry, Register Rscratch);6162virtual void load_earlyret_value(TosState state);6364static const Address l_tmp;65static const Address d_tmp;6667// Handy address generation macros.68#define thread_(field_name) Address(Z_thread, JavaThread::field_name ## _offset())69#define method_(field_name) Address(Z_method, Method::field_name ## _offset())70#define method2_(Rmethod, field_name) Address(Rmethod, Method::field_name ## _offset())7172// Helper routine for frame allocation/deallocation.73// Compute the delta by which the caller's SP has to74// be adjusted to accomodate for the non-argument locals.75void compute_extra_locals_size_in_bytes(Register args_size, Register locals_size, Register delta);7677// dispatch routines78void dispatch_prolog(TosState state, int step = 0);79void dispatch_epilog(TosState state, int step = 0);80void dispatch_only(TosState state, bool generate_poll = false);81// Dispatch normal table via Z_bytecode (assume Z_bytecode is loaded already).82void dispatch_only_normal(TosState state);83void dispatch_normal(TosState state);84void dispatch_next(TosState state, int step = 0, bool generate_poll = false);85void dispatch_next_noverify_oop(TosState state, int step = 0);86void dispatch_via(TosState state, address* table);8788void narrow(Register result, Register ret_type);8990// Jump to an invoked target.91void prepare_to_jump_from_interpreted(Register method);92void jump_from_interpreted(Register method, Register temp);9394// Removes the current activation (incl. unlocking of monitors).95// Additionally this code is used for earlyReturn in which case we96// want to skip throwing an exception and installing an exception.97void remove_activation(TosState state,98Register return_pc,99bool throw_monitor_exception = true,100bool install_monitor_exception = true,101bool notify_jvmti = true);102103public:104// Super call_VM calls - correspond to MacroAssembler::call_VM(_leaf) calls.105void super_call_VM_leaf(address entry_point, Register arg_1, Register arg_2);106void super_call_VM(Register thread_cache, Register oop_result, Register last_java_sp,107address entry_point, Register arg_1, Register arg_2, bool check_exception = true);108109// Generate a subtype check: branch to ok_is_subtype if sub_klass is110// a subtype of super_klass. Blows registers tmp1, tmp2 and tmp3.111void gen_subtype_check(Register sub_klass, Register super_klass, Register tmp1, Register tmp2, Label &ok_is_subtype);112113void get_cache_and_index_at_bcp(Register cache, Register cpe_offset, int bcp_offset, size_t index_size = sizeof(u2));114void get_cache_and_index_and_bytecode_at_bcp(Register cache, Register cpe_offset, Register bytecode,115int byte_no, int bcp_offset, size_t index_size = sizeof(u2));116void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2));117void get_cache_index_at_bcp(Register index, int bcp_offset, size_t index_size = sizeof(u2));118void load_resolved_reference_at_index(Register result, Register index);119// load cpool->resolved_klass_at(index)120void load_resolved_klass_at_offset(Register cpool, Register offset, Register iklass);121122void load_resolved_method_at_index(int byte_no, Register cache, Register cpe_offset, Register method);123124// Pop topmost element from stack. It just disappears. Useful if125// consumed previously by access via stackTop().126void popx(int len);127void pop_i() { popx(1); }128void pop_ptr() { popx(1); }129void pop_l() { popx(2); }130void pop_f() { popx(1); }131void pop_d() { popx(2); }132// Get Address object of stack top. No checks. No pop.133// Purpose: provide address of stack operand to exploit reg-mem operations.134// Avoid RISC-like mem2reg - reg-reg-op sequence.135Address stackTop();136137// Helpers for expression stack.138void pop_i( Register r);139void pop_ptr( Register r);140void pop_l( Register r);141void pop_f(FloatRegister f);142void pop_d(FloatRegister f);143144void push_i( Register r = Z_tos);145void push_ptr( Register r = Z_tos);146void push_l( Register r = Z_tos);147void push_f(FloatRegister f = Z_ftos);148void push_d(FloatRegister f = Z_ftos);149150// Helpers for swap and dup.151void load_ptr(int n, Register val);152void store_ptr(int n, Register val);153154void pop (TosState state); // transition vtos -> state155void push(TosState state); // transition state -> vtos156void empty_expression_stack(void);157158#ifdef ASSERT159void verify_sp(Register Rsp, Register Rtemp);160void verify_esp(Register Resp, Register Rtemp); // Verify that Resp points to a word in the operand stack.161#endif // ASSERT162163public:164void if_cmp(Condition cc, bool ptr_compare);165166// Accessors to the template interpreter state.167168void asm_assert_ijava_state_magic(Register tmp) PRODUCT_RETURN;169170void save_bcp();171172void restore_bcp();173174void save_esp();175176void restore_esp();177178void get_monitors(Register reg);179180void save_monitors(Register reg);181182void get_mdp(Register mdp);183184void save_mdp(Register mdp);185186// Values that are only read (besides initialization).187void restore_locals();188189void get_method(Register reg);190191// Load values from bytecode stream:192193enum signedOrNot { Signed, Unsigned };194enum setCCOrNot { set_CC, dont_set_CC };195196void get_2_byte_integer_at_bcp(Register Rdst,197int bcp_offset,198signedOrNot is_signed );199200void get_4_byte_integer_at_bcp(Register Rdst,201int bcp_offset,202setCCOrNot should_set_CC = dont_set_CC);203204// common code205206void field_offset_at(int n, Register tmp, Register dest, Register base);207int field_offset_at(Register object, address bcp, int offset);208void fast_iaaccess(int n, address bcp);209void fast_iaputfield(address bcp, bool do_store_check);210211void index_check(Register array, Register index, int index_shift, Register tmp, Register res);212void index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res);213214void get_constant_pool(Register Rdst);215void get_constant_pool_cache(Register Rdst);216void get_cpool_and_tags(Register Rcpool, Register Rtags);217void is_a(Label& L);218219220// --------------------------------------------------221222void unlock_if_synchronized_method(TosState state, bool throw_monitor_exception = true, bool install_monitor_exception = true);223224void add_monitor_to_stack(bool stack_is_empty,225Register Rtemp,226Register Rtemp2,227Register Rtemp3);228229void access_local_int(Register index, Register dst);230void access_local_ptr(Register index, Register dst);231void access_local_long(Register index, Register dst);232void access_local_float(Register index, FloatRegister dst);233void access_local_double(Register index, FloatRegister dst);234#ifdef ASSERT235void check_for_regarea_stomp(Register Rindex, int offset, Register Rlimit, Register Rscratch, Register Rscratch1);236#endif // ASSERT237void store_local_int(Register index, Register src);238void store_local_ptr(Register index, Register src);239void store_local_long(Register index, Register src);240void store_local_float(Register index, FloatRegister src);241void store_local_double(Register index, FloatRegister src);242243244Address first_local_in_stack();245static int top_most_monitor_byte_offset(); // Offset in bytes to top of monitor block.246Address top_most_monitor();247void compute_stack_base(Register Rdest);248249enum LoadOrStore { load, store };250void static_iload_or_store(int which_local, LoadOrStore direction, Register Rtmp);251void static_aload_or_store(int which_local, LoadOrStore direction, Register Rtmp);252void static_dload_or_store(int which_local, LoadOrStore direction);253254void static_iinc( int which_local, jint increment, Register Rtmp, Register Rtmp2);255256void get_method_counters(Register Rmethod, Register Rcounters, Label& skip);257void increment_invocation_counter(Register Rcounters, Register RctrSum);258void increment_backedge_counter(Register Rcounters, Register RctrSum);259void test_backedge_count_for_osr(Register backedge_count, Register branch_bcp, Register Rtmp);260261void record_static_call_in_profile(Register Rentry, Register Rtmp);262void record_receiver_call_in_profile(Register Rklass, Register Rentry, Register Rtmp);263264// Object locking265void lock_object (Register lock_reg, Register obj_reg);266void unlock_object(Register lock_reg, Register obj_reg=noreg);267268// Interpreter profiling operations269void set_method_data_pointer_for_bcp();270void test_method_data_pointer(Register mdp, Label& zero_continue);271void verify_method_data_pointer();272273void set_mdp_data_at(Register mdp_in, int constant, Register value);274void increment_mdp_data_at(Register mdp_in, int constant,275Register tmp = Z_R1_scratch, bool decrement = false);276void increment_mask_and_jump(Address counter_addr,277int increment, Address mask,278Register scratch, bool preloaded,279branch_condition cond, Label* where);280void set_mdp_flag_at(Register mdp_in, int flag_constant);281void test_mdp_data_at(Register mdp_in, int offset, Register value,282Register test_value_out,283Label& not_equal_continue);284285void record_klass_in_profile(Register receiver, Register mdp,286Register reg2, bool is_virtual_call);287void record_klass_in_profile_helper(Register receiver, Register mdp,288Register reg2, int start_row,289Label& done, bool is_virtual_call);290291void update_mdp_by_offset(Register mdp_in, int offset_of_offset);292void update_mdp_by_offset(Register mdp_in, Register dataidx, int offset_of_disp);293void update_mdp_by_constant(Register mdp_in, int constant);294void update_mdp_for_ret(Register return_bci);295296void profile_taken_branch(Register mdp, Register bumped_count);297void profile_not_taken_branch(Register mdp);298void profile_call(Register mdp);299void profile_final_call(Register mdp);300void profile_virtual_call(Register receiver, Register mdp,301Register scratch2,302bool receiver_can_be_null = false);303void profile_ret(Register return_bci, Register mdp);304void profile_null_seen(Register mdp);305void profile_typecheck(Register mdp, Register klass, Register scratch);306void profile_typecheck_failed(Register mdp, Register tmp);307void profile_switch_default(Register mdp);308void profile_switch_case(Register index_in_scratch, Register mdp,309Register scratch1, Register scratch2);310311void profile_obj_type(Register obj, Address mdo_addr, Register klass, bool cmp_done = false);312void profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual);313void profile_return_type(Register mdp, Register ret, Register tmp);314void profile_parameters_type(Register mdp, Register tmp1, Register tmp2);315316// Debugging317void verify_oop(Register reg, TosState state = atos); // Only if +VerifyOops && state == atos.318void verify_oop_or_return_address(Register reg, Register rtmp); // for astore319void verify_FPU(int stack_depth, TosState state = ftos);320321// JVMTI helpers322void skip_if_jvmti_mode(Label &Lskip, Register Rscratch = Z_R0);323324// support for JVMTI/Dtrace325typedef enum { NotifyJVMTI, SkipNotifyJVMTI } NotifyMethodExitMode;326void notify_method_entry();327void notify_method_exit(bool native_method, TosState state, NotifyMethodExitMode mode);328329// Pop the topmost TOP_IJAVA_FRAME and set it's sender_sp as new Z_SP.330// The return pc is loaded into the Register return_pc.331void pop_interpreter_frame(Register return_pc, Register tmp1, Register tmp2);332};333334#endif // CPU_S390_INTERP_MASM_S390_HPP335336337