1209 const int n_shadow_pages = StackOverflow::stack_shadow_zone_size() / page_size;
1210 const int start_page = native_call ? n_shadow_pages : 1;
1211 BLOCK_COMMENT("bang_stack_shadow_pages:");
1212 for (int pages = start_page; pages <= n_shadow_pages; pages++) {
1213 __ bang_stack_with_offset(pages*page_size);
1214 }
1215 }
1216
1217 // Interpreter stub for calling a native method. (asm interpreter)
1218 // This sets up a somewhat different looking stack for calling the
1219 // native method than the typical interpreter frame setup.
1220 //
1221 // On entry:
1222 // R19_method - method
1223 // R16_thread - JavaThread*
1224 // R15_esp - intptr_t* sender tos
1225 //
1226 // abstract stack (grows up)
1227 // [ IJava (caller of JNI callee) ] <-- ASP
1228 // ...
1229 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
1230
1231 address entry = __ pc();
1232
1233 const bool inc_counter = UseCompiler || CountCompiledCalls;
1234
1235 // -----------------------------------------------------------------------------
1236 // Allocate a new frame that represents the native callee (i2n frame).
1237 // This is not a full-blown interpreter frame, but in particular, the
1238 // following registers are valid after this:
1239 // - R19_method
1240 // - R18_local (points to start of arguments to native function)
1241 //
1242 // abstract stack (grows up)
1243 // [ IJava (caller of JNI callee) ] <-- ASP
1244 // ...
1245
1246 const Register signature_handler_fd = R11_scratch1;
1247 const Register pending_exception = R0;
1248 const Register result_handler_addr = R31;
1249 const Register native_method_fd = R12_scratch2; // preferred in MacroAssembler::branch_to
1250 const Register access_flags = R22_tmp2;
1251 const Register active_handles = R11_scratch1; // R26_monitor saved to state.
1252 const Register sync_state = R12_scratch2;
1253 const Register sync_state_addr = sync_state; // Address is dead after use.
1687 __ mr(R4_ARG2/*issuing_pc*/, return_pc);
1688
1689 // Return to exception handler.
1690 __ blr();
1691
1692 //=============================================================================
1693 // Counter overflow.
1694
1695 if (inc_counter) {
1696 // Handle invocation counter overflow.
1697 __ bind(invocation_counter_overflow);
1698
1699 generate_counter_overflow(continue_after_compile);
1700 }
1701
1702 return entry;
1703 }
1704
1705 // Generic interpreted method entry to (asm) interpreter.
1706 //
1707 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) {
1708 bool inc_counter = UseCompiler || CountCompiledCalls;
1709 address entry = __ pc();
1710 // Generate the code to allocate the interpreter stack frame.
1711 Register Rsize_of_parameters = R4_ARG2, // Written by generate_fixed_frame.
1712 Rsize_of_locals = R5_ARG3; // Written by generate_fixed_frame.
1713
1714 // Does also a stack check to assure this frame fits on the stack.
1715 generate_fixed_frame(false, Rsize_of_parameters, Rsize_of_locals);
1716
1717 // --------------------------------------------------------------------------
1718 // Zero out non-parameter locals.
1719 // Note: *Always* zero out non-parameter locals as Sparc does. It's not
1720 // worth to ask the flag, just do it.
1721 Register Rslot_addr = R6_ARG4,
1722 Rnum = R7_ARG5;
1723 Label Lno_locals, Lzero_loop;
1724
1725 // Set up the zeroing loop.
1726 __ subf(Rnum, Rsize_of_parameters, Rsize_of_locals);
1727 __ subf(Rslot_addr, Rsize_of_parameters, R18_locals);
1728 __ srdi_(Rnum, Rnum, Interpreter::logStackElementSize);
2350 __ cmpd(CR0, R12_scratch2, R11_scratch1);
2351 __ blt(CR0, Lskip_vm_call);
2352 }
2353
2354 __ push(state);
2355 // Load 2 topmost expression stack values.
2356 __ ld(R6_ARG4, tsize*Interpreter::stackElementSize, R15_esp);
2357 __ ld(R5_ARG3, Interpreter::stackElementSize, R15_esp);
2358 __ mflr(R31);
2359 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), /* unused */ R4_ARG2, R5_ARG3, R6_ARG4, false);
2360 __ mtlr(R31);
2361 __ pop(state);
2362
2363 if (TraceBytecodesAt > 0) {
2364 __ bind(Lskip_vm_call);
2365 }
2366 __ blr();
2367 BLOCK_COMMENT("} trace_code");
2368 return entry;
2369 }
2370
2371 void TemplateInterpreterGenerator::count_bytecode() {
2372 int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeCounter::_counter_value, R12_scratch2, true);
2373 __ ld(R12_scratch2, offs, R11_scratch1);
2374 __ addi(R12_scratch2, R12_scratch2, 1);
2375 __ std(R12_scratch2, offs, R11_scratch1);
2376 }
2377
2378 void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
2379 int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeHistogram::_counters[t->bytecode()], R12_scratch2, true);
2380 __ lwz(R12_scratch2, offs, R11_scratch1);
2381 __ addi(R12_scratch2, R12_scratch2, 1);
2382 __ stw(R12_scratch2, offs, R11_scratch1);
2383 }
2384
2385 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
2386 const Register addr = R11_scratch1,
2387 tmp = R12_scratch2;
2388 // Get index, shift out old bytecode, bring in new bytecode, and store it.
2389 // _index = (_index >> log2_number_of_codes) |
2390 // (bytecode << log2_number_of_codes);
2391 int offs1 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_index, tmp, true);
2392 __ lwz(tmp, offs1, addr);
2393 __ srwi(tmp, tmp, BytecodePairHistogram::log2_number_of_codes);
2394 __ ori(tmp, tmp, ((int) t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
2395 __ stw(tmp, offs1, addr);
2396
2397 // Bump bucket contents.
2398 // _counters[_index] ++;
2399 int offs2 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_counters, R0, true);
2400 __ sldi(tmp, tmp, LogBytesPerInt);
2401 __ add(addr, tmp, addr);
2402 __ lwz(tmp, offs2, addr);
2403 __ addi(tmp, tmp, 1);
2404 __ stw(tmp, offs2, addr);
|
1209 const int n_shadow_pages = StackOverflow::stack_shadow_zone_size() / page_size;
1210 const int start_page = native_call ? n_shadow_pages : 1;
1211 BLOCK_COMMENT("bang_stack_shadow_pages:");
1212 for (int pages = start_page; pages <= n_shadow_pages; pages++) {
1213 __ bang_stack_with_offset(pages*page_size);
1214 }
1215 }
1216
1217 // Interpreter stub for calling a native method. (asm interpreter)
1218 // This sets up a somewhat different looking stack for calling the
1219 // native method than the typical interpreter frame setup.
1220 //
1221 // On entry:
1222 // R19_method - method
1223 // R16_thread - JavaThread*
1224 // R15_esp - intptr_t* sender tos
1225 //
1226 // abstract stack (grows up)
1227 // [ IJava (caller of JNI callee) ] <-- ASP
1228 // ...
1229 address TemplateInterpreterGenerator::generate_native_entry(bool synchronized, bool runtime_upcalls) {
1230
1231 address entry = __ pc();
1232
1233 const bool inc_counter = (UseCompiler || CountCompiledCalls) && !PreloadOnly;
1234
1235 // -----------------------------------------------------------------------------
1236 // Allocate a new frame that represents the native callee (i2n frame).
1237 // This is not a full-blown interpreter frame, but in particular, the
1238 // following registers are valid after this:
1239 // - R19_method
1240 // - R18_local (points to start of arguments to native function)
1241 //
1242 // abstract stack (grows up)
1243 // [ IJava (caller of JNI callee) ] <-- ASP
1244 // ...
1245
1246 const Register signature_handler_fd = R11_scratch1;
1247 const Register pending_exception = R0;
1248 const Register result_handler_addr = R31;
1249 const Register native_method_fd = R12_scratch2; // preferred in MacroAssembler::branch_to
1250 const Register access_flags = R22_tmp2;
1251 const Register active_handles = R11_scratch1; // R26_monitor saved to state.
1252 const Register sync_state = R12_scratch2;
1253 const Register sync_state_addr = sync_state; // Address is dead after use.
1687 __ mr(R4_ARG2/*issuing_pc*/, return_pc);
1688
1689 // Return to exception handler.
1690 __ blr();
1691
1692 //=============================================================================
1693 // Counter overflow.
1694
1695 if (inc_counter) {
1696 // Handle invocation counter overflow.
1697 __ bind(invocation_counter_overflow);
1698
1699 generate_counter_overflow(continue_after_compile);
1700 }
1701
1702 return entry;
1703 }
1704
1705 // Generic interpreted method entry to (asm) interpreter.
1706 //
1707 address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized, bool runtime_upcalls) {
1708 bool inc_counter = (UseCompiler || CountCompiledCalls) && !PreloadOnly;
1709 address entry = __ pc();
1710 // Generate the code to allocate the interpreter stack frame.
1711 Register Rsize_of_parameters = R4_ARG2, // Written by generate_fixed_frame.
1712 Rsize_of_locals = R5_ARG3; // Written by generate_fixed_frame.
1713
1714 // Does also a stack check to assure this frame fits on the stack.
1715 generate_fixed_frame(false, Rsize_of_parameters, Rsize_of_locals);
1716
1717 // --------------------------------------------------------------------------
1718 // Zero out non-parameter locals.
1719 // Note: *Always* zero out non-parameter locals as Sparc does. It's not
1720 // worth to ask the flag, just do it.
1721 Register Rslot_addr = R6_ARG4,
1722 Rnum = R7_ARG5;
1723 Label Lno_locals, Lzero_loop;
1724
1725 // Set up the zeroing loop.
1726 __ subf(Rnum, Rsize_of_parameters, Rsize_of_locals);
1727 __ subf(Rslot_addr, Rsize_of_parameters, R18_locals);
1728 __ srdi_(Rnum, Rnum, Interpreter::logStackElementSize);
2350 __ cmpd(CR0, R12_scratch2, R11_scratch1);
2351 __ blt(CR0, Lskip_vm_call);
2352 }
2353
2354 __ push(state);
2355 // Load 2 topmost expression stack values.
2356 __ ld(R6_ARG4, tsize*Interpreter::stackElementSize, R15_esp);
2357 __ ld(R5_ARG3, Interpreter::stackElementSize, R15_esp);
2358 __ mflr(R31);
2359 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::trace_bytecode), /* unused */ R4_ARG2, R5_ARG3, R6_ARG4, false);
2360 __ mtlr(R31);
2361 __ pop(state);
2362
2363 if (TraceBytecodesAt > 0) {
2364 __ bind(Lskip_vm_call);
2365 }
2366 __ blr();
2367 BLOCK_COMMENT("} trace_code");
2368 return entry;
2369 }
2370 #endif //PRODUCT
2371
2372 void TemplateInterpreterGenerator::count_bytecode() {
2373 int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeCounter::_counter_value, R12_scratch2, true);
2374 __ ld(R12_scratch2, offs, R11_scratch1);
2375 __ addi(R12_scratch2, R12_scratch2, 1);
2376 __ std(R12_scratch2, offs, R11_scratch1);
2377 }
2378
2379 void TemplateInterpreterGenerator::histogram_bytecode(Template* t) {
2380 int offs = __ load_const_optimized(R11_scratch1, (address) &BytecodeHistogram::_counters[t->bytecode()], R12_scratch2, true);
2381 __ lwz(R12_scratch2, offs, R11_scratch1);
2382 __ addi(R12_scratch2, R12_scratch2, 1);
2383 __ stw(R12_scratch2, offs, R11_scratch1);
2384 }
2385
2386 #ifndef PRODUCT
2387 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) {
2388 const Register addr = R11_scratch1,
2389 tmp = R12_scratch2;
2390 // Get index, shift out old bytecode, bring in new bytecode, and store it.
2391 // _index = (_index >> log2_number_of_codes) |
2392 // (bytecode << log2_number_of_codes);
2393 int offs1 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_index, tmp, true);
2394 __ lwz(tmp, offs1, addr);
2395 __ srwi(tmp, tmp, BytecodePairHistogram::log2_number_of_codes);
2396 __ ori(tmp, tmp, ((int) t->bytecode()) << BytecodePairHistogram::log2_number_of_codes);
2397 __ stw(tmp, offs1, addr);
2398
2399 // Bump bucket contents.
2400 // _counters[_index] ++;
2401 int offs2 = __ load_const_optimized(addr, (address)&BytecodePairHistogram::_counters, R0, true);
2402 __ sldi(tmp, tmp, LogBytesPerInt);
2403 __ add(addr, tmp, addr);
2404 __ lwz(tmp, offs2, addr);
2405 __ addi(tmp, tmp, 1);
2406 __ stw(tmp, offs2, addr);
|