30 31 // MacroAssembler extends Assembler by frequently used macros. 32 // 33 // Instructions for which a 'better' code sequence exists depending 34 // on arguments should also go in here. 35 36 class MacroAssembler: public Assembler { 37 friend class LIR_Assembler; 38 39 public: 40 using Assembler::mov; 41 using Assembler::movi; 42 43 protected: 44 45 // Support for VM calls 46 // 47 // This is the base routine called by the different versions of call_VM_leaf. The interpreter 48 // may customize this version by overriding it for its purposes (e.g., to save/restore 49 // additional registers when doing a VM call). 50 #ifdef CC_INTERP 51 // c++ interpreter never wants to use interp_masm version of call_VM 52 #define VIRTUAL 53 #else 54 #define VIRTUAL virtual 55 #endif 56 57 VIRTUAL void call_VM_leaf_base( 58 address entry_point, // the entry point 59 int number_of_arguments, // the number of arguments to pop after the call 60 Label *retaddr = NULL 61 ); 62 63 VIRTUAL void call_VM_leaf_base( 64 address entry_point, // the entry point 65 int number_of_arguments, // the number of arguments to pop after the call 66 Label &retaddr) { 67 call_VM_leaf_base(entry_point, number_of_arguments, &retaddr); 68 } 69 70 // This is the base routine called by the different versions of call_VM. The interpreter 71 // may customize this version by overriding it for its purposes (e.g., to save/restore 72 // additional registers when doing a VM call). 73 // 74 // If no java_thread register is specified (noreg) than rthread will be used instead. call_VM_base 75 // returns the register which contains the thread upon return. If a thread register has been 76 // specified, the return value will correspond to that register. If no last_java_sp is specified 77 // (noreg) than rsp will be used instead. 78 VIRTUAL void call_VM_base( // returns the register containing the thread upon return 79 Register oop_result, // where an oop-result ends up if any; use noreg otherwise 80 Register java_thread, // the thread if computed before ; use noreg otherwise 81 Register last_java_sp, // to set up last_Java_frame in stubs; use noreg otherwise 82 address entry_point, // the entry point 83 int number_of_arguments, // the number of arguments (w/o thread) to pop after the call 84 bool check_exceptions // whether to check for pending exceptions after return 85 ); 86 87 // These routines should emit JVMTI PopFrame and ForceEarlyReturn handling code. 88 // The implementation is only non-empty for the InterpreterMacroAssembler, 89 // as only the interpreter handles PopFrame and ForceEarlyReturn requests. 90 virtual void check_and_handle_popframe(Register java_thread); 91 virtual void check_and_handle_earlyret(Register java_thread); 92 93 void call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions = true); 94 95 // Maximum size of class area in Metaspace when compressed 96 uint64_t use_XOR_for_compressed_class_base; 97 98 public: 986 address ic_call(address entry); 987 988 public: 989 990 // Data 991 992 void mov_metadata(Register dst, Metadata* obj); 993 Address allocate_metadata_address(Metadata* obj); 994 Address constant_oop_address(jobject obj); 995 996 void movoop(Register dst, jobject obj, bool immediate = false); 997 998 // CRC32 code for java.util.zip.CRC32::updateBytes() instrinsic. 999 void kernel_crc32(Register crc, Register buf, Register len, 1000 Register table0, Register table1, Register table2, Register table3, 1001 Register tmp, Register tmp2, Register tmp3); 1002 // CRC32 code for java.util.zip.CRC32C::updateBytes() instrinsic. 1003 void kernel_crc32c(Register crc, Register buf, Register len, 1004 Register table0, Register table1, Register table2, Register table3, 1005 Register tmp, Register tmp2, Register tmp3); 1006 1007 #undef VIRTUAL 1008 1009 // Stack push and pop individual 64 bit registers 1010 void push(Register src); 1011 void pop(Register dst); 1012 1013 // push all registers onto the stack 1014 void pusha(); 1015 void popa(); 1016 1017 void repne_scan(Register addr, Register value, Register count, 1018 Register scratch); 1019 void repne_scanw(Register addr, Register value, Register count, 1020 Register scratch); 1021 1022 typedef void (MacroAssembler::* add_sub_imm_insn)(Register Rd, Register Rn, unsigned imm); 1023 typedef void (MacroAssembler::* add_sub_reg_insn)(Register Rd, Register Rn, Register Rm, enum shift_kind kind, unsigned shift); 1024 1025 // If a constant does not fit in an immediate field, generate some 1026 // number of MOV instructions and then perform the operation 1027 void wrap_add_sub_imm_insn(Register Rd, Register Rn, unsigned imm, | 30 31 // MacroAssembler extends Assembler by frequently used macros. 32 // 33 // Instructions for which a 'better' code sequence exists depending 34 // on arguments should also go in here. 35 36 class MacroAssembler: public Assembler { 37 friend class LIR_Assembler; 38 39 public: 40 using Assembler::mov; 41 using Assembler::movi; 42 43 protected: 44 45 // Support for VM calls 46 // 47 // This is the base routine called by the different versions of call_VM_leaf. The interpreter 48 // may customize this version by overriding it for its purposes (e.g., to save/restore 49 // additional registers when doing a VM call). 50 virtual void call_VM_leaf_base( 51 address entry_point, // the entry point 52 int number_of_arguments, // the number of arguments to pop after the call 53 Label *retaddr = NULL 54 ); 55 56 virtual void call_VM_leaf_base( 57 address entry_point, // the entry point 58 int number_of_arguments, // the number of arguments to pop after the call 59 Label &retaddr) { 60 call_VM_leaf_base(entry_point, number_of_arguments, &retaddr); 61 } 62 63 // This is the base routine called by the different versions of call_VM. The interpreter 64 // may customize this version by overriding it for its purposes (e.g., to save/restore 65 // additional registers when doing a VM call). 66 // 67 // If no java_thread register is specified (noreg) than rthread will be used instead. call_VM_base 68 // returns the register which contains the thread upon return. If a thread register has been 69 // specified, the return value will correspond to that register. If no last_java_sp is specified 70 // (noreg) than rsp will be used instead. 71 virtual void call_VM_base( // returns the register containing the thread upon return 72 Register oop_result, // where an oop-result ends up if any; use noreg otherwise 73 Register java_thread, // the thread if computed before ; use noreg otherwise 74 Register last_java_sp, // to set up last_Java_frame in stubs; use noreg otherwise 75 address entry_point, // the entry point 76 int number_of_arguments, // the number of arguments (w/o thread) to pop after the call 77 bool check_exceptions // whether to check for pending exceptions after return 78 ); 79 80 // These routines should emit JVMTI PopFrame and ForceEarlyReturn handling code. 81 // The implementation is only non-empty for the InterpreterMacroAssembler, 82 // as only the interpreter handles PopFrame and ForceEarlyReturn requests. 83 virtual void check_and_handle_popframe(Register java_thread); 84 virtual void check_and_handle_earlyret(Register java_thread); 85 86 void call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions = true); 87 88 // Maximum size of class area in Metaspace when compressed 89 uint64_t use_XOR_for_compressed_class_base; 90 91 public: 979 address ic_call(address entry); 980 981 public: 982 983 // Data 984 985 void mov_metadata(Register dst, Metadata* obj); 986 Address allocate_metadata_address(Metadata* obj); 987 Address constant_oop_address(jobject obj); 988 989 void movoop(Register dst, jobject obj, bool immediate = false); 990 991 // CRC32 code for java.util.zip.CRC32::updateBytes() instrinsic. 992 void kernel_crc32(Register crc, Register buf, Register len, 993 Register table0, Register table1, Register table2, Register table3, 994 Register tmp, Register tmp2, Register tmp3); 995 // CRC32 code for java.util.zip.CRC32C::updateBytes() instrinsic. 996 void kernel_crc32c(Register crc, Register buf, Register len, 997 Register table0, Register table1, Register table2, Register table3, 998 Register tmp, Register tmp2, Register tmp3); 999 1000 // Stack push and pop individual 64 bit registers 1001 void push(Register src); 1002 void pop(Register dst); 1003 1004 // push all registers onto the stack 1005 void pusha(); 1006 void popa(); 1007 1008 void repne_scan(Register addr, Register value, Register count, 1009 Register scratch); 1010 void repne_scanw(Register addr, Register value, Register count, 1011 Register scratch); 1012 1013 typedef void (MacroAssembler::* add_sub_imm_insn)(Register Rd, Register Rn, unsigned imm); 1014 typedef void (MacroAssembler::* add_sub_reg_insn)(Register Rd, Register Rn, Register Rm, enum shift_kind kind, unsigned shift); 1015 1016 // If a constant does not fit in an immediate field, generate some 1017 // number of MOV instructions and then perform the operation 1018 void wrap_add_sub_imm_insn(Register Rd, Register Rn, unsigned imm, |