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