< prev index next >

src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp

Print this page

 972 
 973   __ ld(t0, Address(xthread, JavaThread::shadow_zone_growth_watermark()));
 974   __ bgtu(sp, t0, L_done);
 975 
 976   for (int p = 1; p <= n_shadow_pages; p++) {
 977     __ bang_stack_with_offset(p * page_size);
 978   }
 979 
 980   // Record the new watermark, but only if the update is above the safe limit.
 981   // Otherwise, the next time around the check above would pass the safe limit.
 982   __ ld(t0, Address(xthread, JavaThread::shadow_zone_safe_limit()));
 983   __ bleu(sp, t0, L_done);
 984   __ sd(sp, Address(xthread, JavaThread::shadow_zone_growth_watermark()));
 985 
 986   __ bind(L_done);
 987 }
 988 
 989 // Interpreter stub for calling a native method. (asm interpreter)
 990 // This sets up a somewhat different looking stack for calling the
 991 // native method than the typical interpreter frame setup.
 992 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
 993   // determine code generation flags
 994   bool inc_counter = UseCompiler || CountCompiledCalls;
 995 
 996   // x11: Method*
 997   // x30: sender sp
 998 
 999   address entry_point = __ pc();
1000 
1001   const Address constMethod       (xmethod, Method::const_offset());
1002   const Address access_flags      (xmethod, Method::access_flags_offset());
1003   const Address size_of_parameters(x12, ConstMethod::
1004                                    size_of_parameters_offset());
1005 
1006   // get parameter size (always needed)
1007   __ ld(x12, constMethod);
1008   __ load_unsigned_short(x12, size_of_parameters);
1009 
1010   // Native calls don't need the stack size check since they have no
1011   // expression stack and the arguments are already on the stack and
1012   // we only add a handful of words to the stack.
1013 
1014   // xmethod: Method*

1423 
1424   JFR_ONLY(__ leave_jfr_critical_section();)
1425 
1426   // restore sender sp
1427   __ mv(sp, esp);
1428 
1429   __ ret();
1430 
1431   if (inc_counter) {
1432     // Handle overflow of counter and compile method
1433     __ bind(invocation_counter_overflow);
1434     generate_counter_overflow(continue_after_compile);
1435   }
1436 
1437   return entry_point;
1438 }
1439 
1440 //
1441 // Generic interpreted method entry to (asm) interpreter
1442 //
1443 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
1444 
1445   // determine code generation flags
1446   const bool inc_counter  = UseCompiler || CountCompiledCalls;
1447 
1448   // t0: sender sp
1449   address entry_point = __ pc();
1450 
1451   const Address constMethod(xmethod, Method::const_offset());
1452   const Address access_flags(xmethod, Method::access_flags_offset());
1453   const Address size_of_parameters(x13,
1454                                    ConstMethod::size_of_parameters_offset());
1455   const Address size_of_locals(x13, ConstMethod::size_of_locals_offset());
1456 
1457   // get parameter size (always needed)
1458   // need to load the const method first
1459   __ ld(x13, constMethod);
1460   __ load_unsigned_short(x12, size_of_parameters);
1461 
1462   // x12: size of parameters
1463 
1464   __ load_unsigned_short(x13, size_of_locals); // get size of locals in words
1465   __ sub(x13, x13, x12); // x13 = no. of additional locals
1466 

1856 
1857 //-----------------------------------------------------------------------------
1858 
1859 // Non-product code
1860 #ifndef PRODUCT
1861 address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
1862   address entry = __ pc();
1863 
1864   __ push_reg(ra);
1865   __ push(state);
1866   __ push_reg(RegSet::range(x10, x17) + RegSet::range(x5, x7) + RegSet::range(x28, x31), sp);
1867   __ mv(c_rarg2, x10);  // Pass itos
1868   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), c_rarg1, c_rarg2, c_rarg3);
1869   __ pop_reg(RegSet::range(x10, x17) + RegSet::range(x5, x7) + RegSet::range(x28, x31), sp);
1870   __ pop(state);
1871   __ pop_reg(ra);
1872   __ ret();                                   // return from result handler
1873 
1874   return entry;
1875 }

1876 
1877 void TemplateInterpreterGenerator::count_bytecode() {
1878   __ mv(x7, (address) &BytecodeCounter::_counter_value);
1879   __ atomic_add(noreg, 1, x7);
1880 }
1881 
1882 void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
1883   __ mv(x7, (address) &BytecodeHistogram::_counters[t->bytecode()]);
1884   __ atomic_addw(noreg, 1, x7);
1885 }
1886 

1887 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
1888   // Calculate new index for counter:
1889   //   _index = (_index >> log2_number_of_codes) |
1890   //            (bytecode << log2_number_of_codes);
1891   Register index_addr = t1;
1892   Register index = t0;
1893   __ mv(index_addr, (address) &BytecodePairHistogram::_index);
1894   __ lw(index, index_addr);
1895   __ mv(x7, ((int)t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
1896   __ srli(index, index, BytecodePairHistogram::log2_number_of_codes);
1897   __ orrw(index, x7, index);
1898   __ sw(index, index_addr);
1899   // Bump bucket contents:
1900   //   _counters[_index] ++;
1901   Register counter_addr = t1;
1902   __ mv(x7, (address) &BytecodePairHistogram::_counters);
1903   __ shadd(counter_addr, index, x7, counter_addr, LogBytesPerInt);
1904   __ atomic_addw(noreg, 1, counter_addr);
1905  }
1906 

 972 
 973   __ ld(t0, Address(xthread, JavaThread::shadow_zone_growth_watermark()));
 974   __ bgtu(sp, t0, L_done);
 975 
 976   for (int p = 1; p <= n_shadow_pages; p++) {
 977     __ bang_stack_with_offset(p * page_size);
 978   }
 979 
 980   // Record the new watermark, but only if the update is above the safe limit.
 981   // Otherwise, the next time around the check above would pass the safe limit.
 982   __ ld(t0, Address(xthread, JavaThread::shadow_zone_safe_limit()));
 983   __ bleu(sp, t0, L_done);
 984   __ sd(sp, Address(xthread, JavaThread::shadow_zone_growth_watermark()));
 985 
 986   __ bind(L_done);
 987 }
 988 
 989 // Interpreter stub for calling a native method. (asm interpreter)
 990 // This sets up a somewhat different looking stack for calling the
 991 // native method than the typical interpreter frame setup.
 992 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized, bool runtime_upcalls) {
 993   // determine code generation flags
 994   bool inc_counter = (UseCompiler || CountCompiledCalls) && !PreloadOnly;
 995 
 996   // x11: Method*
 997   // x30: sender sp
 998 
 999   address entry_point = __ pc();
1000 
1001   const Address constMethod       (xmethod, Method::const_offset());
1002   const Address access_flags      (xmethod, Method::access_flags_offset());
1003   const Address size_of_parameters(x12, ConstMethod::
1004                                    size_of_parameters_offset());
1005 
1006   // get parameter size (always needed)
1007   __ ld(x12, constMethod);
1008   __ load_unsigned_short(x12, size_of_parameters);
1009 
1010   // Native calls don't need the stack size check since they have no
1011   // expression stack and the arguments are already on the stack and
1012   // we only add a handful of words to the stack.
1013 
1014   // xmethod: Method*

1423 
1424   JFR_ONLY(__ leave_jfr_critical_section();)
1425 
1426   // restore sender sp
1427   __ mv(sp, esp);
1428 
1429   __ ret();
1430 
1431   if (inc_counter) {
1432     // Handle overflow of counter and compile method
1433     __ bind(invocation_counter_overflow);
1434     generate_counter_overflow(continue_after_compile);
1435   }
1436 
1437   return entry_point;
1438 }
1439 
1440 //
1441 // Generic interpreted method entry to (asm) interpreter
1442 //
1443 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized, bool runtime_upcalls) {
1444 
1445   // determine code generation flags
1446   const bool inc_counter = (UseCompiler || CountCompiledCalls) && !PreloadOnly;
1447 
1448   // t0: sender sp
1449   address entry_point = __ pc();
1450 
1451   const Address constMethod(xmethod, Method::const_offset());
1452   const Address access_flags(xmethod, Method::access_flags_offset());
1453   const Address size_of_parameters(x13,
1454                                    ConstMethod::size_of_parameters_offset());
1455   const Address size_of_locals(x13, ConstMethod::size_of_locals_offset());
1456 
1457   // get parameter size (always needed)
1458   // need to load the const method first
1459   __ ld(x13, constMethod);
1460   __ load_unsigned_short(x12, size_of_parameters);
1461 
1462   // x12: size of parameters
1463 
1464   __ load_unsigned_short(x13, size_of_locals); // get size of locals in words
1465   __ sub(x13, x13, x12); // x13 = no. of additional locals
1466 

1856 
1857 //-----------------------------------------------------------------------------
1858 
1859 // Non-product code
1860 #ifndef PRODUCT
1861 address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
1862   address entry = __ pc();
1863 
1864   __ push_reg(ra);
1865   __ push(state);
1866   __ push_reg(RegSet::range(x10, x17) + RegSet::range(x5, x7) + RegSet::range(x28, x31), sp);
1867   __ mv(c_rarg2, x10);  // Pass itos
1868   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), c_rarg1, c_rarg2, c_rarg3);
1869   __ pop_reg(RegSet::range(x10, x17) + RegSet::range(x5, x7) + RegSet::range(x28, x31), sp);
1870   __ pop(state);
1871   __ pop_reg(ra);
1872   __ ret();                                   // return from result handler
1873 
1874   return entry;
1875 }
1876 #endif // PRODUCT
1877 
1878 void TemplateInterpreterGenerator::count_bytecode() {
1879   __ mv(x7, (address) &BytecodeCounter::_counter_value);
1880   __ atomic_add(noreg, 1, x7);
1881 }
1882 
1883 void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
1884   __ mv(x7, (address) &BytecodeHistogram::_counters[t->bytecode()]);
1885   __ atomic_addw(noreg, 1, x7);
1886 }
1887 
1888 #ifndef PRODUCT
1889 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
1890   // Calculate new index for counter:
1891   //   _index = (_index >> log2_number_of_codes) |
1892   //            (bytecode << log2_number_of_codes);
1893   Register index_addr = t1;
1894   Register index = t0;
1895   __ mv(index_addr, (address) &BytecodePairHistogram::_index);
1896   __ lw(index, index_addr);
1897   __ mv(x7, ((int)t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
1898   __ srli(index, index, BytecodePairHistogram::log2_number_of_codes);
1899   __ orrw(index, x7, index);
1900   __ sw(index, index_addr);
1901   // Bump bucket contents:
1902   //   _counters[_index] ++;
1903   Register counter_addr = t1;
1904   __ mv(x7, (address) &BytecodePairHistogram::_counters);
1905   __ shadd(counter_addr, index, x7, counter_addr, LogBytesPerInt);
1906   __ atomic_addw(noreg, 1, counter_addr);
1907  }
1908 
< prev index next >