< prev index next >

src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp

Print this page

1306     __ save_return_pc();       // Save Z_R14.
1307     __ push_frame_abi160(0);   // Without new frame the RT call could overwrite the saved Z_R14.
1308 
1309     __ call_VM_leaf(runtime_entry);
1310 
1311     __ pop_frame();
1312     __ restore_return_pc();    // Restore Z_R14.
1313   }
1314 
1315   // Pop c2i arguments (if any) off when we return.
1316   __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
1317 
1318   __ z_br(Z_R14);
1319 
1320   return entry;
1321 }
1322 
1323 // Interpreter stub for calling a native method. (asm interpreter).
1324 // This sets up a somewhat different looking stack for calling the
1325 // native method than the typical interpreter frame setup.
1326 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
1327   // Determine code generation flags.
1328   bool inc_counter = UseCompiler || CountCompiledCalls;
1329 
1330   // Interpreter entry for ordinary Java methods.
1331   //
1332   // Registers alive
1333   //   Z_SP          - stack pointer
1334   //   Z_thread      - JavaThread*
1335   //   Z_method      - callee's method (method to be invoked)
1336   //   Z_esp         - operand (or expression) stack pointer of caller. one slot above last arg.
1337   //   Z_R10         - sender sp (before modifications, e.g. by c2i adapter
1338   //                   and as well by generate_fixed_frame below)
1339   //   Z_R14         - return address to caller (call_stub or c2i_adapter)
1340   //
1341   // Registers updated
1342   //   Z_SP          - stack pointer
1343   //   Z_fp          - callee's framepointer
1344   //   Z_esp         - callee's operand stack pointer
1345   //                   points to the slot above the value on top
1346   //   Z_locals      - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
1347   //   Z_tos         - integer result, if any
1348   //   z_ftos        - floating point result, if any

1664   // Pop the native method's interpreter frame.
1665   __ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/);
1666 
1667   // Return to caller.
1668   __ z_br(Z_R14);
1669 
1670   if (inc_counter) {
1671     // Handle overflow of counter and compile method.
1672     __ bind(invocation_counter_overflow);
1673     generate_counter_overflow(continue_after_compile);
1674   }
1675 
1676   BLOCK_COMMENT("} native_entry");
1677 
1678   return entry_point;
1679 }
1680 
1681 //
1682 // Generic interpreted method entry to template interpreter.
1683 //
1684 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
1685   address entry_point = __ pc();
1686 
1687   bool inc_counter = UseCompiler || CountCompiledCalls;
1688 
1689   // Interpreter entry for ordinary Java methods.
1690   //
1691   // Registers alive
1692   //   Z_SP       - stack pointer
1693   //   Z_thread   - JavaThread*
1694   //   Z_method   - callee's method (method to be invoked)
1695   //   Z_esp      - operand (or expression) stack pointer of caller. one slot above last arg.
1696   //   Z_R10      - sender sp (before modifications, e.g. by c2i adapter
1697   //                           and as well by generate_fixed_frame below)
1698   //   Z_R14      - return address to caller (call_stub or c2i_adapter)
1699   //
1700   // Registers updated
1701   //   Z_SP       - stack pointer
1702   //   Z_fp       - callee's framepointer
1703   //   Z_esp      - callee's operand stack pointer
1704   //                points to the slot above the value on top
1705   //   Z_locals   - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
1706   //   Z_tos      - integer result, if any
1707   //   z_ftos     - floating point result, if any

2368 
2369   __ push(state);
2370   // Preserved return pointer is in Z_R14.
2371   // InterpreterRuntime::trace_bytecode() preserved and returns the value passed as second argument.
2372   __ z_lgr(Z_ARG2, Z_R14);
2373   __ z_lg(Z_ARG3, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)));
2374   if (WizardMode) {
2375     __ z_lgr(Z_ARG4, Z_esp); // Trace Z_esp in WizardMode.
2376   } else {
2377     __ z_lg(Z_ARG4, Address(Z_esp, Interpreter::expr_offset_in_bytes(offset2)));
2378   }
2379   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), Z_ARG2, Z_ARG3, Z_ARG4);
2380   __ z_lgr(Z_R14, Z_RET); // Estore return address (see above).
2381   __ pop(state);
2382 
2383   __ bind(counter_below_trace_threshold);
2384   __ z_br(Z_R14); // return
2385 
2386   return entry;
2387 }

2388 
2389 // Make feasible for old CPUs.
2390 void TemplateInterpreterGenerator::count_bytecode() {
2391   __ load_absolute_address(Z_R1_scratch, (address) &BytecodeCounter::_counter_value);
2392   __ add2mem_64(Address(Z_R1_scratch), 1, Z_R0_scratch);
2393 }
2394 
2395 void TemplateInterpreterGenerator::histogram_bytecode(Template * t) {
2396   __ load_absolute_address(Z_R1_scratch, (address)&BytecodeHistogram::_counters[ t->bytecode() ]);
2397   __ add2mem_32(Address(Z_R1_scratch), 1, Z_tmp_1);
2398 }
2399 

2400 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template * t) {
2401   Address  index_addr(Z_tmp_1, (intptr_t) 0);
2402   Register index = Z_tmp_2;
2403 
2404   // Load previous index.
2405   __ load_absolute_address(Z_tmp_1, (address) &BytecodePairHistogram::_index);
2406   __ mem2reg_opt(index, index_addr, false);
2407 
2408   // Mask with current bytecode and store as new previous index.
2409   __ z_srl(index, BytecodePairHistogram::log2_number_of_codes);
2410   __ load_const_optimized(Z_R0_scratch,
2411                           (int)t->bytecode() << BytecodePairHistogram::log2_number_of_codes);
2412   __ z_or(index, Z_R0_scratch);
2413   __ reg2mem_opt(index, index_addr, false);
2414 
2415   // Load counter array's address.
2416   __ z_lgfr(index, index);   // Sign extend for addressing.
2417   __ z_sllg(index, index, LogBytesPerInt);  // index2bytes
2418   __ load_absolute_address(Z_R1_scratch,
2419                            (address) &BytecodePairHistogram::_counters);

1306     __ save_return_pc();       // Save Z_R14.
1307     __ push_frame_abi160(0);   // Without new frame the RT call could overwrite the saved Z_R14.
1308 
1309     __ call_VM_leaf(runtime_entry);
1310 
1311     __ pop_frame();
1312     __ restore_return_pc();    // Restore Z_R14.
1313   }
1314 
1315   // Pop c2i arguments (if any) off when we return.
1316   __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
1317 
1318   __ z_br(Z_R14);
1319 
1320   return entry;
1321 }
1322 
1323 // Interpreter stub for calling a native method. (asm interpreter).
1324 // This sets up a somewhat different looking stack for calling the
1325 // native method than the typical interpreter frame setup.
1326 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized, bool runtime_upcalls) {
1327   // Determine code generation flags.
1328   bool inc_counter = (UseCompiler || CountCompiledCalls) && !PreloadOnly;
1329 
1330   // Interpreter entry for ordinary Java methods.
1331   //
1332   // Registers alive
1333   //   Z_SP          - stack pointer
1334   //   Z_thread      - JavaThread*
1335   //   Z_method      - callee's method (method to be invoked)
1336   //   Z_esp         - operand (or expression) stack pointer of caller. one slot above last arg.
1337   //   Z_R10         - sender sp (before modifications, e.g. by c2i adapter
1338   //                   and as well by generate_fixed_frame below)
1339   //   Z_R14         - return address to caller (call_stub or c2i_adapter)
1340   //
1341   // Registers updated
1342   //   Z_SP          - stack pointer
1343   //   Z_fp          - callee's framepointer
1344   //   Z_esp         - callee's operand stack pointer
1345   //                   points to the slot above the value on top
1346   //   Z_locals      - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
1347   //   Z_tos         - integer result, if any
1348   //   z_ftos        - floating point result, if any

1664   // Pop the native method's interpreter frame.
1665   __ pop_interpreter_frame(Z_R14 /*return_pc*/, Z_ARG2/*tmp1*/, Z_ARG3/*tmp2*/);
1666 
1667   // Return to caller.
1668   __ z_br(Z_R14);
1669 
1670   if (inc_counter) {
1671     // Handle overflow of counter and compile method.
1672     __ bind(invocation_counter_overflow);
1673     generate_counter_overflow(continue_after_compile);
1674   }
1675 
1676   BLOCK_COMMENT("} native_entry");
1677 
1678   return entry_point;
1679 }
1680 
1681 //
1682 // Generic interpreted method entry to template interpreter.
1683 //
1684 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized, bool runtime_upcalls) {
1685   address entry_point = __ pc();
1686 
1687   bool inc_counter = (UseCompiler || CountCompiledCalls) && !PreloadOnly;
1688 
1689   // Interpreter entry for ordinary Java methods.
1690   //
1691   // Registers alive
1692   //   Z_SP       - stack pointer
1693   //   Z_thread   - JavaThread*
1694   //   Z_method   - callee's method (method to be invoked)
1695   //   Z_esp      - operand (or expression) stack pointer of caller. one slot above last arg.
1696   //   Z_R10      - sender sp (before modifications, e.g. by c2i adapter
1697   //                           and as well by generate_fixed_frame below)
1698   //   Z_R14      - return address to caller (call_stub or c2i_adapter)
1699   //
1700   // Registers updated
1701   //   Z_SP       - stack pointer
1702   //   Z_fp       - callee's framepointer
1703   //   Z_esp      - callee's operand stack pointer
1704   //                points to the slot above the value on top
1705   //   Z_locals   - used to access locals: locals[i] := *(Z_locals - i*BytesPerWord)
1706   //   Z_tos      - integer result, if any
1707   //   z_ftos     - floating point result, if any

2368 
2369   __ push(state);
2370   // Preserved return pointer is in Z_R14.
2371   // InterpreterRuntime::trace_bytecode() preserved and returns the value passed as second argument.
2372   __ z_lgr(Z_ARG2, Z_R14);
2373   __ z_lg(Z_ARG3, Address(Z_esp, Interpreter::expr_offset_in_bytes(0)));
2374   if (WizardMode) {
2375     __ z_lgr(Z_ARG4, Z_esp); // Trace Z_esp in WizardMode.
2376   } else {
2377     __ z_lg(Z_ARG4, Address(Z_esp, Interpreter::expr_offset_in_bytes(offset2)));
2378   }
2379   __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), Z_ARG2, Z_ARG3, Z_ARG4);
2380   __ z_lgr(Z_R14, Z_RET); // Estore return address (see above).
2381   __ pop(state);
2382 
2383   __ bind(counter_below_trace_threshold);
2384   __ z_br(Z_R14); // return
2385 
2386   return entry;
2387 }
2388 #endif
2389 
2390 // Make feasible for old CPUs.
2391 void TemplateInterpreterGenerator::count_bytecode() {
2392   __ load_absolute_address(Z_R1_scratch, (address) &BytecodeCounter::_counter_value);
2393   __ add2mem_64(Address(Z_R1_scratch), 1, Z_R0_scratch);
2394 }
2395 
2396 void TemplateInterpreterGenerator::histogram_bytecode(Template * t) {
2397   __ load_absolute_address(Z_R1_scratch, (address)&BytecodeHistogram::_counters[ t->bytecode() ]);
2398   __ add2mem_32(Address(Z_R1_scratch), 1, Z_tmp_1);
2399 }
2400 
2401 #ifndef PRODUCT
2402 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template * t) {
2403   Address  index_addr(Z_tmp_1, (intptr_t) 0);
2404   Register index = Z_tmp_2;
2405 
2406   // Load previous index.
2407   __ load_absolute_address(Z_tmp_1, (address) &BytecodePairHistogram::_index);
2408   __ mem2reg_opt(index, index_addr, false);
2409 
2410   // Mask with current bytecode and store as new previous index.
2411   __ z_srl(index, BytecodePairHistogram::log2_number_of_codes);
2412   __ load_const_optimized(Z_R0_scratch,
2413                           (int)t->bytecode() << BytecodePairHistogram::log2_number_of_codes);
2414   __ z_or(index, Z_R0_scratch);
2415   __ reg2mem_opt(index, index_addr, false);
2416 
2417   // Load counter array's address.
2418   __ z_lgfr(index, index);   // Sign extend for addressing.
2419   __ z_sllg(index, index, LogBytesPerInt);  // index2bytes
2420   __ load_absolute_address(Z_R1_scratch,
2421                            (address) &BytecodePairHistogram::_counters);
< prev index next >