8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9

Tue, 01 Apr 2014 09:36:49 +0200

author
roland
date
Tue, 01 Apr 2014 09:36:49 +0200
changeset 6723
0bf37f737702
parent 6721
ad51f24671c2
child 6724
6c06bce8d5bd

8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
Summary: make compiled code bang the stack by the worst case size of the interpreter frame at deoptimization points.
Reviewed-by: twisti, kvn

src/cpu/ppc/vm/cppInterpreter_ppc.cpp file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/ppc.ad file | annotate | diff | comparison | revisions
src/cpu/ppc/vm/templateInterpreter_ppc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/cppInterpreter_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/macroAssembler_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/sharedRuntime_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/sparc.ad file | annotate | diff | comparison | revisions
src/cpu/sparc/vm/templateInterpreter_sparc.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/c1_LIRAssembler_x86.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/c1_MacroAssembler_x86.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/cppInterpreter_x86.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/macroAssembler_x86.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/macroAssembler_x86.hpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/sharedRuntime_x86_32.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/sharedRuntime_x86_64.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/templateInterpreter_x86.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/templateInterpreter_x86_32.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/templateInterpreter_x86_64.cpp file | annotate | diff | comparison | revisions
src/cpu/x86/vm/x86_32.ad file | annotate | diff | comparison | revisions
src/cpu/x86/vm/x86_64.ad file | annotate | diff | comparison | revisions
src/cpu/zero/vm/cppInterpreter_zero.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_Compilation.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_Compilation.hpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_IR.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_IR.hpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_LIRAssembler.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_LIRAssembler.hpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_LinearScan.cpp file | annotate | diff | comparison | revisions
src/share/vm/c1/c1_MacroAssembler.hpp file | annotate | diff | comparison | revisions
src/share/vm/ci/ciMethod.cpp file | annotate | diff | comparison | revisions
src/share/vm/ci/ciMethod.hpp file | annotate | diff | comparison | revisions
src/share/vm/interpreter/abstractInterpreter.hpp file | annotate | diff | comparison | revisions
src/share/vm/opto/callnode.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/callnode.hpp file | annotate | diff | comparison | revisions
src/share/vm/opto/compile.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/compile.hpp file | annotate | diff | comparison | revisions
src/share/vm/opto/output.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/deoptimization.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/sharedRuntime.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/vframeArray.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/vframeArray.hpp file | annotate | diff | comparison | revisions
test/compiler/uncommontrap/TestStackBangMonitorOwned.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/cpu/ppc/vm/cppInterpreter_ppc.cpp	Mon Jun 09 15:42:31 2014 -0700
     1.2 +++ b/src/cpu/ppc/vm/cppInterpreter_ppc.cpp	Tue Apr 01 09:36:49 2014 +0200
     1.3 @@ -1,7 +1,7 @@
     1.4  
     1.5  /*
     1.6 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7 - * Copyright 2012, 2013 SAP AG. All rights reserved.
     1.8 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     1.9 + * Copyright 2012, 2014 SAP AG. All rights reserved.
    1.10   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    1.11   *
    1.12   * This code is free software; you can redistribute it and/or modify it
    1.13 @@ -2948,17 +2948,60 @@
    1.14    istate->_last_Java_fp = last_Java_fp;
    1.15  }
    1.16  
    1.17 -int AbstractInterpreter::layout_activation(Method* method,
    1.18 -                                           int temps,        // Number of slots on java expression stack in use.
    1.19 -                                           int popframe_args,
    1.20 -                                           int monitors,     // Number of active monitors.
    1.21 -                                           int caller_actual_parameters,
    1.22 -                                           int callee_params,// Number of slots for callee parameters.
    1.23 -                                           int callee_locals,// Number of slots for locals.
    1.24 -                                           frame* caller,
    1.25 -                                           frame* interpreter_frame,
    1.26 -                                           bool is_top_frame,
    1.27 -                                           bool is_bottom_frame) {
    1.28 +// Computes monitor_size and top_frame_size in bytes.
    1.29 +static void frame_size_helper(int max_stack,
    1.30 +                              int monitors,
    1.31 +                              int& monitor_size,
    1.32 +                              int& top_frame_size) {
    1.33 +  monitor_size = frame::interpreter_frame_monitor_size_in_bytes() * monitors;
    1.34 +  top_frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
    1.35 +                            + monitor_size
    1.36 +                            + max_stack * Interpreter::stackElementSize
    1.37 +                            + 2 * Interpreter::stackElementSize,
    1.38 +                            frame::alignment_in_bytes)
    1.39 +                   + frame::top_ijava_frame_abi_size;
    1.40 +}
    1.41 +
    1.42 +// Returns number of stackElementWords needed for the interpreter frame with the
    1.43 +// given sections.
    1.44 +int AbstractInterpreter::size_activation(int max_stack,
    1.45 +                                         int temps,
    1.46 +                                         int extra_args,
    1.47 +                                         int monitors,
    1.48 +                                         int callee_params,
    1.49 +                                         int callee_locals,
    1.50 +                                         bool is_top_frame) {
    1.51 +  int monitor_size = 0;
    1.52 +  int top_frame_size = 0;
    1.53 +  frame_size_helper(max_stack, monitors, monitor_size, top_frame_size);
    1.54 +
    1.55 +  int frame_size;
    1.56 +  if (is_top_frame) {
    1.57 +    frame_size = top_frame_size;
    1.58 +  } else {
    1.59 +    frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
    1.60 +                          + monitor_size
    1.61 +                          + (temps - callee_params + callee_locals) * Interpreter::stackElementSize
    1.62 +                          + 2 * Interpreter::stackElementSize,
    1.63 +                          frame::alignment_in_bytes)
    1.64 +                 + frame::parent_ijava_frame_abi_size;
    1.65 +    assert(extra_args == 0, "non-zero for top_frame only");
    1.66 +  }
    1.67 +
    1.68 +  return frame_size / Interpreter::stackElementSize;
    1.69 +}
    1.70 +
    1.71 +void AbstractInterpreter::layout_activation(Method* method,
    1.72 +                                            int temps,        // Number of slots on java expression stack in use.
    1.73 +                                            int popframe_args,
    1.74 +                                            int monitors,     // Number of active monitors.
    1.75 +                                            int caller_actual_parameters,
    1.76 +                                            int callee_params,// Number of slots for callee parameters.
    1.77 +                                            int callee_locals,// Number of slots for locals.
    1.78 +                                            frame* caller,
    1.79 +                                            frame* interpreter_frame,
    1.80 +                                            bool is_top_frame,
    1.81 +                                            bool is_bottom_frame) {
    1.82  
    1.83    // NOTE this code must exactly mimic what
    1.84    // InterpreterGenerator::generate_compute_interpreter_state() does
    1.85 @@ -2968,86 +3011,64 @@
    1.86    // both the abi scratch area and a place to hold a result from a
    1.87    // callee on its way to the callers stack.
    1.88  
    1.89 -  int monitor_size = frame::interpreter_frame_monitor_size_in_bytes() * monitors;
    1.90 -  int frame_size;
    1.91 -  int top_frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
    1.92 -                                + monitor_size
    1.93 -                                + (method->max_stack() *Interpreter::stackElementWords * BytesPerWord)
    1.94 -                                + 2*BytesPerWord,
    1.95 -                                frame::alignment_in_bytes)
    1.96 -                      + frame::top_ijava_frame_abi_size;
    1.97 -  if (is_top_frame) {
    1.98 -    frame_size = top_frame_size;
    1.99 +  int monitor_size = 0;
   1.100 +  int top_frame_size = 0;
   1.101 +  frame_size_helper(method->max_stack(), monitors, monitor_size, top_frame_size);
   1.102 +
   1.103 +  intptr_t sp = (intptr_t)interpreter_frame->sp();
   1.104 +  intptr_t fp = *(intptr_t *)sp;
   1.105 +  assert(fp == (intptr_t)caller->sp(), "fp must match");
   1.106 +  interpreterState cur_state =
   1.107 +    (interpreterState)(fp - frame::interpreter_frame_cinterpreterstate_size_in_bytes());
   1.108 +
   1.109 +  // Now fill in the interpreterState object.
   1.110 +
   1.111 +  intptr_t* locals;
   1.112 +  if (caller->is_interpreted_frame()) {
   1.113 +    // Locals must agree with the caller because it will be used to set the
   1.114 +    // caller's tos when we return.
   1.115 +    interpreterState prev  = caller->get_interpreterState();
   1.116 +    // Calculate start of "locals" for MH calls.  For MH calls, the
   1.117 +    // current method() (= MH target) and prev->callee() (=
   1.118 +    // MH.invoke*()) are different and especially have different
   1.119 +    // signatures. To pop the argumentsof the caller, we must use
   1.120 +    // the prev->callee()->size_of_arguments() because that's what
   1.121 +    // the caller actually pushed.  Currently, for synthetic MH
   1.122 +    // calls (deoptimized from inlined MH calls), detected by
   1.123 +    // is_method_handle_invoke(), we use the callee's arguments
   1.124 +    // because here, the caller's and callee's signature match.
   1.125 +    if (true /*!caller->is_at_mh_callsite()*/) {
   1.126 +      locals = prev->stack() + method->size_of_parameters();
   1.127 +    } else {
   1.128 +      // Normal MH call.
   1.129 +      locals = prev->stack() + prev->callee()->size_of_parameters();
   1.130 +    }
   1.131    } else {
   1.132 -    frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
   1.133 -                          + monitor_size
   1.134 -                          + ((temps - callee_params + callee_locals) *
   1.135 -                             Interpreter::stackElementWords * BytesPerWord)
   1.136 -                          + 2*BytesPerWord,
   1.137 -                          frame::alignment_in_bytes)
   1.138 -                 + frame::parent_ijava_frame_abi_size;
   1.139 -    assert(popframe_args==0, "non-zero for top_frame only");
   1.140 +    bool is_deopted;
   1.141 +    locals = (intptr_t*) (fp + ((method->max_locals() - 1) * BytesPerWord) +
   1.142 +                          frame::parent_ijava_frame_abi_size);
   1.143    }
   1.144  
   1.145 -  // If we actually have a frame to layout we must now fill in all the pieces.
   1.146 -  if (interpreter_frame != NULL) {
   1.147 -
   1.148 -    intptr_t sp = (intptr_t)interpreter_frame->sp();
   1.149 -    intptr_t fp = *(intptr_t *)sp;
   1.150 -    assert(fp == (intptr_t)caller->sp(), "fp must match");
   1.151 -    interpreterState cur_state =
   1.152 -      (interpreterState)(fp - frame::interpreter_frame_cinterpreterstate_size_in_bytes());
   1.153 -
   1.154 -    // Now fill in the interpreterState object.
   1.155 -
   1.156 -    intptr_t* locals;
   1.157 -    if (caller->is_interpreted_frame()) {
   1.158 -      // Locals must agree with the caller because it will be used to set the
   1.159 -      // caller's tos when we return.
   1.160 -      interpreterState prev  = caller->get_interpreterState();
   1.161 -      // Calculate start of "locals" for MH calls.  For MH calls, the
   1.162 -      // current method() (= MH target) and prev->callee() (=
   1.163 -      // MH.invoke*()) are different and especially have different
   1.164 -      // signatures. To pop the argumentsof the caller, we must use
   1.165 -      // the prev->callee()->size_of_arguments() because that's what
   1.166 -      // the caller actually pushed.  Currently, for synthetic MH
   1.167 -      // calls (deoptimized from inlined MH calls), detected by
   1.168 -      // is_method_handle_invoke(), we use the callee's arguments
   1.169 -      // because here, the caller's and callee's signature match.
   1.170 -      if (true /*!caller->is_at_mh_callsite()*/) {
   1.171 -        locals = prev->stack() + method->size_of_parameters();
   1.172 -      } else {
   1.173 -        // Normal MH call.
   1.174 -        locals = prev->stack() + prev->callee()->size_of_parameters();
   1.175 -      }
   1.176 -    } else {
   1.177 -      bool is_deopted;
   1.178 -      locals = (intptr_t*) (fp + ((method->max_locals() - 1) * BytesPerWord) +
   1.179 -                            frame::parent_ijava_frame_abi_size);
   1.180 -    }
   1.181 -
   1.182 -    intptr_t* monitor_base = (intptr_t*) cur_state;
   1.183 -    intptr_t* stack_base   = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
   1.184 -
   1.185 -    // Provide pop_frame capability on PPC64, add popframe_args.
   1.186 -    // +1 because stack is always prepushed.
   1.187 -    intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (temps + popframe_args + 1) * BytesPerWord);
   1.188 -
   1.189 -    BytecodeInterpreter::layout_interpreterState(cur_state,
   1.190 -                                                 caller,
   1.191 -                                                 interpreter_frame,
   1.192 -                                                 method,
   1.193 -                                                 locals,
   1.194 -                                                 stack,
   1.195 -                                                 stack_base,
   1.196 -                                                 monitor_base,
   1.197 -                                                 (intptr_t*)(((intptr_t)fp)-top_frame_size),
   1.198 -                                                 is_top_frame);
   1.199 -
   1.200 -    BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address,
   1.201 -                                                    interpreter_frame->fp());
   1.202 -  }
   1.203 -  return frame_size/BytesPerWord;
   1.204 +  intptr_t* monitor_base = (intptr_t*) cur_state;
   1.205 +  intptr_t* stack_base   = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
   1.206 +
   1.207 +  // Provide pop_frame capability on PPC64, add popframe_args.
   1.208 +  // +1 because stack is always prepushed.
   1.209 +  intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (temps + popframe_args + 1) * BytesPerWord);
   1.210 +
   1.211 +  BytecodeInterpreter::layout_interpreterState(cur_state,
   1.212 +                                               caller,
   1.213 +                                               interpreter_frame,
   1.214 +                                               method,
   1.215 +                                               locals,
   1.216 +                                               stack,
   1.217 +                                               stack_base,
   1.218 +                                               monitor_base,
   1.219 +                                               (intptr_t*)(((intptr_t)fp) - top_frame_size),
   1.220 +                                               is_top_frame);
   1.221 +
   1.222 +  BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address,
   1.223 +                                                  interpreter_frame->fp());
   1.224  }
   1.225  
   1.226  #endif // CC_INTERP
     2.1 --- a/src/cpu/ppc/vm/ppc.ad	Mon Jun 09 15:42:31 2014 -0700
     2.2 +++ b/src/cpu/ppc/vm/ppc.ad	Tue Apr 01 09:36:49 2014 +0200
     2.3 @@ -1,6 +1,6 @@
     2.4  //
     2.5 -// Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     2.6 -// Copyright 2012, 2013 SAP AG. All rights reserved.
     2.7 +// Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
     2.8 +// Copyright 2012, 2014 SAP AG. All rights reserved.
     2.9  // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    2.10  //
    2.11  // This code is free software; you can redistribute it and/or modify it
    2.12 @@ -1363,8 +1363,8 @@
    2.13    Compile* C = ra_->C;
    2.14    MacroAssembler _masm(&cbuf);
    2.15  
    2.16 -  const long framesize = ((long)C->frame_slots()) << LogBytesPerInt;
    2.17 -  assert(framesize%(2*wordSize) == 0, "must preserve 2*wordSize alignment");
    2.18 +  const long framesize = C->frame_size_in_bytes();
    2.19 +  assert(framesize % (2 * wordSize) == 0, "must preserve 2*wordSize alignment");
    2.20  
    2.21    const bool method_is_frameless      = false /* TODO: PPC port C->is_frameless_method()*/;
    2.22  
    2.23 @@ -1389,19 +1389,22 @@
    2.24    // careful, because some VM calls (such as call site linkage) can
    2.25    // use several kilobytes of stack. But the stack safety zone should
    2.26    // account for that. See bugs 4446381, 4468289, 4497237.
    2.27 -  if (C->need_stack_bang(framesize) && UseStackBanging) {
    2.28 +
    2.29 +  int bangsize = C->bang_size_in_bytes();
    2.30 +  assert(bangsize >= framesize || bangsize <= 0, "stack bang size incorrect");
    2.31 +  if (C->need_stack_bang(bangsize) && UseStackBanging) {
    2.32      // Unfortunately we cannot use the function provided in
    2.33      // assembler.cpp as we have to emulate the pipes. So I had to
    2.34      // insert the code of generate_stack_overflow_check(), see
    2.35      // assembler.cpp for some illuminative comments.
    2.36      const int page_size = os::vm_page_size();
    2.37 -    int bang_end = StackShadowPages*page_size;
    2.38 +    int bang_end = StackShadowPages * page_size;
    2.39  
    2.40      // This is how far the previous frame's stack banging extended.
    2.41      const int bang_end_safe = bang_end;
    2.42  
    2.43 -    if (framesize > page_size) {
    2.44 -      bang_end += framesize;
    2.45 +    if (bangsize > page_size) {
    2.46 +      bang_end += bangsize;
    2.47      }
    2.48  
    2.49      int bang_offset = bang_end_safe;
    2.50 @@ -1447,7 +1450,7 @@
    2.51  
    2.52    unsigned int bytes = (unsigned int)framesize;
    2.53    long offset = Assembler::align_addr(bytes, frame::alignment_in_bytes);
    2.54 -  ciMethod *currMethod = C -> method();
    2.55 +  ciMethod *currMethod = C->method();
    2.56  
    2.57    // Optimized version for most common case.
    2.58    if (UsePower6SchedulerPPC64 &&
     3.1 --- a/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Mon Jun 09 15:42:31 2014 -0700
     3.2 +++ b/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Tue Apr 01 09:36:49 2014 +0200
     3.3 @@ -1328,21 +1328,42 @@
     3.4  int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
     3.5    const int max_alignment_size = 2;
     3.6    const int abi_scratch = frame::abi_reg_args_size;
     3.7 -  return method->max_locals() + method->max_stack() + frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch;
     3.8 +  return method->max_locals() + method->max_stack() +
     3.9 +         frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch;
    3.10  }
    3.11  
    3.12 -// Fills a sceletal interpreter frame generated during deoptimizations
    3.13 -// and returns the frame size in slots.
    3.14 +// Returns number of stackElementWords needed for the interpreter frame with the
    3.15 +// given sections.
    3.16 +// This overestimates the stack by one slot in case of alignments.
    3.17 +int AbstractInterpreter::size_activation(int max_stack,
    3.18 +                                         int temps,
    3.19 +                                         int extra_args,
    3.20 +                                         int monitors,
    3.21 +                                         int callee_params,
    3.22 +                                         int callee_locals,
    3.23 +                                         bool is_top_frame) {
    3.24 +  // Note: This calculation must exactly parallel the frame setup
    3.25 +  // in AbstractInterpreterGenerator::generate_method_entry.
    3.26 +  assert(Interpreter::stackElementWords == 1, "sanity");
    3.27 +  const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize;
    3.28 +  const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
    3.29 +                                         (frame::abi_minframe_size / Interpreter::stackElementSize);
    3.30 +  const int size =
    3.31 +    max_stack                                                +
    3.32 +    (callee_locals - callee_params)                          +
    3.33 +    monitors * frame::interpreter_frame_monitor_size()       +
    3.34 +    max_alignment_space                                      +
    3.35 +    abi_scratch                                              +
    3.36 +    frame::ijava_state_size / Interpreter::stackElementSize;
    3.37 +
    3.38 +  // Fixed size of an interpreter frame, align to 16-byte.
    3.39 +  return (size & -2);
    3.40 +}
    3.41 +
    3.42 +// Fills a sceletal interpreter frame generated during deoptimizations.
    3.43  //
    3.44  // Parameters:
    3.45  //
    3.46 -// interpreter_frame == NULL:
    3.47 -//   Only calculate the size of an interpreter activation, no actual layout.
    3.48 -//   Note: This calculation must exactly parallel the frame setup
    3.49 -//   in TemplateInterpreter::generate_normal_entry. But it does not
    3.50 -//   account for the SP alignment, that might further enhance the
    3.51 -//   frame size, depending on FP.
    3.52 -//
    3.53  // interpreter_frame != NULL:
    3.54  //   set up the method, locals, and monitors.
    3.55  //   The frame interpreter_frame, if not NULL, is guaranteed to be the
    3.56 @@ -1359,59 +1380,41 @@
    3.57  //   the arguments off advance the esp by dummy popframe_extra_args slots.
    3.58  //   Popping off those will establish the stack layout as it was before the call.
    3.59  //
    3.60 -int AbstractInterpreter::layout_activation(Method* method,
    3.61 -                                           int tempcount,
    3.62 -                                           int popframe_extra_args,
    3.63 -                                           int moncount,
    3.64 -                                           int caller_actual_parameters,
    3.65 -                                           int callee_param_count,
    3.66 -                                           int callee_locals,
    3.67 -                                           frame* caller,
    3.68 -                                           frame* interpreter_frame,
    3.69 -                                           bool is_top_frame,
    3.70 -                                           bool is_bottom_frame) {
    3.71 +void AbstractInterpreter::layout_activation(Method* method,
    3.72 +                                            int tempcount,
    3.73 +                                            int popframe_extra_args,
    3.74 +                                            int moncount,
    3.75 +                                            int caller_actual_parameters,
    3.76 +                                            int callee_param_count,
    3.77 +                                            int callee_locals_count,
    3.78 +                                            frame* caller,
    3.79 +                                            frame* interpreter_frame,
    3.80 +                                            bool is_top_frame,
    3.81 +                                            bool is_bottom_frame) {
    3.82  
    3.83 -  const int max_alignment_space = 2;
    3.84    const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
    3.85 -                                         (frame::abi_minframe_size / Interpreter::stackElementSize) ;
    3.86 -  const int conservative_framesize_in_slots =
    3.87 -    method->max_stack() + callee_locals - callee_param_count +
    3.88 -    (moncount * frame::interpreter_frame_monitor_size()) + max_alignment_space +
    3.89 -    abi_scratch + frame::ijava_state_size / Interpreter::stackElementSize;
    3.90 +                                         (frame::abi_minframe_size / Interpreter::stackElementSize);
    3.91  
    3.92 -  assert(!is_top_frame || conservative_framesize_in_slots * 8 > frame::abi_reg_args_size + frame::ijava_state_size, "frame too small");
    3.93 +  intptr_t* locals_base  = (caller->is_interpreted_frame()) ?
    3.94 +    caller->interpreter_frame_esp() + caller_actual_parameters :
    3.95 +    caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize) ;
    3.96  
    3.97 -  if (interpreter_frame == NULL) {
    3.98 -    // Since we don't know the exact alignment, we return the conservative size.
    3.99 -    return (conservative_framesize_in_slots & -2);
   3.100 -  } else {
   3.101 -    // Now we know our caller, calc the exact frame layout and size.
   3.102 -    intptr_t* locals_base  = (caller->is_interpreted_frame()) ?
   3.103 -      caller->interpreter_frame_esp() + caller_actual_parameters :
   3.104 -      caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize) ;
   3.105 +  intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize ;
   3.106 +  intptr_t* monitor      = monitor_base - (moncount * frame::interpreter_frame_monitor_size());
   3.107 +  intptr_t* esp_base     = monitor - 1;
   3.108 +  intptr_t* esp          = esp_base - tempcount - popframe_extra_args;
   3.109 +  intptr_t* sp           = (intptr_t *) (((intptr_t) (esp_base - callee_locals_count + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes);
   3.110 +  intptr_t* sender_sp    = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
   3.111 +  intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
   3.112  
   3.113 -    intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize ;
   3.114 -    intptr_t* monitor      = monitor_base - (moncount * frame::interpreter_frame_monitor_size());
   3.115 -    intptr_t* esp_base     = monitor - 1;
   3.116 -    intptr_t* esp          = esp_base - tempcount - popframe_extra_args;
   3.117 -    intptr_t* sp           = (intptr_t *) (((intptr_t) (esp_base- callee_locals + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes);
   3.118 -    intptr_t* sender_sp    = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
   3.119 -    intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
   3.120 -
   3.121 -    interpreter_frame->interpreter_frame_set_method(method);
   3.122 -    interpreter_frame->interpreter_frame_set_locals(locals_base);
   3.123 -    interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());
   3.124 -    interpreter_frame->interpreter_frame_set_esp(esp);
   3.125 -    interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);
   3.126 -    interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);
   3.127 -    if (!is_bottom_frame) {
   3.128 -      interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);
   3.129 -    }
   3.130 -
   3.131 -    int framesize_in_slots = caller->sp() - sp;
   3.132 -    assert(!is_top_frame ||framesize_in_slots >= (frame::abi_reg_args_size / Interpreter::stackElementSize) + frame::ijava_state_size / Interpreter::stackElementSize, "frame too small");
   3.133 -    assert(framesize_in_slots <= conservative_framesize_in_slots, "exact frame size must be smaller than the convervative size!");
   3.134 -    return framesize_in_slots;
   3.135 +  interpreter_frame->interpreter_frame_set_method(method);
   3.136 +  interpreter_frame->interpreter_frame_set_locals(locals_base);
   3.137 +  interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());
   3.138 +  interpreter_frame->interpreter_frame_set_esp(esp);
   3.139 +  interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);
   3.140 +  interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);
   3.141 +  if (!is_bottom_frame) {
   3.142 +    interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);
   3.143    }
   3.144  }
   3.145  
     4.1 --- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Mon Jun 09 15:42:31 2014 -0700
     4.2 +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Tue Apr 01 09:36:49 2014 +0200
     4.3 @@ -152,7 +152,7 @@
     4.4  }
     4.5  
     4.6  
     4.7 -int LIR_Assembler::initial_frame_size_in_bytes() {
     4.8 +int LIR_Assembler::initial_frame_size_in_bytes() const {
     4.9    return in_bytes(frame_map()->framesize_in_bytes());
    4.10  }
    4.11  
    4.12 @@ -182,7 +182,7 @@
    4.13    int number_of_locks = entry_state->locks_size();
    4.14  
    4.15    // Create a frame for the compiled activation.
    4.16 -  __ build_frame(initial_frame_size_in_bytes());
    4.17 +  __ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
    4.18  
    4.19    // OSR buffer is
    4.20    //
     5.1 --- a/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp	Mon Jun 09 15:42:31 2014 -0700
     5.2 +++ b/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp	Tue Apr 01 09:36:49 2014 +0200
     5.3 @@ -55,9 +55,9 @@
     5.4  }
     5.5  
     5.6  
     5.7 -void C1_MacroAssembler::build_frame(int frame_size_in_bytes) {
     5.8 -
     5.9 -  generate_stack_overflow_check(frame_size_in_bytes);
    5.10 +void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
    5.11 +  assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
    5.12 +  generate_stack_overflow_check(bang_size_in_bytes);
    5.13    // Create the frame.
    5.14    save_frame_c1(frame_size_in_bytes);
    5.15  }
     6.1 --- a/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Mon Jun 09 15:42:31 2014 -0700
     6.2 +++ b/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Tue Apr 01 09:36:49 2014 +0200
     6.3 @@ -2101,7 +2101,7 @@
     6.4    int monitor_size    = method->is_synchronized() ?
     6.5                                  1*frame::interpreter_frame_monitor_size() : 0;
     6.6    return size_activation_helper(method->max_locals(), method->max_stack(),
     6.7 -                                 monitor_size) + call_stub_size;
     6.8 +                                monitor_size) + call_stub_size;
     6.9  }
    6.10  
    6.11  void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill,
    6.12 @@ -2185,31 +2185,31 @@
    6.13    istate->_last_Java_pc = (intptr_t*) last_Java_pc;
    6.14  }
    6.15  
    6.16 +static int frame_size_helper(int max_stack,
    6.17 +                             int moncount,
    6.18 +                             int callee_param_size,
    6.19 +                             int callee_locals_size,
    6.20 +                             bool is_top_frame,
    6.21 +                             int& monitor_size,
    6.22 +                             int& full_frame_words) {
    6.23 +  int extra_locals_size = callee_locals_size - callee_param_size;
    6.24 +  monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
    6.25 +  full_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size);
    6.26 +  int short_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size);
    6.27 +  int frame_words = is_top_frame ? full_frame_words : short_frame_words;
    6.28  
    6.29 -int AbstractInterpreter::layout_activation(Method* method,
    6.30 -                                           int tempcount, // Number of slots on java expression stack in use
    6.31 -                                           int popframe_extra_args,
    6.32 -                                           int moncount,  // Number of active monitors
    6.33 -                                           int caller_actual_parameters,
    6.34 -                                           int callee_param_size,
    6.35 -                                           int callee_locals_size,
    6.36 -                                           frame* caller,
    6.37 -                                           frame* interpreter_frame,
    6.38 -                                           bool is_top_frame,
    6.39 -                                           bool is_bottom_frame) {
    6.40 +  return frame_words;
    6.41 +}
    6.42  
    6.43 -  assert(popframe_extra_args == 0, "NEED TO FIX");
    6.44 -  // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
    6.45 -  // does as far as allocating an interpreter frame.
    6.46 -  // If interpreter_frame!=NULL, set up the method, locals, and monitors.
    6.47 -  // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
    6.48 -  // as determined by a previous call to this method.
    6.49 -  // It is also guaranteed to be walkable even though it is in a skeletal state
    6.50 +int AbstractInterpreter::size_activation(int max_stack,
    6.51 +                                         int tempcount,
    6.52 +                                         int extra_args,
    6.53 +                                         int moncount,
    6.54 +                                         int callee_param_size,
    6.55 +                                         int callee_locals_size,
    6.56 +                                         bool is_top_frame) {
    6.57 +  assert(extra_args == 0, "NEED TO FIX");
    6.58    // NOTE: return size is in words not bytes
    6.59 -  // NOTE: tempcount is the current size of the java expression stack. For top most
    6.60 -  //       frames we will allocate a full sized expression stack and not the curback
    6.61 -  //       version that non-top frames have.
    6.62 -
    6.63    // Calculate the amount our frame will be adjust by the callee. For top frame
    6.64    // this is zero.
    6.65  
    6.66 @@ -2218,87 +2218,108 @@
    6.67    // to it. So it ignores last_frame_adjust value. Seems suspicious as far
    6.68    // as getting sender_sp correct.
    6.69  
    6.70 -  int extra_locals_size = callee_locals_size - callee_param_size;
    6.71 -  int monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
    6.72 -  int full_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
    6.73 -  int short_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
    6.74 -  int frame_words = is_top_frame ? full_frame_words : short_frame_words;
    6.75 +  int unused_monitor_size = 0;
    6.76 +  int unused_full_frame_words = 0;
    6.77 +  return frame_size_helper(max_stack, moncount, callee_param_size, callee_locals_size, is_top_frame,
    6.78 +                           unused_monitor_size, unused_full_frame_words);
    6.79 +}
    6.80 +void AbstractInterpreter::layout_activation(Method* method,
    6.81 +                                            int tempcount, // Number of slots on java expression stack in use
    6.82 +                                            int popframe_extra_args,
    6.83 +                                            int moncount,  // Number of active monitors
    6.84 +                                            int caller_actual_parameters,
    6.85 +                                            int callee_param_size,
    6.86 +                                            int callee_locals_size,
    6.87 +                                            frame* caller,
    6.88 +                                            frame* interpreter_frame,
    6.89 +                                            bool is_top_frame,
    6.90 +                                            bool is_bottom_frame) {
    6.91 +  assert(popframe_extra_args == 0, "NEED TO FIX");
    6.92 +  // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
    6.93 +  // does as far as allocating an interpreter frame.
    6.94 +  // Set up the method, locals, and monitors.
    6.95 +  // The frame interpreter_frame is guaranteed to be the right size,
    6.96 +  // as determined by a previous call to the size_activation() method.
    6.97 +  // It is also guaranteed to be walkable even though it is in a skeletal state
    6.98 +  // NOTE: tempcount is the current size of the java expression stack. For top most
    6.99 +  //       frames we will allocate a full sized expression stack and not the curback
   6.100 +  //       version that non-top frames have.
   6.101  
   6.102 +  int monitor_size = 0;
   6.103 +  int full_frame_words = 0;
   6.104 +  int frame_words = frame_size_helper(method->max_stack(), moncount, callee_param_size, callee_locals_size,
   6.105 +                                      is_top_frame, monitor_size, full_frame_words);
   6.106  
   6.107    /*
   6.108 -    if we actually have a frame to layout we must now fill in all the pieces. This means both
   6.109 +    We must now fill in all the pieces of the frame. This means both
   6.110      the interpreterState and the registers.
   6.111    */
   6.112 -  if (interpreter_frame != NULL) {
   6.113  
   6.114 -    // MUCHO HACK
   6.115 +  // MUCHO HACK
   6.116  
   6.117 -    intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
   6.118 -    // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode.
   6.119 -    assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation");
   6.120 -    frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS);
   6.121 +  intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
   6.122 +  // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode.
   6.123 +  assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation");
   6.124 +  frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS);
   6.125  
   6.126 -    /* Now fillin the interpreterState object */
   6.127 +  /* Now fillin the interpreterState object */
   6.128  
   6.129 -    interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() -  sizeof(BytecodeInterpreter));
   6.130 +  interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() -  sizeof(BytecodeInterpreter));
   6.131  
   6.132  
   6.133 -    intptr_t* locals;
   6.134 +  intptr_t* locals;
   6.135  
   6.136 -    // Calculate the postion of locals[0]. This is painful because of
   6.137 -    // stack alignment (same as ia64). The problem is that we can
   6.138 -    // not compute the location of locals from fp(). fp() will account
   6.139 -    // for the extra locals but it also accounts for aligning the stack
   6.140 -    // and we can't determine if the locals[0] was misaligned but max_locals
   6.141 -    // was enough to have the
   6.142 -    // calculate postion of locals. fp already accounts for extra locals.
   6.143 -    // +2 for the static long no_params() issue.
   6.144 +  // Calculate the postion of locals[0]. This is painful because of
   6.145 +  // stack alignment (same as ia64). The problem is that we can
   6.146 +  // not compute the location of locals from fp(). fp() will account
   6.147 +  // for the extra locals but it also accounts for aligning the stack
   6.148 +  // and we can't determine if the locals[0] was misaligned but max_locals
   6.149 +  // was enough to have the
   6.150 +  // calculate postion of locals. fp already accounts for extra locals.
   6.151 +  // +2 for the static long no_params() issue.
   6.152  
   6.153 -    if (caller->is_interpreted_frame()) {
   6.154 -      // locals must agree with the caller because it will be used to set the
   6.155 -      // caller's tos when we return.
   6.156 -      interpreterState prev  = caller->get_interpreterState();
   6.157 -      // stack() is prepushed.
   6.158 -      locals = prev->stack() + method->size_of_parameters();
   6.159 +  if (caller->is_interpreted_frame()) {
   6.160 +    // locals must agree with the caller because it will be used to set the
   6.161 +    // caller's tos when we return.
   6.162 +    interpreterState prev  = caller->get_interpreterState();
   6.163 +    // stack() is prepushed.
   6.164 +    locals = prev->stack() + method->size_of_parameters();
   6.165 +  } else {
   6.166 +    // Lay out locals block in the caller adjacent to the register window save area.
   6.167 +    //
   6.168 +    // Compiled frames do not allocate a varargs area which is why this if
   6.169 +    // statement is needed.
   6.170 +    //
   6.171 +    intptr_t* fp = interpreter_frame->fp();
   6.172 +    int local_words = method->max_locals() * Interpreter::stackElementWords;
   6.173 +
   6.174 +    if (caller->is_compiled_frame()) {
   6.175 +      locals = fp + frame::register_save_words + local_words - 1;
   6.176      } else {
   6.177 -      // Lay out locals block in the caller adjacent to the register window save area.
   6.178 -      //
   6.179 -      // Compiled frames do not allocate a varargs area which is why this if
   6.180 -      // statement is needed.
   6.181 -      //
   6.182 -      intptr_t* fp = interpreter_frame->fp();
   6.183 -      int local_words = method->max_locals() * Interpreter::stackElementWords;
   6.184 -
   6.185 -      if (caller->is_compiled_frame()) {
   6.186 -        locals = fp + frame::register_save_words + local_words - 1;
   6.187 -      } else {
   6.188 -        locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
   6.189 -      }
   6.190 -
   6.191 +      locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
   6.192      }
   6.193 -    // END MUCHO HACK
   6.194 -
   6.195 -    intptr_t* monitor_base = (intptr_t*) cur_state;
   6.196 -    intptr_t* stack_base =  monitor_base - monitor_size;
   6.197 -    /* +1 because stack is always prepushed */
   6.198 -    intptr_t* stack = stack_base - (tempcount + 1);
   6.199 -
   6.200 -
   6.201 -    BytecodeInterpreter::layout_interpreterState(cur_state,
   6.202 -                                          caller,
   6.203 -                                          interpreter_frame,
   6.204 -                                          method,
   6.205 -                                          locals,
   6.206 -                                          stack,
   6.207 -                                          stack_base,
   6.208 -                                          monitor_base,
   6.209 -                                          frame_bottom,
   6.210 -                                          is_top_frame);
   6.211 -
   6.212 -    BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
   6.213  
   6.214    }
   6.215 -  return frame_words;
   6.216 +  // END MUCHO HACK
   6.217 +
   6.218 +  intptr_t* monitor_base = (intptr_t*) cur_state;
   6.219 +  intptr_t* stack_base =  monitor_base - monitor_size;
   6.220 +  /* +1 because stack is always prepushed */
   6.221 +  intptr_t* stack = stack_base - (tempcount + 1);
   6.222 +
   6.223 +
   6.224 +  BytecodeInterpreter::layout_interpreterState(cur_state,
   6.225 +                                               caller,
   6.226 +                                               interpreter_frame,
   6.227 +                                               method,
   6.228 +                                               locals,
   6.229 +                                               stack,
   6.230 +                                               stack_base,
   6.231 +                                               monitor_base,
   6.232 +                                               frame_bottom,
   6.233 +                                               is_top_frame);
   6.234 +
   6.235 +  BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
   6.236  }
   6.237  
   6.238  #endif // CC_INTERP
     7.1 --- a/src/cpu/sparc/vm/macroAssembler_sparc.cpp	Mon Jun 09 15:42:31 2014 -0700
     7.2 +++ b/src/cpu/sparc/vm/macroAssembler_sparc.cpp	Tue Apr 01 09:36:49 2014 +0200
     7.3 @@ -3531,7 +3531,7 @@
     7.4    // was post-decremented.)  Skip this address by starting at i=1, and
     7.5    // touch a few more pages below.  N.B.  It is important to touch all
     7.6    // the way down to and including i=StackShadowPages.
     7.7 -  for (int i = 1; i <= StackShadowPages; i++) {
     7.8 +  for (int i = 1; i < StackShadowPages; i++) {
     7.9      set((-i*offset)+STACK_BIAS, Rscratch);
    7.10      st(G0, Rtsp, Rscratch);
    7.11    }
     8.1 --- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Mon Jun 09 15:42:31 2014 -0700
     8.2 +++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Tue Apr 01 09:36:49 2014 +0200
     8.3 @@ -3355,13 +3355,16 @@
     8.4    Register        O4array_size       = O4;
     8.5    Label           loop;
     8.6  
     8.7 -  // Before we make new frames, check to see if stack is available.
     8.8 -  // Do this after the caller's return address is on top of stack
     8.9 +#ifdef ASSERT
    8.10 +  // Compilers generate code that bang the stack by as much as the
    8.11 +  // interpreter would need. So this stack banging should never
    8.12 +  // trigger a fault. Verify that it does not on non product builds.
    8.13    if (UseStackBanging) {
    8.14      // Get total frame size for interpreted frames
    8.15      __ ld(O2UnrollBlock, Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes(), O4);
    8.16      __ bang_stack_size(O4, O3, G3_scratch);
    8.17    }
    8.18 +#endif
    8.19  
    8.20    __ ld(O2UnrollBlock, Deoptimization::UnrollBlock::number_of_frames_offset_in_bytes(), O4array_size);
    8.21    __ ld_ptr(O2UnrollBlock, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes(), G3pcs);
    8.22 @@ -3409,9 +3412,11 @@
    8.23    ResourceMark rm;
    8.24    // setup code generation tools
    8.25    int pad = VerifyThread ? 512 : 0;// Extra slop space for more verify code
    8.26 +#ifdef ASSERT
    8.27    if (UseStackBanging) {
    8.28      pad += StackShadowPages*16 + 32;
    8.29    }
    8.30 +#endif
    8.31  #ifdef _LP64
    8.32    CodeBuffer buffer("deopt_blob", 2100+pad, 512);
    8.33  #else
    8.34 @@ -3632,9 +3637,11 @@
    8.35    ResourceMark rm;
    8.36    // setup code generation tools
    8.37    int pad = VerifyThread ? 512 : 0;
    8.38 +#ifdef ASSERT
    8.39    if (UseStackBanging) {
    8.40      pad += StackShadowPages*16 + 32;
    8.41    }
    8.42 +#endif
    8.43  #ifdef _LP64
    8.44    CodeBuffer buffer("uncommon_trap_blob", 2700+pad, 512);
    8.45  #else
     9.1 --- a/src/cpu/sparc/vm/sparc.ad	Mon Jun 09 15:42:31 2014 -0700
     9.2 +++ b/src/cpu/sparc/vm/sparc.ad	Tue Apr 01 09:36:49 2014 +0200
     9.3 @@ -1193,15 +1193,16 @@
     9.4      st->print_cr("Verify_Thread"); st->print("\t");
     9.5    }
     9.6  
     9.7 -  size_t framesize = C->frame_slots() << LogBytesPerInt;
     9.8 +  size_t framesize = C->frame_size_in_bytes();
     9.9 +  int bangsize = C->bang_size_in_bytes();
    9.10  
    9.11    // Calls to C2R adapters often do not accept exceptional returns.
    9.12    // We require that their callers must bang for them.  But be careful, because
    9.13    // some VM calls (such as call site linkage) can use several kilobytes of
    9.14    // stack.  But the stack safety zone should account for that.
    9.15    // See bugs 4446381, 4468289, 4497237.
    9.16 -  if (C->need_stack_bang(framesize)) {
    9.17 -    st->print_cr("! stack bang"); st->print("\t");
    9.18 +  if (C->need_stack_bang(bangsize)) {
    9.19 +    st->print_cr("! stack bang (%d bytes)", bangsize); st->print("\t");
    9.20    }
    9.21  
    9.22    if (Assembler::is_simm13(-framesize)) {
    9.23 @@ -1225,17 +1226,18 @@
    9.24  
    9.25    __ verify_thread();
    9.26  
    9.27 -  size_t framesize = C->frame_slots() << LogBytesPerInt;
    9.28 +  size_t framesize = C->frame_size_in_bytes();
    9.29    assert(framesize >= 16*wordSize, "must have room for reg. save area");
    9.30    assert(framesize%(2*wordSize) == 0, "must preserve 2*wordSize alignment");
    9.31 +  int bangsize = C->bang_size_in_bytes();
    9.32  
    9.33    // Calls to C2R adapters often do not accept exceptional returns.
    9.34    // We require that their callers must bang for them.  But be careful, because
    9.35    // some VM calls (such as call site linkage) can use several kilobytes of
    9.36    // stack.  But the stack safety zone should account for that.
    9.37    // See bugs 4446381, 4468289, 4497237.
    9.38 -  if (C->need_stack_bang(framesize)) {
    9.39 -    __ generate_stack_overflow_check(framesize);
    9.40 +  if (C->need_stack_bang(bangsize)) {
    9.41 +    __ generate_stack_overflow_check(bangsize);
    9.42    }
    9.43  
    9.44    if (Assembler::is_simm13(-framesize)) {
    9.45 @@ -2547,7 +2549,7 @@
    9.46    enc_class call_epilog %{
    9.47      if( VerifyStackAtCalls ) {
    9.48        MacroAssembler _masm(&cbuf);
    9.49 -      int framesize = ra_->C->frame_slots() << LogBytesPerInt;
    9.50 +      int framesize = ra_->C->frame_size_in_bytes();
    9.51        Register temp_reg = G3;
    9.52        __ add(SP, framesize, temp_reg);
    9.53        __ cmp(temp_reg, FP);
    10.1 --- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Mon Jun 09 15:42:31 2014 -0700
    10.2 +++ b/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Tue Apr 01 09:36:49 2014 +0200
    10.3 @@ -1564,37 +1564,23 @@
    10.4    int monitor_size    = method->is_synchronized() ?
    10.5                                  1*frame::interpreter_frame_monitor_size() : 0;
    10.6    return size_activation_helper(method->max_locals(), method->max_stack(),
    10.7 -                                 monitor_size) + call_stub_size;
    10.8 +                                monitor_size) + call_stub_size;
    10.9  }
   10.10  
   10.11 -int AbstractInterpreter::layout_activation(Method* method,
   10.12 -                                           int tempcount,
   10.13 -                                           int popframe_extra_args,
   10.14 -                                           int moncount,
   10.15 -                                           int caller_actual_parameters,
   10.16 -                                           int callee_param_count,
   10.17 -                                           int callee_local_count,
   10.18 -                                           frame* caller,
   10.19 -                                           frame* interpreter_frame,
   10.20 -                                           bool is_top_frame,
   10.21 -                                           bool is_bottom_frame) {
   10.22 +int AbstractInterpreter::size_activation(int max_stack,
   10.23 +                                         int temps,
   10.24 +                                         int extra_args,
   10.25 +                                         int monitors,
   10.26 +                                         int callee_params,
   10.27 +                                         int callee_locals,
   10.28 +                                         bool is_top_frame) {
   10.29    // Note: This calculation must exactly parallel the frame setup
   10.30    // in InterpreterGenerator::generate_fixed_frame.
   10.31 -  // If f!=NULL, set up the following variables:
   10.32 -  //   - Lmethod
   10.33 -  //   - Llocals
   10.34 -  //   - Lmonitors (to the indicated number of monitors)
   10.35 -  //   - Lesp (to the indicated number of temps)
   10.36 -  // The frame f (if not NULL) on entry is a description of the caller of the frame
   10.37 -  // we are about to layout. We are guaranteed that we will be able to fill in a
   10.38 -  // new interpreter frame as its callee (i.e. the stack space is allocated and
   10.39 -  // the amount was determined by an earlier call to this method with f == NULL).
   10.40 -  // On return f (if not NULL) while describe the interpreter frame we just layed out.
   10.41  
   10.42 -  int monitor_size           = moncount * frame::interpreter_frame_monitor_size();
   10.43 -  int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
   10.44 +  int monitor_size           = monitors * frame::interpreter_frame_monitor_size();
   10.45  
   10.46    assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
   10.47 +
   10.48    //
   10.49    // Note: if you look closely this appears to be doing something much different
   10.50    // than generate_fixed_frame. What is happening is this. On sparc we have to do
   10.51 @@ -1619,146 +1605,171 @@
   10.52    // there is no sense in messing working code.
   10.53    //
   10.54  
   10.55 -  int rounded_cls = round_to((callee_local_count - callee_param_count), WordsPerLong);
   10.56 +  int rounded_cls = round_to((callee_locals - callee_params), WordsPerLong);
   10.57    assert(rounded_cls == round_to(rounded_cls, WordsPerLong), "must align");
   10.58  
   10.59 -  int raw_frame_size = size_activation_helper(rounded_cls, method->max_stack(),
   10.60 -                                              monitor_size);
   10.61 +  int raw_frame_size = size_activation_helper(rounded_cls, max_stack, monitor_size);
   10.62  
   10.63 -  if (interpreter_frame != NULL) {
   10.64 -    // The skeleton frame must already look like an interpreter frame
   10.65 -    // even if not fully filled out.
   10.66 -    assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame");
   10.67 +  return raw_frame_size;
   10.68 +}
   10.69  
   10.70 -    intptr_t* fp = interpreter_frame->fp();
   10.71 +void AbstractInterpreter::layout_activation(Method* method,
   10.72 +                                            int tempcount,
   10.73 +                                            int popframe_extra_args,
   10.74 +                                            int moncount,
   10.75 +                                            int caller_actual_parameters,
   10.76 +                                            int callee_param_count,
   10.77 +                                            int callee_local_count,
   10.78 +                                            frame* caller,
   10.79 +                                            frame* interpreter_frame,
   10.80 +                                            bool is_top_frame,
   10.81 +                                            bool is_bottom_frame) {
   10.82 +  // Set up the following variables:
   10.83 +  //   - Lmethod
   10.84 +  //   - Llocals
   10.85 +  //   - Lmonitors (to the indicated number of monitors)
   10.86 +  //   - Lesp (to the indicated number of temps)
   10.87 +  // The frame caller on entry is a description of the caller of the
   10.88 +  // frame we are about to layout. We are guaranteed that we will be
   10.89 +  // able to fill in a new interpreter frame as its callee (i.e. the
   10.90 +  // stack space is allocated and the amount was determined by an
   10.91 +  // earlier call to the size_activation() method).  On return caller
   10.92 +  // while describe the interpreter frame we just layed out.
   10.93  
   10.94 -    JavaThread* thread = JavaThread::current();
   10.95 -    RegisterMap map(thread, false);
   10.96 -    // More verification that skeleton frame is properly walkable
   10.97 -    assert(fp == caller->sp(), "fp must match");
   10.98 +  // The skeleton frame must already look like an interpreter frame
   10.99 +  // even if not fully filled out.
  10.100 +  assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame");
  10.101  
  10.102 -    intptr_t* montop     = fp - rounded_vm_local_words;
  10.103 +  int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
  10.104 +  int monitor_size           = moncount * frame::interpreter_frame_monitor_size();
  10.105 +  assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
  10.106  
  10.107 -    // preallocate monitors (cf. __ add_monitor_to_stack)
  10.108 -    intptr_t* monitors = montop - monitor_size;
  10.109 +  intptr_t* fp = interpreter_frame->fp();
  10.110  
  10.111 -    // preallocate stack space
  10.112 -    intptr_t*  esp = monitors - 1 -
  10.113 -                     (tempcount * Interpreter::stackElementWords) -
  10.114 -                     popframe_extra_args;
  10.115 +  JavaThread* thread = JavaThread::current();
  10.116 +  RegisterMap map(thread, false);
  10.117 +  // More verification that skeleton frame is properly walkable
  10.118 +  assert(fp == caller->sp(), "fp must match");
  10.119  
  10.120 -    int local_words = method->max_locals() * Interpreter::stackElementWords;
  10.121 -    NEEDS_CLEANUP;
  10.122 -    intptr_t* locals;
  10.123 -    if (caller->is_interpreted_frame()) {
  10.124 -      // Can force the locals area to end up properly overlapping the top of the expression stack.
  10.125 -      intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1;
  10.126 -      // Note that this computation means we replace size_of_parameters() values from the caller
  10.127 -      // interpreter frame's expression stack with our argument locals
  10.128 -      int parm_words  = caller_actual_parameters * Interpreter::stackElementWords;
  10.129 -      locals = Lesp_ptr + parm_words;
  10.130 -      int delta = local_words - parm_words;
  10.131 -      int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
  10.132 -      *interpreter_frame->register_addr(I5_savedSP)    = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
  10.133 -      if (!is_bottom_frame) {
  10.134 -        // Llast_SP is set below for the current frame to SP (with the
  10.135 -        // extra space for the callee's locals). Here we adjust
  10.136 -        // Llast_SP for the caller's frame, removing the extra space
  10.137 -        // for the current method's locals.
  10.138 -        *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
  10.139 -      } else {
  10.140 -        assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
  10.141 -      }
  10.142 +  intptr_t* montop     = fp - rounded_vm_local_words;
  10.143 +
  10.144 +  // preallocate monitors (cf. __ add_monitor_to_stack)
  10.145 +  intptr_t* monitors = montop - monitor_size;
  10.146 +
  10.147 +  // preallocate stack space
  10.148 +  intptr_t*  esp = monitors - 1 -
  10.149 +    (tempcount * Interpreter::stackElementWords) -
  10.150 +    popframe_extra_args;
  10.151 +
  10.152 +  int local_words = method->max_locals() * Interpreter::stackElementWords;
  10.153 +  NEEDS_CLEANUP;
  10.154 +  intptr_t* locals;
  10.155 +  if (caller->is_interpreted_frame()) {
  10.156 +    // Can force the locals area to end up properly overlapping the top of the expression stack.
  10.157 +    intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1;
  10.158 +    // Note that this computation means we replace size_of_parameters() values from the caller
  10.159 +    // interpreter frame's expression stack with our argument locals
  10.160 +    int parm_words  = caller_actual_parameters * Interpreter::stackElementWords;
  10.161 +    locals = Lesp_ptr + parm_words;
  10.162 +    int delta = local_words - parm_words;
  10.163 +    int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
  10.164 +    *interpreter_frame->register_addr(I5_savedSP)    = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
  10.165 +    if (!is_bottom_frame) {
  10.166 +      // Llast_SP is set below for the current frame to SP (with the
  10.167 +      // extra space for the callee's locals). Here we adjust
  10.168 +      // Llast_SP for the caller's frame, removing the extra space
  10.169 +      // for the current method's locals.
  10.170 +      *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
  10.171      } else {
  10.172 -      assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
  10.173 -      // Don't have Lesp available; lay out locals block in the caller
  10.174 -      // adjacent to the register window save area.
  10.175 -      //
  10.176 -      // Compiled frames do not allocate a varargs area which is why this if
  10.177 -      // statement is needed.
  10.178 -      //
  10.179 -      if (caller->is_compiled_frame()) {
  10.180 -        locals = fp + frame::register_save_words + local_words - 1;
  10.181 -      } else {
  10.182 -        locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
  10.183 -      }
  10.184 -      if (!caller->is_entry_frame()) {
  10.185 -        // Caller wants his own SP back
  10.186 -        int caller_frame_size = caller->cb()->frame_size();
  10.187 -        *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS;
  10.188 +      assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
  10.189 +    }
  10.190 +  } else {
  10.191 +    assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
  10.192 +    // Don't have Lesp available; lay out locals block in the caller
  10.193 +    // adjacent to the register window save area.
  10.194 +    //
  10.195 +    // Compiled frames do not allocate a varargs area which is why this if
  10.196 +    // statement is needed.
  10.197 +    //
  10.198 +    if (caller->is_compiled_frame()) {
  10.199 +      locals = fp + frame::register_save_words + local_words - 1;
  10.200 +    } else {
  10.201 +      locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
  10.202 +    }
  10.203 +    if (!caller->is_entry_frame()) {
  10.204 +      // Caller wants his own SP back
  10.205 +      int caller_frame_size = caller->cb()->frame_size();
  10.206 +      *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS;
  10.207 +    }
  10.208 +  }
  10.209 +  if (TraceDeoptimization) {
  10.210 +    if (caller->is_entry_frame()) {
  10.211 +      // make sure I5_savedSP and the entry frames notion of saved SP
  10.212 +      // agree.  This assertion duplicate a check in entry frame code
  10.213 +      // but catches the failure earlier.
  10.214 +      assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP),
  10.215 +             "would change callers SP");
  10.216 +    }
  10.217 +    if (caller->is_entry_frame()) {
  10.218 +      tty->print("entry ");
  10.219 +    }
  10.220 +    if (caller->is_compiled_frame()) {
  10.221 +      tty->print("compiled ");
  10.222 +      if (caller->is_deoptimized_frame()) {
  10.223 +        tty->print("(deopt) ");
  10.224        }
  10.225      }
  10.226 -    if (TraceDeoptimization) {
  10.227 -      if (caller->is_entry_frame()) {
  10.228 -        // make sure I5_savedSP and the entry frames notion of saved SP
  10.229 -        // agree.  This assertion duplicate a check in entry frame code
  10.230 -        // but catches the failure earlier.
  10.231 -        assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP),
  10.232 -               "would change callers SP");
  10.233 -      }
  10.234 -      if (caller->is_entry_frame()) {
  10.235 -        tty->print("entry ");
  10.236 -      }
  10.237 -      if (caller->is_compiled_frame()) {
  10.238 -        tty->print("compiled ");
  10.239 -        if (caller->is_deoptimized_frame()) {
  10.240 -          tty->print("(deopt) ");
  10.241 -        }
  10.242 -      }
  10.243 -      if (caller->is_interpreted_frame()) {
  10.244 -        tty->print("interpreted ");
  10.245 -      }
  10.246 -      tty->print_cr("caller fp=0x%x sp=0x%x", caller->fp(), caller->sp());
  10.247 -      tty->print_cr("save area = 0x%x, 0x%x", caller->sp(), caller->sp() + 16);
  10.248 -      tty->print_cr("save area = 0x%x, 0x%x", caller->fp(), caller->fp() + 16);
  10.249 -      tty->print_cr("interpreter fp=0x%x sp=0x%x", interpreter_frame->fp(), interpreter_frame->sp());
  10.250 -      tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->sp(), interpreter_frame->sp() + 16);
  10.251 -      tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->fp(), interpreter_frame->fp() + 16);
  10.252 -      tty->print_cr("Llocals = 0x%x", locals);
  10.253 -      tty->print_cr("Lesp = 0x%x", esp);
  10.254 -      tty->print_cr("Lmonitors = 0x%x", monitors);
  10.255 +    if (caller->is_interpreted_frame()) {
  10.256 +      tty->print("interpreted ");
  10.257      }
  10.258 +    tty->print_cr("caller fp=0x%x sp=0x%x", caller->fp(), caller->sp());
  10.259 +    tty->print_cr("save area = 0x%x, 0x%x", caller->sp(), caller->sp() + 16);
  10.260 +    tty->print_cr("save area = 0x%x, 0x%x", caller->fp(), caller->fp() + 16);
  10.261 +    tty->print_cr("interpreter fp=0x%x sp=0x%x", interpreter_frame->fp(), interpreter_frame->sp());
  10.262 +    tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->sp(), interpreter_frame->sp() + 16);
  10.263 +    tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->fp(), interpreter_frame->fp() + 16);
  10.264 +    tty->print_cr("Llocals = 0x%x", locals);
  10.265 +    tty->print_cr("Lesp = 0x%x", esp);
  10.266 +    tty->print_cr("Lmonitors = 0x%x", monitors);
  10.267 +  }
  10.268  
  10.269 -    if (method->max_locals() > 0) {
  10.270 -      assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area");
  10.271 -      assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area");
  10.272 -      assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area");
  10.273 -      assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area");
  10.274 -    }
  10.275 +  if (method->max_locals() > 0) {
  10.276 +    assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area");
  10.277 +    assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area");
  10.278 +    assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area");
  10.279 +    assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area");
  10.280 +  }
  10.281  #ifdef _LP64
  10.282 -    assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd");
  10.283 +  assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd");
  10.284  #endif
  10.285  
  10.286 -    *interpreter_frame->register_addr(Lmethod)     = (intptr_t) method;
  10.287 -    *interpreter_frame->register_addr(Llocals)     = (intptr_t) locals;
  10.288 -    *interpreter_frame->register_addr(Lmonitors)   = (intptr_t) monitors;
  10.289 -    *interpreter_frame->register_addr(Lesp)        = (intptr_t) esp;
  10.290 -    // Llast_SP will be same as SP as there is no adapter space
  10.291 -    *interpreter_frame->register_addr(Llast_SP)    = (intptr_t) interpreter_frame->sp() - STACK_BIAS;
  10.292 -    *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache();
  10.293 +  *interpreter_frame->register_addr(Lmethod)     = (intptr_t) method;
  10.294 +  *interpreter_frame->register_addr(Llocals)     = (intptr_t) locals;
  10.295 +  *interpreter_frame->register_addr(Lmonitors)   = (intptr_t) monitors;
  10.296 +  *interpreter_frame->register_addr(Lesp)        = (intptr_t) esp;
  10.297 +  // Llast_SP will be same as SP as there is no adapter space
  10.298 +  *interpreter_frame->register_addr(Llast_SP)    = (intptr_t) interpreter_frame->sp() - STACK_BIAS;
  10.299 +  *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache();
  10.300  #ifdef FAST_DISPATCH
  10.301 -    *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table();
  10.302 +  *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table();
  10.303  #endif
  10.304  
  10.305  
  10.306  #ifdef ASSERT
  10.307 -    BasicObjectLock* mp = (BasicObjectLock*)monitors;
  10.308 +  BasicObjectLock* mp = (BasicObjectLock*)monitors;
  10.309  
  10.310 -    assert(interpreter_frame->interpreter_frame_method() == method, "method matches");
  10.311 -    assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match");
  10.312 -    assert(interpreter_frame->interpreter_frame_monitor_end()   == mp, "monitor_end matches");
  10.313 -    assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches");
  10.314 -    assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches");
  10.315 +  assert(interpreter_frame->interpreter_frame_method() == method, "method matches");
  10.316 +  assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match");
  10.317 +  assert(interpreter_frame->interpreter_frame_monitor_end()   == mp, "monitor_end matches");
  10.318 +  assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches");
  10.319 +  assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches");
  10.320  
  10.321 -    // check bounds
  10.322 -    intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1);
  10.323 -    intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words;
  10.324 -    assert(lo < monitors && montop <= hi, "monitors in bounds");
  10.325 -    assert(lo <= esp && esp < monitors, "esp in bounds");
  10.326 +  // check bounds
  10.327 +  intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1);
  10.328 +  intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words;
  10.329 +  assert(lo < monitors && montop <= hi, "monitors in bounds");
  10.330 +  assert(lo <= esp && esp < monitors, "esp in bounds");
  10.331  #endif // ASSERT
  10.332 -  }
  10.333 -
  10.334 -  return raw_frame_size;
  10.335  }
  10.336  
  10.337  //----------------------------------------------------------------------------------------------------
    11.1 --- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Mon Jun 09 15:42:31 2014 -0700
    11.2 +++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Tue Apr 01 09:36:49 2014 +0200
    11.3 @@ -288,7 +288,7 @@
    11.4  
    11.5    // build frame
    11.6    ciMethod* m = compilation()->method();
    11.7 -  __ build_frame(initial_frame_size_in_bytes());
    11.8 +  __ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
    11.9  
   11.10    // OSR buffer is
   11.11    //
   11.12 @@ -376,7 +376,7 @@
   11.13  }
   11.14  
   11.15  // This specifies the rsp decrement needed to build the frame
   11.16 -int LIR_Assembler::initial_frame_size_in_bytes() {
   11.17 +int LIR_Assembler::initial_frame_size_in_bytes() const {
   11.18    // if rounding, must let FrameMap know!
   11.19  
   11.20    // The frame_map records size in slots (32bit word)
    12.1 --- a/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp	Mon Jun 09 15:42:31 2014 -0700
    12.2 +++ b/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp	Tue Apr 01 09:36:49 2014 +0200
    12.3 @@ -349,13 +349,14 @@
    12.4  }
    12.5  
    12.6  
    12.7 -void C1_MacroAssembler::build_frame(int frame_size_in_bytes) {
    12.8 +void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
    12.9 +  assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
   12.10    // Make sure there is enough stack space for this method's activation.
   12.11    // Note that we do this before doing an enter(). This matches the
   12.12    // ordering of C2's stack overflow check / rsp decrement and allows
   12.13    // the SharedRuntime stack overflow handling to be consistent
   12.14    // between the two compilers.
   12.15 -  generate_stack_overflow_check(frame_size_in_bytes);
   12.16 +  generate_stack_overflow_check(bang_size_in_bytes);
   12.17  
   12.18    push(rbp);
   12.19  #ifdef TIERED
    13.1 --- a/src/cpu/x86/vm/cppInterpreter_x86.cpp	Mon Jun 09 15:42:31 2014 -0700
    13.2 +++ b/src/cpu/x86/vm/cppInterpreter_x86.cpp	Tue Apr 01 09:36:49 2014 +0200
    13.3 @@ -2336,29 +2336,42 @@
    13.4           "Stack top out of range");
    13.5  }
    13.6  
    13.7 -int AbstractInterpreter::layout_activation(Method* method,
    13.8 -                                           int tempcount,  //
    13.9 -                                           int popframe_extra_args,
   13.10 -                                           int moncount,
   13.11 -                                           int caller_actual_parameters,
   13.12 -                                           int callee_param_count,
   13.13 -                                           int callee_locals,
   13.14 -                                           frame* caller,
   13.15 -                                           frame* interpreter_frame,
   13.16 -                                           bool is_top_frame,
   13.17 -                                           bool is_bottom_frame) {
   13.18 -
   13.19 -  assert(popframe_extra_args == 0, "FIX ME");
   13.20 -  // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
   13.21 -  // does as far as allocating an interpreter frame.
   13.22 -  // If interpreter_frame!=NULL, set up the method, locals, and monitors.
   13.23 -  // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
   13.24 -  // as determined by a previous call to this method.
   13.25 -  // It is also guaranteed to be walkable even though it is in a skeletal state
   13.26 +
   13.27 +static int frame_size_helper(int max_stack,
   13.28 +                             int tempcount,
   13.29 +                             int moncount,
   13.30 +                             int callee_param_count,
   13.31 +                             int callee_locals,
   13.32 +                             bool is_top_frame,
   13.33 +                             int& monitor_size,
   13.34 +                             int& full_frame_size) {
   13.35 +  int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
   13.36 +  monitor_size = sizeof(BasicObjectLock) * moncount;
   13.37 +
   13.38 +  // First calculate the frame size without any java expression stack
   13.39 +  int short_frame_size = size_activation_helper(extra_locals_size,
   13.40 +                                                monitor_size);
   13.41 +
   13.42 +  // Now with full size expression stack
   13.43 +  full_frame_size = short_frame_size + max_stack * BytesPerWord;
   13.44 +
   13.45 +  // and now with only live portion of the expression stack
   13.46 +  short_frame_size = short_frame_size + tempcount * BytesPerWord;
   13.47 +
   13.48 +  // the size the activation is right now. Only top frame is full size
   13.49 +  int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
   13.50 +  return frame_size;
   13.51 +}
   13.52 +
   13.53 +int AbstractInterpreter::size_activation(int max_stack,
   13.54 +                                         int tempcount,
   13.55 +                                         int extra_args,
   13.56 +                                         int moncount,
   13.57 +                                         int callee_param_count,
   13.58 +                                         int callee_locals,
   13.59 +                                         bool is_top_frame) {
   13.60 +  assert(extra_args == 0, "FIX ME");
   13.61    // NOTE: return size is in words not bytes
   13.62 -  // NOTE: tempcount is the current size of the java expression stack. For top most
   13.63 -  //       frames we will allocate a full sized expression stack and not the curback
   13.64 -  //       version that non-top frames have.
   13.65  
   13.66    // Calculate the amount our frame will be adjust by the callee. For top frame
   13.67    // this is zero.
   13.68 @@ -2368,87 +2381,102 @@
   13.69    // to it. So it ignores last_frame_adjust value. Seems suspicious as far
   13.70    // as getting sender_sp correct.
   13.71  
   13.72 -  int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
   13.73 -  int monitor_size = sizeof(BasicObjectLock) * moncount;
   13.74 -
   13.75 -  // First calculate the frame size without any java expression stack
   13.76 -  int short_frame_size = size_activation_helper(extra_locals_size,
   13.77 -                                                monitor_size);
   13.78 -
   13.79 -  // Now with full size expression stack
   13.80 -  int full_frame_size = short_frame_size + method->max_stack() * BytesPerWord;
   13.81 -
   13.82 -  // and now with only live portion of the expression stack
   13.83 -  short_frame_size = short_frame_size + tempcount * BytesPerWord;
   13.84 -
   13.85 -  // the size the activation is right now. Only top frame is full size
   13.86 -  int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
   13.87 -
   13.88 -  if (interpreter_frame != NULL) {
   13.89 +  int unused_monitor_size = 0;
   13.90 +  int unused_full_frame_size = 0;
   13.91 +  return frame_size_helper(max_stack, tempcount, moncount, callee_param_count, callee_locals,
   13.92 +                           is_top_frame, unused_monitor_size, unused_full_frame_size)/BytesPerWord;
   13.93 +}
   13.94 +
   13.95 +void AbstractInterpreter::layout_activation(Method* method,
   13.96 +                                            int tempcount,  //
   13.97 +                                            int popframe_extra_args,
   13.98 +                                            int moncount,
   13.99 +                                            int caller_actual_parameters,
  13.100 +                                            int callee_param_count,
  13.101 +                                            int callee_locals,
  13.102 +                                            frame* caller,
  13.103 +                                            frame* interpreter_frame,
  13.104 +                                            bool is_top_frame,
  13.105 +                                            bool is_bottom_frame) {
  13.106 +
  13.107 +  assert(popframe_extra_args == 0, "FIX ME");
  13.108 +  // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
  13.109 +  // does as far as allocating an interpreter frame.
  13.110 +  // Set up the method, locals, and monitors.
  13.111 +  // The frame interpreter_frame is guaranteed to be the right size,
  13.112 +  // as determined by a previous call to the size_activation() method.
  13.113 +  // It is also guaranteed to be walkable even though it is in a skeletal state
  13.114 +  // NOTE: tempcount is the current size of the java expression stack. For top most
  13.115 +  //       frames we will allocate a full sized expression stack and not the curback
  13.116 +  //       version that non-top frames have.
  13.117 +
  13.118 +  int monitor_size = 0;
  13.119 +  int full_frame_size = 0;
  13.120 +  int frame_size = frame_size_helper(method->max_stack(), tempcount, moncount, callee_param_count, callee_locals,
  13.121 +                                     is_top_frame, monitor_size, full_frame_size);
  13.122 +
  13.123  #ifdef ASSERT
  13.124 -    assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
  13.125 +  assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
  13.126  #endif
  13.127  
  13.128 -    // MUCHO HACK
  13.129 -
  13.130 -    intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
  13.131 -
  13.132 -    /* Now fillin the interpreterState object */
  13.133 -
  13.134 -    // The state object is the first thing on the frame and easily located
  13.135 -
  13.136 -    interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
  13.137 -
  13.138 -
  13.139 -    // Find the locals pointer. This is rather simple on x86 because there is no
  13.140 -    // confusing rounding at the callee to account for. We can trivially locate
  13.141 -    // our locals based on the current fp().
  13.142 -    // Note: the + 2 is for handling the "static long no_params() method" issue.
  13.143 -    // (too bad I don't really remember that issue well...)
  13.144 -
  13.145 -    intptr_t* locals;
  13.146 -    // If the caller is interpreted we need to make sure that locals points to the first
  13.147 -    // argument that the caller passed and not in an area where the stack might have been extended.
  13.148 -    // because the stack to stack to converter needs a proper locals value in order to remove the
  13.149 -    // arguments from the caller and place the result in the proper location. Hmm maybe it'd be
  13.150 -    // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code
  13.151 -    // adjust the stack?? HMMM QQQ
  13.152 -    //
  13.153 -    if (caller->is_interpreted_frame()) {
  13.154 -      // locals must agree with the caller because it will be used to set the
  13.155 -      // caller's tos when we return.
  13.156 -      interpreterState prev  = caller->get_interpreterState();
  13.157 -      // stack() is prepushed.
  13.158 -      locals = prev->stack() + method->size_of_parameters();
  13.159 -      // locals = caller->unextended_sp() + (method->size_of_parameters() - 1);
  13.160 -      if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) {
  13.161 -        // os::breakpoint();
  13.162 -      }
  13.163 -    } else {
  13.164 -      // this is where a c2i would have placed locals (except for the +2)
  13.165 -      locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2;
  13.166 +  // MUCHO HACK
  13.167 +
  13.168 +  intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
  13.169 +
  13.170 +  /* Now fillin the interpreterState object */
  13.171 +
  13.172 +  // The state object is the first thing on the frame and easily located
  13.173 +
  13.174 +  interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
  13.175 +
  13.176 +
  13.177 +  // Find the locals pointer. This is rather simple on x86 because there is no
  13.178 +  // confusing rounding at the callee to account for. We can trivially locate
  13.179 +  // our locals based on the current fp().
  13.180 +  // Note: the + 2 is for handling the "static long no_params() method" issue.
  13.181 +  // (too bad I don't really remember that issue well...)
  13.182 +
  13.183 +  intptr_t* locals;
  13.184 +  // If the caller is interpreted we need to make sure that locals points to the first
  13.185 +  // argument that the caller passed and not in an area where the stack might have been extended.
  13.186 +  // because the stack to stack to converter needs a proper locals value in order to remove the
  13.187 +  // arguments from the caller and place the result in the proper location. Hmm maybe it'd be
  13.188 +  // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code
  13.189 +  // adjust the stack?? HMMM QQQ
  13.190 +  //
  13.191 +  if (caller->is_interpreted_frame()) {
  13.192 +    // locals must agree with the caller because it will be used to set the
  13.193 +    // caller's tos when we return.
  13.194 +    interpreterState prev  = caller->get_interpreterState();
  13.195 +    // stack() is prepushed.
  13.196 +    locals = prev->stack() + method->size_of_parameters();
  13.197 +    // locals = caller->unextended_sp() + (method->size_of_parameters() - 1);
  13.198 +    if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) {
  13.199 +      // os::breakpoint();
  13.200      }
  13.201 -
  13.202 -    intptr_t* monitor_base = (intptr_t*) cur_state;
  13.203 -    intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
  13.204 -    /* +1 because stack is always prepushed */
  13.205 -    intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
  13.206 -
  13.207 -
  13.208 -    BytecodeInterpreter::layout_interpreterState(cur_state,
  13.209 -                                          caller,
  13.210 -                                          interpreter_frame,
  13.211 -                                          method,
  13.212 -                                          locals,
  13.213 -                                          stack,
  13.214 -                                          stack_base,
  13.215 -                                          monitor_base,
  13.216 -                                          frame_bottom,
  13.217 -                                          is_top_frame);
  13.218 -
  13.219 -    // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
  13.220 +  } else {
  13.221 +    // this is where a c2i would have placed locals (except for the +2)
  13.222 +    locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2;
  13.223    }
  13.224 -  return frame_size/BytesPerWord;
  13.225 +
  13.226 +  intptr_t* monitor_base = (intptr_t*) cur_state;
  13.227 +  intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
  13.228 +  /* +1 because stack is always prepushed */
  13.229 +  intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
  13.230 +
  13.231 +
  13.232 +  BytecodeInterpreter::layout_interpreterState(cur_state,
  13.233 +                                               caller,
  13.234 +                                               interpreter_frame,
  13.235 +                                               method,
  13.236 +                                               locals,
  13.237 +                                               stack,
  13.238 +                                               stack_base,
  13.239 +                                               monitor_base,
  13.240 +                                               frame_bottom,
  13.241 +                                               is_top_frame);
  13.242 +
  13.243 +  // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
  13.244  }
  13.245  
  13.246  #endif // CC_INTERP (all)
    14.1 --- a/src/cpu/x86/vm/macroAssembler_x86.cpp	Mon Jun 09 15:42:31 2014 -0700
    14.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.cpp	Tue Apr 01 09:36:49 2014 +0200
    14.3 @@ -1052,7 +1052,7 @@
    14.4    // was post-decremented.)  Skip this address by starting at i=1, and
    14.5    // touch a few more pages below.  N.B.  It is important to touch all
    14.6    // the way down to and including i=StackShadowPages.
    14.7 -  for (int i = 1; i <= StackShadowPages; i++) {
    14.8 +  for (int i = 1; i < StackShadowPages; i++) {
    14.9      // this could be any sized move but this is can be a debugging crumb
   14.10      // so the bigger the better.
   14.11      movptr(Address(tmp, (-i*os::vm_page_size())), size );
   14.12 @@ -6096,7 +6096,7 @@
   14.13  
   14.14  
   14.15  // C2 compiled method's prolog code.
   14.16 -void MacroAssembler::verified_entry(int framesize, bool stack_bang, bool fp_mode_24b) {
   14.17 +void MacroAssembler::verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b) {
   14.18  
   14.19    // WARNING: Initial instruction MUST be 5 bytes or longer so that
   14.20    // NativeJump::patch_verified_entry will be able to patch out the entry
   14.21 @@ -6104,18 +6104,20 @@
   14.22    // the frame allocation can be either 3 or 6 bytes. So if we don't do
   14.23    // stack bang then we must use the 6 byte frame allocation even if
   14.24    // we have no frame. :-(
   14.25 +  assert(stack_bang_size >= framesize || stack_bang_size <= 0, "stack bang size incorrect");
   14.26  
   14.27    assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
   14.28    // Remove word for return addr
   14.29    framesize -= wordSize;
   14.30 +  stack_bang_size -= wordSize;
   14.31  
   14.32    // Calls to C2R adapters often do not accept exceptional returns.
   14.33    // We require that their callers must bang for them.  But be careful, because
   14.34    // some VM calls (such as call site linkage) can use several kilobytes of
   14.35    // stack.  But the stack safety zone should account for that.
   14.36    // See bugs 4446381, 4468289, 4497237.
   14.37 -  if (stack_bang) {
   14.38 -    generate_stack_overflow_check(framesize);
   14.39 +  if (stack_bang_size > 0) {
   14.40 +    generate_stack_overflow_check(stack_bang_size);
   14.41  
   14.42      // We always push rbp, so that on return to interpreter rbp, will be
   14.43      // restored correctly and we can correct the stack.
    15.1 --- a/src/cpu/x86/vm/macroAssembler_x86.hpp	Mon Jun 09 15:42:31 2014 -0700
    15.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.hpp	Tue Apr 01 09:36:49 2014 +0200
    15.3 @@ -1170,7 +1170,7 @@
    15.4    void movl2ptr(Register dst, Register src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(if (dst != src) movl(dst, src)); }
    15.5  
    15.6    // C2 compiled method's prolog code.
    15.7 -  void verified_entry(int framesize, bool stack_bang, bool fp_mode_24b);
    15.8 +  void verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b);
    15.9  
   15.10    // clear memory of size 'cnt' qwords, starting at 'base'.
   15.11    void clear_mem(Register base, Register cnt, Register rtmp);
    16.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Jun 09 15:42:31 2014 -0700
    16.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Tue Apr 01 09:36:49 2014 +0200
    16.3 @@ -3014,11 +3014,15 @@
    16.4    // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
    16.5    __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
    16.6  
    16.7 -  // Stack bang to make sure there's enough room for these interpreter frames.
    16.8 +#ifdef ASSERT
    16.9 +  // Compilers generate code that bang the stack by as much as the
   16.10 +  // interpreter would need. So this stack banging should never
   16.11 +  // trigger a fault. Verify that it does not on non product builds.
   16.12    if (UseStackBanging) {
   16.13      __ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
   16.14      __ bang_stack_size(rbx, rcx);
   16.15    }
   16.16 +#endif
   16.17  
   16.18    // Load array of frame pcs into ECX
   16.19    __ movptr(rcx,Address(rdi,Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
   16.20 @@ -3240,12 +3244,15 @@
   16.21    // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
   16.22    __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
   16.23  
   16.24 -  // Stack bang to make sure there's enough room for these interpreter frames.
   16.25 +#ifdef ASSERT
   16.26 +  // Compilers generate code that bang the stack by as much as the
   16.27 +  // interpreter would need. So this stack banging should never
   16.28 +  // trigger a fault. Verify that it does not on non product builds.
   16.29    if (UseStackBanging) {
   16.30      __ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
   16.31      __ bang_stack_size(rbx, rcx);
   16.32    }
   16.33 -
   16.34 +#endif
   16.35  
   16.36    // Load array of frame pcs into ECX
   16.37    __ movl(rcx,Address(rdi,Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
    17.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Jun 09 15:42:31 2014 -0700
    17.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Tue Apr 01 09:36:49 2014 +0200
    17.3 @@ -3484,11 +3484,15 @@
    17.4    // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
    17.5    __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
    17.6  
    17.7 -  // Stack bang to make sure there's enough room for these interpreter frames.
    17.8 +#ifdef ASSERT
    17.9 +  // Compilers generate code that bang the stack by as much as the
   17.10 +  // interpreter would need. So this stack banging should never
   17.11 +  // trigger a fault. Verify that it does not on non product builds.
   17.12    if (UseStackBanging) {
   17.13      __ movl(rbx, Address(rdi, Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
   17.14      __ bang_stack_size(rbx, rcx);
   17.15    }
   17.16 +#endif
   17.17  
   17.18    // Load address of array of frame pcs into rcx
   17.19    __ movptr(rcx, Address(rdi, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
   17.20 @@ -3682,11 +3686,15 @@
   17.21    // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
   17.22    __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
   17.23  
   17.24 -  // Stack bang to make sure there's enough room for these interpreter frames.
   17.25 +#ifdef ASSERT
   17.26 +  // Compilers generate code that bang the stack by as much as the
   17.27 +  // interpreter would need. So this stack banging should never
   17.28 +  // trigger a fault. Verify that it does not on non product builds.
   17.29    if (UseStackBanging) {
   17.30      __ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
   17.31      __ bang_stack_size(rbx, rcx);
   17.32    }
   17.33 +#endif
   17.34  
   17.35    // Load address of array of frame pcs into rcx (address*)
   17.36    __ movptr(rcx, Address(rdi, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86.cpp	Tue Apr 01 09:36:49 2014 +0200
    18.3 @@ -0,0 +1,124 @@
    18.4 +/*
    18.5 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + *
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + *
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + *
   18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 + * or visit www.oracle.com if you need additional information or have any
   18.24 + * questions.
   18.25 + *
   18.26 + */
   18.27 +
   18.28 +#include "precompiled.hpp"
   18.29 +#include "ci/ciMethod.hpp"
   18.30 +#include "interpreter/interpreter.hpp"
   18.31 +#include "runtime/frame.inline.hpp"
   18.32 +
   18.33 +#ifndef CC_INTERP
   18.34 +
   18.35 +// asm based interpreter deoptimization helpers
   18.36 +int AbstractInterpreter::size_activation(int max_stack,
   18.37 +                                         int temps,
   18.38 +                                         int extra_args,
   18.39 +                                         int monitors,
   18.40 +                                         int callee_params,
   18.41 +                                         int callee_locals,
   18.42 +                                         bool is_top_frame) {
   18.43 +  // Note: This calculation must exactly parallel the frame setup
   18.44 +  // in AbstractInterpreterGenerator::generate_method_entry.
   18.45 +
   18.46 +  // fixed size of an interpreter frame:
   18.47 +  int overhead = frame::sender_sp_offset -
   18.48 +                 frame::interpreter_frame_initial_sp_offset;
   18.49 +  // Our locals were accounted for by the caller (or last_frame_adjust
   18.50 +  // on the transistion) Since the callee parameters already account
   18.51 +  // for the callee's params we only need to account for the extra
   18.52 +  // locals.
   18.53 +  int size = overhead +
   18.54 +         (callee_locals - callee_params)*Interpreter::stackElementWords +
   18.55 +         monitors * frame::interpreter_frame_monitor_size() +
   18.56 +         temps* Interpreter::stackElementWords + extra_args;
   18.57 +
   18.58 +  return size;
   18.59 +}
   18.60 +
   18.61 +void AbstractInterpreter::layout_activation(Method* method,
   18.62 +                                            int tempcount,
   18.63 +                                            int popframe_extra_args,
   18.64 +                                            int moncount,
   18.65 +                                            int caller_actual_parameters,
   18.66 +                                            int callee_param_count,
   18.67 +                                            int callee_locals,
   18.68 +                                            frame* caller,
   18.69 +                                            frame* interpreter_frame,
   18.70 +                                            bool is_top_frame,
   18.71 +                                            bool is_bottom_frame) {
   18.72 +  // The frame interpreter_frame is guaranteed to be the right size,
   18.73 +  // as determined by a previous call to the size_activation() method.
   18.74 +  // It is also guaranteed to be walkable even though it is in a
   18.75 +  // skeletal state
   18.76 +
   18.77 +  int max_locals = method->max_locals() * Interpreter::stackElementWords;
   18.78 +  int extra_locals = (method->max_locals() - method->size_of_parameters()) *
   18.79 +    Interpreter::stackElementWords;
   18.80 +
   18.81 +#ifdef ASSERT
   18.82 +  if (!EnableInvokeDynamic) {
   18.83 +    // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences?
   18.84 +    // Probably, since deoptimization doesn't work yet.
   18.85 +    assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
   18.86 +  }
   18.87 +  assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)");
   18.88 +#endif
   18.89 +
   18.90 +  interpreter_frame->interpreter_frame_set_method(method);
   18.91 +  // NOTE the difference in using sender_sp and
   18.92 +  // interpreter_frame_sender_sp interpreter_frame_sender_sp is
   18.93 +  // the original sp of the caller (the unextended_sp) and
   18.94 +  // sender_sp is fp+8/16 (32bit/64bit) XXX
   18.95 +  intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
   18.96 +
   18.97 +#ifdef ASSERT
   18.98 +  if (caller->is_interpreted_frame()) {
   18.99 +    assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
  18.100 +  }
  18.101 +#endif
  18.102 +
  18.103 +  interpreter_frame->interpreter_frame_set_locals(locals);
  18.104 +  BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
  18.105 +  BasicObjectLock* monbot = montop - moncount;
  18.106 +  interpreter_frame->interpreter_frame_set_monitor_end(monbot);
  18.107 +
  18.108 +  // Set last_sp
  18.109 +  intptr_t*  esp = (intptr_t*) monbot -
  18.110 +    tempcount*Interpreter::stackElementWords -
  18.111 +    popframe_extra_args;
  18.112 +  interpreter_frame->interpreter_frame_set_last_sp(esp);
  18.113 +
  18.114 +  // All frames but the initial (oldest) interpreter frame we fill in have
  18.115 +  // a value for sender_sp that allows walking the stack but isn't
  18.116 +  // truly correct. Correct the value here.
  18.117 +  if (extra_locals != 0 &&
  18.118 +      interpreter_frame->sender_sp() ==
  18.119 +      interpreter_frame->interpreter_frame_sender_sp()) {
  18.120 +    interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
  18.121 +                                                       extra_locals);
  18.122 +  }
  18.123 +  *interpreter_frame->interpreter_frame_cache_addr() =
  18.124 +    method->constants()->cache();
  18.125 +}
  18.126 +
  18.127 +#endif // CC_INTERP
    19.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Mon Jun 09 15:42:31 2014 -0700
    19.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Tue Apr 01 09:36:49 2014 +0200
    19.3 @@ -1686,91 +1686,6 @@
    19.4    return overhead_size + method_stack + stub_code;
    19.5  }
    19.6  
    19.7 -// asm based interpreter deoptimization helpers
    19.8 -
    19.9 -int AbstractInterpreter::layout_activation(Method* method,
   19.10 -                                           int tempcount,
   19.11 -                                           int popframe_extra_args,
   19.12 -                                           int moncount,
   19.13 -                                           int caller_actual_parameters,
   19.14 -                                           int callee_param_count,
   19.15 -                                           int callee_locals,
   19.16 -                                           frame* caller,
   19.17 -                                           frame* interpreter_frame,
   19.18 -                                           bool is_top_frame,
   19.19 -                                           bool is_bottom_frame) {
   19.20 -  // Note: This calculation must exactly parallel the frame setup
   19.21 -  // in AbstractInterpreterGenerator::generate_method_entry.
   19.22 -  // If interpreter_frame!=NULL, set up the method, locals, and monitors.
   19.23 -  // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
   19.24 -  // as determined by a previous call to this method.
   19.25 -  // It is also guaranteed to be walkable even though it is in a skeletal state
   19.26 -  // NOTE: return size is in words not bytes
   19.27 -
   19.28 -  // fixed size of an interpreter frame:
   19.29 -  int max_locals = method->max_locals() * Interpreter::stackElementWords;
   19.30 -  int extra_locals = (method->max_locals() - method->size_of_parameters()) *
   19.31 -                     Interpreter::stackElementWords;
   19.32 -
   19.33 -  int overhead = frame::sender_sp_offset - frame::interpreter_frame_initial_sp_offset;
   19.34 -
   19.35 -  // Our locals were accounted for by the caller (or last_frame_adjust on the transistion)
   19.36 -  // Since the callee parameters already account for the callee's params we only need to account for
   19.37 -  // the extra locals.
   19.38 -
   19.39 -
   19.40 -  int size = overhead +
   19.41 -         ((callee_locals - callee_param_count)*Interpreter::stackElementWords) +
   19.42 -         (moncount*frame::interpreter_frame_monitor_size()) +
   19.43 -         tempcount*Interpreter::stackElementWords + popframe_extra_args;
   19.44 -
   19.45 -  if (interpreter_frame != NULL) {
   19.46 -#ifdef ASSERT
   19.47 -    if (!EnableInvokeDynamic)
   19.48 -      // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences?
   19.49 -      // Probably, since deoptimization doesn't work yet.
   19.50 -      assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
   19.51 -    assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)");
   19.52 -#endif
   19.53 -
   19.54 -    interpreter_frame->interpreter_frame_set_method(method);
   19.55 -    // NOTE the difference in using sender_sp and interpreter_frame_sender_sp
   19.56 -    // interpreter_frame_sender_sp is the original sp of the caller (the unextended_sp)
   19.57 -    // and sender_sp is fp+8
   19.58 -    intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
   19.59 -
   19.60 -#ifdef ASSERT
   19.61 -    if (caller->is_interpreted_frame()) {
   19.62 -      assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
   19.63 -    }
   19.64 -#endif
   19.65 -
   19.66 -    interpreter_frame->interpreter_frame_set_locals(locals);
   19.67 -    BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
   19.68 -    BasicObjectLock* monbot = montop - moncount;
   19.69 -    interpreter_frame->interpreter_frame_set_monitor_end(monbot);
   19.70 -
   19.71 -    // Set last_sp
   19.72 -    intptr_t*  rsp = (intptr_t*) monbot  -
   19.73 -                     tempcount*Interpreter::stackElementWords -
   19.74 -                     popframe_extra_args;
   19.75 -    interpreter_frame->interpreter_frame_set_last_sp(rsp);
   19.76 -
   19.77 -    // All frames but the initial (oldest) interpreter frame we fill in have a
   19.78 -    // value for sender_sp that allows walking the stack but isn't
   19.79 -    // truly correct. Correct the value here.
   19.80 -
   19.81 -    if (extra_locals != 0 &&
   19.82 -        interpreter_frame->sender_sp() == interpreter_frame->interpreter_frame_sender_sp() ) {
   19.83 -      interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() + extra_locals);
   19.84 -    }
   19.85 -    *interpreter_frame->interpreter_frame_cache_addr() =
   19.86 -      method->constants()->cache();
   19.87 -  }
   19.88 -  return size;
   19.89 -}
   19.90 -
   19.91 -
   19.92  //------------------------------------------------------------------------------------------------------------------------
   19.93  // Exceptions
   19.94  
    20.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Jun 09 15:42:31 2014 -0700
    20.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Tue Apr 01 09:36:49 2014 +0200
    20.3 @@ -1695,87 +1695,6 @@
    20.4    return (overhead_size + method_stack + stub_code);
    20.5  }
    20.6  
    20.7 -int AbstractInterpreter::layout_activation(Method* method,
    20.8 -                                           int tempcount,
    20.9 -                                           int popframe_extra_args,
   20.10 -                                           int moncount,
   20.11 -                                           int caller_actual_parameters,
   20.12 -                                           int callee_param_count,
   20.13 -                                           int callee_locals,
   20.14 -                                           frame* caller,
   20.15 -                                           frame* interpreter_frame,
   20.16 -                                           bool is_top_frame,
   20.17 -                                           bool is_bottom_frame) {
   20.18 -  // Note: This calculation must exactly parallel the frame setup
   20.19 -  // in AbstractInterpreterGenerator::generate_method_entry.
   20.20 -  // If interpreter_frame!=NULL, set up the method, locals, and monitors.
   20.21 -  // The frame interpreter_frame, if not NULL, is guaranteed to be the
   20.22 -  // right size, as determined by a previous call to this method.
   20.23 -  // It is also guaranteed to be walkable even though it is in a skeletal state
   20.24 -
   20.25 -  // fixed size of an interpreter frame:
   20.26 -  int max_locals = method->max_locals() * Interpreter::stackElementWords;
   20.27 -  int extra_locals = (method->max_locals() - method->size_of_parameters()) *
   20.28 -                     Interpreter::stackElementWords;
   20.29 -
   20.30 -  int overhead = frame::sender_sp_offset -
   20.31 -                 frame::interpreter_frame_initial_sp_offset;
   20.32 -  // Our locals were accounted for by the caller (or last_frame_adjust
   20.33 -  // on the transistion) Since the callee parameters already account
   20.34 -  // for the callee's params we only need to account for the extra
   20.35 -  // locals.
   20.36 -  int size = overhead +
   20.37 -         (callee_locals - callee_param_count)*Interpreter::stackElementWords +
   20.38 -         moncount * frame::interpreter_frame_monitor_size() +
   20.39 -         tempcount* Interpreter::stackElementWords + popframe_extra_args;
   20.40 -  if (interpreter_frame != NULL) {
   20.41 -#ifdef ASSERT
   20.42 -    if (!EnableInvokeDynamic)
   20.43 -      // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences?
   20.44 -      // Probably, since deoptimization doesn't work yet.
   20.45 -      assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
   20.46 -    assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)");
   20.47 -#endif
   20.48 -
   20.49 -    interpreter_frame->interpreter_frame_set_method(method);
   20.50 -    // NOTE the difference in using sender_sp and
   20.51 -    // interpreter_frame_sender_sp interpreter_frame_sender_sp is
   20.52 -    // the original sp of the caller (the unextended_sp) and
   20.53 -    // sender_sp is fp+16 XXX
   20.54 -    intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
   20.55 -
   20.56 -#ifdef ASSERT
   20.57 -    if (caller->is_interpreted_frame()) {
   20.58 -      assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
   20.59 -    }
   20.60 -#endif
   20.61 -
   20.62 -    interpreter_frame->interpreter_frame_set_locals(locals);
   20.63 -    BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
   20.64 -    BasicObjectLock* monbot = montop - moncount;
   20.65 -    interpreter_frame->interpreter_frame_set_monitor_end(monbot);
   20.66 -
   20.67 -    // Set last_sp
   20.68 -    intptr_t*  esp = (intptr_t*) monbot -
   20.69 -                     tempcount*Interpreter::stackElementWords -
   20.70 -                     popframe_extra_args;
   20.71 -    interpreter_frame->interpreter_frame_set_last_sp(esp);
   20.72 -
   20.73 -    // All frames but the initial (oldest) interpreter frame we fill in have
   20.74 -    // a value for sender_sp that allows walking the stack but isn't
   20.75 -    // truly correct. Correct the value here.
   20.76 -    if (extra_locals != 0 &&
   20.77 -        interpreter_frame->sender_sp() ==
   20.78 -        interpreter_frame->interpreter_frame_sender_sp()) {
   20.79 -      interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
   20.80 -                                                         extra_locals);
   20.81 -    }
   20.82 -    *interpreter_frame->interpreter_frame_cache_addr() =
   20.83 -      method->constants()->cache();
   20.84 -  }
   20.85 -  return size;
   20.86 -}
   20.87 -
   20.88  //-----------------------------------------------------------------------------
   20.89  // Exceptions
   20.90  
    21.1 --- a/src/cpu/x86/vm/x86_32.ad	Mon Jun 09 15:42:31 2014 -0700
    21.2 +++ b/src/cpu/x86/vm/x86_32.ad	Tue Apr 01 09:36:49 2014 +0200
    21.3 @@ -512,14 +512,15 @@
    21.4  void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
    21.5    Compile* C = ra_->C;
    21.6  
    21.7 -  int framesize = C->frame_slots() << LogBytesPerInt;
    21.8 +  int framesize = C->frame_size_in_bytes();
    21.9 +  int bangsize = C->bang_size_in_bytes();
   21.10    assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
   21.11    // Remove wordSize for return addr which is already pushed.
   21.12    framesize -= wordSize;
   21.13  
   21.14 -  if (C->need_stack_bang(framesize)) {
   21.15 +  if (C->need_stack_bang(bangsize)) {
   21.16      framesize -= wordSize;
   21.17 -    st->print("# stack bang");
   21.18 +    st->print("# stack bang (%d bytes)", bangsize);
   21.19      st->print("\n\t");
   21.20      st->print("PUSH   EBP\t# Save EBP");
   21.21      if (framesize) {
   21.22 @@ -563,9 +564,10 @@
   21.23    Compile* C = ra_->C;
   21.24    MacroAssembler _masm(&cbuf);
   21.25  
   21.26 -  int framesize = C->frame_slots() << LogBytesPerInt;
   21.27 -
   21.28 -  __ verified_entry(framesize, C->need_stack_bang(framesize), C->in_24_bit_fp_mode());
   21.29 +  int framesize = C->frame_size_in_bytes();
   21.30 +  int bangsize = C->bang_size_in_bytes();
   21.31 +
   21.32 +  __ verified_entry(framesize, C->need_stack_bang(bangsize)?bangsize:0, C->in_24_bit_fp_mode());
   21.33  
   21.34    C->set_frame_complete(cbuf.insts_size());
   21.35  
   21.36 @@ -589,7 +591,7 @@
   21.37  #ifndef PRODUCT
   21.38  void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const {
   21.39    Compile *C = ra_->C;
   21.40 -  int framesize = C->frame_slots() << LogBytesPerInt;
   21.41 +  int framesize = C->frame_size_in_bytes();
   21.42    assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
   21.43    // Remove two words for return addr and rbp,
   21.44    framesize -= 2*wordSize;
   21.45 @@ -629,7 +631,7 @@
   21.46      masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
   21.47    }
   21.48  
   21.49 -  int framesize = C->frame_slots() << LogBytesPerInt;
   21.50 +  int framesize = C->frame_size_in_bytes();
   21.51    assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
   21.52    // Remove two words for return addr and rbp,
   21.53    framesize -= 2*wordSize;
   21.54 @@ -663,7 +665,7 @@
   21.55    if (C->max_vector_size() > 16) size += 3; // vzeroupper
   21.56    if (do_polling() && C->is_method_compilation()) size += 6;
   21.57  
   21.58 -  int framesize = C->frame_slots() << LogBytesPerInt;
   21.59 +  int framesize = C->frame_size_in_bytes();
   21.60    assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
   21.61    // Remove two words for return addr and rbp,
   21.62    framesize -= 2*wordSize;
    22.1 --- a/src/cpu/x86/vm/x86_64.ad	Mon Jun 09 15:42:31 2014 -0700
    22.2 +++ b/src/cpu/x86/vm/x86_64.ad	Tue Apr 01 09:36:49 2014 +0200
    22.3 @@ -713,14 +713,15 @@
    22.4  void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
    22.5    Compile* C = ra_->C;
    22.6  
    22.7 -  int framesize = C->frame_slots() << LogBytesPerInt;
    22.8 +  int framesize = C->frame_size_in_bytes();
    22.9 +  int bangsize = C->bang_size_in_bytes();
   22.10    assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
   22.11    // Remove wordSize for return addr which is already pushed.
   22.12    framesize -= wordSize;
   22.13  
   22.14 -  if (C->need_stack_bang(framesize)) {
   22.15 +  if (C->need_stack_bang(bangsize)) {
   22.16      framesize -= wordSize;
   22.17 -    st->print("# stack bang");
   22.18 +    st->print("# stack bang (%d bytes)", bangsize);
   22.19      st->print("\n\t");
   22.20      st->print("pushq   rbp\t# Save rbp");
   22.21      if (framesize) {
   22.22 @@ -751,9 +752,10 @@
   22.23    Compile* C = ra_->C;
   22.24    MacroAssembler _masm(&cbuf);
   22.25  
   22.26 -  int framesize = C->frame_slots() << LogBytesPerInt;
   22.27 -
   22.28 -  __ verified_entry(framesize, C->need_stack_bang(framesize), false);
   22.29 +  int framesize = C->frame_size_in_bytes();
   22.30 +  int bangsize = C->bang_size_in_bytes();
   22.31 +
   22.32 +  __ verified_entry(framesize, C->need_stack_bang(bangsize)?bangsize:0, false);
   22.33  
   22.34    C->set_frame_complete(cbuf.insts_size());
   22.35  
   22.36 @@ -786,7 +788,7 @@
   22.37      st->cr(); st->print("\t");
   22.38    }
   22.39  
   22.40 -  int framesize = C->frame_slots() << LogBytesPerInt;
   22.41 +  int framesize = C->frame_size_in_bytes();
   22.42    assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
   22.43    // Remove word for return adr already pushed
   22.44    // and RBP
   22.45 @@ -822,7 +824,7 @@
   22.46      __ vzeroupper();
   22.47    }
   22.48  
   22.49 -  int framesize = C->frame_slots() << LogBytesPerInt;
   22.50 +  int framesize = C->frame_size_in_bytes();
   22.51    assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
   22.52    // Remove word for return adr already pushed
   22.53    // and RBP
    23.1 --- a/src/cpu/zero/vm/cppInterpreter_zero.cpp	Mon Jun 09 15:42:31 2014 -0700
    23.2 +++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp	Tue Apr 01 09:36:49 2014 +0200
    23.3 @@ -916,17 +916,32 @@
    23.4    return (InterpreterFrame *) fp;
    23.5  }
    23.6  
    23.7 -int AbstractInterpreter::layout_activation(Method* method,
    23.8 -                                           int       tempcount,
    23.9 -                                           int       popframe_extra_args,
   23.10 -                                           int       moncount,
   23.11 -                                           int       caller_actual_parameters,
   23.12 -                                           int       callee_param_count,
   23.13 -                                           int       callee_locals,
   23.14 -                                           frame*    caller,
   23.15 -                                           frame*    interpreter_frame,
   23.16 -                                           bool      is_top_frame,
   23.17 -                                           bool      is_bottom_frame) {
   23.18 +int AbstractInterpreter::size_activation(int       max_stack,
   23.19 +                                         int       tempcount,
   23.20 +                                         int       extra_args,
   23.21 +                                         int       moncount,
   23.22 +                                         int       callee_param_count,
   23.23 +                                         int       callee_locals,
   23.24 +                                         bool      is_top_frame) {
   23.25 +  int header_words        = InterpreterFrame::header_words;
   23.26 +  int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
   23.27 +  int stack_words         = is_top_frame ? max_stack : tempcount;
   23.28 +  int callee_extra_locals = callee_locals - callee_param_count;
   23.29 +
   23.30 +  return header_words + monitor_words + stack_words + callee_extra_locals;
   23.31 +}
   23.32 +
   23.33 +void AbstractInterpreter::layout_activation(Method* method,
   23.34 +                                            int       tempcount,
   23.35 +                                            int       popframe_extra_args,
   23.36 +                                            int       moncount,
   23.37 +                                            int       caller_actual_parameters,
   23.38 +                                            int       callee_param_count,
   23.39 +                                            int       callee_locals,
   23.40 +                                            frame*    caller,
   23.41 +                                            frame*    interpreter_frame,
   23.42 +                                            bool      is_top_frame,
   23.43 +                                            bool      is_bottom_frame) {
   23.44    assert(popframe_extra_args == 0, "what to do?");
   23.45    assert(!is_top_frame || (!callee_locals && !callee_param_count),
   23.46           "top frame should have no caller");
   23.47 @@ -935,39 +950,31 @@
   23.48    // does (the full InterpreterFrame::build, that is, not the
   23.49    // one that creates empty frames for the deoptimizer).
   23.50    //
   23.51 -  // If interpreter_frame is not NULL then it will be filled in.
   23.52 -  // It's size is determined by a previous call to this method,
   23.53 -  // so it should be correct.
   23.54 +  // interpreter_frame will be filled in.  It's size is determined by
   23.55 +  // a previous call to the size_activation() method,
   23.56    //
   23.57    // Note that tempcount is the current size of the expression
   23.58    // stack.  For top most frames we will allocate a full sized
   23.59    // expression stack and not the trimmed version that non-top
   23.60    // frames have.
   23.61  
   23.62 -  int header_words        = InterpreterFrame::header_words;
   23.63    int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
   23.64 -  int stack_words         = is_top_frame ? method->max_stack() : tempcount;
   23.65 -  int callee_extra_locals = callee_locals - callee_param_count;
   23.66 +  intptr_t *locals        = interpreter_frame->fp() + method->max_locals();
   23.67 +  interpreterState istate = interpreter_frame->get_interpreterState();
   23.68 +  intptr_t *monitor_base  = (intptr_t*) istate;
   23.69 +  intptr_t *stack_base    = monitor_base - monitor_words;
   23.70 +  intptr_t *stack         = stack_base - tempcount - 1;
   23.71  
   23.72 -  if (interpreter_frame) {
   23.73 -    intptr_t *locals        = interpreter_frame->fp() + method->max_locals();
   23.74 -    interpreterState istate = interpreter_frame->get_interpreterState();
   23.75 -    intptr_t *monitor_base  = (intptr_t*) istate;
   23.76 -    intptr_t *stack_base    = monitor_base - monitor_words;
   23.77 -    intptr_t *stack         = stack_base - tempcount - 1;
   23.78 -
   23.79 -    BytecodeInterpreter::layout_interpreterState(istate,
   23.80 -                                                 caller,
   23.81 -                                                 NULL,
   23.82 -                                                 method,
   23.83 -                                                 locals,
   23.84 -                                                 stack,
   23.85 -                                                 stack_base,
   23.86 -                                                 monitor_base,
   23.87 -                                                 NULL,
   23.88 -                                                 is_top_frame);
   23.89 -  }
   23.90 -  return header_words + monitor_words + stack_words + callee_extra_locals;
   23.91 +  BytecodeInterpreter::layout_interpreterState(istate,
   23.92 +                                               caller,
   23.93 +                                               NULL,
   23.94 +                                               method,
   23.95 +                                               locals,
   23.96 +                                               stack,
   23.97 +                                               stack_base,
   23.98 +                                               monitor_base,
   23.99 +                                               NULL,
  23.100 +                                               is_top_frame);
  23.101  }
  23.102  
  23.103  void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
    24.1 --- a/src/share/vm/c1/c1_Compilation.cpp	Mon Jun 09 15:42:31 2014 -0700
    24.2 +++ b/src/share/vm/c1/c1_Compilation.cpp	Tue Apr 01 09:36:49 2014 +0200
    24.3 @@ -546,6 +546,7 @@
    24.4  , _code(buffer_blob)
    24.5  , _has_access_indexed(false)
    24.6  , _current_instruction(NULL)
    24.7 +, _interpreter_frame_size(0)
    24.8  #ifndef PRODUCT
    24.9  , _last_instruction_printed(NULL)
   24.10  #endif // PRODUCT
    25.1 --- a/src/share/vm/c1/c1_Compilation.hpp	Mon Jun 09 15:42:31 2014 -0700
    25.2 +++ b/src/share/vm/c1/c1_Compilation.hpp	Tue Apr 01 09:36:49 2014 +0200
    25.3 @@ -88,6 +88,7 @@
    25.4    CodeOffsets        _offsets;
    25.5    CodeBuffer         _code;
    25.6    bool               _has_access_indexed;
    25.7 +  int                _interpreter_frame_size; // Stack space needed in case of a deoptimization
    25.8  
    25.9    // compilation helpers
   25.10    void initialize();
   25.11 @@ -262,6 +263,18 @@
   25.12  
   25.13    // Dump inlining replay data to the stream.
   25.14    void dump_inline_data(outputStream* out) { /* do nothing now */ }
   25.15 +
   25.16 +  // How much stack space would the interpreter need in case of a
   25.17 +  // deoptimization (worst case)
   25.18 +  void update_interpreter_frame_size(int size) {
   25.19 +    if (_interpreter_frame_size < size) {
   25.20 +      _interpreter_frame_size = size;
   25.21 +    }
   25.22 +  }
   25.23 +
   25.24 +  int interpreter_frame_size() const {
   25.25 +    return _interpreter_frame_size;
   25.26 +  }
   25.27  };
   25.28  
   25.29  
    26.1 --- a/src/share/vm/c1/c1_IR.cpp	Mon Jun 09 15:42:31 2014 -0700
    26.2 +++ b/src/share/vm/c1/c1_IR.cpp	Tue Apr 01 09:36:49 2014 +0200
    26.3 @@ -226,8 +226,38 @@
    26.4    _oop_map->set_oop(name);
    26.5  }
    26.6  
    26.7 +// Mirror the stack size calculation in the deopt code
    26.8 +// How much stack space would we need at this point in the program in
    26.9 +// case of deoptimization?
   26.10 +int CodeEmitInfo::interpreter_frame_size() const {
   26.11 +  ValueStack* state = _stack;
   26.12 +  int size = 0;
   26.13 +  int callee_parameters = 0;
   26.14 +  int callee_locals = 0;
   26.15 +  int extra_args = state->scope()->method()->max_stack() - state->stack_size();
   26.16  
   26.17 +  while (state != NULL) {
   26.18 +    int locks = state->locks_size();
   26.19 +    int temps = state->stack_size();
   26.20 +    bool is_top_frame = (state == _stack);
   26.21 +    ciMethod* method = state->scope()->method();
   26.22  
   26.23 +    int frame_size = BytesPerWord * Interpreter::size_activation(method->max_stack(),
   26.24 +                                                                 temps + callee_parameters,
   26.25 +                                                                 extra_args,
   26.26 +                                                                 locks,
   26.27 +                                                                 callee_parameters,
   26.28 +                                                                 callee_locals,
   26.29 +                                                                 is_top_frame);
   26.30 +    size += frame_size;
   26.31 +
   26.32 +    callee_parameters = method->size_of_parameters();
   26.33 +    callee_locals = method->max_locals();
   26.34 +    extra_args = 0;
   26.35 +    state = state->caller_state();
   26.36 +  }
   26.37 +  return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord;
   26.38 +}
   26.39  
   26.40  // Implementation of IR
   26.41  
    27.1 --- a/src/share/vm/c1/c1_IR.hpp	Mon Jun 09 15:42:31 2014 -0700
    27.2 +++ b/src/share/vm/c1/c1_IR.hpp	Tue Apr 01 09:36:49 2014 +0200
    27.3 @@ -280,6 +280,8 @@
    27.4  
    27.5    bool     is_method_handle_invoke() const { return _is_method_handle_invoke;     }
    27.6    void set_is_method_handle_invoke(bool x) {        _is_method_handle_invoke = x; }
    27.7 +
    27.8 +  int interpreter_frame_size() const;
    27.9  };
   27.10  
   27.11  
    28.1 --- a/src/share/vm/c1/c1_LIRAssembler.cpp	Mon Jun 09 15:42:31 2014 -0700
    28.2 +++ b/src/share/vm/c1/c1_LIRAssembler.cpp	Tue Apr 01 09:36:49 2014 +0200
    28.3 @@ -185,6 +185,13 @@
    28.4    return _masm->pc();
    28.5  }
    28.6  
    28.7 +// To bang the stack of this compiled method we use the stack size
    28.8 +// that the interpreter would need in case of a deoptimization. This
    28.9 +// removes the need to bang the stack in the deoptimization blob which
   28.10 +// in turn simplifies stack overflow handling.
   28.11 +int LIR_Assembler::bang_size_in_bytes() const {
   28.12 +  return MAX2(initial_frame_size_in_bytes(), _compilation->interpreter_frame_size());
   28.13 +}
   28.14  
   28.15  void LIR_Assembler::emit_exception_entries(ExceptionInfoList* info_list) {
   28.16    for (int i = 0; i < info_list->length(); i++) {
   28.17 @@ -792,7 +799,7 @@
   28.18  
   28.19  
   28.20  void LIR_Assembler::build_frame() {
   28.21 -  _masm->build_frame(initial_frame_size_in_bytes());
   28.22 +  _masm->build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
   28.23  }
   28.24  
   28.25  
    29.1 --- a/src/share/vm/c1/c1_LIRAssembler.hpp	Mon Jun 09 15:42:31 2014 -0700
    29.2 +++ b/src/share/vm/c1/c1_LIRAssembler.hpp	Tue Apr 01 09:36:49 2014 +0200
    29.3 @@ -132,7 +132,8 @@
    29.4    int code_offset() const;
    29.5    address pc() const;
    29.6  
    29.7 -  int  initial_frame_size_in_bytes();
    29.8 +  int  initial_frame_size_in_bytes() const;
    29.9 +  int  bang_size_in_bytes() const;
   29.10  
   29.11    // test for constants which can be encoded directly in instructions
   29.12    static bool is_small_constant(LIR_Opr opr);
    30.1 --- a/src/share/vm/c1/c1_LinearScan.cpp	Mon Jun 09 15:42:31 2014 -0700
    30.2 +++ b/src/share/vm/c1/c1_LinearScan.cpp	Tue Apr 01 09:36:49 2014 +0200
    30.3 @@ -2441,6 +2441,9 @@
    30.4      CodeEmitInfo* info = visitor.info_at(i);
    30.5      OopMap* oop_map = first_oop_map;
    30.6  
    30.7 +    // compute worst case interpreter size in case of a deoptimization
    30.8 +    _compilation->update_interpreter_frame_size(info->interpreter_frame_size());
    30.9 +
   30.10      if (info->stack()->locks_size() != first_info->stack()->locks_size()) {
   30.11        // this info has a different number of locks then the precomputed oop map
   30.12        // (possible for lock and unlock instructions) -> compute oop map with
    31.1 --- a/src/share/vm/c1/c1_MacroAssembler.hpp	Mon Jun 09 15:42:31 2014 -0700
    31.2 +++ b/src/share/vm/c1/c1_MacroAssembler.hpp	Tue Apr 01 09:36:49 2014 +0200
    31.3 @@ -39,7 +39,7 @@
    31.4    void explicit_null_check(Register base);
    31.5  
    31.6    void inline_cache_check(Register receiver, Register iCache);
    31.7 -  void build_frame(int frame_size_in_bytes);
    31.8 +  void build_frame(int frame_size_in_bytes, int bang_size_in_bytes);
    31.9    void remove_frame(int frame_size_in_bytes);
   31.10  
   31.11    void unverified_entry(Register receiver, Register ic_klass);
    32.1 --- a/src/share/vm/ci/ciMethod.cpp	Mon Jun 09 15:42:31 2014 -0700
    32.2 +++ b/src/share/vm/ci/ciMethod.cpp	Tue Apr 01 09:36:49 2014 +0200
    32.3 @@ -80,6 +80,7 @@
    32.4    _code_size          = h_m()->code_size();
    32.5    _intrinsic_id       = h_m()->intrinsic_id();
    32.6    _handler_count      = h_m()->exception_table_length();
    32.7 +  _size_of_parameters = h_m()->size_of_parameters();
    32.8    _uses_monitors      = h_m()->access_flags().has_monitor_bytecodes();
    32.9    _balanced_monitors  = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
   32.10    _is_c1_compilable   = !h_m()->is_not_c1_compilable();
    33.1 --- a/src/share/vm/ci/ciMethod.hpp	Mon Jun 09 15:42:31 2014 -0700
    33.2 +++ b/src/share/vm/ci/ciMethod.hpp	Tue Apr 01 09:36:49 2014 +0200
    33.3 @@ -71,6 +71,7 @@
    33.4    int _interpreter_invocation_count;
    33.5    int _interpreter_throwout_count;
    33.6    int _instructions_size;
    33.7 +  int _size_of_parameters;
    33.8  
    33.9    bool _uses_monitors;
   33.10    bool _balanced_monitors;
   33.11 @@ -166,6 +167,7 @@
   33.12    int exception_table_length() const             { check_is_loaded(); return _handler_count; }
   33.13    int interpreter_invocation_count() const       { check_is_loaded(); return _interpreter_invocation_count; }
   33.14    int interpreter_throwout_count() const         { check_is_loaded(); return _interpreter_throwout_count; }
   33.15 +  int size_of_parameters() const                 { check_is_loaded(); return _size_of_parameters; }
   33.16  
   33.17    // Code size for inlining decisions.
   33.18    int code_size_for_inlining();
   33.19 @@ -241,7 +243,6 @@
   33.20  
   33.21    ciField*      get_field_at_bci( int bci, bool &will_link);
   33.22    ciMethod*     get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature);
   33.23 -
   33.24    // Given a certain calling environment, find the monomorphic target
   33.25    // for the call.  Return NULL if the call is not monomorphic in
   33.26    // its calling environment.
    34.1 --- a/src/share/vm/interpreter/abstractInterpreter.hpp	Mon Jun 09 15:42:31 2014 -0700
    34.2 +++ b/src/share/vm/interpreter/abstractInterpreter.hpp	Tue Apr 01 09:36:49 2014 +0200
    34.3 @@ -181,30 +181,16 @@
    34.4    // Deoptimization should reexecute this bytecode
    34.5    static bool    bytecode_should_reexecute(Bytecodes::Code code);
    34.6  
    34.7 -  // share implementation of size_activation and layout_activation:
    34.8 -  static int        size_activation(Method* method,
    34.9 +  // deoptimization support
   34.10 +  static int        size_activation(int max_stack,
   34.11                                      int temps,
   34.12 -                                    int popframe_args,
   34.13 +                                    int extra_args,
   34.14                                      int monitors,
   34.15 -                                    int caller_actual_parameters,
   34.16                                      int callee_params,
   34.17                                      int callee_locals,
   34.18 -                                    bool is_top_frame,
   34.19 -                                    bool is_bottom_frame) {
   34.20 -    return layout_activation(method,
   34.21 -                             temps,
   34.22 -                             popframe_args,
   34.23 -                             monitors,
   34.24 -                             caller_actual_parameters,
   34.25 -                             callee_params,
   34.26 -                             callee_locals,
   34.27 -                             (frame*)NULL,
   34.28 -                             (frame*)NULL,
   34.29 -                             is_top_frame,
   34.30 -                             is_bottom_frame);
   34.31 -  }
   34.32 +                                    bool is_top_frame);
   34.33  
   34.34 -  static int       layout_activation(Method* method,
   34.35 +  static void      layout_activation(Method* method,
   34.36                                       int temps,
   34.37                                       int popframe_args,
   34.38                                       int monitors,
    35.1 --- a/src/share/vm/opto/callnode.cpp	Mon Jun 09 15:42:31 2014 -0700
    35.2 +++ b/src/share/vm/opto/callnode.cpp	Tue Apr 01 09:36:49 2014 +0200
    35.3 @@ -607,6 +607,39 @@
    35.4    }
    35.5  }
    35.6  
    35.7 +// Mirror the stack size calculation in the deopt code
    35.8 +// How much stack space would we need at this point in the program in
    35.9 +// case of deoptimization?
   35.10 +int JVMState::interpreter_frame_size() const {
   35.11 +  const JVMState* jvms = this;
   35.12 +  int size = 0;
   35.13 +  int callee_parameters = 0;
   35.14 +  int callee_locals = 0;
   35.15 +  int extra_args = method()->max_stack() - stk_size();
   35.16 +
   35.17 +  while (jvms != NULL) {
   35.18 +    int locks = jvms->nof_monitors();
   35.19 +    int temps = jvms->stk_size();
   35.20 +    bool is_top_frame = (jvms == this);
   35.21 +    ciMethod* method = jvms->method();
   35.22 +
   35.23 +    int frame_size = BytesPerWord * Interpreter::size_activation(method->max_stack(),
   35.24 +                                                                 temps + callee_parameters,
   35.25 +                                                                 extra_args,
   35.26 +                                                                 locks,
   35.27 +                                                                 callee_parameters,
   35.28 +                                                                 callee_locals,
   35.29 +                                                                 is_top_frame);
   35.30 +    size += frame_size;
   35.31 +
   35.32 +    callee_parameters = method->size_of_parameters();
   35.33 +    callee_locals = method->max_locals();
   35.34 +    extra_args = 0;
   35.35 +    jvms = jvms->caller();
   35.36 +  }
   35.37 +  return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord;
   35.38 +}
   35.39 +
   35.40  //=============================================================================
   35.41  uint CallNode::cmp( const Node &n ) const
   35.42  { return _tf == ((CallNode&)n)._tf && _jvms == ((CallNode&)n)._jvms; }
    36.1 --- a/src/share/vm/opto/callnode.hpp	Mon Jun 09 15:42:31 2014 -0700
    36.2 +++ b/src/share/vm/opto/callnode.hpp	Tue Apr 01 09:36:49 2014 +0200
    36.3 @@ -300,6 +300,7 @@
    36.4    JVMState* clone_shallow(Compile* C) const; // retains uncloned caller
    36.5    void      set_map_deep(SafePointNode *map);// reset map for all callers
    36.6    void      adapt_position(int delta);       // Adapt offsets in in-array after adding an edge.
    36.7 +  int       interpreter_frame_size() const;
    36.8  
    36.9  #ifndef PRODUCT
   36.10    void      format(PhaseRegAlloc *regalloc, const Node *n, outputStream* st) const;
    37.1 --- a/src/share/vm/opto/compile.cpp	Mon Jun 09 15:42:31 2014 -0700
    37.2 +++ b/src/share/vm/opto/compile.cpp	Tue Apr 01 09:36:49 2014 +0200
    37.3 @@ -439,6 +439,14 @@
    37.4    return words;
    37.5  }
    37.6  
    37.7 +// To bang the stack of this compiled method we use the stack size
    37.8 +// that the interpreter would need in case of a deoptimization. This
    37.9 +// removes the need to bang the stack in the deoptimization blob which
   37.10 +// in turn simplifies stack overflow handling.
   37.11 +int Compile::bang_size_in_bytes() const {
   37.12 +  return MAX2(_interpreter_frame_size, frame_size_in_bytes());
   37.13 +}
   37.14 +
   37.15  // ============================================================================
   37.16  //------------------------------CompileWrapper---------------------------------
   37.17  class CompileWrapper : public StackObj {
   37.18 @@ -662,7 +670,8 @@
   37.19                    _inlining_incrementally(false),
   37.20                    _print_inlining_list(NULL),
   37.21                    _print_inlining_idx(0),
   37.22 -                  _preserve_jvm_state(0) {
   37.23 +                  _preserve_jvm_state(0),
   37.24 +                  _interpreter_frame_size(0) {
   37.25    C = this;
   37.26  
   37.27    CompileWrapper cw(this);
   37.28 @@ -969,7 +978,8 @@
   37.29      _print_inlining_list(NULL),
   37.30      _print_inlining_idx(0),
   37.31      _preserve_jvm_state(0),
   37.32 -    _allowed_reasons(0) {
   37.33 +    _allowed_reasons(0),
   37.34 +    _interpreter_frame_size(0) {
   37.35    C = this;
   37.36  
   37.37  #ifndef PRODUCT
   37.38 @@ -3078,8 +3088,12 @@
   37.39        Node* m = n->in(i);
   37.40        ++i;
   37.41        if (m != NULL && !frc._visited.test_set(m->_idx)) {
   37.42 -        if (m->is_SafePoint() && m->as_SafePoint()->jvms() != NULL)
   37.43 +        if (m->is_SafePoint() && m->as_SafePoint()->jvms() != NULL) {
   37.44 +          // compute worst case interpreter size in case of a deoptimization
   37.45 +          update_interpreter_frame_size(m->as_SafePoint()->jvms()->interpreter_frame_size());
   37.46 +
   37.47            sfpt.push(m);
   37.48 +        }
   37.49          cnt = m->req();
   37.50          nstack.push(n, i); // put on stack parent and next input's index
   37.51          n = m;
    38.1 --- a/src/share/vm/opto/compile.hpp	Mon Jun 09 15:42:31 2014 -0700
    38.2 +++ b/src/share/vm/opto/compile.hpp	Tue Apr 01 09:36:49 2014 +0200
    38.3 @@ -487,6 +487,7 @@
    38.4    RegMask               _FIRST_STACK_mask;      // All stack slots usable for spills (depends on frame layout)
    38.5    Arena*                _indexSet_arena;        // control IndexSet allocation within PhaseChaitin
    38.6    void*                 _indexSet_free_block_list; // free list of IndexSet bit blocks
    38.7 +  int                   _interpreter_frame_size;
    38.8  
    38.9    uint                  _node_bundling_limit;
   38.10    Bundle*               _node_bundling_base;    // Information for instruction bundling
   38.11 @@ -946,6 +947,7 @@
   38.12    PhaseRegAlloc*    regalloc()                  { return _regalloc; }
   38.13    int               frame_slots() const         { return _frame_slots; }
   38.14    int               frame_size_in_words() const; // frame_slots in units of the polymorphic 'words'
   38.15 +  int               frame_size_in_bytes() const { return _frame_slots << LogBytesPerInt; }
   38.16    RegMask&          FIRST_STACK_mask()          { return _FIRST_STACK_mask; }
   38.17    Arena*            indexSet_arena()            { return _indexSet_arena; }
   38.18    void*             indexSet_free_block_list()  { return _indexSet_free_block_list; }
   38.19 @@ -957,6 +959,13 @@
   38.20    bool          need_stack_bang(int frame_size_in_bytes) const;
   38.21    bool          need_register_stack_bang() const;
   38.22  
   38.23 +  void  update_interpreter_frame_size(int size) {
   38.24 +    if (_interpreter_frame_size < size) {
   38.25 +      _interpreter_frame_size = size;
   38.26 +    }
   38.27 +  }
   38.28 +  int           bang_size_in_bytes() const;
   38.29 +
   38.30    void          set_matcher(Matcher* m)                 { _matcher = m; }
   38.31  //void          set_regalloc(PhaseRegAlloc* ra)           { _regalloc = ra; }
   38.32    void          set_indexSet_arena(Arena* a)            { _indexSet_arena = a; }
    39.1 --- a/src/share/vm/opto/output.cpp	Mon Jun 09 15:42:31 2014 -0700
    39.2 +++ b/src/share/vm/opto/output.cpp	Tue Apr 01 09:36:49 2014 +0200
    39.3 @@ -165,8 +165,13 @@
    39.4    // Determine if we need to generate a stack overflow check.
    39.5    // Do it if the method is not a stub function and
    39.6    // has java calls or has frame size > vm_page_size/8.
    39.7 +  // The debug VM checks that deoptimization doesn't trigger an
    39.8 +  // unexpected stack overflow (compiled method stack banging should
    39.9 +  // guarantee it doesn't happen) so we always need the stack bang in
   39.10 +  // a debug VM.
   39.11    return (UseStackBanging && stub_function() == NULL &&
   39.12 -          (has_java_calls() || frame_size_in_bytes > os::vm_page_size()>>3));
   39.13 +          (has_java_calls() || frame_size_in_bytes > os::vm_page_size()>>3
   39.14 +           DEBUG_ONLY(|| true)));
   39.15  }
   39.16  
   39.17  bool Compile::need_register_stack_bang() const {
    40.1 --- a/src/share/vm/runtime/deoptimization.cpp	Mon Jun 09 15:42:31 2014 -0700
    40.2 +++ b/src/share/vm/runtime/deoptimization.cpp	Tue Apr 01 09:36:49 2014 +0200
    40.3 @@ -422,15 +422,9 @@
    40.4      // frame[number_of_frames - 1 ] = on_stack_size(youngest)
    40.5      // frame[number_of_frames - 2 ] = on_stack_size(sender(youngest))
    40.6      // frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest)))
    40.7 -    int caller_parms = callee_parameters;
    40.8 -    if ((index == array->frames() - 1) && caller_was_method_handle) {
    40.9 -      caller_parms = 0;
   40.10 -    }
   40.11 -    frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(caller_parms,
   40.12 -                                                                                                    callee_parameters,
   40.13 +    frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(callee_parameters,
   40.14                                                                                                      callee_locals,
   40.15                                                                                                      index == 0,
   40.16 -                                                                                                    index == array->frames() - 1,
   40.17                                                                                                      popframe_extra_args);
   40.18      // This pc doesn't have to be perfect just good enough to identify the frame
   40.19      // as interpreted so the skeleton frame will be walkable
    41.1 --- a/src/share/vm/runtime/sharedRuntime.cpp	Mon Jun 09 15:42:31 2014 -0700
    41.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp	Tue Apr 01 09:36:49 2014 +0200
    41.3 @@ -785,10 +785,13 @@
    41.4          // going to be unwound. Dispatch to a shared runtime stub
    41.5          // which will cause the StackOverflowError to be fabricated
    41.6          // and processed.
    41.7 -        // For stack overflow in deoptimization blob, cleanup thread.
    41.8 -        if (thread->deopt_mark() != NULL) {
    41.9 -          Deoptimization::cleanup_deopt_info(thread, NULL);
   41.10 -        }
   41.11 +        // Stack overflow should never occur during deoptimization:
   41.12 +        // the compiled method bangs the stack by as much as the
   41.13 +        // interpreter would need in case of a deoptimization. The
   41.14 +        // deoptimization blob and uncommon trap blob bang the stack
   41.15 +        // in a debug VM to verify the correctness of the compiled
   41.16 +        // method stack banging.
   41.17 +        assert(thread->deopt_mark() == NULL, "no stack overflow from deopt blob/uncommon trap");
   41.18          Events::log_exception(thread, "StackOverflowError at " INTPTR_FORMAT, pc);
   41.19          return StubRoutines::throw_StackOverflowError_entry();
   41.20        }
    42.1 --- a/src/share/vm/runtime/vframeArray.cpp	Mon Jun 09 15:42:31 2014 -0700
    42.2 +++ b/src/share/vm/runtime/vframeArray.cpp	Tue Apr 01 09:36:49 2014 +0200
    42.3 @@ -419,24 +419,20 @@
    42.4  
    42.5  }
    42.6  
    42.7 -int vframeArrayElement::on_stack_size(int caller_actual_parameters,
    42.8 -                                      int callee_parameters,
    42.9 +int vframeArrayElement::on_stack_size(int callee_parameters,
   42.10                                        int callee_locals,
   42.11                                        bool is_top_frame,
   42.12 -                                      bool is_bottom_frame,
   42.13                                        int popframe_extra_stack_expression_els) const {
   42.14    assert(method()->max_locals() == locals()->size(), "just checking");
   42.15    int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors();
   42.16    int temps = expressions()->size();
   42.17 -  return Interpreter::size_activation(method(),
   42.18 +  return Interpreter::size_activation(method()->max_stack(),
   42.19                                        temps + callee_parameters,
   42.20                                        popframe_extra_stack_expression_els,
   42.21                                        locks,
   42.22 -                                      caller_actual_parameters,
   42.23                                        callee_parameters,
   42.24                                        callee_locals,
   42.25 -                                      is_top_frame,
   42.26 -                                      is_bottom_frame);
   42.27 +                                      is_top_frame);
   42.28  }
   42.29  
   42.30  
    43.1 --- a/src/share/vm/runtime/vframeArray.hpp	Mon Jun 09 15:42:31 2014 -0700
    43.2 +++ b/src/share/vm/runtime/vframeArray.hpp	Tue Apr 01 09:36:49 2014 +0200
    43.3 @@ -85,10 +85,8 @@
    43.4  
    43.5    // Returns the on stack word size for this frame
    43.6    // callee_parameters is the number of callee locals residing inside this frame
    43.7 -  int on_stack_size(int caller_actual_parameters,
    43.8 -                    int callee_parameters,
    43.9 +  int on_stack_size(int callee_parameters,
   43.10                      int callee_locals,
   43.11 -                    bool is_bottom_frame,
   43.12                      bool is_top_frame,
   43.13                      int popframe_extra_stack_expression_els) const;
   43.14  
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/test/compiler/uncommontrap/TestStackBangMonitorOwned.java	Tue Apr 01 09:36:49 2014 +0200
    44.3 @@ -0,0 +1,268 @@
    44.4 +/*
    44.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    44.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.7 + *
    44.8 + * This code is free software; you can redistribute it and/or modify it
    44.9 + * under the terms of the GNU General Public License version 2 only, as
   44.10 + * published by the Free Software Foundation.
   44.11 + *
   44.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   44.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   44.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   44.15 + * version 2 for more details (a copy is included in the LICENSE file that
   44.16 + * accompanied this code).
   44.17 + *
   44.18 + * You should have received a copy of the GNU General Public License version
   44.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   44.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   44.21 + *
   44.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   44.23 + * or visit www.oracle.com if you need additional information or have any
   44.24 + * questions.
   44.25 + */
   44.26 +
   44.27 +/*
   44.28 + * @test
   44.29 + * @bug 8032410
   44.30 + * @summary Stack overflow at deoptimization doesn't release owned monitors
   44.31 + * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangMonitorOwned::m1 -XX:CompileCommand=exclude,TestStackBangMonitorOwned::m2 -Xss256K -XX:-UseOnStackReplacement TestStackBangMonitorOwned
   44.32 + *
   44.33 + */
   44.34 +public class TestStackBangMonitorOwned {
   44.35 +
   44.36 +    static class UnloadedClass1 {
   44.37 +        volatile int field;
   44.38 +    }
   44.39 +
   44.40 +    static Object m1(boolean deopt) {
   44.41 +        long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
   44.42 +        l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
   44.43 +        l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
   44.44 +        l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
   44.45 +        l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
   44.46 +        l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
   44.47 +        l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
   44.48 +        l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,
   44.49 +        l97, l98, l99, l100, l101, l102, l103, l104, l105, l106, l107,
   44.50 +        l108, l109, l110, l111, l112, l113, l114, l115, l116, l117,
   44.51 +        l118, l119, l120, l121, l122, l123, l124, l125, l126, l127,
   44.52 +        l128, l129, l130, l131, l132, l133, l134, l135, l136, l137,
   44.53 +        l138, l139, l140, l141, l142, l143, l144, l145, l146, l147,
   44.54 +        l148, l149, l150, l151, l152, l153, l154, l155, l156, l157,
   44.55 +        l158, l159, l160, l161, l162, l163, l164, l165, l166, l167,
   44.56 +        l168, l169, l170, l171, l172, l173, l174, l175, l176, l177,
   44.57 +        l178, l179, l180, l181, l182, l183, l184, l185, l186, l187,
   44.58 +        l188, l189, l190, l191, l192, l193, l194, l195, l196, l197,
   44.59 +        l198, l199, l200, l201, l202, l203, l204, l205, l206, l207,
   44.60 +        l208, l209, l210, l211, l212, l213, l214, l215, l216, l217,
   44.61 +        l218, l219, l220, l221, l222, l223, l224, l225, l226, l227,
   44.62 +        l228, l229, l230, l231, l232, l233, l234, l235, l236, l237,
   44.63 +        l238, l239, l240, l241, l242, l243, l244, l245, l246, l247,
   44.64 +        l248, l249, l250, l251, l252, l253, l254, l255, l256, l257,
   44.65 +        l258, l259, l260, l261, l262, l263, l264, l265, l266, l267,
   44.66 +        l268, l269, l270, l271, l272, l273, l274, l275, l276, l277,
   44.67 +        l278, l279, l280, l281, l282, l283, l284, l285, l286, l287,
   44.68 +        l288, l289, l290, l291, l292, l293, l294, l295, l296, l297,
   44.69 +        l298, l299, l300, l301, l302, l303, l304, l305, l306, l307,
   44.70 +        l308, l309, l310, l311, l312, l313, l314, l315, l316, l317,
   44.71 +        l318, l319, l320, l321, l322, l323, l324, l325, l326, l327,
   44.72 +        l328, l329, l330, l331, l332, l333, l334, l335, l336, l337,
   44.73 +        l338, l339, l340, l341, l342, l343, l344, l345, l346, l347,
   44.74 +        l348, l349, l350, l351, l352, l353, l354, l355, l356, l357,
   44.75 +        l358, l359, l360, l361, l362, l363, l364, l365, l366, l367,
   44.76 +        l368, l369, l370, l371, l372, l373, l374, l375, l376, l377,
   44.77 +        l378, l379, l380, l381, l382, l383, l384, l385, l386, l387,
   44.78 +        l388, l389, l390, l391, l392, l393, l394, l395, l396, l397,
   44.79 +        l398, l399, l400, l401, l402, l403, l404, l405, l406, l407,
   44.80 +        l408, l409, l410, l411, l412, l413, l414, l415, l416, l417,
   44.81 +        l418, l419, l420, l421, l422, l423, l424, l425, l426, l427,
   44.82 +        l428, l429, l430, l431, l432, l433, l434, l435, l436, l437,
   44.83 +        l438, l439, l440, l441, l442, l443, l444, l445, l446, l447,
   44.84 +        l448, l449, l450, l451, l452, l453, l454, l455, l456, l457,
   44.85 +        l458, l459, l460, l461, l462, l463, l464, l465, l466, l467,
   44.86 +        l468, l469, l470, l471, l472, l473, l474, l475, l476, l477,
   44.87 +        l478, l479, l480, l481, l482, l483, l484, l485, l486, l487,
   44.88 +        l488, l489, l490, l491, l492, l493, l494, l495, l496, l497,
   44.89 +        l498, l499, l500, l501, l502, l503, l504, l505, l506, l507,
   44.90 +        l508, l509, l510, l511;
   44.91 +
   44.92 +        long ll0, ll1, ll2, ll3, ll4, ll5, ll6, ll7, ll8, ll9, ll10, ll11, ll12,
   44.93 +        ll13, ll14, ll15, ll16, ll17, ll18, ll19, ll20, ll21, ll22, ll23, ll24,
   44.94 +        ll25, ll26, ll27, ll28, ll29, ll30, ll31, ll32, ll33, ll34, ll35, ll36,
   44.95 +        ll37, ll38, ll39, ll40, ll41, ll42, ll43, ll44, ll45, ll46, ll47, ll48,
   44.96 +        ll49, ll50, ll51, ll52, ll53, ll54, ll55, ll56, ll57, ll58, ll59, ll60,
   44.97 +        ll61, ll62, ll63, ll64, ll65, ll66, ll67, ll68, ll69, ll70, ll71, ll72,
   44.98 +        ll73, ll74, ll75, ll76, ll77, ll78, ll79, ll80, ll81, ll82, ll83, ll84,
   44.99 +        ll85, ll86, ll87, ll88, ll89, ll90, ll91, ll92, ll93, ll94, ll95, ll96,
  44.100 +        ll97, ll98, ll99, ll100, ll101, ll102, ll103, ll104, ll105, ll106, ll107,
  44.101 +        ll108, ll109, ll110, ll111, ll112, ll113, ll114, ll115, ll116, ll117,
  44.102 +        ll118, ll119, ll120, ll121, ll122, ll123, ll124, ll125, ll126, ll127,
  44.103 +        ll128, ll129, ll130, ll131, ll132, ll133, ll134, ll135, ll136, ll137,
  44.104 +        ll138, ll139, ll140, ll141, ll142, ll143, ll144, ll145, ll146, ll147,
  44.105 +        ll148, ll149, ll150, ll151, ll152, ll153, ll154, ll155, ll156, ll157,
  44.106 +        ll158, ll159, ll160, ll161, ll162, ll163, ll164, ll165, ll166, ll167,
  44.107 +        ll168, ll169, ll170, ll171, ll172, ll173, ll174, ll175, ll176, ll177,
  44.108 +        ll178, ll179, ll180, ll181, ll182, ll183, ll184, ll185, ll186, ll187,
  44.109 +        ll188, ll189, ll190, ll191, ll192, ll193, ll194, ll195, ll196, ll197,
  44.110 +        ll198, ll199, ll200, ll201, ll202, ll203, ll204, ll205, ll206, ll207,
  44.111 +        ll208, ll209, ll210, ll211, ll212, ll213, ll214, ll215, ll216, ll217,
  44.112 +        ll218, ll219, ll220, ll221, ll222, ll223, ll224, ll225, ll226, ll227,
  44.113 +        ll228, ll229, ll230, ll231, ll232, ll233, ll234, ll235, ll236, ll237,
  44.114 +        ll238, ll239, ll240, ll241, ll242, ll243, ll244, ll245, ll246, ll247,
  44.115 +        ll248, ll249, ll250, ll251, ll252, ll253, ll254, ll255, ll256, ll257,
  44.116 +        ll258, ll259, ll260, ll261, ll262, ll263, ll264, ll265, ll266, ll267,
  44.117 +        ll268, ll269, ll270, ll271, ll272, ll273, ll274, ll275, ll276, ll277,
  44.118 +        ll278, ll279, ll280, ll281, ll282, ll283, ll284, ll285, ll286, ll287,
  44.119 +        ll288, ll289, ll290, ll291, ll292, ll293, ll294, ll295, ll296, ll297,
  44.120 +        ll298, ll299, ll300, ll301, ll302, ll303, ll304, ll305, ll306, ll307,
  44.121 +        ll308, ll309, ll310, ll311, ll312, ll313, ll314, ll315, ll316, ll317,
  44.122 +        ll318, ll319, ll320, ll321, ll322, ll323, ll324, ll325, ll326, ll327,
  44.123 +        ll328, ll329, ll330, ll331, ll332, ll333, ll334, ll335, ll336, ll337,
  44.124 +        ll338, ll339, ll340, ll341, ll342, ll343, ll344, ll345, ll346, ll347,
  44.125 +        ll348, ll349, ll350, ll351, ll352, ll353, ll354, ll355, ll356, ll357,
  44.126 +        ll358, ll359, ll360, ll361, ll362, ll363, ll364, ll365, ll366, ll367,
  44.127 +        ll368, ll369, ll370, ll371, ll372, ll373, ll374, ll375, ll376, ll377,
  44.128 +        ll378, ll379, ll380, ll381, ll382, ll383, ll384, ll385, ll386, ll387,
  44.129 +        ll388, ll389, ll390, ll391, ll392, ll393, ll394, ll395, ll396, ll397,
  44.130 +        ll398, ll399, ll400, ll401, ll402, ll403, ll404, ll405, ll406, ll407,
  44.131 +        ll408, ll409, ll410, ll411, ll412, ll413, ll414, ll415, ll416, ll417,
  44.132 +        ll418, ll419, ll420, ll421, ll422, ll423, ll424, ll425, ll426, ll427,
  44.133 +        ll428, ll429, ll430, ll431, ll432, ll433, ll434, ll435, ll436, ll437,
  44.134 +        ll438, ll439, ll440, ll441, ll442, ll443, ll444, ll445, ll446, ll447,
  44.135 +        ll448, ll449, ll450, ll451, ll452, ll453, ll454, ll455, ll456, ll457,
  44.136 +        ll458, ll459, ll460, ll461, ll462, ll463, ll464, ll465, ll466, ll467,
  44.137 +        ll468, ll469, ll470, ll471, ll472, ll473, ll474, ll475, ll476, ll477,
  44.138 +        ll478, ll479, ll480, ll481, ll482, ll483, ll484, ll485, ll486, ll487,
  44.139 +        ll488, ll489, ll490, ll491, ll492, ll493, ll494, ll495, ll496, ll497,
  44.140 +        ll498, ll499, ll500, ll501, ll502, ll503, ll504, ll505, ll506, ll507,
  44.141 +        ll508, ll509, ll510, ll511;
  44.142 +
  44.143 +        if (deopt) {
  44.144 +            method_entered = true;
  44.145 +            synchronized(monitor) {
  44.146 +                do_monitor_acquire = true;
  44.147 +                UnloadedClass1 res = new UnloadedClass1(); // forces deopt with c2
  44.148 +                res.field = 0; //forced deopt with c1
  44.149 +                return res;
  44.150 +            }
  44.151 +        }
  44.152 +        return null;
  44.153 +    }
  44.154 +
  44.155 +    static boolean m2(boolean deopt) {
  44.156 +        long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
  44.157 +        l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
  44.158 +        l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
  44.159 +        l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
  44.160 +        l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
  44.161 +        l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
  44.162 +        l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
  44.163 +        l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,
  44.164 +        l97, l98, l99, l100, l101, l102, l103, l104, l105, l106, l107,
  44.165 +        l108, l109, l110, l111, l112, l113, l114, l115, l116, l117,
  44.166 +        l118, l119, l120, l121, l122, l123, l124, l125, l126, l127,
  44.167 +        l128, l129, l130, l131, l132, l133, l134, l135, l136, l137,
  44.168 +        l138, l139, l140, l141, l142, l143, l144, l145, l146, l147,
  44.169 +        l148, l149, l150, l151, l152, l153, l154, l155, l156, l157,
  44.170 +        l158, l159, l160, l161, l162, l163, l164, l165, l166, l167,
  44.171 +        l168, l169, l170, l171, l172, l173, l174, l175, l176, l177,
  44.172 +        l178, l179, l180, l181, l182, l183, l184, l185, l186, l187,
  44.173 +        l188, l189, l190, l191, l192, l193, l194, l195, l196, l197,
  44.174 +        l198, l199, l200, l201, l202, l203, l204, l205, l206, l207,
  44.175 +        l208, l209, l210, l211, l212, l213, l214, l215, l216, l217,
  44.176 +        l218, l219, l220, l221, l222, l223, l224, l225, l226, l227,
  44.177 +        l228, l229, l230, l231, l232, l233, l234, l235, l236, l237,
  44.178 +        l238, l239, l240, l241, l242, l243, l244, l245, l246, l247,
  44.179 +        l248, l249, l250, l251, l252, l253, l254, l255, l256, l257,
  44.180 +        l258, l259, l260, l261, l262, l263, l264, l265, l266, l267,
  44.181 +        l268, l269, l270, l271, l272, l273, l274, l275, l276, l277,
  44.182 +        l278, l279, l280, l281, l282, l283, l284, l285, l286, l287,
  44.183 +        l288, l289, l290, l291, l292, l293, l294, l295, l296, l297,
  44.184 +        l298, l299, l300, l301, l302, l303, l304, l305, l306, l307,
  44.185 +        l308, l309, l310, l311, l312, l313, l314, l315, l316, l317,
  44.186 +        l318, l319, l320, l321, l322, l323, l324, l325, l326, l327,
  44.187 +        l328, l329, l330, l331, l332, l333, l334, l335, l336, l337,
  44.188 +        l338, l339, l340, l341, l342, l343, l344, l345, l346, l347,
  44.189 +        l348, l349, l350, l351, l352, l353, l354, l355, l356, l357,
  44.190 +        l358, l359, l360, l361, l362, l363, l364, l365, l366, l367,
  44.191 +        l368, l369, l370, l371, l372, l373, l374, l375, l376, l377,
  44.192 +        l378, l379, l380, l381, l382, l383, l384, l385, l386, l387,
  44.193 +        l388, l389, l390, l391, l392, l393, l394, l395, l396, l397,
  44.194 +        l398, l399, l400, l401, l402, l403, l404, l405, l406, l407,
  44.195 +        l408, l409, l410, l411, l412, l413, l414, l415, l416, l417,
  44.196 +        l418, l419, l420, l421, l422, l423, l424, l425, l426, l427,
  44.197 +        l428, l429, l430, l431, l432, l433, l434, l435, l436, l437,
  44.198 +        l438, l439, l440, l441, l442, l443, l444, l445, l446, l447,
  44.199 +        l448, l449, l450, l451, l452, l453, l454, l455, l456, l457,
  44.200 +        l458, l459, l460, l461, l462, l463, l464, l465, l466, l467,
  44.201 +        l468, l469, l470, l471, l472, l473, l474, l475, l476, l477,
  44.202 +        l478, l479, l480, l481, l482, l483, l484, l485, l486, l487,
  44.203 +        l488, l489, l490, l491, l492, l493, l494, l495, l496, l497,
  44.204 +        l498, l499, l500, l501, l502, l503, l504, l505, l506, l507,
  44.205 +        l508, l509, l510, l511;
  44.206 +
  44.207 +        boolean do_m3 = false;
  44.208 +        try {
  44.209 +            do_m3 = m2(deopt);
  44.210 +        } catch (StackOverflowError e) {
  44.211 +            return true;
  44.212 +        }
  44.213 +        if (do_m3) {
  44.214 +            try {
  44.215 +                m1(deopt);
  44.216 +            } catch (StackOverflowError e) {}
  44.217 +        }
  44.218 +        return false;
  44.219 +    }
  44.220 +
  44.221 +    // Used for synchronization betwen threads
  44.222 +    static volatile boolean thread_started = false;
  44.223 +    static volatile boolean do_monitor_acquire = false;
  44.224 +    static volatile boolean monitor_acquired = false;
  44.225 +    static volatile boolean method_entered = false;
  44.226 +
  44.227 +    static Object monitor = new Object();
  44.228 +
  44.229 +    static public void main(String[] args) {
  44.230 +        // get m1 compiled
  44.231 +        for (int i = 0; i < 20000; i++) {
  44.232 +            m1(false);
  44.233 +        }
  44.234 +
  44.235 +        Thread thread = new Thread() {
  44.236 +            public void run() {
  44.237 +                thread_started = true;
  44.238 +                while(!do_monitor_acquire);
  44.239 +                System.out.println("Ok to try to acquire the lock");
  44.240 +                synchronized(monitor) {
  44.241 +                    monitor_acquired = true;
  44.242 +                }
  44.243 +            }
  44.244 +        };
  44.245 +
  44.246 +        thread.setDaemon(true);
  44.247 +        thread.start();
  44.248 +
  44.249 +        while(!thread_started);
  44.250 +
  44.251 +        m2(true);
  44.252 +
  44.253 +        if (!method_entered) {
  44.254 +            System.out.println("TEST PASSED");
  44.255 +            return;
  44.256 +        }
  44.257 +
  44.258 +        for (int i = 0; i < 10; i++) {
  44.259 +            System.out.println("Is lock acquired?");
  44.260 +            if (monitor_acquired) {
  44.261 +                System.out.println("TEST PASSED");
  44.262 +                return;
  44.263 +            }
  44.264 +            try {
  44.265 +                Thread.sleep(10000);
  44.266 +            } catch(InterruptedException ie) {
  44.267 +            }
  44.268 +        }
  44.269 +        System.out.println("TEST FAILED");
  44.270 +    }
  44.271 +}

mercurial