25 #include "precompiled.hpp"
26 #include "asm/assembler.hpp"
27 #include "assembler_sparc.inline.hpp"
28 #include "gc_interface/collectedHeap.inline.hpp"
29 #include "interpreter/interpreter.hpp"
30 #include "memory/cardTableModRefBS.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "prims/methodHandles.hpp"
33 #include "runtime/biasedLocking.hpp"
34 #include "runtime/interfaceSupport.hpp"
35 #include "runtime/objectMonitor.hpp"
36 #include "runtime/os.hpp"
37 #include "runtime/sharedRuntime.hpp"
38 #include "runtime/stubRoutines.hpp"
39 #ifndef SERIALGC
40 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
41 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
42 #include "gc_implementation/g1/heapRegion.hpp"
43 #endif
44
45 // Convert the raw encoding form into the form expected by the
46 // constructor for Address.
47 Address Address::make_raw(int base, int index, int scale, int disp, bool disp_is_oop) {
48 assert(scale == 0, "not supported");
49 RelocationHolder rspec;
50 if (disp_is_oop) {
51 rspec = Relocation::spec_simple(relocInfo::oop_type);
52 }
53
54 Register rindex = as_Register(index);
55 if (rindex != G0) {
56 Address madr(as_Register(base), rindex);
57 madr._rspec = rspec;
58 return madr;
59 } else {
60 Address madr(as_Register(base), disp);
61 madr._rspec = rspec;
62 return madr;
63 }
64 }
1055 assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
1056
1057 // 64-bit last_java_sp is biased!
1058 set_last_Java_frame(last_java_sp, noreg);
1059 if (VerifyThread) mov(G2_thread, O0); // about to be smashed; pass early
1060 save_thread(thread_cache);
1061 // do the call
1062 call(entry_point, relocInfo::runtime_call_type);
1063 if (!VerifyThread)
1064 delayed()->mov(G2_thread, O0); // pass thread as first argument
1065 else
1066 delayed()->nop(); // (thread already passed)
1067 restore_thread(thread_cache);
1068 reset_last_Java_frame();
1069
1070 // check for pending exceptions. use Gtemp as scratch register.
1071 if (check_exceptions) {
1072 check_and_forward_exception(Gtemp);
1073 }
1074
1075 // get oop result if there is one and reset the value in the thread
1076 if (oop_result->is_valid()) {
1077 get_vm_result(oop_result);
1078 }
1079 }
1080
1081 void MacroAssembler::check_and_forward_exception(Register scratch_reg)
1082 {
1083 Label L;
1084
1085 check_and_handle_popframe(scratch_reg);
1086 check_and_handle_earlyret(scratch_reg);
1087
1088 Address exception_addr(G2_thread, Thread::pending_exception_offset());
1089 ld_ptr(exception_addr, scratch_reg);
1090 br_null(scratch_reg,false,pt,L);
1091 delayed()->nop();
1092 // we use O7 linkage so that forward_exception_entry has the issuing PC
1093 call(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
1094 delayed()->nop();
1160 }
1161
1162
1163 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
1164 // O0 is reserved for the thread
1165 mov(arg_1, O1);
1166 mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
1167 mov(arg_3, O3); assert(arg_3 != O1 && arg_3 != O2, "smashed argument");
1168 call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
1169 }
1170
1171
1172
1173 void MacroAssembler::call_VM_leaf_base(Register thread_cache, address entry_point, int number_of_arguments) {
1174 assert_not_delayed();
1175 save_thread(thread_cache);
1176 // do the call
1177 call(entry_point, relocInfo::runtime_call_type);
1178 delayed()->nop();
1179 restore_thread(thread_cache);
1180 }
1181
1182
1183 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, int number_of_arguments) {
1184 call_VM_leaf_base(thread_cache, entry_point, number_of_arguments);
1185 }
1186
1187
1188 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1) {
1189 mov(arg_1, O0);
1190 call_VM_leaf(thread_cache, entry_point, 1);
1191 }
1192
1193
1194 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2) {
1195 mov(arg_1, O0);
1196 mov(arg_2, O1); assert(arg_2 != O0, "smashed argument");
1197 call_VM_leaf(thread_cache, entry_point, 2);
1198 }
1199
1501 return count;
1502 }
1503
1504 // compute size in bytes of sparc frame, given
1505 // number of extraWords
1506 int MacroAssembler::total_frame_size_in_bytes(int extraWords) {
1507
1508 int nWords = frame::memory_parameter_word_sp_offset;
1509
1510 nWords += extraWords;
1511
1512 if (nWords & 1) ++nWords; // round up to double-word
1513
1514 return nWords * BytesPerWord;
1515 }
1516
1517
1518 // save_frame: given number of "extra" words in frame,
1519 // issue approp. save instruction (p 200, v8 manual)
1520
1521 void MacroAssembler::save_frame(int extraWords = 0) {
1522 int delta = -total_frame_size_in_bytes(extraWords);
1523 if (is_simm13(delta)) {
1524 save(SP, delta, SP);
1525 } else {
1526 set(delta, G3_scratch);
1527 save(SP, G3_scratch, SP);
1528 }
1529 }
1530
1531
1532 void MacroAssembler::save_frame_c1(int size_in_bytes) {
1533 if (is_simm13(-size_in_bytes)) {
1534 save(SP, -size_in_bytes, SP);
1535 } else {
1536 set(-size_in_bytes, G3_scratch);
1537 save(SP, G3_scratch, SP);
1538 }
1539 }
1540
1541
1713 // pushes double TOS element of FPU stack on CPU stack; pops from FPU stack
1714 void MacroAssembler::push_fTOS() {
1715 // %%%%%% need to implement this
1716 }
1717
1718 // pops double TOS element from CPU stack and pushes on FPU stack
1719 void MacroAssembler::pop_fTOS() {
1720 // %%%%%% need to implement this
1721 }
1722
1723 void MacroAssembler::empty_FPU_stack() {
1724 // %%%%%% need to implement this
1725 }
1726
1727 void MacroAssembler::_verify_oop(Register reg, const char* msg, const char * file, int line) {
1728 // plausibility check for oops
1729 if (!VerifyOops) return;
1730
1731 if (reg == G0) return; // always NULL, which is always an oop
1732
1733 char buffer[64];
1734 #ifdef COMPILER1
1735 if (CommentedAssembly) {
1736 snprintf(buffer, sizeof(buffer), "verify_oop at %d", offset());
1737 block_comment(buffer);
1738 }
1739 #endif
1740
1741 int len = strlen(file) + strlen(msg) + 1 + 4;
1742 sprintf(buffer, "%d", line);
1743 len += strlen(buffer);
1744 sprintf(buffer, " at offset %d ", offset());
1745 len += strlen(buffer);
1746 char * real_msg = new char[len];
1747 sprintf(real_msg, "%s%s(%s:%d)", msg, buffer, file, line);
1748
1749 // Call indirectly to solve generation ordering problem
1750 AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
1751
1752 // Make some space on stack above the current register window.
1753 // Enough to hold 8 64-bit registers.
1754 add(SP,-8*8,SP);
1755
1756 // Save some 64-bit registers; a normal 'save' chops the heads off
1757 // of 64-bit longs in the 32-bit build.
1758 stx(O0,SP,frame::register_save_words*wordSize+STACK_BIAS+0*8);
1759 stx(O1,SP,frame::register_save_words*wordSize+STACK_BIAS+1*8);
1760 mov(reg,O0); // Move arg into O0; arg might be in O7 which is about to be crushed
1761 stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
1762
1763 set((intptr_t)real_msg, O1);
1764 // Load address to call to into O7
1765 load_ptr_contents(a, O7);
1766 // Register call to verify_oop_subroutine
1767 callr(O7, G0);
1768 delayed()->nop();
1769 // recover frame size
1770 add(SP, 8*8,SP);
1771 }
1772
1773 void MacroAssembler::_verify_oop_addr(Address addr, const char* msg, const char * file, int line) {
1774 // plausibility check for oops
1775 if (!VerifyOops) return;
1776
1777 char buffer[64];
1778 sprintf(buffer, "%d", line);
1779 int len = strlen(file) + strlen(msg) + 1 + 4 + strlen(buffer);
1780 sprintf(buffer, " at SP+%d ", addr.disp());
1781 len += strlen(buffer);
1782 char * real_msg = new char[len];
1783 sprintf(real_msg, "%s at SP+%d (%s:%d)", msg, addr.disp(), file, line);
1784
1785 // Call indirectly to solve generation ordering problem
1786 AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
1787
1788 // Make some space on stack above the current register window.
1789 // Enough to hold 8 64-bit registers.
1790 add(SP,-8*8,SP);
2023
2024
2025 void MacroAssembler::debug(char* msg, RegistersForDebugging* regs) {
2026 if ( ShowMessageBoxOnError ) {
2027 JavaThreadState saved_state = JavaThread::current()->thread_state();
2028 JavaThread::current()->set_thread_state(_thread_in_vm);
2029 {
2030 // In order to get locks work, we need to fake a in_VM state
2031 ttyLocker ttyl;
2032 ::tty->print_cr("EXECUTION STOPPED: %s\n", msg);
2033 if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
2034 ::tty->print_cr("Interpreter::bytecode_counter = %d", BytecodeCounter::counter_value());
2035 }
2036 if (os::message_box(msg, "Execution stopped, print registers?"))
2037 regs->print(::tty);
2038 }
2039 ThreadStateTransition::transition(JavaThread::current(), _thread_in_vm, saved_state);
2040 }
2041 else
2042 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg);
2043 assert(false, "error");
2044 }
2045
2046
2047 #ifndef PRODUCT
2048 void MacroAssembler::test() {
2049 ResourceMark rm;
2050
2051 CodeBuffer cb("test", 10000, 10000);
2052 MacroAssembler* a = new MacroAssembler(&cb);
2053 VM_Version::allow_all();
2054 a->test_v9();
2055 a->test_v8_onlys();
2056 VM_Version::revert();
2057
2058 StubRoutines::Sparc::test_stop_entry()();
2059 }
2060 #endif
2061
2062
2063 void MacroAssembler::calc_mem_param_words(Register Rparam_words, Register Rresult) {
3213
3214 // pick out the interpreted side of the handler
3215 // NOTE: vmentry is not an oop!
3216 ld_ptr(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes, temp_reg), temp_reg);
3217
3218 // off we go...
3219 ld_ptr(temp_reg, MethodHandleEntry::from_interpreted_entry_offset_in_bytes(), temp_reg);
3220 jmp(temp_reg, 0);
3221
3222 // for the various stubs which take control at this point,
3223 // see MethodHandles::generate_method_handle_stub
3224
3225 // Some callers can fill the delay slot.
3226 if (emit_delayed_nop) {
3227 delayed()->nop();
3228 }
3229 }
3230
3231
3232 RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot,
3233 int extra_slot_offset) {
3234 // cf. TemplateTable::prepare_invoke(), if (load_receiver).
3235 int stackElementSize = Interpreter::stackElementSize;
3236 int offset = extra_slot_offset * stackElementSize;
3237 if (arg_slot.is_constant()) {
3238 offset += arg_slot.as_constant() * stackElementSize;
3239 return offset;
3240 } else {
3241 Register temp = arg_slot.as_register();
3242 sll_ptr(temp, exact_log2(stackElementSize), temp);
3243 if (offset != 0)
3244 add(temp, offset, temp);
3245 return temp;
3246 }
3247 }
3248
3249
3250 Address MacroAssembler::argument_address(RegisterOrConstant arg_slot,
3251 int extra_slot_offset) {
3252 return Address(Gargs, argument_offset(arg_slot, extra_slot_offset));
3253 }
3254
3255
3256 void MacroAssembler::biased_locking_enter(Register obj_reg, Register mark_reg,
3257 Register temp_reg,
3258 Label& done, Label* slow_case,
3259 BiasedLockingCounters* counters) {
3260 assert(UseBiasedLocking, "why call this otherwise?");
3261
3262 if (PrintBiasedLockingStatistics) {
3263 assert_different_registers(obj_reg, mark_reg, temp_reg, O7);
3264 if (counters == NULL)
3265 counters = BiasedLocking::counters();
3266 }
3267
3268 Label cas_label;
3269
3270 // Biased locking
3271 // See whether the lock is currently biased toward our thread and
3272 // whether the epoch is still valid
|
25 #include "precompiled.hpp"
26 #include "asm/assembler.hpp"
27 #include "assembler_sparc.inline.hpp"
28 #include "gc_interface/collectedHeap.inline.hpp"
29 #include "interpreter/interpreter.hpp"
30 #include "memory/cardTableModRefBS.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "prims/methodHandles.hpp"
33 #include "runtime/biasedLocking.hpp"
34 #include "runtime/interfaceSupport.hpp"
35 #include "runtime/objectMonitor.hpp"
36 #include "runtime/os.hpp"
37 #include "runtime/sharedRuntime.hpp"
38 #include "runtime/stubRoutines.hpp"
39 #ifndef SERIALGC
40 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
41 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
42 #include "gc_implementation/g1/heapRegion.hpp"
43 #endif
44
45 #ifdef PRODUCT
46 #define BLOCK_COMMENT(str) /* nothing */
47 #else
48 #define BLOCK_COMMENT(str) block_comment(str)
49 #endif
50
51 // Convert the raw encoding form into the form expected by the
52 // constructor for Address.
53 Address Address::make_raw(int base, int index, int scale, int disp, bool disp_is_oop) {
54 assert(scale == 0, "not supported");
55 RelocationHolder rspec;
56 if (disp_is_oop) {
57 rspec = Relocation::spec_simple(relocInfo::oop_type);
58 }
59
60 Register rindex = as_Register(index);
61 if (rindex != G0) {
62 Address madr(as_Register(base), rindex);
63 madr._rspec = rspec;
64 return madr;
65 } else {
66 Address madr(as_Register(base), disp);
67 madr._rspec = rspec;
68 return madr;
69 }
70 }
1061 assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
1062
1063 // 64-bit last_java_sp is biased!
1064 set_last_Java_frame(last_java_sp, noreg);
1065 if (VerifyThread) mov(G2_thread, O0); // about to be smashed; pass early
1066 save_thread(thread_cache);
1067 // do the call
1068 call(entry_point, relocInfo::runtime_call_type);
1069 if (!VerifyThread)
1070 delayed()->mov(G2_thread, O0); // pass thread as first argument
1071 else
1072 delayed()->nop(); // (thread already passed)
1073 restore_thread(thread_cache);
1074 reset_last_Java_frame();
1075
1076 // check for pending exceptions. use Gtemp as scratch register.
1077 if (check_exceptions) {
1078 check_and_forward_exception(Gtemp);
1079 }
1080
1081 #ifdef ASSERT
1082 set(badHeapWordVal, G3);
1083 set(badHeapWordVal, G4);
1084 set(badHeapWordVal, G5);
1085 #endif
1086
1087 // get oop result if there is one and reset the value in the thread
1088 if (oop_result->is_valid()) {
1089 get_vm_result(oop_result);
1090 }
1091 }
1092
1093 void MacroAssembler::check_and_forward_exception(Register scratch_reg)
1094 {
1095 Label L;
1096
1097 check_and_handle_popframe(scratch_reg);
1098 check_and_handle_earlyret(scratch_reg);
1099
1100 Address exception_addr(G2_thread, Thread::pending_exception_offset());
1101 ld_ptr(exception_addr, scratch_reg);
1102 br_null(scratch_reg,false,pt,L);
1103 delayed()->nop();
1104 // we use O7 linkage so that forward_exception_entry has the issuing PC
1105 call(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
1106 delayed()->nop();
1172 }
1173
1174
1175 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
1176 // O0 is reserved for the thread
1177 mov(arg_1, O1);
1178 mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
1179 mov(arg_3, O3); assert(arg_3 != O1 && arg_3 != O2, "smashed argument");
1180 call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
1181 }
1182
1183
1184
1185 void MacroAssembler::call_VM_leaf_base(Register thread_cache, address entry_point, int number_of_arguments) {
1186 assert_not_delayed();
1187 save_thread(thread_cache);
1188 // do the call
1189 call(entry_point, relocInfo::runtime_call_type);
1190 delayed()->nop();
1191 restore_thread(thread_cache);
1192 #ifdef ASSERT
1193 set(badHeapWordVal, G3);
1194 set(badHeapWordVal, G4);
1195 set(badHeapWordVal, G5);
1196 #endif
1197 }
1198
1199
1200 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, int number_of_arguments) {
1201 call_VM_leaf_base(thread_cache, entry_point, number_of_arguments);
1202 }
1203
1204
1205 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1) {
1206 mov(arg_1, O0);
1207 call_VM_leaf(thread_cache, entry_point, 1);
1208 }
1209
1210
1211 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2) {
1212 mov(arg_1, O0);
1213 mov(arg_2, O1); assert(arg_2 != O0, "smashed argument");
1214 call_VM_leaf(thread_cache, entry_point, 2);
1215 }
1216
1518 return count;
1519 }
1520
1521 // compute size in bytes of sparc frame, given
1522 // number of extraWords
1523 int MacroAssembler::total_frame_size_in_bytes(int extraWords) {
1524
1525 int nWords = frame::memory_parameter_word_sp_offset;
1526
1527 nWords += extraWords;
1528
1529 if (nWords & 1) ++nWords; // round up to double-word
1530
1531 return nWords * BytesPerWord;
1532 }
1533
1534
1535 // save_frame: given number of "extra" words in frame,
1536 // issue approp. save instruction (p 200, v8 manual)
1537
1538 void MacroAssembler::save_frame(int extraWords) {
1539 int delta = -total_frame_size_in_bytes(extraWords);
1540 if (is_simm13(delta)) {
1541 save(SP, delta, SP);
1542 } else {
1543 set(delta, G3_scratch);
1544 save(SP, G3_scratch, SP);
1545 }
1546 }
1547
1548
1549 void MacroAssembler::save_frame_c1(int size_in_bytes) {
1550 if (is_simm13(-size_in_bytes)) {
1551 save(SP, -size_in_bytes, SP);
1552 } else {
1553 set(-size_in_bytes, G3_scratch);
1554 save(SP, G3_scratch, SP);
1555 }
1556 }
1557
1558
1730 // pushes double TOS element of FPU stack on CPU stack; pops from FPU stack
1731 void MacroAssembler::push_fTOS() {
1732 // %%%%%% need to implement this
1733 }
1734
1735 // pops double TOS element from CPU stack and pushes on FPU stack
1736 void MacroAssembler::pop_fTOS() {
1737 // %%%%%% need to implement this
1738 }
1739
1740 void MacroAssembler::empty_FPU_stack() {
1741 // %%%%%% need to implement this
1742 }
1743
1744 void MacroAssembler::_verify_oop(Register reg, const char* msg, const char * file, int line) {
1745 // plausibility check for oops
1746 if (!VerifyOops) return;
1747
1748 if (reg == G0) return; // always NULL, which is always an oop
1749
1750 BLOCK_COMMENT("verify_oop {");
1751 char buffer[64];
1752 #ifdef COMPILER1
1753 if (CommentedAssembly) {
1754 snprintf(buffer, sizeof(buffer), "verify_oop at %d", offset());
1755 block_comment(buffer);
1756 }
1757 #endif
1758
1759 int len = strlen(file) + strlen(msg) + 1 + 4;
1760 sprintf(buffer, "%d", line);
1761 len += strlen(buffer);
1762 sprintf(buffer, " at offset %d ", offset());
1763 len += strlen(buffer);
1764 char * real_msg = new char[len];
1765 sprintf(real_msg, "%s%s(%s:%d)", msg, buffer, file, line);
1766
1767 // Call indirectly to solve generation ordering problem
1768 AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
1769
1770 // Make some space on stack above the current register window.
1771 // Enough to hold 8 64-bit registers.
1772 add(SP,-8*8,SP);
1773
1774 // Save some 64-bit registers; a normal 'save' chops the heads off
1775 // of 64-bit longs in the 32-bit build.
1776 stx(O0,SP,frame::register_save_words*wordSize+STACK_BIAS+0*8);
1777 stx(O1,SP,frame::register_save_words*wordSize+STACK_BIAS+1*8);
1778 mov(reg,O0); // Move arg into O0; arg might be in O7 which is about to be crushed
1779 stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
1780
1781 set((intptr_t)real_msg, O1);
1782 // Load address to call to into O7
1783 load_ptr_contents(a, O7);
1784 // Register call to verify_oop_subroutine
1785 callr(O7, G0);
1786 delayed()->nop();
1787 // recover frame size
1788 add(SP, 8*8,SP);
1789 BLOCK_COMMENT("} verify_oop");
1790 }
1791
1792 void MacroAssembler::_verify_oop_addr(Address addr, const char* msg, const char * file, int line) {
1793 // plausibility check for oops
1794 if (!VerifyOops) return;
1795
1796 char buffer[64];
1797 sprintf(buffer, "%d", line);
1798 int len = strlen(file) + strlen(msg) + 1 + 4 + strlen(buffer);
1799 sprintf(buffer, " at SP+%d ", addr.disp());
1800 len += strlen(buffer);
1801 char * real_msg = new char[len];
1802 sprintf(real_msg, "%s at SP+%d (%s:%d)", msg, addr.disp(), file, line);
1803
1804 // Call indirectly to solve generation ordering problem
1805 AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
1806
1807 // Make some space on stack above the current register window.
1808 // Enough to hold 8 64-bit registers.
1809 add(SP,-8*8,SP);
2042
2043
2044 void MacroAssembler::debug(char* msg, RegistersForDebugging* regs) {
2045 if ( ShowMessageBoxOnError ) {
2046 JavaThreadState saved_state = JavaThread::current()->thread_state();
2047 JavaThread::current()->set_thread_state(_thread_in_vm);
2048 {
2049 // In order to get locks work, we need to fake a in_VM state
2050 ttyLocker ttyl;
2051 ::tty->print_cr("EXECUTION STOPPED: %s\n", msg);
2052 if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
2053 ::tty->print_cr("Interpreter::bytecode_counter = %d", BytecodeCounter::counter_value());
2054 }
2055 if (os::message_box(msg, "Execution stopped, print registers?"))
2056 regs->print(::tty);
2057 }
2058 ThreadStateTransition::transition(JavaThread::current(), _thread_in_vm, saved_state);
2059 }
2060 else
2061 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg);
2062 assert(false, err_msg("DEBUG MESSAGE: %s", msg));
2063 }
2064
2065
2066 #ifndef PRODUCT
2067 void MacroAssembler::test() {
2068 ResourceMark rm;
2069
2070 CodeBuffer cb("test", 10000, 10000);
2071 MacroAssembler* a = new MacroAssembler(&cb);
2072 VM_Version::allow_all();
2073 a->test_v9();
2074 a->test_v8_onlys();
2075 VM_Version::revert();
2076
2077 StubRoutines::Sparc::test_stop_entry()();
2078 }
2079 #endif
2080
2081
2082 void MacroAssembler::calc_mem_param_words(Register Rparam_words, Register Rresult) {
3232
3233 // pick out the interpreted side of the handler
3234 // NOTE: vmentry is not an oop!
3235 ld_ptr(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes, temp_reg), temp_reg);
3236
3237 // off we go...
3238 ld_ptr(temp_reg, MethodHandleEntry::from_interpreted_entry_offset_in_bytes(), temp_reg);
3239 jmp(temp_reg, 0);
3240
3241 // for the various stubs which take control at this point,
3242 // see MethodHandles::generate_method_handle_stub
3243
3244 // Some callers can fill the delay slot.
3245 if (emit_delayed_nop) {
3246 delayed()->nop();
3247 }
3248 }
3249
3250
3251 RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot,
3252 Register temp_reg,
3253 int extra_slot_offset) {
3254 // cf. TemplateTable::prepare_invoke(), if (load_receiver).
3255 int stackElementSize = Interpreter::stackElementSize;
3256 int offset = extra_slot_offset * stackElementSize;
3257 if (arg_slot.is_constant()) {
3258 offset += arg_slot.as_constant() * stackElementSize;
3259 return offset;
3260 } else {
3261 assert(temp_reg != noreg, "must specify");
3262 sll_ptr(arg_slot.as_register(), exact_log2(stackElementSize), temp_reg);
3263 if (offset != 0)
3264 add(temp_reg, offset, temp_reg);
3265 return temp_reg;
3266 }
3267 }
3268
3269
3270 Address MacroAssembler::argument_address(RegisterOrConstant arg_slot,
3271 Register temp_reg,
3272 int extra_slot_offset) {
3273 return Address(Gargs, argument_offset(arg_slot, temp_reg, extra_slot_offset));
3274 }
3275
3276
3277 void MacroAssembler::biased_locking_enter(Register obj_reg, Register mark_reg,
3278 Register temp_reg,
3279 Label& done, Label* slow_case,
3280 BiasedLockingCounters* counters) {
3281 assert(UseBiasedLocking, "why call this otherwise?");
3282
3283 if (PrintBiasedLockingStatistics) {
3284 assert_different_registers(obj_reg, mark_reg, temp_reg, O7);
3285 if (counters == NULL)
3286 counters = BiasedLocking::counters();
3287 }
3288
3289 Label cas_label;
3290
3291 // Biased locking
3292 // See whether the lock is currently biased toward our thread and
3293 // whether the epoch is still valid
|