Updated icedtea6 Zero (somewhat)
Gary Benson
gbenson at redhat.com
Fri May 7 02:56:28 PDT 2010
Hi all,
This commit updates Zero in icedtea6 to something closer to what is
upstream. Most importantly this includes the new stack overflow code
I wrote about here: http://gbenson.net/?p=184
Cheers,
Gary
--
http://gbenson.net/
-------------- next part --------------
diff -r 540dc0858c17 ChangeLog
--- a/ChangeLog Wed May 05 11:28:27 2010 +0100
+++ b/ChangeLog Fri May 07 10:49:00 2010 +0100
@@ -1,3 +1,53 @@
+2010-05-07 Gary Benson <gbenson at redhat.com>
+
+ * ports/hotspot/src/cpu/zero/vm/stack_zero.hpp
+ (ZeroStack::_shadow_pages_size): New field.
+ (ZeroStack::ZeroStack): Initialize the above.
+ (ZeroStack::shadow_pages_size): New method.
+ (ZeroStack::overflow_check): Likewise.
+ (ZeroStack::handle_overflow): Likewise.
+ * ports/hotspot/src/cpu/zero/vm/stack_zero.inline.hpp: New file.
+ * ports/hotspot/src/cpu/zero/vm/stack_zero.cpp: Likewise.
+ * ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp
+ (CppInterpreter::stack_overflow_imminent): Removed.
+ * ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
+ (CppInterpreter::stack_overflow_imminent): Likewise.
+ (CppInterpreter::normal_entry): Use new stack overflow code.
+ (CppInterpreter::main_loop): Likewise.
+ (CppInterpreter::native_entry): Likewise.
+ (InterpreterFrame::build): Likewise.
+ * ports/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp
+ (EntryFrame::build): Likewise.
+ * ports/hotspot/src/cpu/zero/vm/fakeStubFrame_zero.hpp
+ (FakeStubFrame::build): Likewise.
+ * ports/hotspot/src/cpu/zero/vm/interpreterFrame_zero.hpp
+ (InterpreterFrame::build): Likewise.
+ * ports/hotspot/src/cpu/zero/vm/interpreterRT_zero.cpp
+ (InterpreterRuntime::slow_signature_handler): Likewise.
+ * ports/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp
+ (StubGenerator::call_stub): Likewise.
+ (EntryFrame::build): Likewise.
+ * ports/hotspot/src/share/vm/shark/sharkRuntime.cpp
+ (SharkRuntime::uncommon_trap): Likewise.
+ (FakeStubFrame::build): Likewise.
+
+ * ports/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp
+ (JavaThread::set_last_Java_frame): Refactored.
+ (JavaThread::reset_last_Java_frame): Likewise.
+
+ * ports/hotspot/src/cpu/zero/vm/disassembler_zero.hpp
+ (Disassembler::pd_instruction_alignment): Implemented.
+ (Disassembler::pd_cpu_opts): Likewise.
+
+ * ports/hotspot/src/cpu/zero/vm/globals_zero.hpp: Updated.
+ * ports/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp: Likewise.
+
+ * ports/hotspot/src/share/vm/includeDB_zero: Updated.
+ * ports/hotspot/src/share/vm/includeDB_shark: Likewise.
+
+ * ports/hotspot/src/share/vm/shark/sharkCacheDecache.cpp
+ (SharkDecacher::end_frame): Updated for newer HotSpot.
+
2010-05-05 Gary Benson <gbenson at redhat.com>
PR icedtea/481
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
--- a/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp Fri May 07 10:49:00 2010 +0100
@@ -39,21 +39,9 @@
void CppInterpreter::normal_entry(methodOop method, intptr_t UNUSED, TRAPS) {
JavaThread *thread = (JavaThread *) THREAD;
- ZeroStack *stack = thread->zero_stack();
-
- // Adjust the caller's stack frame to accomodate any additional
- // local variables we have contiguously with our parameters.
- int extra_locals = method->max_locals() - method->size_of_parameters();
- if (extra_locals > 0) {
- if (extra_locals > stack->available_words()) {
- Unimplemented();
- }
- for (int i = 0; i < extra_locals; i++)
- stack->push(0);
- }
// Allocate and initialize our frame.
- InterpreterFrame *frame = InterpreterFrame::build(stack, method, thread);
+ InterpreterFrame *frame = InterpreterFrame::build(method, CHECK);
thread->push_zero_frame(frame);
// Execute those bytecodes!
@@ -76,12 +64,6 @@
intptr_t *result = NULL;
int result_slots = 0;
- // 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;
- }
-
while (true) {
// We can set up the frame anchor with everything we want at
// this point as we are thread_in_Java and no safepoints can
@@ -123,9 +105,9 @@
int monitor_words = frame::interpreter_frame_monitor_size();
// Allocate the space
- if (monitor_words > stack->available_words()) {
- Unimplemented();
- }
+ stack->overflow_check(monitor_words, THREAD);
+ if (HAS_PENDING_EXCEPTION)
+ break;
stack->alloc(monitor_words * wordSize);
// Move the expression stack contents
@@ -172,8 +154,6 @@
}
}
- unwind_and_return:
-
// Unwind the current frame
thread->pop_zero_frame();
@@ -193,17 +173,11 @@
ZeroStack *stack = thread->zero_stack();
// Allocate and initialize our frame
- InterpreterFrame *frame = InterpreterFrame::build(stack, method, thread);
+ InterpreterFrame *frame = InterpreterFrame::build(method, CHECK);
thread->push_zero_frame(frame);
interpreterState istate = frame->interpreter_state();
intptr_t *locals = istate->locals();
- // 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;
- }
-
// Update the invocation counter
if ((UseCompiler || CountCompiledCalls) && !method->is_synchronized()) {
InvocationCounter *counter = method->invocation_counter();
@@ -264,9 +238,10 @@
assert(function != NULL, "should be set if signature handler is");
// Build the argument list
- if (handler->argument_count() * 2 > stack->available_words()) {
- Unimplemented();
- }
+ stack->overflow_check(handler->argument_count() * 2, THREAD);
+ if (HAS_PENDING_EXCEPTION)
+ goto unlock_unwind_and_return;
+
void **arguments;
void *mirror; {
arguments =
@@ -503,9 +478,7 @@
switch (entry->flag_state()) {
case ltos:
case dtos:
- if (stack->available_words() < 1) {
- Unimplemented();
- }
+ stack->overflow_check(1, CHECK);
stack->alloc(wordSize);
break;
}
@@ -601,39 +574,30 @@
stack->set_sp(stack->sp() + method->size_of_parameters());
}
-bool CppInterpreter::stack_overflow_imminent(JavaThread *thread) {
- // How is the ABI stack?
- address stack_top = thread->stack_base() - thread->stack_size();
- int free_stack = os::current_stack_pointer() - stack_top;
- if (free_stack < StackShadowPages * os::vm_page_size()) {
- return true;
+InterpreterFrame *InterpreterFrame::build(const methodOop method, TRAPS) {
+ JavaThread *thread = (JavaThread *) THREAD;
+ ZeroStack *stack = thread->zero_stack();
+
+ // Calculate the size of the frame we'll build, including
+ // any adjustments to the caller's frame that we'll make.
+ int extra_locals = 0;
+ int monitor_words = 0;
+ int stack_words = 0;
+
+ if (!method->is_native()) {
+ extra_locals = method->max_locals() - method->size_of_parameters();
+ stack_words = method->max_stack();
}
+ if (method->is_synchronized()) {
+ monitor_words = frame::interpreter_frame_monitor_size();
+ }
+ stack->overflow_check(
+ extra_locals + header_words + monitor_words + stack_words, CHECK_NULL);
- // How is the Zero stack?
- // Throwing a StackOverflowError involves a VM call, which means
- // we need a frame on the stack. We should be checking here to
- // ensure that methods we call have enough room to install the
- // largest possible frame, but that's more than twice the size
- // of the entire Zero stack we get by default, so we just check
- // we have *some* space instead...
- free_stack = thread->zero_stack()->available_words() * wordSize;
- if (free_stack < StackShadowPages * os::vm_page_size()) {
- return true;
- }
-
- return false;
-}
-
-InterpreterFrame *InterpreterFrame::build(ZeroStack* stack,
- const methodOop method,
- JavaThread* thread) {
- int monitor_words =
- method->is_synchronized() ? frame::interpreter_frame_monitor_size() : 0;
- int stack_words = method->is_native() ? 0 : method->max_stack();
-
- if (header_words + monitor_words + stack_words > stack->available_words()) {
- Unimplemented();
- }
+ // Adjust the caller's stack frame to accomodate any additional
+ // local variables we have contiguously with our parameters.
+ for (int i = 0; i < extra_locals; i++)
+ stack->push(0);
intptr_t *locals;
if (method->is_native())
@@ -819,14 +783,13 @@
// Deoptimization helpers
-InterpreterFrame *InterpreterFrame::build(ZeroStack* stack, int size) {
+InterpreterFrame *InterpreterFrame::build(int size, TRAPS) {
+ ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack();
+
int size_in_words = size >> LogBytesPerWord;
assert(size_in_words * wordSize == size, "unaligned");
assert(size_in_words >= header_words, "too small");
-
- if (size_in_words > stack->available_words()) {
- Unimplemented();
- }
+ stack->overflow_check(size_in_words, CHECK_NULL);
stack->push(0); // next_frame, filled in later
intptr_t *fp = stack->sp();
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp Fri May 07 10:49:00 2010 +0100
@@ -39,9 +39,5 @@
static void main_loop(int recurse, TRAPS);
private:
- // Stack overflow checks
- static bool stack_overflow_imminent(JavaThread *thread);
-
- private:
// Fast result type determination
static BasicType result_type_of(methodOop method);
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/disassembler_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/disassembler_zero.hpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/disassembler_zero.hpp Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2007, 2010 Red Hat, Inc.
+ * Copyright 2007 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,13 @@
*
*/
+// The disassembler prints out zero code annotated
+// with Java specific information.
+
static int pd_instruction_alignment() {
- return 1;
+ ShouldNotCallThis();
}
static const char* pd_cpu_opts() {
- return "";
+ ShouldNotCallThis();
}
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/entryFrame_zero.hpp Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2008 Red Hat, Inc.
+ * Copyright 2008, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,10 +47,10 @@
};
public:
- static EntryFrame *build(ZeroStack* stack,
- const intptr_t* parameters,
+ static EntryFrame *build(const intptr_t* parameters,
int parameter_words,
- JavaCallWrapper* call_wrapper);
+ JavaCallWrapper* call_wrapper,
+ TRAPS);
public:
JavaCallWrapper *call_wrapper() const {
return (JavaCallWrapper *) value_of_word(call_wrapper_off);
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/fakeStubFrame_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/fakeStubFrame_zero.hpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/fakeStubFrame_zero.hpp Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2008 Red Hat, Inc.
+ * Copyright 2008, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
};
public:
- static FakeStubFrame *build(ZeroStack* stack);
+ static FakeStubFrame *build(TRAPS);
public:
void identify_word(int frame_index,
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/globals_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/globals_zero.hpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/globals_zero.hpp Fri May 07 10:49:00 2010 +0100
@@ -35,17 +35,8 @@
define_pd_global(bool, UncommonNullCast, true);
define_pd_global(intx, CodeEntryAlignment, 32);
-define_pd_global(uintx, TLABSize, 0);
-#ifdef _LP64
-define_pd_global(uintx, NewSize, ScaleForWordSize(2048 * K));
-#else
-define_pd_global(uintx, NewSize, ScaleForWordSize(1024 * K));
-#endif // _LP64
+define_pd_global(intx, OptoLoopAlignment, 16);
define_pd_global(intx, InlineFrequencyCount, 100);
-#ifdef SHARK
-// Only required for older HotSpot versions
-define_pd_global(intx, InlineSmallCode, 1000);
-#endif // SHARK
define_pd_global(intx, PreInflateSpin, 10);
define_pd_global(intx, StackYellowPages, 2);
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/interpreterFrame_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/interpreterFrame_zero.hpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/interpreterFrame_zero.hpp Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2008 Red Hat, Inc.
+ * Copyright 2008, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,10 +55,8 @@
};
public:
- static InterpreterFrame *build(ZeroStack* stack,
- const methodOop method,
- JavaThread* thread);
- static InterpreterFrame *build(ZeroStack* stack, int size);
+ static InterpreterFrame *build(const methodOop method, TRAPS);
+ static InterpreterFrame *build(int size, TRAPS);
public:
interpreterState interpreter_state() const {
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/interpreterRT_zero.cpp
--- a/ports/hotspot/src/cpu/zero/vm/interpreterRT_zero.cpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/interpreterRT_zero.cpp Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
/*
* Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2007, 2008 Red Hat, Inc.
+ * Copyright 2007, 2008, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -140,9 +140,8 @@
int required_words =
(align_size_up(sizeof(ffi_cif), wordSize) >> LogBytesPerWord) +
(method->is_static() ? 2 : 1) + method->size_of_parameters() + 1;
- if (required_words > stack->available_words()) {
- Unimplemented();
- }
+
+ stack->overflow_check(required_words, CHECK_NULL);
intptr_t *buf = (intptr_t *) stack->alloc(required_words * wordSize);
SlowSignatureHandlerGenerator sshg(methodHandle(thread, method), buf);
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp Fri May 07 10:49:00 2010 +0100
@@ -47,6 +47,7 @@
define_pd_global(intx, OnStackReplacePercentage, 933 );
define_pd_global(intx, FreqInlineSize, 325 );
+define_pd_global(intx, InlineSmallCode, 1000 );
define_pd_global(intx, NewRatio, 12 );
define_pd_global(intx, NewSizeThreadIncrease, 4*K );
define_pd_global(intx, InitialCodeCacheSize, 160*K);
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/stack_zero.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ports/hotspot/src/cpu/zero/vm/stack_zero.cpp Fri May 07 10:49:00 2010 +0100
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 Red Hat, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+#include "incls/_precompiled.incl"
+#include "incls/_stack_zero.cpp.incl"
+
+void ZeroStack::handle_overflow(TRAPS) {
+ JavaThread *thread = (JavaThread *) THREAD;
+
+ // Set up the frame anchor if it isn't already
+ bool has_last_Java_frame = thread->has_last_Java_frame();
+ if (!has_last_Java_frame) {
+ ZeroFrame *frame = thread->top_zero_frame();
+ while (frame) {
+ if (frame->is_shark_frame())
+ break;
+
+ if (frame->is_interpreter_frame()) {
+ interpreterState istate =
+ frame->as_interpreter_frame()->interpreter_state();
+ if (istate->self_link() == istate)
+ break;
+ }
+
+ frame = frame->next();
+ }
+
+ if (frame == NULL)
+ fatal("unrecoverable stack overflow");
+
+ thread->set_last_Java_frame(frame);
+ }
+
+ // Throw the exception
+ switch (thread->thread_state()) {
+ case _thread_in_Java:
+ InterpreterRuntime::throw_StackOverflowError(thread);
+ break;
+
+ case _thread_in_vm:
+ Exceptions::throw_stack_overflow_exception(thread, __FILE__, __LINE__);
+ break;
+
+ default:
+ ShouldNotReachHere();
+ }
+
+ // Reset the frame anchor if necessary
+ if (!has_last_Java_frame)
+ thread->reset_last_Java_frame();
+}
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/stack_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/stack_zero.hpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/stack_zero.hpp Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2008, 2009 Red Hat, Inc.
+ * Copyright 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,9 +29,14 @@
intptr_t *_top; // the word past the end of the stack
intptr_t *_sp; // the top word on the stack
+ private:
+ int _shadow_pages_size; // how much ABI stack must we keep free?
+
public:
ZeroStack()
- : _base(NULL), _top(NULL), _sp(NULL) {}
+ : _base(NULL), _top(NULL), _sp(NULL) {
+ _shadow_pages_size = StackShadowPages * os::vm_page_size();
+ }
bool needs_setup() const {
return _base == NULL;
@@ -81,6 +86,14 @@
return _sp -= count;
}
+ int shadow_pages_size() const {
+ return _shadow_pages_size;
+ }
+
+ public:
+ void overflow_check(int required_words, TRAPS);
+ static void handle_overflow(TRAPS);
+
public:
static ByteSize base_offset() {
return byte_offset_of(ZeroStack, _base);
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/stack_zero.inline.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ports/hotspot/src/cpu/zero/vm/stack_zero.inline.hpp Fri May 07 10:49:00 2010 +0100
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 Red Hat, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+// This function should match SharkStack::CreateStackOverflowCheck
+inline void ZeroStack::overflow_check(int required_words, TRAPS) {
+ JavaThread *thread = (JavaThread *) THREAD;
+
+ // Check the Zero stack
+ if (required_words > available_words()) {
+ handle_overflow(THREAD);
+ return;
+ }
+
+ // Check the ABI stack
+ address stack_top = thread->stack_base() - thread->stack_size();
+ int free_stack = ((address) &stack_top) - stack_top;
+ if (free_stack < shadow_pages_size()) {
+ handle_overflow(THREAD);
+ return;
+ }
+}
diff -r 540dc0858c17 ports/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp
--- a/ports/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
/*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2007, 2008 Red Hat, Inc.
+ * Copyright 2007, 2008, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -60,38 +60,43 @@
}
// Allocate and initialize our frame
- thread->push_zero_frame(
- EntryFrame::build(stack, parameters, parameter_words, call_wrapper));
+ EntryFrame *frame =
+ EntryFrame::build(parameters, parameter_words, call_wrapper, THREAD);
- // Make the call
- Interpreter::invoke_method(method, entry_point, THREAD);
+ if (!HAS_PENDING_EXCEPTION) {
+ // Push the frame
+ thread->push_zero_frame(frame);
- // Store result depending on type
- if (!HAS_PENDING_EXCEPTION) {
- switch (result_type) {
- case T_INT:
- *(jint *) result = *(jint *) stack->sp();
- break;
- case T_LONG:
- *(jlong *) result = *(jlong *) stack->sp();
- break;
- case T_FLOAT:
- *(jfloat *) result = *(jfloat *) stack->sp();
- break;
- case T_DOUBLE:
- *(jdouble *) result = *(jdouble *) stack->sp();
- break;
- case T_OBJECT:
- *(oop *) result = *(oop *) stack->sp();
- break;
- default:
- ShouldNotReachHere();
+ // Make the call
+ Interpreter::invoke_method(method, entry_point, THREAD);
+
+ // Store the result
+ if (!HAS_PENDING_EXCEPTION) {
+ switch (result_type) {
+ case T_INT:
+ *(jint *) result = *(jint *) stack->sp();
+ break;
+ case T_LONG:
+ *(jlong *) result = *(jlong *) stack->sp();
+ break;
+ case T_FLOAT:
+ *(jfloat *) result = *(jfloat *) stack->sp();
+ break;
+ case T_DOUBLE:
+ *(jdouble *) result = *(jdouble *) stack->sp();
+ break;
+ case T_OBJECT:
+ *(oop *) result = *(oop *) stack->sp();
+ break;
+ default:
+ ShouldNotReachHere();
+ }
}
+
+ // Unwind the frame
+ thread->pop_zero_frame();
}
- // Unwind our frame
- thread->pop_zero_frame();
-
// Tear down the stack if necessary
if (stack_needs_teardown)
stack->teardown();
@@ -226,13 +231,13 @@
StubGenerator g(code, all);
}
-EntryFrame *EntryFrame::build(ZeroStack* stack,
- const intptr_t* parameters,
+EntryFrame *EntryFrame::build(const intptr_t* parameters,
int parameter_words,
- JavaCallWrapper* call_wrapper) {
- if (header_words + parameter_words > stack->available_words()) {
- Unimplemented();
- }
+ JavaCallWrapper* call_wrapper,
+ TRAPS) {
+
+ ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack();
+ stack->overflow_check(header_words + parameter_words, CHECK_NULL);
stack->push(0); // next_frame, filled in later
intptr_t *fp = stack->sp();
diff -r 540dc0858c17 ports/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp
--- a/ports/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
/*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2007, 2008, 2009 Red Hat, Inc.
+ * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,12 +68,13 @@
public:
void set_last_Java_frame() {
- JavaFrameAnchor *jfa = frame_anchor();
- jfa->set_last_Java_sp((intptr_t *) top_zero_frame());
+ set_last_Java_frame(top_zero_frame());
}
void reset_last_Java_frame() {
- JavaFrameAnchor *jfa = frame_anchor();
- jfa->set_last_Java_sp(NULL);
+ set_last_Java_frame(NULL);
+ }
+ void set_last_Java_frame(ZeroFrame* frame) {
+ frame_anchor()->set_last_Java_sp((intptr_t *) frame);
}
private:
diff -r 540dc0858c17 ports/hotspot/src/share/vm/includeDB_shark
--- a/ports/hotspot/src/share/vm/includeDB_shark Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/share/vm/includeDB_shark Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
//
// Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
-// Copyright 2008, 2009 Red Hat, Inc.
+// Copyright 2008, 2009, 2010 Red Hat, Inc.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
@@ -273,6 +273,7 @@
sharkRuntime.cpp llvmHeaders.hpp
sharkRuntime.cpp klassOop.hpp
sharkRuntime.cpp sharkRuntime.hpp
+sharkRuntime.cpp stack_<arch>.inline.hpp
sharkRuntime.cpp thread.hpp
sharkRuntime.hpp allocation.hpp
diff -r 540dc0858c17 ports/hotspot/src/share/vm/includeDB_zero
--- a/ports/hotspot/src/share/vm/includeDB_zero Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/share/vm/includeDB_zero Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
//
// Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
-// Copyright 2009 Red Hat, Inc.
+// Copyright 2009, 2010 Red Hat, Inc.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
// NOTE: DO NOT CHANGE THIS COPYRIGHT TO NEW STYLE - IT WILL BREAK makeDeps!
+cppInterpreter_<arch>.cpp stack_<arch>.inline.hpp
+
entryFrame_<arch>.hpp javaCalls.hpp
entryFrame_<arch>.hpp stack_<arch>.hpp
@@ -47,9 +49,20 @@
interpreterFrame_<arch>.hpp stack_<arch>.hpp
interpreterFrame_<arch>.hpp thread.hpp
+interpreterRT_<arch>.cpp stack_<arch>.inline.hpp
+
sharkFrame_<arch>.hpp methodOop.hpp
sharkFrame_<arch>.hpp stack_<arch>.hpp
stack_<arch>.hpp sizes.hpp
+stack_<arch>.inline.hpp stack_<arch>.hpp
+stack_<arch>.inline.hpp thread.hpp
+
+stack_<arch>.cpp interpreterRuntime.hpp
+stack_<arch>.cpp stack_<arch>.hpp
+stack_<arch>.cpp stack_<arch>.inline.hpp
+
+stubGenerator_<arch>.cpp stack_<arch>.inline.hpp
+
thread.hpp stack_<arch>.hpp
diff -r 540dc0858c17 ports/hotspot/src/share/vm/shark/sharkCacheDecache.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkCacheDecache.cpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/share/vm/shark/sharkCacheDecache.cpp Fri May 07 10:49:00 2010 +0100
@@ -149,6 +149,7 @@
pc_offset(),
target(),
bci(),
+ true,
debug_info()->create_scope_values(locarray()),
debug_info()->create_scope_values(exparray()),
debug_info()->create_monitor_values(monarray()));
diff -r 540dc0858c17 ports/hotspot/src/share/vm/shark/sharkRuntime.cpp
--- a/ports/hotspot/src/share/vm/shark/sharkRuntime.cpp Wed May 05 11:28:27 2010 +0100
+++ b/ports/hotspot/src/share/vm/shark/sharkRuntime.cpp Fri May 07 10:49:00 2010 +0100
@@ -1,6 +1,6 @@
/*
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2008, 2009 Red Hat, Inc.
+ * Copyright 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -195,10 +195,12 @@
void SharkRuntime::uncommon_trap(JavaThread* thread, int trap_request) {
// In C2, uncommon_trap_blob creates a frame, so all the various
// deoptimization functions expect to find the frame of the method
- // being deopted one frame down on the stack. Create a dummy frame
- // to mirror this.
- ZeroStack *stack = thread->zero_stack();
- thread->push_zero_frame(FakeStubFrame::build(stack));
+ // being deopted one frame down on the stack. We create a dummy
+ // frame to mirror this.
+ FakeStubFrame *stubframe = FakeStubFrame::build(thread);
+ if (thread->has_pending_exception())
+ return;
+ thread->push_zero_frame(stubframe);
// Initiate the trap
thread->set_last_Java_frame();
@@ -214,11 +216,17 @@
int number_of_frames = urb->number_of_frames();
for (int i = 0; i < number_of_frames; i++) {
intptr_t size = urb->frame_sizes()[i];
- thread->push_zero_frame(InterpreterFrame::build(stack, size));
+ InterpreterFrame *frame = InterpreterFrame::build(size, thread);
+ if (thread->has_pending_exception())
+ return;
+ thread->push_zero_frame(frame);
}
// Push another dummy frame
- thread->push_zero_frame(FakeStubFrame::build(stack));
+ stubframe = FakeStubFrame::build(thread);
+ if (thread->has_pending_exception())
+ return;
+ thread->push_zero_frame(stubframe);
// Fill in the skeleton frames
thread->set_last_Java_frame();
@@ -236,10 +244,9 @@
#endif // CC_INTERP
}
-FakeStubFrame* FakeStubFrame::build(ZeroStack* stack) {
- if (header_words > stack->available_words()) {
- Unimplemented();
- }
+FakeStubFrame* FakeStubFrame::build(TRAPS) {
+ ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack();
+ stack->overflow_check(header_words, CHECK_NULL);
stack->push(0); // next_frame, filled in later
intptr_t *fp = stack->sp();
More information about the zero-dev
mailing list