1288 __ save_return_pc(); // Save Z_R14.
1289 __ push_frame_abi160(0); // Without new frame the RT call could overwrite the saved Z_R14.
1290
1291 __ call_VM_leaf(runtime_entry);
1292
1293 __ pop_frame();
1294 __ restore_return_pc(); // Restore Z_R14.
1295 }
1296
1297 // Pop c2i arguments (if any) off when we return.
1298 __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
1299
1300 __ z_br(Z_R14);
1301
1302 return entry;
1303 }
1304
1305 // Interpreter stub for calling a native method. (asm interpreter).
1306 // This sets up a somewhat different looking stack for calling the
1307 // native method than the typical interpreter frame setup.
1308 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
1309 // Determine code generation flags.
1310 bool inc_counter = UseCompiler || CountCompiledCalls;
1311
1312 // Interpreter entry for ordinary Java methods.
1313 //
1314 // Registers alive
1315 // Z_SP - stack pointer
1316 // Z_thread - JavaThread*
1317 // Z_method - callee's method (method to be invoked)
1318 // Z_esp - operand (or expression) stack pointer of caller. one slot above last arg.
1319 // Z_R10 - sender sp (before modifications, e.g. by c2i adapter
1320 // and as well by generate_fixed_frame below)
1321 // Z_R14 - return address to caller (call_stub or c2i_adapter)
1322 //
1323 // Registers updated
1324 // Z_SP - stack pointer
1325 // Z_fp - callee's framepointer
1326 // Z_esp - callee's operand stack pointer
1327 // points to the slot above the value on top
1328 // Z_locals - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
1329 // Z_tos - integer result, if any
1330 // z_ftos - floating point result, if any
1646 // Pop the native method's interpreter frame.
1647 __ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/);
1648
1649 // Return to caller.
1650 __ z_br(Z_R14);
1651
1652 if (inc_counter) {
1653 // Handle overflow of counter and compile method.
1654 __ bind(invocation_counter_overflow);
1655 generate_counter_overflow(continue_after_compile);
1656 }
1657
1658 BLOCK_COMMENT("} native_entry");
1659
1660 return entry_point;
1661 }
1662
1663 //
1664 // Generic interpreted method entry to template interpreter.
1665 //
1666 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
1667 address entry_point = __ pc();
1668
1669 bool inc_counter = UseCompiler || CountCompiledCalls;
1670
1671 // Interpreter entry for ordinary Java methods.
1672 //
1673 // Registers alive
1674 // Z_SP - stack pointer
1675 // Z_thread - JavaThread*
1676 // Z_method - callee's method (method to be invoked)
1677 // Z_esp - operand (or expression) stack pointer of caller. one slot above last arg.
1678 // Z_R10 - sender sp (before modifications, e.g. by c2i adapter
1679 // and as well by generate_fixed_frame below)
1680 // Z_R14 - return address to caller (call_stub or c2i_adapter)
1681 //
1682 // Registers updated
1683 // Z_SP - stack pointer
1684 // Z_fp - callee's framepointer
1685 // Z_esp - callee's operand stack pointer
1686 // points to the slot above the value on top
1687 // Z_locals - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
1688 // Z_tos - integer result, if any
1689 // z_ftos - floating point result, if any
2291 address& iep,
2292 address& lep,
2293 address& fep,
2294 address& dep,
2295 address& vep) {
2296 assert(t->is_valid() && t->tos_in() == vtos, "illegal template");
2297 Label L;
2298 aep = __ pc(); __ push_ptr(); __ z_bru(L);
2299 fep = __ pc(); __ push_f(); __ z_bru(L);
2300 dep = __ pc(); __ push_d(); __ z_bru(L);
2301 lep = __ pc(); __ push_l(); __ z_bru(L);
2302 bep = cep = sep =
2303 iep = __ pc(); __ push_i();
2304 vep = __ pc();
2305 __ bind(L);
2306 generate_and_dispatch(t);
2307 }
2308
2309 //-----------------------------------------------------------------------------
2310
2311 #ifndef PRODUCT
2312 address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
2313 address entry = __ pc();
2314 NearLabel counter_below_trace_threshold;
2315
2316 if (TraceBytecodesAt > 0) {
2317 // Skip runtime call, if the trace threshold is not yet reached.
2318 __ load_absolute_address(Z_tmp_1, (address)&BytecodeCounter::_counter_value);
2319 __ load_absolute_address(Z_tmp_2, (address)&TraceBytecodesAt);
2320 __ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 4, false /*signed*/);
2321 __ load_sized_value(Z_tmp_2, Address(Z_tmp_2), 8, false /*signed*/);
2322 __ compareU64_and_branch(Z_tmp_1, Z_tmp_2, Assembler::bcondLow, counter_below_trace_threshold);
2323 }
2324
2325 int offset2 = state == ltos || state == dtos ? 2 : 1;
2326
2327 __ push(state);
2328 // Preserved return pointer is in Z_R14.
2329 // InterpreterRuntime::trace_bytecode() preserved and returns the value passed as second argument.
2330 __ z_lgr(Z_ARG2, Z_R14);
2331 __ z_lg(Z_ARG3, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)));
2332 if (WizardMode) {
2333 __ z_lgr(Z_ARG4, Z_esp); // Trace Z_esp in WizardMode.
2334 } else {
2335 __ z_lg(Z_ARG4, Address(Z_esp, Interpreter::expr_offset_in_bytes(offset2)));
2336 }
2337 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), Z_ARG2, Z_ARG3, Z_ARG4);
2338 __ z_lgr(Z_R14, Z_RET); // Estore return address (see above).
2339 __ pop(state);
2340
2341 __ bind(counter_below_trace_threshold);
2342 __ z_br(Z_R14); // return
2343
2344 return entry;
2345 }
2346
2347 // Make feasible for old CPUs.
2348 void TemplateInterpreterGenerator::count_bytecode() {
2349 __ load_absolute_address(Z_R1_scratch, (address) &BytecodeCounter::_counter_value);
2350 __ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
2351 }
2352
2353 void TemplateInterpreterGenerator::histogram_bytecode(Template * t) {
2354 __ load_absolute_address(Z_R1_scratch, (address)&BytecodeHistogram::_counters[ t->bytecode() ]);
2355 __ add2mem_32(Address(Z_R1_scratch), 1, Z_tmp_1);
2356 }
2357
2358 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template * t) {
2359 Address index_addr(Z_tmp_1, (intptr_t) 0);
2360 Register index = Z_tmp_2;
2361
2362 // Load previous index.
2363 __ load_absolute_address(Z_tmp_1, (address) &BytecodePairHistogram::_index);
2364 __ mem2reg_opt(index, index_addr, false);
2365
2366 // Mask with current bytecode and store as new previous index.
2367 __ z_srl(index, BytecodePairHistogram::log2_number_of_codes);
2368 __ load_const_optimized(Z_R0_scratch,
2369 (int)t->bytecode() << BytecodePairHistogram::log2_number_of_codes);
2370 __ z_or(index, Z_R0_scratch);
2371 __ reg2mem_opt(index, index_addr, false);
2372
2373 // Load counter array's address.
2374 __ z_lgfr(index, index); // Sign extend for addressing.
2375 __ z_sllg(index, index, LogBytesPerInt); // index2bytes
2376 __ load_absolute_address(Z_R1_scratch,
2377 (address) &BytecodePairHistogram::_counters);
|
1288 __ save_return_pc(); // Save Z_R14.
1289 __ push_frame_abi160(0); // Without new frame the RT call could overwrite the saved Z_R14.
1290
1291 __ call_VM_leaf(runtime_entry);
1292
1293 __ pop_frame();
1294 __ restore_return_pc(); // Restore Z_R14.
1295 }
1296
1297 // Pop c2i arguments (if any) off when we return.
1298 __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
1299
1300 __ z_br(Z_R14);
1301
1302 return entry;
1303 }
1304
1305 // Interpreter stub for calling a native method. (asm interpreter).
1306 // This sets up a somewhat different looking stack for calling the
1307 // native method than the typical interpreter frame setup.
1308 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized, bool runtime_upcalls) {
1309 // Determine code generation flags.
1310 bool inc_counter = (UseCompiler || CountCompiledCalls) && !PreloadOnly;
1311
1312 // Interpreter entry for ordinary Java methods.
1313 //
1314 // Registers alive
1315 // Z_SP - stack pointer
1316 // Z_thread - JavaThread*
1317 // Z_method - callee's method (method to be invoked)
1318 // Z_esp - operand (or expression) stack pointer of caller. one slot above last arg.
1319 // Z_R10 - sender sp (before modifications, e.g. by c2i adapter
1320 // and as well by generate_fixed_frame below)
1321 // Z_R14 - return address to caller (call_stub or c2i_adapter)
1322 //
1323 // Registers updated
1324 // Z_SP - stack pointer
1325 // Z_fp - callee's framepointer
1326 // Z_esp - callee's operand stack pointer
1327 // points to the slot above the value on top
1328 // Z_locals - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
1329 // Z_tos - integer result, if any
1330 // z_ftos - floating point result, if any
1646 // Pop the native method's interpreter frame.
1647 __ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/);
1648
1649 // Return to caller.
1650 __ z_br(Z_R14);
1651
1652 if (inc_counter) {
1653 // Handle overflow of counter and compile method.
1654 __ bind(invocation_counter_overflow);
1655 generate_counter_overflow(continue_after_compile);
1656 }
1657
1658 BLOCK_COMMENT("} native_entry");
1659
1660 return entry_point;
1661 }
1662
1663 //
1664 // Generic interpreted method entry to template interpreter.
1665 //
1666 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized, bool runtime_upcalls) {
1667 address entry_point = __ pc();
1668
1669 bool inc_counter = (UseCompiler || CountCompiledCalls) && !PreloadOnly;
1670
1671 // Interpreter entry for ordinary Java methods.
1672 //
1673 // Registers alive
1674 // Z_SP - stack pointer
1675 // Z_thread - JavaThread*
1676 // Z_method - callee's method (method to be invoked)
1677 // Z_esp - operand (or expression) stack pointer of caller. one slot above last arg.
1678 // Z_R10 - sender sp (before modifications, e.g. by c2i adapter
1679 // and as well by generate_fixed_frame below)
1680 // Z_R14 - return address to caller (call_stub or c2i_adapter)
1681 //
1682 // Registers updated
1683 // Z_SP - stack pointer
1684 // Z_fp - callee's framepointer
1685 // Z_esp - callee's operand stack pointer
1686 // points to the slot above the value on top
1687 // Z_locals - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
1688 // Z_tos - integer result, if any
1689 // z_ftos - floating point result, if any
2291 address& iep,
2292 address& lep,
2293 address& fep,
2294 address& dep,
2295 address& vep) {
2296 assert(t->is_valid() && t->tos_in() == vtos, "illegal template");
2297 Label L;
2298 aep = __ pc(); __ push_ptr(); __ z_bru(L);
2299 fep = __ pc(); __ push_f(); __ z_bru(L);
2300 dep = __ pc(); __ push_d(); __ z_bru(L);
2301 lep = __ pc(); __ push_l(); __ z_bru(L);
2302 bep = cep = sep =
2303 iep = __ pc(); __ push_i();
2304 vep = __ pc();
2305 __ bind(L);
2306 generate_and_dispatch(t);
2307 }
2308
2309 //-----------------------------------------------------------------------------
2310
2311 // Make feasible for old CPUs.
2312 void TemplateInterpreterGenerator::count_bytecode() {
2313 __ load_absolute_address(Z_R1_scratch, (address) &BytecodeCounter::_counter_value);
2314 __ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
2315 }
2316
2317 void TemplateInterpreterGenerator::histogram_bytecode(Template * t) {
2318 __ load_absolute_address(Z_R1_scratch, (address)&BytecodeHistogram::_counters[ t->bytecode() ]);
2319 __ add2mem_32(Address(Z_R1_scratch), 1, Z_tmp_1);
2320 }
2321
2322 #ifndef PRODUCT
2323 address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
2324 address entry = __ pc();
2325 NearLabel counter_below_trace_threshold;
2326
2327 if (TraceBytecodesAt > 0) {
2328 // Skip runtime call, if the trace threshold is not yet reached.
2329 __ load_absolute_address(Z_tmp_1, (address)&BytecodeCounter::_counter_value);
2330 __ load_absolute_address(Z_tmp_2, (address)&TraceBytecodesAt);
2331 __ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 4, false /*signed*/);
2332 __ load_sized_value(Z_tmp_2, Address(Z_tmp_2), 8, false /*signed*/);
2333 __ compareU64_and_branch(Z_tmp_1, Z_tmp_2, Assembler::bcondLow, counter_below_trace_threshold);
2334 }
2335
2336 int offset2 = state == ltos || state == dtos ? 2 : 1;
2337
2338 __ push(state);
2339 // Preserved return pointer is in Z_R14.
2340 // InterpreterRuntime::trace_bytecode() preserved and returns the value passed as second argument.
2341 __ z_lgr(Z_ARG2, Z_R14);
2342 __ z_lg(Z_ARG3, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)));
2343 if (WizardMode) {
2344 __ z_lgr(Z_ARG4, Z_esp); // Trace Z_esp in WizardMode.
2345 } else {
2346 __ z_lg(Z_ARG4, Address(Z_esp, Interpreter::expr_offset_in_bytes(offset2)));
2347 }
2348 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), Z_ARG2, Z_ARG3, Z_ARG4);
2349 __ z_lgr(Z_R14, Z_RET); // Estore return address (see above).
2350 __ pop(state);
2351
2352 __ bind(counter_below_trace_threshold);
2353 __ z_br(Z_R14); // return
2354
2355 return entry;
2356 }
2357
2358 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template * t) {
2359 Address index_addr(Z_tmp_1, (intptr_t) 0);
2360 Register index = Z_tmp_2;
2361
2362 // Load previous index.
2363 __ load_absolute_address(Z_tmp_1, (address) &BytecodePairHistogram::_index);
2364 __ mem2reg_opt(index, index_addr, false);
2365
2366 // Mask with current bytecode and store as new previous index.
2367 __ z_srl(index, BytecodePairHistogram::log2_number_of_codes);
2368 __ load_const_optimized(Z_R0_scratch,
2369 (int)t->bytecode() << BytecodePairHistogram::log2_number_of_codes);
2370 __ z_or(index, Z_R0_scratch);
2371 __ reg2mem_opt(index, index_addr, false);
2372
2373 // Load counter array's address.
2374 __ z_lgfr(index, index); // Sign extend for addressing.
2375 __ z_sllg(index, index, LogBytesPerInt); // index2bytes
2376 __ load_absolute_address(Z_R1_scratch,
2377 (address) &BytecodePairHistogram::_counters);
|