< prev index next >

src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp

Print this page

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)

1645   // Pop the native method's interpreter frame.
1646   __ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/);
1647 
1648   // Return to caller.
1649   __ z_br(Z_R14);
1650 
1651   if (inc_counter) {
1652     // Handle overflow of counter and compile method.
1653     __ bind(invocation_counter_overflow);
1654     generate_counter_overflow(continue_after_compile);
1655   }
1656 
1657   BLOCK_COMMENT("} native_entry");
1658 
1659   return entry_point;
1660 }
1661 
1662 //
1663 // Generic interpreted method entry to template interpreter.
1664 //
1665 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
1666   address entry_point = __ pc();
1667 
1668   bool inc_counter = UseCompiler || CountCompiledCalls;
1669 
1670   // Interpreter entry for ordinary Java methods.
1671   //
1672   // Registers alive
1673   //   Z_SP       - stack pointer
1674   //   Z_thread   - JavaThread*
1675   //   Z_method   - callee's method (method to be invoked)
1676   //   Z_esp      - operand (or expression) stack pointer of caller. one slot above last arg.
1677   //   Z_R10      - sender sp (before modifications, e.g. by c2i adapter
1678   //                           and as well by generate_fixed_frame below)
1679   //   Z_R14      - return address to caller (call_stub or c2i_adapter)
1680   //
1681   // Registers updated
1682   //   Z_SP       - stack pointer
1683   //   Z_fp       - callee's framepointer
1684   //   Z_esp      - callee's operand stack pointer
1685   //                points to the slot above the value on top

2290                                                          address& iep,
2291                                                          address& lep,
2292                                                          address& fep,
2293                                                          address& dep,
2294                                                          address& vep) {
2295   assert(t->is_valid() && t->tos_in() == vtos, "illegal template");
2296   Label L;
2297   aep = __ pc(); __ push_ptr(); __ z_bru(L);
2298   fep = __ pc(); __ push_f();   __ z_bru(L);
2299   dep = __ pc(); __ push_d();   __ z_bru(L);
2300   lep = __ pc(); __ push_l();   __ z_bru(L);
2301   bep = cep = sep =
2302   iep = __ pc(); __ push_i();
2303   vep = __ pc();
2304   __ bind(L);
2305   generate_and_dispatch(t);
2306 }
2307 
2308 //-----------------------------------------------------------------------------
2309 











2310 #ifndef PRODUCT
2311 address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
2312   address entry = __ pc();
2313   NearLabel counter_below_trace_threshold;
2314 
2315   if (TraceBytecodesAt > 0) {
2316     // Skip runtime call, if the trace threshold is not yet reached.
2317     __ load_absolute_address(Z_tmp_1, (address)&BytecodeCounter::_counter_value);
2318     __ load_absolute_address(Z_tmp_2, (address)&TraceBytecodesAt);
2319     __ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 4, false /*signed*/);
2320     __ load_sized_value(Z_tmp_2, Address(Z_tmp_2), 8, false /*signed*/);
2321     __ compareU64_and_branch(Z_tmp_1, Z_tmp_2, Assembler::bcondLow, counter_below_trace_threshold);
2322   }
2323 
2324   int offset2 = state == ltos || state == dtos ? 2 : 1;
2325 
2326   __ push(state);
2327   // Preserved return pointer is in Z_R14.
2328   // InterpreterRuntime::trace_bytecode() preserved and returns the value passed as second argument.
2329   __ z_lgr(Z_ARG2, Z_R14);
2330   __ z_lg(Z_ARG3, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)));
2331   if (WizardMode) {
2332     __ z_lgr(Z_ARG4, Z_esp); // Trace Z_esp in WizardMode.
2333   } else {
2334     __ z_lg(Z_ARG4, Address(Z_esp, Interpreter::expr_offset_in_bytes(offset2)));
2335   }
2336   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), Z_ARG2, Z_ARG3, Z_ARG4);
2337   __ z_lgr(Z_R14, Z_RET); // Estore return address (see above).
2338   __ pop(state);
2339 
2340   __ bind(counter_below_trace_threshold);
2341   __ z_br(Z_R14); // return
2342 
2343   return entry;
2344 }
2345 
2346 // Make feasible for old CPUs.
2347 void TemplateInterpreterGenerator::count_bytecode() {
2348   __ load_absolute_address(Z_R1_scratch, (address) &BytecodeCounter::_counter_value);
2349   __ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
2350 }
2351 
2352 void TemplateInterpreterGenerator::histogram_bytecode(Template * t) {
2353   __ load_absolute_address(Z_R1_scratch, (address)&BytecodeHistogram::_counters[ t->bytecode() ]);
2354   __ add2mem_32(Address(Z_R1_scratch), 1, Z_tmp_1);
2355 }
2356 
2357 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template * t) {
2358   Address  index_addr(Z_tmp_1, (intptr_t) 0);
2359   Register index = Z_tmp_2;
2360 
2361   // Load previous index.
2362   __ load_absolute_address(Z_tmp_1, (address) &BytecodePairHistogram::_index);
2363   __ mem2reg_opt(index, index_addr, false);
2364 
2365   // Mask with current bytecode and store as new previous index.
2366   __ z_srl(index, BytecodePairHistogram::log2_number_of_codes);
2367   __ load_const_optimized(Z_R0_scratch,
2368                           (int)t->bytecode() << BytecodePairHistogram::log2_number_of_codes);
2369   __ z_or(index, Z_R0_scratch);
2370   __ reg2mem_opt(index, index_addr, false);
2371 
2372   // Load counter array's address.
2373   __ z_lgfr(index, index);   // Sign extend for addressing.
2374   __ z_sllg(index, index, LogBytesPerInt);  // index2bytes
2375   __ load_absolute_address(Z_R1_scratch,
2376                            (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)

1645   // Pop the native method's interpreter frame.
1646   __ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/);
1647 
1648   // Return to caller.
1649   __ z_br(Z_R14);
1650 
1651   if (inc_counter) {
1652     // Handle overflow of counter and compile method.
1653     __ bind(invocation_counter_overflow);
1654     generate_counter_overflow(continue_after_compile);
1655   }
1656 
1657   BLOCK_COMMENT("} native_entry");
1658 
1659   return entry_point;
1660 }
1661 
1662 //
1663 // Generic interpreted method entry to template interpreter.
1664 //
1665 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized, bool runtime_upcalls) {
1666   address entry_point = __ pc();
1667 
1668   bool inc_counter = UseCompiler || CountCompiledCalls;
1669 
1670   // Interpreter entry for ordinary Java methods.
1671   //
1672   // Registers alive
1673   //   Z_SP       - stack pointer
1674   //   Z_thread   - JavaThread*
1675   //   Z_method   - callee's method (method to be invoked)
1676   //   Z_esp      - operand (or expression) stack pointer of caller. one slot above last arg.
1677   //   Z_R10      - sender sp (before modifications, e.g. by c2i adapter
1678   //                           and as well by generate_fixed_frame below)
1679   //   Z_R14      - return address to caller (call_stub or c2i_adapter)
1680   //
1681   // Registers updated
1682   //   Z_SP       - stack pointer
1683   //   Z_fp       - callee's framepointer
1684   //   Z_esp      - callee's operand stack pointer
1685   //                points to the slot above the value on top

2290                                                          address& iep,
2291                                                          address& lep,
2292                                                          address& fep,
2293                                                          address& dep,
2294                                                          address& vep) {
2295   assert(t->is_valid() && t->tos_in() == vtos, "illegal template");
2296   Label L;
2297   aep = __ pc(); __ push_ptr(); __ z_bru(L);
2298   fep = __ pc(); __ push_f();   __ z_bru(L);
2299   dep = __ pc(); __ push_d();   __ z_bru(L);
2300   lep = __ pc(); __ push_l();   __ z_bru(L);
2301   bep = cep = sep =
2302   iep = __ pc(); __ push_i();
2303   vep = __ pc();
2304   __ bind(L);
2305   generate_and_dispatch(t);
2306 }
2307 
2308 //-----------------------------------------------------------------------------
2309 
2310 // Make feasible for old CPUs.
2311 void TemplateInterpreterGenerator::count_bytecode() {
2312   __ load_absolute_address(Z_R1_scratch, (address) &BytecodeCounter::_counter_value);
2313   __ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch);
2314 }
2315 
2316 void TemplateInterpreterGenerator::histogram_bytecode(Template * t) {
2317   __ load_absolute_address(Z_R1_scratch, (address)&BytecodeHistogram::_counters[ t->bytecode() ]);
2318   __ add2mem_32(Address(Z_R1_scratch), 1, Z_tmp_1);
2319 }
2320 
2321 #ifndef PRODUCT
2322 address TemplateInterpreterGenerator::generate_trace_code(TosState state) {
2323   address entry = __ pc();
2324   NearLabel counter_below_trace_threshold;
2325 
2326   if (TraceBytecodesAt > 0) {
2327     // Skip runtime call, if the trace threshold is not yet reached.
2328     __ load_absolute_address(Z_tmp_1, (address)&BytecodeCounter::_counter_value);
2329     __ load_absolute_address(Z_tmp_2, (address)&TraceBytecodesAt);
2330     __ load_sized_value(Z_tmp_1, Address(Z_tmp_1), 4, false /*signed*/);
2331     __ load_sized_value(Z_tmp_2, Address(Z_tmp_2), 8, false /*signed*/);
2332     __ compareU64_and_branch(Z_tmp_1, Z_tmp_2, Assembler::bcondLow, counter_below_trace_threshold);
2333   }
2334 
2335   int offset2 = state == ltos || state == dtos ? 2 : 1;
2336 
2337   __ push(state);
2338   // Preserved return pointer is in Z_R14.
2339   // InterpreterRuntime::trace_bytecode() preserved and returns the value passed as second argument.
2340   __ z_lgr(Z_ARG2, Z_R14);
2341   __ z_lg(Z_ARG3, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)));
2342   if (WizardMode) {
2343     __ z_lgr(Z_ARG4, Z_esp); // Trace Z_esp in WizardMode.
2344   } else {
2345     __ z_lg(Z_ARG4, Address(Z_esp, Interpreter::expr_offset_in_bytes(offset2)));
2346   }
2347   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), Z_ARG2, Z_ARG3, Z_ARG4);
2348   __ z_lgr(Z_R14, Z_RET); // Estore return address (see above).
2349   __ pop(state);
2350 
2351   __ bind(counter_below_trace_threshold);
2352   __ z_br(Z_R14); // return
2353 
2354   return entry;
2355 }
2356 











2357 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template * t) {
2358   Address  index_addr(Z_tmp_1, (intptr_t) 0);
2359   Register index = Z_tmp_2;
2360 
2361   // Load previous index.
2362   __ load_absolute_address(Z_tmp_1, (address) &BytecodePairHistogram::_index);
2363   __ mem2reg_opt(index, index_addr, false);
2364 
2365   // Mask with current bytecode and store as new previous index.
2366   __ z_srl(index, BytecodePairHistogram::log2_number_of_codes);
2367   __ load_const_optimized(Z_R0_scratch,
2368                           (int)t->bytecode() << BytecodePairHistogram::log2_number_of_codes);
2369   __ z_or(index, Z_R0_scratch);
2370   __ reg2mem_opt(index, index_addr, false);
2371 
2372   // Load counter array's address.
2373   __ z_lgfr(index, index);   // Sign extend for addressing.
2374   __ z_sllg(index, index, LogBytesPerInt);  // index2bytes
2375   __ load_absolute_address(Z_R1_scratch,
2376                            (address) &BytecodePairHistogram::_counters);
< prev index next >