Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp
32285 views
/*1* Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2012, 2017 SAP AG. 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_VM_MACROASSEMBLER_PPC_HPP26#define CPU_PPC_VM_MACROASSEMBLER_PPC_HPP2728#include "asm/assembler.hpp"2930// MacroAssembler extends Assembler by a few frequently used macros.3132class ciTypeArray;3334class MacroAssembler: public Assembler {35public:36MacroAssembler(CodeBuffer* code) : Assembler(code) {}3738//39// Optimized instruction emitters40//4142inline static int largeoffset_si16_si16_hi(int si31) { return (si31 + (1<<15)) >> 16; }43inline static int largeoffset_si16_si16_lo(int si31) { return si31 - (((si31 + (1<<15)) >> 16) << 16); }4445// load d = *[a+si31]46// Emits several instructions if the offset is not encodable in one instruction.47void ld_largeoffset_unchecked(Register d, int si31, Register a, int emit_filler_nop);48void ld_largeoffset (Register d, int si31, Register a, int emit_filler_nop);49inline static bool is_ld_largeoffset(address a);50inline static int get_ld_largeoffset_offset(address a);5152inline void round_to(Register r, int modulus);5354// Load/store with type given by parameter.55void load_sized_value( Register dst, RegisterOrConstant offs, Register base, size_t size_in_bytes, bool is_signed);56void store_sized_value(Register dst, RegisterOrConstant offs, Register base, size_t size_in_bytes);5758// Move register if destination register and target register are different59inline void mr_if_needed(Register rd, Register rs);60inline void fmr_if_needed(FloatRegister rd, FloatRegister rs);61// This is dedicated for emitting scheduled mach nodes. For better62// readability of the ad file I put it here.63// Endgroups are not needed if64// - the scheduler is off65// - the scheduler found that there is a natural group end, in that66// case it reduced the size of the instruction used in the test67// yielding 'needed'.68inline void endgroup_if_needed(bool needed);6970// Memory barriers.71inline void membar(int bits);72inline void release();73inline void acquire();74inline void fence();7576// nop padding77void align(int modulus, int max = 252, int rem = 0);7879//80// Constants, loading constants, TOC support81//8283// Address of the global TOC.84inline static address global_toc();85// Offset of given address to the global TOC.86inline static int offset_to_global_toc(const address addr);8788// Address of TOC of the current method.89inline address method_toc();90// Offset of given address to TOC of the current method.91inline int offset_to_method_toc(const address addr);9293// Global TOC.94void calculate_address_from_global_toc(Register dst, address addr,95bool hi16 = true, bool lo16 = true,96bool add_relocation = true, bool emit_dummy_addr = false);97inline void calculate_address_from_global_toc_hi16only(Register dst, address addr) {98calculate_address_from_global_toc(dst, addr, true, false);99};100inline void calculate_address_from_global_toc_lo16only(Register dst, address addr) {101calculate_address_from_global_toc(dst, addr, false, true);102};103104inline static bool is_calculate_address_from_global_toc_at(address a, address bound);105static int patch_calculate_address_from_global_toc_at(address a, address addr, address bound);106static address get_address_of_calculate_address_from_global_toc_at(address a, address addr);107108#ifdef _LP64109// Patch narrow oop constant.110inline static bool is_set_narrow_oop(address a, address bound);111static int patch_set_narrow_oop(address a, address bound, narrowOop data);112static narrowOop get_narrow_oop(address a, address bound);113#endif114115inline static bool is_load_const_at(address a);116117// Emits an oop const to the constant pool, loads the constant, and118// sets a relocation info with address current_pc.119void load_const_from_method_toc(Register dst, AddressLiteral& a, Register toc);120void load_toc_from_toc(Register dst, AddressLiteral& a, Register toc) {121assert(dst == R2_TOC, "base register must be TOC");122load_const_from_method_toc(dst, a, toc);123}124125static bool is_load_const_from_method_toc_at(address a);126static int get_offset_of_load_const_from_method_toc_at(address a);127128// Get the 64 bit constant from a `load_const' sequence.129static long get_const(address load_const);130131// Patch the 64 bit constant of a `load_const' sequence. This is a132// low level procedure. It neither flushes the instruction cache nor133// is it atomic.134static void patch_const(address load_const, long x);135136// Metadata in code that we have to keep track of.137AddressLiteral allocate_metadata_address(Metadata* obj); // allocate_index138AddressLiteral constant_metadata_address(Metadata* obj); // find_index139// Oops used directly in compiled code are stored in the constant pool,140// and loaded from there.141// Allocate new entry for oop in constant pool. Generate relocation.142AddressLiteral allocate_oop_address(jobject obj);143// Find oop obj in constant pool. Return relocation with it's index.144AddressLiteral constant_oop_address(jobject obj);145146// Find oop in constant pool and emit instructions to load it.147// Uses constant_oop_address.148inline void set_oop_constant(jobject obj, Register d);149// Same as load_address.150inline void set_oop (AddressLiteral obj_addr, Register d);151152// Read runtime constant: Issue load if constant not yet established,153// else use real constant.154virtual RegisterOrConstant delayed_value_impl(intptr_t* delayed_value_addr,155Register tmp,156int offset);157158//159// branch, jump160//161162inline void pd_patch_instruction(address branch, address target);163NOT_PRODUCT(static void pd_print_patched_instruction(address branch);)164165// Conditional far branch for destinations encodable in 24+2 bits.166// Same interface as bc, e.g. no inverse boint-field.167enum {168bc_far_optimize_not = 0,169bc_far_optimize_on_relocate = 1170};171// optimize: flag for telling the conditional far branch to optimize172// itself when relocated.173void bc_far(int boint, int biint, Label& dest, int optimize);174// Relocation of conditional far branches.175static bool is_bc_far_at(address instruction_addr);176static address get_dest_of_bc_far_at(address instruction_addr);177static void set_dest_of_bc_far_at(address instruction_addr, address dest);178private:179static bool inline is_bc_far_variant1_at(address instruction_addr);180static bool inline is_bc_far_variant2_at(address instruction_addr);181static bool inline is_bc_far_variant3_at(address instruction_addr);182public:183184// Convenience bc_far versions.185inline void blt_far(ConditionRegister crx, Label& L, int optimize);186inline void bgt_far(ConditionRegister crx, Label& L, int optimize);187inline void beq_far(ConditionRegister crx, Label& L, int optimize);188inline void bso_far(ConditionRegister crx, Label& L, int optimize);189inline void bge_far(ConditionRegister crx, Label& L, int optimize);190inline void ble_far(ConditionRegister crx, Label& L, int optimize);191inline void bne_far(ConditionRegister crx, Label& L, int optimize);192inline void bns_far(ConditionRegister crx, Label& L, int optimize);193194// Emit, identify and patch a NOT mt-safe patchable 64 bit absolute call/jump.195private:196enum {197bxx64_patchable_instruction_count = (2/*load_codecache_const*/ + 3/*5load_const*/ + 1/*mtctr*/ + 1/*bctrl*/),198bxx64_patchable_size = bxx64_patchable_instruction_count * BytesPerInstWord,199bxx64_patchable_ret_addr_offset = bxx64_patchable_size200};201void bxx64_patchable(address target, relocInfo::relocType rt, bool link);202static bool is_bxx64_patchable_at( address instruction_addr, bool link);203// Does the instruction use a pc-relative encoding of the destination?204static bool is_bxx64_patchable_pcrelative_at( address instruction_addr, bool link);205static bool is_bxx64_patchable_variant1_at( address instruction_addr, bool link);206// Load destination relative to global toc.207static bool is_bxx64_patchable_variant1b_at( address instruction_addr, bool link);208static bool is_bxx64_patchable_variant2_at( address instruction_addr, bool link);209static void set_dest_of_bxx64_patchable_at( address instruction_addr, address target, bool link);210static address get_dest_of_bxx64_patchable_at(address instruction_addr, bool link);211212public:213// call214enum {215bl64_patchable_instruction_count = bxx64_patchable_instruction_count,216bl64_patchable_size = bxx64_patchable_size,217bl64_patchable_ret_addr_offset = bxx64_patchable_ret_addr_offset218};219inline void bl64_patchable(address target, relocInfo::relocType rt) {220bxx64_patchable(target, rt, /*link=*/true);221}222inline static bool is_bl64_patchable_at(address instruction_addr) {223return is_bxx64_patchable_at(instruction_addr, /*link=*/true);224}225inline static bool is_bl64_patchable_pcrelative_at(address instruction_addr) {226return is_bxx64_patchable_pcrelative_at(instruction_addr, /*link=*/true);227}228inline static void set_dest_of_bl64_patchable_at(address instruction_addr, address target) {229set_dest_of_bxx64_patchable_at(instruction_addr, target, /*link=*/true);230}231inline static address get_dest_of_bl64_patchable_at(address instruction_addr) {232return get_dest_of_bxx64_patchable_at(instruction_addr, /*link=*/true);233}234// jump235enum {236b64_patchable_instruction_count = bxx64_patchable_instruction_count,237b64_patchable_size = bxx64_patchable_size,238};239inline void b64_patchable(address target, relocInfo::relocType rt) {240bxx64_patchable(target, rt, /*link=*/false);241}242inline static bool is_b64_patchable_at(address instruction_addr) {243return is_bxx64_patchable_at(instruction_addr, /*link=*/false);244}245inline static bool is_b64_patchable_pcrelative_at(address instruction_addr) {246return is_bxx64_patchable_pcrelative_at(instruction_addr, /*link=*/false);247}248inline static void set_dest_of_b64_patchable_at(address instruction_addr, address target) {249set_dest_of_bxx64_patchable_at(instruction_addr, target, /*link=*/false);250}251inline static address get_dest_of_b64_patchable_at(address instruction_addr) {252return get_dest_of_bxx64_patchable_at(instruction_addr, /*link=*/false);253}254255//256// Support for frame handling257//258259// some ABI-related functions260void save_nonvolatile_gprs( Register dst_base, int offset);261void restore_nonvolatile_gprs(Register src_base, int offset);262void save_volatile_gprs( Register dst_base, int offset);263void restore_volatile_gprs(Register src_base, int offset);264void save_LR_CR( Register tmp); // tmp contains LR on return.265void restore_LR_CR(Register tmp);266267// Get current PC using bl-next-instruction trick.268address get_PC_trash_LR(Register result);269270// Resize current frame either relatively wrt to current SP or absolute.271void resize_frame(Register offset, Register tmp);272void resize_frame(int offset, Register tmp);273void resize_frame_absolute(Register addr, Register tmp1, Register tmp2);274275// Push a frame of size bytes.276void push_frame(Register bytes, Register tmp);277278// Push a frame of size `bytes'. No abi space provided.279void push_frame(unsigned int bytes, Register tmp);280281// Push a frame of size `bytes' plus abi_reg_args on top.282void push_frame_reg_args(unsigned int bytes, Register tmp);283284// Setup up a new C frame with a spill area for non-volatile GPRs and additional285// space for local variables286void push_frame_reg_args_nonvolatiles(unsigned int bytes, Register tmp);287288// pop current C frame289void pop_frame();290291//292// Calls293//294295private:296address _last_calls_return_pc;297298#if defined(ABI_ELFv2)299// Generic version of a call to C function.300// Updates and returns _last_calls_return_pc.301address branch_to(Register function_entry, bool and_link);302#else303// Generic version of a call to C function via a function descriptor304// with variable support for C calling conventions (TOC, ENV, etc.).305// updates and returns _last_calls_return_pc.306address branch_to(Register function_descriptor, bool and_link, bool save_toc_before_call,307bool restore_toc_after_call, bool load_toc_of_callee, bool load_env_of_callee);308#endif309310public:311312// Get the pc where the last call will return to. returns _last_calls_return_pc.313inline address last_calls_return_pc();314315#if defined(ABI_ELFv2)316// Call a C function via a function descriptor and use full C317// calling conventions. Updates and returns _last_calls_return_pc.318address call_c(Register function_entry);319// For tail calls: only branch, don't link, so callee returns to caller of this function.320address call_c_and_return_to_caller(Register function_entry);321address call_c(address function_entry, relocInfo::relocType rt);322#else323// Call a C function via a function descriptor and use full C324// calling conventions. Updates and returns _last_calls_return_pc.325address call_c(Register function_descriptor);326// For tail calls: only branch, don't link, so callee returns to caller of this function.327address call_c_and_return_to_caller(Register function_descriptor);328address call_c(const FunctionDescriptor* function_descriptor, relocInfo::relocType rt);329address call_c_using_toc(const FunctionDescriptor* function_descriptor, relocInfo::relocType rt,330Register toc);331#endif332333protected:334335// It is imperative that all calls into the VM are handled via the336// call_VM macros. They make sure that the stack linkage is setup337// correctly. call_VM's correspond to ENTRY/ENTRY_X entry points338// while call_VM_leaf's correspond to LEAF entry points.339//340// This is the base routine called by the different versions of341// call_VM. The interpreter may customize this version by overriding342// it for its purposes (e.g., to save/restore additional registers343// when doing a VM call).344//345// If no last_java_sp is specified (noreg) then SP will be used instead.346virtual void call_VM_base(347// where an oop-result ends up if any; use noreg otherwise348Register oop_result,349// to set up last_Java_frame in stubs; use noreg otherwise350Register last_java_sp,351// the entry point352address entry_point,353// flag which indicates if exception should be checked354bool check_exception = true355);356357// Support for VM calls. This is the base routine called by the358// different versions of call_VM_leaf. The interpreter may customize359// this version by overriding it for its purposes (e.g., to360// save/restore additional registers when doing a VM call).361void call_VM_leaf_base(address entry_point);362363public:364// Call into the VM.365// Passes the thread pointer (in R3_ARG1) as a prepended argument.366// Makes sure oop return values are visible to the GC.367void call_VM(Register oop_result, address entry_point, bool check_exceptions = true);368void call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions = true);369void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions = true);370void call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg3, bool check_exceptions = true);371void call_VM_leaf(address entry_point);372void call_VM_leaf(address entry_point, Register arg_1);373void call_VM_leaf(address entry_point, Register arg_1, Register arg_2);374void call_VM_leaf(address entry_point, Register arg_1, Register arg_2, Register arg_3);375376// Call a stub function via a function descriptor, but don't save377// TOC before call, don't setup TOC and ENV for call, and don't378// restore TOC after call. Updates and returns _last_calls_return_pc.379inline address call_stub(Register function_entry);380inline void call_stub_and_return_to(Register function_entry, Register return_pc);381382//383// Java utilities384//385386// Read from the polling page, its address is already in a register.387inline void load_from_polling_page(Register polling_page_address, int offset = 0);388// Check whether instruction is a read access to the polling page389// which was emitted by load_from_polling_page(..).390static bool is_load_from_polling_page(int instruction, void* ucontext/*may be NULL*/,391address* polling_address_ptr = NULL);392393// Check whether instruction is a write access to the memory394// serialization page realized by one of the instructions stw, stwu,395// stwx, or stwux.396static bool is_memory_serialization(int instruction, JavaThread* thread, void* ucontext);397398// Support for NULL-checks399//400// Generates code that causes a NULL OS exception if the content of reg is NULL.401// If the accessed location is M[reg + offset] and the offset is known, provide the402// offset. No explicit code generation is needed if the offset is within a certain403// range (0 <= offset <= page_size).404405// Stack overflow checking406void bang_stack_with_offset(int offset);407408// If instruction is a stack bang of the form ld, stdu, or409// stdux, return the banged address. Otherwise, return 0.410static address get_stack_bang_address(int instruction, void* ucontext);411412// Atomics413// CmpxchgX sets condition register to cmpX(current, compare).414// (flag == ne) => (dest_current_value != compare_value), (!swapped)415// (flag == eq) => (dest_current_value == compare_value), ( swapped)416static inline bool cmpxchgx_hint_acquire_lock() { return true; }417// The stxcx will probably not be succeeded by a releasing store.418static inline bool cmpxchgx_hint_release_lock() { return false; }419static inline bool cmpxchgx_hint_atomic_update() { return false; }420421// Cmpxchg semantics422enum {423MemBarNone = 0,424MemBarRel = 1,425MemBarAcq = 2,426MemBarFenceAfter = 4 // use powers of 2427};428void cmpxchgw(ConditionRegister flag,429Register dest_current_value, Register compare_value, Register exchange_value, Register addr_base,430int semantics, bool cmpxchgx_hint = false,431Register int_flag_success = noreg, bool contention_hint = false);432void cmpxchgd(ConditionRegister flag,433Register dest_current_value, Register compare_value, Register exchange_value, Register addr_base,434int semantics, bool cmpxchgx_hint = false,435Register int_flag_success = noreg, Label* failed = NULL, bool contention_hint = false);436437// interface method calling438void lookup_interface_method(Register recv_klass,439Register intf_klass,440RegisterOrConstant itable_index,441Register method_result,442Register temp_reg, Register temp2_reg,443Label& no_such_interface,444bool return_method = true);445446// virtual method calling447void lookup_virtual_method(Register recv_klass,448RegisterOrConstant vtable_index,449Register method_result);450451// Test sub_klass against super_klass, with fast and slow paths.452453// The fast path produces a tri-state answer: yes / no / maybe-slow.454// One of the three labels can be NULL, meaning take the fall-through.455// If super_check_offset is -1, the value is loaded up from super_klass.456// No registers are killed, except temp_reg and temp2_reg.457// If super_check_offset is not -1, temp2_reg is not used and can be noreg.458void check_klass_subtype_fast_path(Register sub_klass,459Register super_klass,460Register temp1_reg,461Register temp2_reg,462Label& L_success,463Label& L_failure);464465// The rest of the type check; must be wired to a corresponding fast path.466// It does not repeat the fast path logic, so don't use it standalone.467// The temp_reg can be noreg, if no temps are available.468// It can also be sub_klass or super_klass, meaning it's OK to kill that one.469// Updates the sub's secondary super cache as necessary.470void check_klass_subtype_slow_path(Register sub_klass,471Register super_klass,472Register temp1_reg,473Register temp2_reg,474Label* L_success = NULL,475Register result_reg = noreg);476477// Simplified, combined version, good for typical uses.478// Falls through on failure.479void check_klass_subtype(Register sub_klass,480Register super_klass,481Register temp1_reg,482Register temp2_reg,483Label& L_success);484485// Method handle support (JSR 292).486void check_method_handle_type(Register mtype_reg, Register mh_reg, Register temp_reg, Label& wrong_method_type);487488RegisterOrConstant argument_offset(RegisterOrConstant arg_slot, Register temp_reg, int extra_slot_offset = 0);489490// Biased locking support491// Upon entry,obj_reg must contain the target object, and mark_reg492// must contain the target object's header.493// Destroys mark_reg if an attempt is made to bias an anonymously494// biased lock. In this case a failure will go either to the slow495// case or fall through with the notEqual condition code set with496// the expectation that the slow case in the runtime will be called.497// In the fall-through case where the CAS-based lock is done,498// mark_reg is not destroyed.499void biased_locking_enter(ConditionRegister cr_reg, Register obj_reg, Register mark_reg, Register temp_reg,500Register temp2_reg, Label& done, Label* slow_case = NULL);501// Upon entry, the base register of mark_addr must contain the oop.502// Destroys temp_reg.503// If allow_delay_slot_filling is set to true, the next instruction504// emitted after this one will go in an annulled delay slot if the505// biased locking exit case failed.506void biased_locking_exit(ConditionRegister cr_reg, Register mark_addr, Register temp_reg, Label& done);507508void compiler_fast_lock_object( ConditionRegister flag, Register oop, Register box, Register tmp1, Register tmp2, Register tmp3);509void compiler_fast_unlock_object(ConditionRegister flag, Register oop, Register box, Register tmp1, Register tmp2, Register tmp3);510511// Support for serializing memory accesses between threads512void serialize_memory(Register thread, Register tmp1, Register tmp2);513514// GC barrier support.515void card_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp);516void card_table_write(jbyte* byte_map_base, Register Rtmp, Register Robj);517518void resolve_jobject(Register value, Register tmp1, Register tmp2, bool needs_frame);519520#if INCLUDE_ALL_GCS521// General G1 pre-barrier generator.522void g1_write_barrier_pre(Register Robj, RegisterOrConstant offset, Register Rpre_val,523Register Rtmp1, Register Rtmp2, bool needs_frame = false);524// General G1 post-barrier generator525void g1_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp1,526Register Rtmp2, Register Rtmp3, Label *filtered_ext = NULL);527#endif528529// Support for managing the JavaThread pointer (i.e.; the reference to530// thread-local information).531532// Support for last Java frame (but use call_VM instead where possible):533// access R16_thread->last_Java_sp.534void set_last_Java_frame(Register last_java_sp, Register last_Java_pc);535void reset_last_Java_frame(void);536void set_top_ijava_frame_at_SP_as_last_Java_frame(Register sp, Register tmp1);537538// Read vm result from thread: oop_result = R16_thread->result;539void get_vm_result (Register oop_result);540void get_vm_result_2(Register metadata_result);541542static bool needs_explicit_null_check(intptr_t offset);543544// Trap-instruction-based checks.545// Range checks can be distinguished from zero checks as they check 32 bit,546// zero checks all 64 bits (tw, td).547inline void trap_null_check(Register a, trap_to_bits cmp = traptoEqual);548static bool is_trap_null_check(int x) {549return is_tdi(x, traptoEqual, -1/*any reg*/, 0) ||550is_tdi(x, traptoGreaterThanUnsigned, -1/*any reg*/, 0);551}552553inline void trap_zombie_not_entrant();554static bool is_trap_zombie_not_entrant(int x) { return is_tdi(x, traptoUnconditional, 0/*reg 0*/, 1); }555556inline void trap_should_not_reach_here();557static bool is_trap_should_not_reach_here(int x) { return is_tdi(x, traptoUnconditional, 0/*reg 0*/, 2); }558559inline void trap_ic_miss_check(Register a, Register b);560static bool is_trap_ic_miss_check(int x) {561return is_td(x, traptoGreaterThanUnsigned | traptoLessThanUnsigned, -1/*any reg*/, -1/*any reg*/);562}563564// Implicit or explicit null check, jumps to static address exception_entry.565inline void null_check_throw(Register a, int offset, Register temp_reg, address exception_entry);566567// Check accessed object for null. Use SIGTRAP-based null checks on AIX.568inline void load_with_trap_null_check(Register d, int si16, Register s1);569570// Load heap oop and decompress. Loaded oop may not be null.571inline void load_heap_oop_not_null(Register d, RegisterOrConstant offs, Register s1 = noreg);572inline void store_heap_oop_not_null(Register d, RegisterOrConstant offs, Register s1,573/*specify if d must stay uncompressed*/ Register tmp = noreg);574575// Null allowed.576inline void load_heap_oop(Register d, RegisterOrConstant offs, Register s1 = noreg);577578// Encode/decode heap oop. Oop may not be null, else en/decoding goes wrong.579inline Register encode_heap_oop_not_null(Register d, Register src = noreg);580inline void decode_heap_oop_not_null(Register d);581582// Null allowed.583inline void decode_heap_oop(Register d);584585// Load/Store klass oop from klass field. Compress.586void load_klass(Register dst, Register src);587void load_klass_with_trap_null_check(Register dst, Register src);588void store_klass(Register dst_oop, Register klass, Register tmp = R0);589void store_klass_gap(Register dst_oop, Register val = noreg); // Will store 0 if val not specified.590static int instr_size_for_decode_klass_not_null();591void decode_klass_not_null(Register dst, Register src = noreg);592void encode_klass_not_null(Register dst, Register src = noreg);593594// Load common heap base into register.595void reinit_heapbase(Register d, Register tmp = noreg);596597// SIGTRAP-based range checks for arrays.598inline void trap_range_check_l(Register a, Register b);599inline void trap_range_check_l(Register a, int si16);600static bool is_trap_range_check_l(int x) {601return (is_tw (x, traptoLessThanUnsigned, -1/*any reg*/, -1/*any reg*/) ||602is_twi(x, traptoLessThanUnsigned, -1/*any reg*/) );603}604inline void trap_range_check_le(Register a, int si16);605static bool is_trap_range_check_le(int x) {606return is_twi(x, traptoEqual | traptoLessThanUnsigned, -1/*any reg*/);607}608inline void trap_range_check_g(Register a, int si16);609static bool is_trap_range_check_g(int x) {610return is_twi(x, traptoGreaterThanUnsigned, -1/*any reg*/);611}612inline void trap_range_check_ge(Register a, Register b);613inline void trap_range_check_ge(Register a, int si16);614static bool is_trap_range_check_ge(int x) {615return (is_tw (x, traptoEqual | traptoGreaterThanUnsigned, -1/*any reg*/, -1/*any reg*/) ||616is_twi(x, traptoEqual | traptoGreaterThanUnsigned, -1/*any reg*/) );617}618static bool is_trap_range_check(int x) {619return is_trap_range_check_l(x) || is_trap_range_check_le(x) ||620is_trap_range_check_g(x) || is_trap_range_check_ge(x);621}622623void clear_memory_doubleword(Register base_ptr, Register cnt_dwords, Register tmp = R0);624625// Needle of length 1.626void string_indexof_1(Register result, Register haystack, Register haycnt,627Register needle, jchar needleChar,628Register tmp1, Register tmp2);629// General indexof, eventually with constant needle length.630void string_indexof(Register result, Register haystack, Register haycnt,631Register needle, ciTypeArray* needle_values, Register needlecnt, int needlecntval,632Register tmp1, Register tmp2, Register tmp3, Register tmp4);633void string_compare(Register str1_reg, Register str2_reg, Register cnt1_reg, Register cnt2_reg,634Register result_reg, Register tmp_reg);635void char_arrays_equals(Register str1_reg, Register str2_reg, Register cnt_reg, Register result_reg,636Register tmp1_reg, Register tmp2_reg, Register tmp3_reg, Register tmp4_reg,637Register tmp5_reg);638void char_arrays_equalsImm(Register str1_reg, Register str2_reg, int cntval, Register result_reg,639Register tmp1_reg, Register tmp2_reg);640641// CRC32 Intrinsics.642void load_reverse_32(Register dst, Register src);643int crc32_table_columns(Register table, Register tc0, Register tc1, Register tc2, Register tc3);644void fold_byte_crc32(Register crc, Register val, Register table, Register tmp);645void fold_8bit_crc32(Register crc, Register table, Register tmp);646void update_byte_crc32(Register crc, Register val, Register table);647void update_byteLoop_crc32(Register crc, Register buf, Register len, Register table,648Register data, bool loopAlignment, bool invertCRC);649void update_1word_crc32(Register crc, Register buf, Register table, int bufDisp, int bufInc,650Register t0, Register t1, Register t2, Register t3,651Register tc0, Register tc1, Register tc2, Register tc3);652void kernel_crc32_2word(Register crc, Register buf, Register len, Register table,653Register t0, Register t1, Register t2, Register t3,654Register tc0, Register tc1, Register tc2, Register tc3);655void kernel_crc32_1word(Register crc, Register buf, Register len, Register table,656Register t0, Register t1, Register t2, Register t3,657Register tc0, Register tc1, Register tc2, Register tc3);658void kernel_crc32_1byte(Register crc, Register buf, Register len, Register table,659Register t0, Register t1, Register t2, Register t3);660void kernel_crc32_1word_vpmsumd(Register crc, Register buf, Register len, Register table,661Register constants, Register barretConstants,662Register t0, Register t1, Register t2, Register t3, Register t4);663void kernel_crc32_1word_aligned(Register crc, Register buf, Register len,664Register constants, Register barretConstants,665Register t0, Register t1, Register t2);666667void kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp);668669// SHA-2 auxiliary functions and public interfaces670private:671void sha256_deque(const VectorRegister src,672const VectorRegister dst1, const VectorRegister dst2, const VectorRegister dst3);673void sha256_load_h_vec(const VectorRegister a, const VectorRegister e, const Register hptr);674void sha256_round(const VectorRegister* hs, const int total_hs, int& h_cnt, const VectorRegister kpw);675void sha256_load_w_plus_k_vec(const Register buf_in, const VectorRegister* ws,676const int total_ws, const Register k, const VectorRegister* kpws,677const int total_kpws);678void sha256_calc_4w(const VectorRegister w0, const VectorRegister w1,679const VectorRegister w2, const VectorRegister w3, const VectorRegister kpw0,680const VectorRegister kpw1, const VectorRegister kpw2, const VectorRegister kpw3,681const Register j, const Register k);682void sha256_update_sha_state(const VectorRegister a, const VectorRegister b,683const VectorRegister c, const VectorRegister d, const VectorRegister e,684const VectorRegister f, const VectorRegister g, const VectorRegister h,685const Register hptr);686687void sha512_load_w_vec(const Register buf_in, const VectorRegister* ws, const int total_ws);688void sha512_update_sha_state(const Register state, const VectorRegister* hs, const int total_hs);689void sha512_round(const VectorRegister* hs, const int total_hs, int& h_cnt, const VectorRegister kpw);690void sha512_load_h_vec(const Register state, const VectorRegister* hs, const int total_hs);691void sha512_calc_2w(const VectorRegister w0, const VectorRegister w1,692const VectorRegister w2, const VectorRegister w3,693const VectorRegister w4, const VectorRegister w5,694const VectorRegister w6, const VectorRegister w7,695const VectorRegister kpw0, const VectorRegister kpw1, const Register j,696const VectorRegister vRb, const Register k);697698public:699void sha256(bool multi_block);700void sha512(bool multi_block);701702703//704// Debugging705//706707// assert on cr0708void asm_assert(bool check_equal, const char* msg, int id);709void asm_assert_eq(const char* msg, int id) { asm_assert(true, msg, id); }710void asm_assert_ne(const char* msg, int id) { asm_assert(false, msg, id); }711712private:713void asm_assert_mems_zero(bool check_equal, int size, int mem_offset, Register mem_base,714const char* msg, int id);715716public:717718void asm_assert_mem8_is_zero(int mem_offset, Register mem_base, const char* msg, int id) {719asm_assert_mems_zero(true, 8, mem_offset, mem_base, msg, id);720}721void asm_assert_mem8_isnot_zero(int mem_offset, Register mem_base, const char* msg, int id) {722asm_assert_mems_zero(false, 8, mem_offset, mem_base, msg, id);723}724725// Verify R16_thread contents.726void verify_thread();727728// Emit code to verify that reg contains a valid oop if +VerifyOops is set.729void verify_oop(Register reg, const char* s = "broken oop");730731// TODO: verify method and klass metadata (compare against vptr?)732void _verify_method_ptr(Register reg, const char * msg, const char * file, int line) {}733void _verify_klass_ptr(Register reg, const char * msg, const char * file, int line) {}734735// Convenience method returning function entry. For the ELFv1 case736// creates function descriptor at the current address and returs737// the pointer to it. For the ELFv2 case returns the current address.738inline address function_entry();739740#define verify_method_ptr(reg) _verify_method_ptr(reg, "broken method " #reg, __FILE__, __LINE__)741#define verify_klass_ptr(reg) _verify_klass_ptr(reg, "broken klass " #reg, __FILE__, __LINE__)742743private:744745enum {746stop_stop = 0,747stop_untested = 1,748stop_unimplemented = 2,749stop_shouldnotreachhere = 3,750stop_end = 4751};752void stop(int type, const char* msg, int id);753754public:755// Prints msg, dumps registers and stops execution.756void stop (const char* msg = "", int id = 0) { stop(stop_stop, msg, id); }757void untested (const char* msg = "", int id = 0) { stop(stop_untested, msg, id); }758void unimplemented(const char* msg = "", int id = 0) { stop(stop_unimplemented, msg, id); }759void should_not_reach_here() { stop(stop_shouldnotreachhere, "", -1); }760761void zap_from_to(Register low, int before, Register high, int after, Register val, Register addr) PRODUCT_RETURN;762};763764// class SkipIfEqualZero:765//766// Instantiating this class will result in assembly code being output that will767// jump around any code emitted between the creation of the instance and it's768// automatic destruction at the end of a scope block, depending on the value of769// the flag passed to the constructor, which will be checked at run-time.770class SkipIfEqualZero : public StackObj {771private:772MacroAssembler* _masm;773Label _label;774775public:776// 'Temp' is a temp register that this object can use (and trash).777explicit SkipIfEqualZero(MacroAssembler*, Register temp, const bool* flag_addr);778~SkipIfEqualZero();779};780781#endif // CPU_PPC_VM_MACROASSEMBLER_PPC_HPP782783784