< prev index next >

src/hotspot/cpu/ppc/macroAssembler_ppc.hpp

Print this page

  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef CPU_PPC_MACROASSEMBLER_PPC_HPP
  27 #define CPU_PPC_MACROASSEMBLER_PPC_HPP
  28 
  29 #include "asm/assembler.hpp"
  30 #include "oops/accessDecorators.hpp"

  31 #include "utilities/macros.hpp"
  32 
  33 // MacroAssembler extends Assembler by a few frequently used macros.
  34 
  35 class ciTypeArray;
  36 class OopMap;



  37 
  38 class MacroAssembler: public Assembler {
  39  public:
  40   MacroAssembler(CodeBuffer* code) : Assembler(code) {}
  41 
  42   // Indicates whether and, if so, which registers must be preserved when calling runtime code.
  43   enum PreservationLevel {
  44     PRESERVATION_NONE,
  45     PRESERVATION_FRAME_LR,
  46     PRESERVATION_FRAME_LR_GP_REGS,
  47     PRESERVATION_FRAME_LR_GP_FP_REGS
  48   };
  49 
  50   //
  51   // Optimized instruction emitters
  52   //
  53 
  54   inline static int largeoffset_si16_si16_hi(int si31) { return (si31 + (1<<15)) >> 16; }
  55   inline static int largeoffset_si16_si16_lo(int si31) { return si31 - (((si31 + (1<<15)) >> 16) << 16); }
  56 

 377     return call_c((const FunctionDescriptor*)function_entry, rt);
 378   }
 379   address call_c_using_toc(const FunctionDescriptor* function_descriptor, relocInfo::relocType rt,
 380                            Register toc);
 381 #endif
 382 
 383   // CompiledIC call
 384   bool ic_call(Register Rmethod_toc,
 385                address target,
 386                jint method_index = 0,
 387                bool scratch_emit = false,
 388                bool fixed_size = false);
 389   static int ic_check_size();
 390   int ic_check(int end_alignment);
 391 
 392   enum { trampoline_stub_size = 6 * 4 };
 393   address trampoline_call(AddressLiteral target,
 394                           Register Rmethod_toc = noreg,
 395                           bool scratch_emit = false);
 396 





 397  protected:
 398 
 399   // It is imperative that all calls into the VM are handled via the
 400   // call_VM macros. They make sure that the stack linkage is setup
 401   // correctly. call_VM's correspond to ENTRY/ENTRY_X entry points
 402   // while call_VM_leaf's correspond to LEAF entry points.
 403   //
 404   // This is the base routine called by the different versions of
 405   // call_VM. The interpreter may customize this version by overriding
 406   // it for its purposes (e.g., to save/restore additional registers
 407   // when doing a VM call).
 408   //
 409   // If no last_java_sp is specified (noreg) then SP will be used instead.
 410   virtual void call_VM_base(
 411      // where an oop-result ends up if any; use noreg otherwise
 412     Register        oop_result,
 413     // to set up last_Java_frame in stubs; use noreg otherwise
 414     Register        last_java_sp,
 415     // the entry point
 416     address         entry_point,

 796 
 797   // Load/Store klass oop from klass field. Compress.
 798   void load_klass_no_decode(Register dst, Register src);
 799   void load_klass(Register dst, Register src);
 800   void load_narrow_klass_compact(Register dst, Register src);
 801   void cmp_klass(ConditionRegister dst, Register obj, Register klass, Register tmp, Register tmp2);
 802   void cmp_klasses_from_objects(ConditionRegister dst, Register obj1, Register obj2, Register tmp1, Register tmp2);
 803   void load_klass_check_null(Register dst, Register src, Label* is_null = nullptr);
 804   void store_klass(Register dst_oop, Register klass, Register tmp = R0);
 805   void store_klass_gap(Register dst_oop, Register val = noreg); // Will store 0 if val not specified.
 806 
 807   void resolve_oop_handle(Register result, Register tmp1, Register tmp2,
 808                           MacroAssembler::PreservationLevel preservation_level);
 809   void resolve_weak_handle(Register result, Register tmp1, Register tmp2,
 810                            MacroAssembler::PreservationLevel preservation_level);
 811   void load_method_holder(Register holder, Register method);
 812 
 813   void decode_klass_not_null(Register dst, Register src = noreg);
 814   Register encode_klass_not_null(Register dst, Register src = noreg);
 815 
































 816   // SIGTRAP-based range checks for arrays.
 817   inline void trap_range_check_l(Register a, Register b);
 818   inline void trap_range_check_l(Register a, int si16);
 819   static bool is_trap_range_check_l(int x) {
 820     return (is_tw (x, traptoLessThanUnsigned, -1/*any reg*/, -1/*any reg*/) ||
 821             is_twi(x, traptoLessThanUnsigned, -1/*any reg*/)                  );
 822   }
 823   inline void trap_range_check_le(Register a, int si16);
 824   static bool is_trap_range_check_le(int x) {
 825     return is_twi(x, traptoEqual | traptoLessThanUnsigned, -1/*any reg*/);
 826   }
 827   inline void trap_range_check_g(Register a, int si16);
 828   static bool is_trap_range_check_g(int x) {
 829     return is_twi(x, traptoGreaterThanUnsigned, -1/*any reg*/);
 830   }
 831   inline void trap_range_check_ge(Register a, Register b);
 832   inline void trap_range_check_ge(Register a, int si16);
 833   static bool is_trap_range_check_ge(int x) {
 834     return (is_tw (x, traptoEqual | traptoGreaterThanUnsigned, -1/*any reg*/, -1/*any reg*/) ||
 835             is_twi(x, traptoEqual | traptoGreaterThanUnsigned, -1/*any reg*/)                  );
 836   }
 837   static bool is_trap_range_check(int x) {
 838     return is_trap_range_check_l(x) || is_trap_range_check_le(x) ||
 839            is_trap_range_check_g(x) || is_trap_range_check_ge(x);
 840   }
 841 
 842   void clear_memory_unrolled(Register base_ptr, int cnt_dwords, Register tmp = R0, int offset = 0);
 843   void clear_memory_constlen(Register base_ptr, int cnt_dwords, Register tmp = R0);
 844   void clear_memory_doubleword(Register base_ptr, Register cnt_dwords, Register tmp = R0, long const_cnt = -1);

 845 
 846   // Emitters for BigInteger.multiplyToLen intrinsic.
 847   inline void multiply64(Register dest_hi, Register dest_lo,
 848                          Register x, Register y);
 849   void add2_with_carry(Register dest_hi, Register dest_lo,
 850                        Register src1, Register src2);
 851   void multiply_64_x_64_loop(Register x, Register xstart, Register x_xstart,
 852                              Register y, Register y_idx, Register z,
 853                              Register carry, Register product_high, Register product,
 854                              Register idx, Register kdx, Register tmp);
 855   void multiply_add_128_x_128(Register x_xstart, Register y, Register z,
 856                               Register yz_idx, Register idx, Register carry,
 857                               Register product_high, Register product, Register tmp,
 858                               int offset);
 859   void multiply_128_x_128_loop(Register x_xstart,
 860                                Register y, Register z,
 861                                Register yz_idx, Register idx, Register carry,
 862                                Register product_high, Register product,
 863                                Register carry2, Register tmp);
 864   void muladd(Register out, Register in, Register offset, Register len, Register k,

 993 
 994  private:
 995   void stop(int type, const char* msg);
 996 
 997  public:
 998   enum {
 999     stop_stop               = 0,
1000     stop_untested           = 1,
1001     stop_unimplemented      = 2,
1002     stop_shouldnotreachhere = 3,
1003     stop_msg_present        = -0x8000
1004   };
1005 
1006   // Prints msg, dumps registers and stops execution.
1007   void stop                 (const char* msg = nullptr) { stop(stop_stop,               msg); }
1008   void untested             (const char* msg = nullptr) { stop(stop_untested,           msg); }
1009   void unimplemented        (const char* msg = nullptr) { stop(stop_unimplemented,      msg); }
1010   void should_not_reach_here(const char* msg = nullptr) { stop(stop_shouldnotreachhere, msg); }
1011 
1012   void zap_from_to(Register low, int before, Register high, int after, Register val, Register addr) PRODUCT_RETURN;



1013 };
1014 
1015 #endif // CPU_PPC_MACROASSEMBLER_PPC_HPP

  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef CPU_PPC_MACROASSEMBLER_PPC_HPP
  27 #define CPU_PPC_MACROASSEMBLER_PPC_HPP
  28 
  29 #include "asm/assembler.hpp"
  30 #include "oops/accessDecorators.hpp"
  31 #include "runtime/signature.hpp"
  32 #include "utilities/macros.hpp"
  33 
  34 // MacroAssembler extends Assembler by a few frequently used macros.
  35 
  36 class ciTypeArray;
  37 class OopMap;
  38 class ciInlineKlass;
  39 class SigEntry;
  40 class VMRegPair;
  41 
  42 class MacroAssembler: public Assembler {
  43  public:
  44   MacroAssembler(CodeBuffer* code) : Assembler(code) {}
  45 
  46   // Indicates whether and, if so, which registers must be preserved when calling runtime code.
  47   enum PreservationLevel {
  48     PRESERVATION_NONE,
  49     PRESERVATION_FRAME_LR,
  50     PRESERVATION_FRAME_LR_GP_REGS,
  51     PRESERVATION_FRAME_LR_GP_FP_REGS
  52   };
  53 
  54   //
  55   // Optimized instruction emitters
  56   //
  57 
  58   inline static int largeoffset_si16_si16_hi(int si31) { return (si31 + (1<<15)) >> 16; }
  59   inline static int largeoffset_si16_si16_lo(int si31) { return si31 - (((si31 + (1<<15)) >> 16) << 16); }
  60 

 381     return call_c((const FunctionDescriptor*)function_entry, rt);
 382   }
 383   address call_c_using_toc(const FunctionDescriptor* function_descriptor, relocInfo::relocType rt,
 384                            Register toc);
 385 #endif
 386 
 387   // CompiledIC call
 388   bool ic_call(Register Rmethod_toc,
 389                address target,
 390                jint method_index = 0,
 391                bool scratch_emit = false,
 392                bool fixed_size = false);
 393   static int ic_check_size();
 394   int ic_check(int end_alignment);
 395 
 396   enum { trampoline_stub_size = 6 * 4 };
 397   address trampoline_call(AddressLiteral target,
 398                           Register Rmethod_toc = noreg,
 399                           bool scratch_emit = false);
 400 
 401   // Inline type specific methods
 402 #include "asm/macroAssembler_common.hpp"
 403 
 404   void save_stack_increment(int sp_inc, int frame_size);
 405 
 406  protected:
 407 
 408   // It is imperative that all calls into the VM are handled via the
 409   // call_VM macros. They make sure that the stack linkage is setup
 410   // correctly. call_VM's correspond to ENTRY/ENTRY_X entry points
 411   // while call_VM_leaf's correspond to LEAF entry points.
 412   //
 413   // This is the base routine called by the different versions of
 414   // call_VM. The interpreter may customize this version by overriding
 415   // it for its purposes (e.g., to save/restore additional registers
 416   // when doing a VM call).
 417   //
 418   // If no last_java_sp is specified (noreg) then SP will be used instead.
 419   virtual void call_VM_base(
 420      // where an oop-result ends up if any; use noreg otherwise
 421     Register        oop_result,
 422     // to set up last_Java_frame in stubs; use noreg otherwise
 423     Register        last_java_sp,
 424     // the entry point
 425     address         entry_point,

 805 
 806   // Load/Store klass oop from klass field. Compress.
 807   void load_klass_no_decode(Register dst, Register src);
 808   void load_klass(Register dst, Register src);
 809   void load_narrow_klass_compact(Register dst, Register src);
 810   void cmp_klass(ConditionRegister dst, Register obj, Register klass, Register tmp, Register tmp2);
 811   void cmp_klasses_from_objects(ConditionRegister dst, Register obj1, Register obj2, Register tmp1, Register tmp2);
 812   void load_klass_check_null(Register dst, Register src, Label* is_null = nullptr);
 813   void store_klass(Register dst_oop, Register klass, Register tmp = R0);
 814   void store_klass_gap(Register dst_oop, Register val = noreg); // Will store 0 if val not specified.
 815 
 816   void resolve_oop_handle(Register result, Register tmp1, Register tmp2,
 817                           MacroAssembler::PreservationLevel preservation_level);
 818   void resolve_weak_handle(Register result, Register tmp1, Register tmp2,
 819                            MacroAssembler::PreservationLevel preservation_level);
 820   void load_method_holder(Register holder, Register method);
 821 
 822   void decode_klass_not_null(Register dst, Register src = noreg);
 823   Register encode_klass_not_null(Register dst, Register src = noreg);
 824 
 825   // markWord tests, kills markWord reg
 826   void test_markword_is_inline_type(Register markword, Label& is_inline_type);
 827 
 828   // inlineKlass queries, kills temp_reg
 829   void test_oop_is_not_inline_type(Register object, Label& not_inline_type, bool can_be_null = true);
 830 
 831   void test_field_is_null_free_inline_type(Register flags, Label& is_null_free);
 832   void test_field_is_not_null_free_inline_type(Register flags, Label& not_null_free);
 833   void test_field_is_flat(Register flags, Label& is_flat);
 834 
 835   // Check oops for special arrays, i.e. flat arrays and/or null-free arrays
 836   void test_oop_prototype_bit(Register oop, Register temp_reg, int32_t test_bit, bool jmp_set, Label& jmp_label, bool maybe_far = false);
 837   void test_flat_array_oop(Register oop, Register temp_reg, Label& is_flat_array, bool maybe_far = false);
 838   void test_non_flat_array_oop(Register oop, Register temp_reg, Label& is_non_flat_array);
 839   void test_null_free_array_oop(Register oop, Register temp_reg, Label& is_null_free_array, bool maybe_far = false);
 840   void test_non_null_free_array_oop(Register oop, Register temp_reg, Label& is_non_null_free_array);
 841 
 842   // Check array klass layout helper for flat or null-free arrays...
 843   void test_flat_array_layout(Register lh, Label& is_flat_array);
 844 
 845   void load_metadata(Register dst, Register src);
 846 
 847   void flat_field_copy(DecoratorSet decorators, Register src, Register dst, Register inline_layout_info);
 848 
 849   void load_prototype_header(Register dst, Register src);
 850 
 851   void inline_layout_info(Register holder_klass, Register index, Register layout_info);
 852 
 853   // inline type data payload offsets...
 854   void payload_offset(Register inline_klass, Register offset);
 855   void payload_address(Register oop, Register data, Register inline_klass, Register t1);
 856 
 857   // SIGTRAP-based range checks for arrays.
 858   inline void trap_range_check_l(Register a, Register b);
 859   inline void trap_range_check_l(Register a, int si16);
 860   static bool is_trap_range_check_l(int x) {
 861     return (is_tw (x, traptoLessThanUnsigned, -1/*any reg*/, -1/*any reg*/) ||
 862             is_twi(x, traptoLessThanUnsigned, -1/*any reg*/)                  );
 863   }
 864   inline void trap_range_check_le(Register a, int si16);
 865   static bool is_trap_range_check_le(int x) {
 866     return is_twi(x, traptoEqual | traptoLessThanUnsigned, -1/*any reg*/);
 867   }
 868   inline void trap_range_check_g(Register a, int si16);
 869   static bool is_trap_range_check_g(int x) {
 870     return is_twi(x, traptoGreaterThanUnsigned, -1/*any reg*/);
 871   }
 872   inline void trap_range_check_ge(Register a, Register b);
 873   inline void trap_range_check_ge(Register a, int si16);
 874   static bool is_trap_range_check_ge(int x) {
 875     return (is_tw (x, traptoEqual | traptoGreaterThanUnsigned, -1/*any reg*/, -1/*any reg*/) ||
 876             is_twi(x, traptoEqual | traptoGreaterThanUnsigned, -1/*any reg*/)                  );
 877   }
 878   static bool is_trap_range_check(int x) {
 879     return is_trap_range_check_l(x) || is_trap_range_check_le(x) ||
 880            is_trap_range_check_g(x) || is_trap_range_check_ge(x);
 881   }
 882 
 883   void clear_memory_unrolled(Register base_ptr, int cnt_dwords, Register tmp = R0, int offset = 0);
 884   void clear_memory_constlen(Register base_ptr, int cnt_dwords, Register tmp = R0);
 885   void clear_memory_doubleword(Register base_ptr, Register cnt_dwords, Register tmp = R0, long const_cnt = -1);
 886   void fill_words(Register base, Register cnt, Register value);
 887 
 888   // Emitters for BigInteger.multiplyToLen intrinsic.
 889   inline void multiply64(Register dest_hi, Register dest_lo,
 890                          Register x, Register y);
 891   void add2_with_carry(Register dest_hi, Register dest_lo,
 892                        Register src1, Register src2);
 893   void multiply_64_x_64_loop(Register x, Register xstart, Register x_xstart,
 894                              Register y, Register y_idx, Register z,
 895                              Register carry, Register product_high, Register product,
 896                              Register idx, Register kdx, Register tmp);
 897   void multiply_add_128_x_128(Register x_xstart, Register y, Register z,
 898                               Register yz_idx, Register idx, Register carry,
 899                               Register product_high, Register product, Register tmp,
 900                               int offset);
 901   void multiply_128_x_128_loop(Register x_xstart,
 902                                Register y, Register z,
 903                                Register yz_idx, Register idx, Register carry,
 904                                Register product_high, Register product,
 905                                Register carry2, Register tmp);
 906   void muladd(Register out, Register in, Register offset, Register len, Register k,

1035 
1036  private:
1037   void stop(int type, const char* msg);
1038 
1039  public:
1040   enum {
1041     stop_stop               = 0,
1042     stop_untested           = 1,
1043     stop_unimplemented      = 2,
1044     stop_shouldnotreachhere = 3,
1045     stop_msg_present        = -0x8000
1046   };
1047 
1048   // Prints msg, dumps registers and stops execution.
1049   void stop                 (const char* msg = nullptr) { stop(stop_stop,               msg); }
1050   void untested             (const char* msg = nullptr) { stop(stop_untested,           msg); }
1051   void unimplemented        (const char* msg = nullptr) { stop(stop_unimplemented,      msg); }
1052   void should_not_reach_here(const char* msg = nullptr) { stop(stop_shouldnotreachhere, msg); }
1053 
1054   void zap_from_to(Register low, int before, Register high, int after, Register val, Register addr) PRODUCT_RETURN;
1055 
1056   // Inline type specific methods
1057   #include "asm/macroAssembler_common.hpp"
1058 };
1059 
1060 #endif // CPU_PPC_MACROASSEMBLER_PPC_HPP
< prev index next >