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*
1406
1407 JFR_ONLY(__ leave_jfr_critical_section();)
1408
1409 // restore sender sp
1410 __ mv(sp, esp);
1411
1412 __ ret();
1413
1414 if (inc_counter) {
1415 // Handle overflow of counter and compile method
1416 __ bind(invocation_counter_overflow);
1417 generate_counter_overflow(continue_after_compile);
1418 }
1419
1420 return entry_point;
1421 }
1422
1423 //
1424 // Generic interpreted method entry to (asm) interpreter
1425 //
1426 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
1427
1428 // determine code generation flags
1429 const bool inc_counter = UseCompiler || CountCompiledCalls;
1430
1431 // t0: sender sp
1432 address entry_point = __ pc();
1433
1434 const Address constMethod(xmethod, Method::const_offset());
1435 const Address access_flags(xmethod, Method::access_flags_offset());
1436 const Address size_of_parameters(x13,
1437 ConstMethod::size_of_parameters_offset());
1438 const Address size_of_locals(x13, ConstMethod::size_of_locals_offset());
1439
1440 // get parameter size (always needed)
1441 // need to load the const method first
1442 __ ld(x13, constMethod);
1443 __ load_unsigned_short(x12, size_of_parameters);
1444
1445 // x12: size of parameters
1446
1447 __ load_unsigned_short(x13, size_of_locals); // get size of locals in words
1448 __ sub(x13, x13, x12); // x13 = no. of additional locals
1449
1838
1839 //-----------------------------------------------------------------------------
1840
1841 // Non-product code
1842 #ifndef PRODUCT
1843 address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
1844 address entry = __ pc();
1845
1846 __ push_reg(ra);
1847 __ push(state);
1848 __ push_reg(RegSet::range(x10, x17) + RegSet::range(x5, x7) + RegSet::range(x28, x31), sp);
1849 __ mv(c_rarg2, x10); // Pass itos
1850 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), c_rarg1, c_rarg2, c_rarg3);
1851 __ pop_reg(RegSet::range(x10, x17) + RegSet::range(x5, x7) + RegSet::range(x28, x31), sp);
1852 __ pop(state);
1853 __ pop_reg(ra);
1854 __ ret(); // return from result handler
1855
1856 return entry;
1857 }
1858
1859 void TemplateInterpreterGenerator::count_bytecode() {
1860 __ mv(x7, (address) &BytecodeCounter::_counter_value);
1861 __ atomic_add(noreg, 1, x7);
1862 }
1863
1864 void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
1865 __ mv(x7, (address) &BytecodeHistogram::_counters[t->bytecode()]);
1866 __ atomic_addw(noreg, 1, x7);
1867 }
1868
1869 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
1870 // Calculate new index for counter:
1871 // _index = (_index >> log2_number_of_codes) |
1872 // (bytecode << log2_number_of_codes);
1873 Register index_addr = t1;
1874 Register index = t0;
1875 __ mv(index_addr, (address) &BytecodePairHistogram::_index);
1876 __ lw(index, index_addr);
1877 __ mv(x7, ((int)t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
1878 __ srli(index, index, BytecodePairHistogram::log2_number_of_codes);
1879 __ orrw(index, x7, index);
1880 __ sw(index, index_addr);
1881 // Bump bucket contents:
1882 // _counters[_index] ++;
1883 Register counter_addr = t1;
1884 __ mv(x7, (address) &BytecodePairHistogram::_counters);
1885 __ shadd(counter_addr, index, x7, counter_addr, LogBytesPerInt);
1886 __ atomic_addw(noreg, 1, counter_addr);
1887 }
1888
|
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*
1406
1407 JFR_ONLY(__ leave_jfr_critical_section();)
1408
1409 // restore sender sp
1410 __ mv(sp, esp);
1411
1412 __ ret();
1413
1414 if (inc_counter) {
1415 // Handle overflow of counter and compile method
1416 __ bind(invocation_counter_overflow);
1417 generate_counter_overflow(continue_after_compile);
1418 }
1419
1420 return entry_point;
1421 }
1422
1423 //
1424 // Generic interpreted method entry to (asm) interpreter
1425 //
1426 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized, bool runtime_upcalls) {
1427
1428 // determine code generation flags
1429 const bool inc_counter = (UseCompiler || CountCompiledCalls) && !PreloadOnly;
1430
1431 // t0: sender sp
1432 address entry_point = __ pc();
1433
1434 const Address constMethod(xmethod, Method::const_offset());
1435 const Address access_flags(xmethod, Method::access_flags_offset());
1436 const Address size_of_parameters(x13,
1437 ConstMethod::size_of_parameters_offset());
1438 const Address size_of_locals(x13, ConstMethod::size_of_locals_offset());
1439
1440 // get parameter size (always needed)
1441 // need to load the const method first
1442 __ ld(x13, constMethod);
1443 __ load_unsigned_short(x12, size_of_parameters);
1444
1445 // x12: size of parameters
1446
1447 __ load_unsigned_short(x13, size_of_locals); // get size of locals in words
1448 __ sub(x13, x13, x12); // x13 = no. of additional locals
1449
1838
1839 //-----------------------------------------------------------------------------
1840
1841 // Non-product code
1842 #ifndef PRODUCT
1843 address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
1844 address entry = __ pc();
1845
1846 __ push_reg(ra);
1847 __ push(state);
1848 __ push_reg(RegSet::range(x10, x17) + RegSet::range(x5, x7) + RegSet::range(x28, x31), sp);
1849 __ mv(c_rarg2, x10); // Pass itos
1850 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), c_rarg1, c_rarg2, c_rarg3);
1851 __ pop_reg(RegSet::range(x10, x17) + RegSet::range(x5, x7) + RegSet::range(x28, x31), sp);
1852 __ pop(state);
1853 __ pop_reg(ra);
1854 __ ret(); // return from result handler
1855
1856 return entry;
1857 }
1858 #endif // PRODUCT
1859
1860 void TemplateInterpreterGenerator::count_bytecode() {
1861 __ mv(x7, (address) &BytecodeCounter::_counter_value);
1862 __ atomic_add(noreg, 1, x7);
1863 }
1864
1865 void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
1866 __ mv(x7, (address) &BytecodeHistogram::_counters[t->bytecode()]);
1867 __ atomic_addw(noreg, 1, x7);
1868 }
1869
1870 #ifndef PRODUCT
1871 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
1872 // Calculate new index for counter:
1873 // _index = (_index >> log2_number_of_codes) |
1874 // (bytecode << log2_number_of_codes);
1875 Register index_addr = t1;
1876 Register index = t0;
1877 __ mv(index_addr, (address) &BytecodePairHistogram::_index);
1878 __ lw(index, index_addr);
1879 __ mv(x7, ((int)t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
1880 __ srli(index, index, BytecodePairHistogram::log2_number_of_codes);
1881 __ orrw(index, x7, index);
1882 __ sw(index, index_addr);
1883 // Bump bucket contents:
1884 // _counters[_index] ++;
1885 Register counter_addr = t1;
1886 __ mv(x7, (address) &BytecodePairHistogram::_counters);
1887 __ shadd(counter_addr, index, x7, counter_addr, LogBytesPerInt);
1888 __ atomic_addw(noreg, 1, counter_addr);
1889 }
1890
|