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