--- a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp Tue Jun 14 19:38:44 2016 +0200
+++ b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp Mon Jun 13 09:28:25 2016 +0200
@@ -845,9 +845,40 @@
__ b(continue_entry);
}
+// See if we've got enough room on the stack for locals plus overhead below
+// JavaThread::stack_overflow_limit(). If not, throw a StackOverflowError
+// without going through the signal handler, i.e., reserved and yellow zones
+// will not be made usable. The shadow zone must suffice to handle the
+// overflow.
+//
+// Kills Rmem_frame_size, Rscratch1.
void TemplateInterpreterGenerator::generate_stack_overflow_check(Register Rmem_frame_size, Register Rscratch1) {
+ Label done;
assert_different_registers(Rmem_frame_size, Rscratch1);
- __ generate_stack_overflow_check_with_compare_and_throw(Rmem_frame_size, Rscratch1);
+
+ BLOCK_COMMENT("stack_overflow_check_with_compare {");
+ __ sub(Rmem_frame_size, R1_SP, Rmem_frame_size);
+ __ ld(Rscratch1, thread_(stack_overflow_limit));
+ __ cmpld(CCR0/*is_stack_overflow*/, Rmem_frame_size, Rscratch1);
+ __ bgt(CCR0/*is_stack_overflow*/, done);
+
+ // The stack overflows. Load target address of the runtime stub and call it.
+ assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "generated in wrong order");
+ __ load_const_optimized(Rscratch1, (StubRoutines::throw_StackOverflowError_entry()), R0);
+ __ mtctr(Rscratch1);
+ // Restore caller_sp.
+#ifdef ASSERT
+ __ ld(Rscratch1, 0, R1_SP);
+ __ ld(R0, 0, R21_sender_SP);
+ __ cmpd(CCR0, R0, Rscratch1);
+ __ asm_assert_eq("backlink", 0x547);
+#endif // ASSERT
+ __ mr(R1_SP, R21_sender_SP);
+ __ bctr();
+
+ __ align(32, 12);
+ __ bind(done);
+ BLOCK_COMMENT("} stack_overflow_check_with_compare");
}
void TemplateInterpreterGenerator::unlock_method(bool check_exceptions) {
@@ -1014,10 +1045,10 @@
// Enlarge by locals-parameters (not in case of native_call), shrink by ESP-SP-ABI48.
if (!native_call) {
- // --------------------------------------------------------------------------
- // Stack overflow check
-
- Label cont;
+ // Stack overflow check.
+ // Native calls don't need the stack size check since they have no
+ // expression stack and the arguments are already on the stack and
+ // we only add a handful of words to the stack.
__ add(R11_scratch1, parent_frame_resize, top_frame_size);
generate_stack_overflow_check(R11_scratch1, R12_scratch2);
}