changeset 1382:d32d2a2f62cd

Merge
author twisti
date Fri, 16 Apr 2010 02:59:34 -0700
parents badea972a310 (diff) a9584793da0f (current diff)
children aa9c266de52a
files
diffstat 24 files changed, 330 insertions(+), 236 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -388,6 +388,60 @@
 }
 
 
+// Emit the code to remove the frame from the stack in the exception
+// unwind path.
+int LIR_Assembler::emit_unwind_handler() {
+#ifndef PRODUCT
+  if (CommentedAssembly) {
+    _masm->block_comment("Unwind handler");
+  }
+#endif
+
+  int offset = code_offset();
+
+  // Fetch the exception from TLS and clear out exception related thread state
+  __ ld_ptr(G2_thread, in_bytes(JavaThread::exception_oop_offset()), O0);
+  __ st_ptr(G0, G2_thread, in_bytes(JavaThread::exception_oop_offset()));
+  __ st_ptr(G0, G2_thread, in_bytes(JavaThread::exception_pc_offset()));
+
+  __ bind(_unwind_handler_entry);
+  __ verify_not_null_oop(O0);
+  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
+    __ mov(O0, I0);  // Preserve the exception
+  }
+
+  // Preform needed unlocking
+  MonitorExitStub* stub = NULL;
+  if (method()->is_synchronized()) {
+    monitor_address(0, FrameMap::I1_opr);
+    stub = new MonitorExitStub(FrameMap::I1_opr, true, 0);
+    __ unlock_object(I3, I2, I1, *stub->entry());
+    __ bind(*stub->continuation());
+  }
+
+  if (compilation()->env()->dtrace_method_probes()) {
+    jobject2reg(method()->constant_encoding(), O0);
+    __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), relocInfo::runtime_call_type);
+    __ delayed()->nop();
+  }
+
+  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
+    __ mov(I0, O0);  // Restore the exception
+  }
+
+  // dispatch to the unwind logic
+  __ call(Runtime1::entry_for(Runtime1::unwind_exception_id), relocInfo::runtime_call_type);
+  __ delayed()->nop();
+
+  // Emit the slow path assembly
+  if (stub != NULL) {
+    stub->emit_code(this);
+  }
+
+  return offset;
+}
+
+
 int LIR_Assembler::emit_deopt_handler() {
   // if the last instruction is a call (typically to do a throw which
   // is coming at the end after block reordering) the return address
@@ -2050,26 +2104,29 @@
 }
 
 
-void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info, bool unwind) {
+void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
   assert(exceptionOop->as_register() == Oexception, "should match");
-  assert(unwind || exceptionPC->as_register() == Oissuing_pc, "should match");
+  assert(exceptionPC->as_register() == Oissuing_pc, "should match");
 
   info->add_register_oop(exceptionOop);
 
-  if (unwind) {
-    __ call(Runtime1::entry_for(Runtime1::unwind_exception_id), relocInfo::runtime_call_type);
-    __ delayed()->nop();
-  } else {
-    // reuse the debug info from the safepoint poll for the throw op itself
-    address pc_for_athrow  = __ pc();
-    int pc_for_athrow_offset = __ offset();
-    RelocationHolder rspec = internal_word_Relocation::spec(pc_for_athrow);
-    __ set(pc_for_athrow, Oissuing_pc, rspec);
-    add_call_info(pc_for_athrow_offset, info); // for exception handler
-
-    __ call(Runtime1::entry_for(Runtime1::handle_exception_id), relocInfo::runtime_call_type);
-    __ delayed()->nop();
-  }
+  // reuse the debug info from the safepoint poll for the throw op itself
+  address pc_for_athrow  = __ pc();
+  int pc_for_athrow_offset = __ offset();
+  RelocationHolder rspec = internal_word_Relocation::spec(pc_for_athrow);
+  __ set(pc_for_athrow, Oissuing_pc, rspec);
+  add_call_info(pc_for_athrow_offset, info); // for exception handler
+
+  __ call(Runtime1::entry_for(Runtime1::handle_exception_id), relocInfo::runtime_call_type);
+  __ delayed()->nop();
+}
+
+
+void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
+  assert(exceptionOop->as_register() == Oexception, "should match");
+
+  __ br(Assembler::always, false, Assembler::pt, _unwind_handler_entry);
+  __ delayed()->nop();
 }
 
 
@@ -2358,7 +2415,7 @@
   if (UseSlowPath ||
       (!UseFastNewObjectArray && (op->type() == T_OBJECT || op->type() == T_ARRAY)) ||
       (!UseFastNewTypeArray   && (op->type() != T_OBJECT && op->type() != T_ARRAY))) {
-    __ br(Assembler::always, false, Assembler::pn, *op->stub()->entry());
+    __ br(Assembler::always, false, Assembler::pt, *op->stub()->entry());
     __ delayed()->nop();
   } else {
     __ allocate_array(op->obj()->as_register(),
--- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -455,6 +455,60 @@
 }
 
 
+// Emit the code to remove the frame from the stack in the exception
+// unwind path.
+int LIR_Assembler::emit_unwind_handler() {
+#ifndef PRODUCT
+  if (CommentedAssembly) {
+    _masm->block_comment("Unwind handler");
+  }
+#endif
+
+  int offset = code_offset();
+
+  // Fetch the exception from TLS and clear out exception related thread state
+  __ get_thread(rsi);
+  __ movptr(rax, Address(rsi, JavaThread::exception_oop_offset()));
+  __ movptr(Address(rsi, JavaThread::exception_oop_offset()), (int32_t)NULL_WORD);
+  __ movptr(Address(rsi, JavaThread::exception_pc_offset()), (int32_t)NULL_WORD);
+
+  __ bind(_unwind_handler_entry);
+  __ verify_not_null_oop(rax);
+  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
+    __ mov(rsi, rax);  // Preserve the exception
+  }
+
+  // Preform needed unlocking
+  MonitorExitStub* stub = NULL;
+  if (method()->is_synchronized()) {
+    monitor_address(0, FrameMap::rax_opr);
+    stub = new MonitorExitStub(FrameMap::rax_opr, true, 0);
+    __ unlock_object(rdi, rbx, rax, *stub->entry());
+    __ bind(*stub->continuation());
+  }
+
+  if (compilation()->env()->dtrace_method_probes()) {
+    __ movoop(Address(rsp, 0), method()->constant_encoding());
+    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit)));
+  }
+
+  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
+    __ mov(rax, rsi);  // Restore the exception
+  }
+
+  // remove the activation and dispatch to the unwind handler
+  __ remove_frame(initial_frame_size_in_bytes());
+  __ jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id)));
+
+  // Emit the slow path assembly
+  if (stub != NULL) {
+    stub->emit_code(this);
+  }
+
+  return offset;
+}
+
+
 int LIR_Assembler::emit_deopt_handler() {
   // if the last instruction is a call (typically to do a throw which
   // is coming at the end after block reordering) the return address
@@ -2795,42 +2849,43 @@
 }
 
 
-void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info, bool unwind) {
+void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
   assert(exceptionOop->as_register() == rax, "must match");
-  assert(unwind || exceptionPC->as_register() == rdx, "must match");
+  assert(exceptionPC->as_register() == rdx, "must match");
 
   // exception object is not added to oop map by LinearScan
   // (LinearScan assumes that no oops are in fixed registers)
   info->add_register_oop(exceptionOop);
   Runtime1::StubID unwind_id;
 
-  if (!unwind) {
-    // get current pc information
-    // pc is only needed if the method has an exception handler, the unwind code does not need it.
-    int pc_for_athrow_offset = __ offset();
-    InternalAddress pc_for_athrow(__ pc());
-    __ lea(exceptionPC->as_register(), pc_for_athrow);
-    add_call_info(pc_for_athrow_offset, info); // for exception handler
-
-    __ verify_not_null_oop(rax);
-    // search an exception handler (rax: exception oop, rdx: throwing pc)
-    if (compilation()->has_fpu_code()) {
-      unwind_id = Runtime1::handle_exception_id;
-    } else {
-      unwind_id = Runtime1::handle_exception_nofpu_id;
-    }
-    __ call(RuntimeAddress(Runtime1::entry_for(unwind_id)));
+  // get current pc information
+  // pc is only needed if the method has an exception handler, the unwind code does not need it.
+  int pc_for_athrow_offset = __ offset();
+  InternalAddress pc_for_athrow(__ pc());
+  __ lea(exceptionPC->as_register(), pc_for_athrow);
+  add_call_info(pc_for_athrow_offset, info); // for exception handler
+
+  __ verify_not_null_oop(rax);
+  // search an exception handler (rax: exception oop, rdx: throwing pc)
+  if (compilation()->has_fpu_code()) {
+    unwind_id = Runtime1::handle_exception_id;
   } else {
-    // remove the activation
-    __ remove_frame(initial_frame_size_in_bytes());
-    __ jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id)));
+    unwind_id = Runtime1::handle_exception_nofpu_id;
   }
+  __ call(RuntimeAddress(Runtime1::entry_for(unwind_id)));
 
   // enough room for two byte trap
   __ nop();
 }
 
 
+void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
+  assert(exceptionOop->as_register() == rax, "must match");
+
+  __ jmp(_unwind_handler_entry);
+}
+
+
 void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, LIR_Opr count, LIR_Opr dest, LIR_Opr tmp) {
 
   // optimized version for linear scan:
--- a/src/cpu/zero/vm/cppInterpreter_zero.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -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;
 
-  // 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;
+  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);
 
-  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())
@@ -812,14 +776,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();
--- a/src/cpu/zero/vm/cppInterpreter_zero.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/zero/vm/cppInterpreter_zero.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -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);
--- a/src/cpu/zero/vm/entryFrame_zero.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/zero/vm/entryFrame_zero.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -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);
--- a/src/cpu/zero/vm/fakeStubFrame_zero.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/zero/vm/fakeStubFrame_zero.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -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,
--- a/src/cpu/zero/vm/interpreterFrame_zero.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/zero/vm/interpreterFrame_zero.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -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 {
--- a/src/cpu/zero/vm/interpreterRT_zero.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/zero/vm/interpreterRT_zero.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -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);
--- a/src/cpu/zero/vm/stack_zero.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/zero/vm/stack_zero.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -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);
--- a/src/cpu/zero/vm/stubGenerator_zero.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/cpu/zero/vm/stubGenerator_zero.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -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);
-
-    // 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();
+      // Push the frame
+      thread->push_zero_frame(frame);
+
+      // 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();
--- a/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/os_cpu/linux_zero/vm/thread_linux_zero.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -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:
--- a/src/share/vm/asm/codeBuffer.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/asm/codeBuffer.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -40,6 +40,7 @@
                  Exceptions,     // Offset where exception handler lives
                  Deopt,          // Offset where deopt handler lives
                  DeoptMH,        // Offset where MethodHandle deopt handler lives
+                 UnwindHandler,  // Offset to default unwind handler
                  max_Entries };
 
   // special value to note codeBlobs where profile (forte) stack walking is
@@ -59,6 +60,7 @@
     _values[Exceptions    ] = -1;
     _values[Deopt         ] = -1;
     _values[DeoptMH       ] = -1;
+    _values[UnwindHandler ] = -1;
   }
 
   int value(Entries e) { return _values[e]; }
--- a/src/share/vm/c1/c1_Compilation.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/c1/c1_Compilation.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -229,6 +229,10 @@
   code_offsets->set_value(CodeOffsets::DeoptMH, assembler->emit_deopt_handler());
   CHECK_BAILOUT();
 
+  // Emit the handler to remove the activation from the stack and
+  // dispatch to the caller.
+  offsets()->set_value(CodeOffsets::UnwindHandler, assembler->emit_unwind_handler());
+
   // done
   masm()->flush();
 }
--- a/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -829,12 +829,8 @@
     // should be left alone since there can be only one and all code
     // should dispatch to the same one.
     XHandler* h = handlers->handler_at(i);
-    if (h->handler_bci() != SynchronizationEntryBCI) {
-      h->set_entry_block(block_at(h->handler_bci()));
-    } else {
-      assert(h->entry_block()->is_set(BlockBegin::default_exception_handler_flag),
-             "should be the synthetic unlock block");
-    }
+    assert(h->handler_bci() != SynchronizationEntryBCI, "must be real");
+    h->set_entry_block(block_at(h->handler_bci()));
   }
   _jsr_xhandlers = handlers;
 }
@@ -2867,19 +2863,6 @@
   _initial_state = state_at_entry();
   start_block->merge(_initial_state);
 
-  // setup an exception handler to do the unlocking and/or
-  // notification and unwind the frame.
-  BlockBegin* sync_handler = new BlockBegin(-1);
-  sync_handler->set(BlockBegin::exception_entry_flag);
-  sync_handler->set(BlockBegin::is_on_work_list_flag);
-  sync_handler->set(BlockBegin::default_exception_handler_flag);
-
-  ciExceptionHandler* desc = new ciExceptionHandler(method()->holder(), 0, method()->code_size(), -1, 0);
-  XHandler* h = new XHandler(desc);
-  h->set_entry_block(sync_handler);
-  scope_data()->xhandlers()->append(h);
-  scope_data()->set_has_handler();
-
   // complete graph
   _vmap        = new ValueMap();
   scope->compute_lock_stack_size();
@@ -2930,19 +2913,6 @@
   }
   CHECK_BAILOUT();
 
-  if (sync_handler && sync_handler->state() != NULL) {
-    Value lock = NULL;
-    if (method()->is_synchronized()) {
-      lock = method()->is_static() ? new Constant(new InstanceConstant(method()->holder()->java_mirror())) :
-                                     _initial_state->local_at(0);
-
-      sync_handler->state()->unlock();
-      sync_handler->state()->lock(scope, lock);
-
-    }
-    fill_sync_handler(lock, sync_handler, true);
-  }
-
   _start = setup_start_block(osr_bci, start_block, _osr_entry, _initial_state);
 
   eliminate_redundant_phis(_start);
--- a/src/share/vm/c1/c1_Instruction.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/c1/c1_Instruction.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -1628,11 +1628,10 @@
     backward_branch_target_flag   = 1 << 4,
     is_on_work_list_flag          = 1 << 5,
     was_visited_flag              = 1 << 6,
-    default_exception_handler_flag = 1 << 8, // identify block which represents the default exception handler
-    parser_loop_header_flag       = 1 << 9,  // set by parser to identify blocks where phi functions can not be created on demand
-    critical_edge_split_flag      = 1 << 10, // set for all blocks that are introduced when critical edges are split
-    linear_scan_loop_header_flag  = 1 << 11, // set during loop-detection for LinearScan
-    linear_scan_loop_end_flag     = 1 << 12  // set during loop-detection for LinearScan
+    parser_loop_header_flag       = 1 << 7,  // set by parser to identify blocks where phi functions can not be created on demand
+    critical_edge_split_flag      = 1 << 8, // set for all blocks that are introduced when critical edges are split
+    linear_scan_loop_header_flag  = 1 << 9, // set during loop-detection for LinearScan
+    linear_scan_loop_end_flag     = 1 << 10  // set during loop-detection for LinearScan
   };
 
   void set(Flag f)                               { _flags |= f; }
--- a/src/share/vm/c1/c1_LIR.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/c1/c1_LIR.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -626,8 +626,7 @@
       break;
     }
 
-    case lir_throw:
-    case lir_unwind: {
+    case lir_throw: {
       assert(op->as_Op2() != NULL, "must be");
       LIR_Op2* op2 = (LIR_Op2*)op;
 
@@ -639,6 +638,17 @@
       break;
     }
 
+    case lir_unwind: {
+      assert(op->as_Op1() != NULL, "must be");
+      LIR_Op1* op1 = (LIR_Op1*)op;
+
+      assert(op1->_info == NULL, "no info");
+      assert(op1->_opr->is_valid(), "exception oop");         do_input(op1->_opr);
+      assert(op1->_result->is_illegal(), "no result");
+
+      break;
+    }
+
 
     case lir_tan:
     case lir_sin:
--- a/src/share/vm/c1/c1_LIR.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/c1/c1_LIR.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -801,6 +801,7 @@
       , lir_monaddr
       , lir_roundfp
       , lir_safepoint
+      , lir_unwind
   , end_op1
   , begin_op2
       , lir_cmp
@@ -830,7 +831,6 @@
       , lir_ushr
       , lir_alloc_array
       , lir_throw
-      , lir_unwind
       , lir_compare_to
   , end_op2
   , begin_op3
@@ -1827,8 +1827,12 @@
   void logical_xor (LIR_Opr left, LIR_Opr right, LIR_Opr dst) { append(new LIR_Op2(lir_logic_xor,  left, right, dst)); }
 
   void null_check(LIR_Opr opr, CodeEmitInfo* info)         { append(new LIR_Op1(lir_null_check, opr, info)); }
-  void throw_exception(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) { append(new LIR_Op2(lir_throw, exceptionPC, exceptionOop, LIR_OprFact::illegalOpr, info)); }
-  void unwind_exception(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) { append(new LIR_Op2(lir_unwind, exceptionPC, exceptionOop, LIR_OprFact::illegalOpr, info)); }
+  void throw_exception(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
+    append(new LIR_Op2(lir_throw, exceptionPC, exceptionOop, LIR_OprFact::illegalOpr, info));
+  }
+  void unwind_exception(LIR_Opr exceptionOop) {
+    append(new LIR_Op1(lir_unwind, exceptionOop));
+  }
 
   void compare_to (LIR_Opr left, LIR_Opr right, LIR_Opr dst) {
     append(new LIR_Op2(lir_compare_to,  left, right, dst));
--- a/src/share/vm/c1/c1_LIRAssembler.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/c1/c1_LIRAssembler.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -552,6 +552,10 @@
       monitor_address(op->in_opr()->as_constant_ptr()->as_jint(), op->result_opr());
       break;
 
+    case lir_unwind:
+      unwind_op(op->in_opr());
+      break;
+
     default:
       Unimplemented();
       break;
@@ -707,8 +711,7 @@
       break;
 
     case lir_throw:
-    case lir_unwind:
-      throw_op(op->in_opr1(), op->in_opr2(), op->info(), op->code() == lir_unwind);
+      throw_op(op->in_opr1(), op->in_opr2(), op->info());
       break;
 
     default:
--- a/src/share/vm/c1/c1_LIRAssembler.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/c1/c1_LIRAssembler.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -39,6 +39,8 @@
   Instruction*       _pending_non_safepoint;
   int                _pending_non_safepoint_offset;
 
+  Label              _unwind_handler_entry;
+
 #ifdef ASSERT
   BlockList          _branch_target_blocks;
   void check_no_unbound_labels();
@@ -134,6 +136,7 @@
 
   // code patterns
   int  emit_exception_handler();
+  int  emit_unwind_handler();
   void emit_exception_entries(ExceptionInfoList* info_list);
   int  emit_deopt_handler();
 
@@ -217,7 +220,8 @@
 
   void build_frame();
 
-  void throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info, bool unwind);
+  void throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info);
+  void unwind_op(LIR_Opr exceptionOop);
   void monitor_address(int monitor_ix, LIR_Opr dst);
 
   void align_backward_branch_target();
--- a/src/share/vm/c1/c1_LIRGenerator.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/c1/c1_LIRGenerator.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -1765,35 +1765,17 @@
     __ null_check(exception_opr, new CodeEmitInfo(info, true));
   }
 
-  if (compilation()->env()->jvmti_can_post_on_exceptions() &&
-      !block()->is_set(BlockBegin::default_exception_handler_flag)) {
+  if (compilation()->env()->jvmti_can_post_on_exceptions()) {
     // we need to go through the exception lookup path to get JVMTI
     // notification done
     unwind = false;
   }
 
-  assert(!block()->is_set(BlockBegin::default_exception_handler_flag) || unwind,
-         "should be no more handlers to dispatch to");
-
-  if (compilation()->env()->dtrace_method_probes() &&
-      block()->is_set(BlockBegin::default_exception_handler_flag)) {
-    // notify that this frame is unwinding
-    BasicTypeList signature;
-    signature.append(T_INT);    // thread
-    signature.append(T_OBJECT); // methodOop
-    LIR_OprList* args = new LIR_OprList();
-    args->append(getThreadPointer());
-    LIR_Opr meth = new_register(T_OBJECT);
-    __ oop2reg(method()->constant_encoding(), meth);
-    args->append(meth);
-    call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), voidType, NULL);
-  }
-
   // move exception oop into fixed register
   __ move(exception_opr, exceptionOopOpr());
 
   if (unwind) {
-    __ unwind_exception(LIR_OprFact::illegalOpr, exceptionOopOpr(), info);
+    __ unwind_exception(exceptionOopOpr());
   } else {
     __ throw_exception(exceptionPcOpr(), exceptionOopOpr(), info);
   }
--- a/src/share/vm/code/nmethod.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/code/nmethod.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -685,6 +685,7 @@
     _exception_offset        = 0;
     _deoptimize_offset       = 0;
     _deoptimize_mh_offset    = 0;
+    _unwind_handler_offset   = -1;
     _trap_offset             = offsets->value(CodeOffsets::Dtrace_trap);
     _orig_pc_offset          = 0;
     _stub_offset             = data_offset();
@@ -798,6 +799,11 @@
     _exception_offset        = _stub_offset + offsets->value(CodeOffsets::Exceptions);
     _deoptimize_offset       = _stub_offset + offsets->value(CodeOffsets::Deopt);
     _deoptimize_mh_offset    = _stub_offset + offsets->value(CodeOffsets::DeoptMH);
+    if (offsets->value(CodeOffsets::UnwindHandler) != -1) {
+      _unwind_handler_offset   = instructions_offset() + offsets->value(CodeOffsets::UnwindHandler);
+    } else {
+      _unwind_handler_offset   = -1;
+    }
     _consts_offset           = instructions_offset() + code_buffer->total_offset_of(code_buffer->consts()->start());
     _scopes_data_offset      = data_offset();
     _scopes_pcs_offset       = _scopes_data_offset   + round_to(debug_info->data_size         (), oopSize);
--- a/src/share/vm/code/nmethod.hpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/code/nmethod.hpp	Fri Apr 16 02:59:34 2010 -0700
@@ -154,6 +154,9 @@
   // All deoptee's at a MethodHandle call site will resume execution
   // at this location described by this offset.
   int _deoptimize_mh_offset;
+  // Offset of the unwind handler if it exists
+  int _unwind_handler_offset;
+
 #ifdef HAVE_DTRACE_H
   int _trap_offset;
 #endif // def HAVE_DTRACE_H
@@ -341,6 +344,7 @@
   address exception_begin       () const          { return           header_begin() + _exception_offset     ; }
   address deopt_handler_begin   () const          { return           header_begin() + _deoptimize_offset    ; }
   address deopt_mh_handler_begin() const          { return           header_begin() + _deoptimize_mh_offset ; }
+  address unwind_handler_begin  () const          { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; }
   address stub_begin            () const          { return           header_begin() + _stub_offset          ; }
   address stub_end              () const          { return           header_begin() + _consts_offset        ; }
   address consts_begin          () const          { return           header_begin() + _consts_offset        ; }
--- a/src/share/vm/includeDB_zero	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/includeDB_zero	Fri Apr 16 02:59:34 2010 -0700
@@ -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,19 @@
 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
+
+stubGenerator_<arch>.cpp                stack_<arch>.inline.hpp
+
 thread.hpp                              stack_<arch>.hpp
--- a/src/share/vm/runtime/sharedRuntime.cpp	Thu Apr 15 03:13:56 2010 -0700
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Fri Apr 16 02:59:34 2010 -0700
@@ -473,6 +473,13 @@
     t = table.entry_for(catch_pco, -1, 0);
   }
 
+#ifdef COMPILER1
+  if (t == NULL && nm->is_compiled_by_c1()) {
+    assert(nm->unwind_handler_begin() != NULL, "");
+    return nm->unwind_handler_begin();
+  }
+#endif
+
   if (t == NULL) {
     tty->print_cr("MISSING EXCEPTION HANDLER for pc " INTPTR_FORMAT " and handler bci %d", ret_pc, handler_bci);
     tty->print_cr("   Exception:");