Mercurial > hg > release > icedtea6-1.8
changeset 1184:a261142d4db9
2008-11-06 Gary Benson <gbenson@redhat.com>
* ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
(CppInterpreter::native_entry): Add stack overflow check.
author | Gary Benson <gbenson@redhat.com> |
---|---|
date | Thu, 06 Nov 2008 06:53:14 -0500 |
parents | bbb37067ce04 |
children | 2edccb28b389 |
files | ChangeLog ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp |
diffstat | 2 files changed, 77 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Nov 06 06:22:51 2008 -0500 +++ b/ChangeLog Thu Nov 06 06:53:14 2008 -0500 @@ -1,3 +1,8 @@ +2008-11-06 Gary Benson <gbenson@redhat.com> + + * ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp + (CppInterpreter::native_entry): Add stack overflow check. + 2008-11-06 Gary Benson <gbenson@redhat.com> * ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp Thu Nov 06 06:22:51 2008 -0500 +++ b/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp Thu Nov 06 06:53:14 2008 -0500 @@ -173,6 +173,9 @@ void CppInterpreter::native_entry(methodOop method, intptr_t UNUSED, TRAPS) { + // Make sure method is native and not abstract + assert(method->is_native() && !method->is_abstract(), "should be"); + JavaThread *thread = (JavaThread *) THREAD; ZeroStack *stack = thread->zero_stack(); @@ -182,11 +185,15 @@ interpreterState istate = frame->interpreter_state(); intptr_t *locals = istate->locals(); - // Make sure method is native and not abstract - assert(method->is_native() && !method->is_abstract(), "should be"); + // Check we're not about to run out of stack + if (stack_overflow_imminent(thread)) { + CALL_VM_NOCHECK(InterpreterRuntime::throw_StackOverflowError(thread)); + goto unwind_and_return; + } // Lock if necessary - BasicObjectLock *monitor = NULL; + BasicObjectLock *monitor; + monitor = NULL; if (method->is_synchronized()) { monitor = (BasicObjectLock*) istate->stack_base(); oop lockee = monitor->obj(); @@ -208,72 +215,79 @@ } // Get the signature handler - address handlerAddr = method->signature_handler(); - if (handlerAddr == NULL) { - CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method)); - if (HAS_PENDING_EXCEPTION) { - thread->pop_zero_frame(); - return; + InterpreterRuntime::SignatureHandler *handler; + { + address handlerAddr = method->signature_handler(); + if (handlerAddr == NULL) { + CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method)); + if (HAS_PENDING_EXCEPTION) { + thread->pop_zero_frame(); + return; + } + handlerAddr = method->signature_handler(); + assert(handlerAddr != NULL, "eh?"); } - handlerAddr = method->signature_handler(); - assert(handlerAddr != NULL, "eh?"); + if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) { + CALL_VM_NOCHECK(handlerAddr = + InterpreterRuntime::slow_signature_handler(thread, method, NULL,NULL)); + if (HAS_PENDING_EXCEPTION) { + thread->pop_zero_frame(); + return; + } + } + handler = \ + InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr); } - if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) { - CALL_VM_NOCHECK(handlerAddr = - InterpreterRuntime::slow_signature_handler(thread, method, NULL, NULL)); - if (HAS_PENDING_EXCEPTION) { - thread->pop_zero_frame(); - return; - } - } - InterpreterRuntime::SignatureHandler *handler = - InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr); // Get the native function entry point - address function = method->native_function(); + address function; + function = method->native_function(); assert(function != NULL, "should be set if signature handler is"); // Build the argument list if (handler->argument_count() * 2 > stack->available_words()) { Unimplemented(); } - void **arguments = - (void **) stack->alloc(handler->argument_count() * sizeof(void **)); - void **dst = arguments; - - void *env = thread->jni_environment(); - *(dst++) = &env; - - void *mirror = NULL; - if (method->is_static()) { - istate->set_oop_temp( - method->constants()->pool_holder()->klass_part()->java_mirror()); - mirror = istate->oop_temp_addr(); - *(dst++) = &mirror; - } - - intptr_t *src = locals; - for (int i = dst - arguments; i < handler->argument_count(); i++) { - ffi_type *type = handler->argument_type(i); - if (type == &ffi_type_pointer) { - if (*src) { - stack->push((intptr_t) src); - *(dst++) = stack->sp(); + void **arguments; + { + arguments = + (void **) stack->alloc(handler->argument_count() * sizeof(void **)); + void **dst = arguments; + + void *env = thread->jni_environment(); + *(dst++) = &env; + + void *mirror = NULL; + if (method->is_static()) { + istate->set_oop_temp( + method->constants()->pool_holder()->klass_part()->java_mirror()); + mirror = istate->oop_temp_addr(); + *(dst++) = &mirror; + } + + intptr_t *src = locals; + for (int i = dst - arguments; i < handler->argument_count(); i++) { + ffi_type *type = handler->argument_type(i); + if (type == &ffi_type_pointer) { + if (*src) { + stack->push((intptr_t) src); + *(dst++) = stack->sp(); + } + else { + *(dst++) = src; + } + src--; + } + else if (type->size == 4) { + *(dst++) = src--; + } + else if (type->size == 8) { + src--; + *(dst++) = src--; } else { - *(dst++) = src; + ShouldNotReachHere(); } - src--; - } - else if (type->size == 4) { - *(dst++) = src--; - } - else if (type->size == 8) { - src--; - *(dst++) = src--; - } - else { - ShouldNotReachHere(); } } @@ -327,6 +341,8 @@ } } + unwind_and_return: + // Unwind the current activation thread->pop_zero_frame();