src/cpu/x86/vm/templateInterpreter_x86.cpp

changeset 6723
0bf37f737702
parent 0
f90c822e73f8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86.cpp	Tue Apr 01 09:36:49 2014 +0200
     1.3 @@ -0,0 +1,124 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "ci/ciMethod.hpp"
    1.30 +#include "interpreter/interpreter.hpp"
    1.31 +#include "runtime/frame.inline.hpp"
    1.32 +
    1.33 +#ifndef CC_INTERP
    1.34 +
    1.35 +// asm based interpreter deoptimization helpers
    1.36 +int AbstractInterpreter::size_activation(int max_stack,
    1.37 +                                         int temps,
    1.38 +                                         int extra_args,
    1.39 +                                         int monitors,
    1.40 +                                         int callee_params,
    1.41 +                                         int callee_locals,
    1.42 +                                         bool is_top_frame) {
    1.43 +  // Note: This calculation must exactly parallel the frame setup
    1.44 +  // in AbstractInterpreterGenerator::generate_method_entry.
    1.45 +
    1.46 +  // fixed size of an interpreter frame:
    1.47 +  int overhead = frame::sender_sp_offset -
    1.48 +                 frame::interpreter_frame_initial_sp_offset;
    1.49 +  // Our locals were accounted for by the caller (or last_frame_adjust
    1.50 +  // on the transistion) Since the callee parameters already account
    1.51 +  // for the callee's params we only need to account for the extra
    1.52 +  // locals.
    1.53 +  int size = overhead +
    1.54 +         (callee_locals - callee_params)*Interpreter::stackElementWords +
    1.55 +         monitors * frame::interpreter_frame_monitor_size() +
    1.56 +         temps* Interpreter::stackElementWords + extra_args;
    1.57 +
    1.58 +  return size;
    1.59 +}
    1.60 +
    1.61 +void AbstractInterpreter::layout_activation(Method* method,
    1.62 +                                            int tempcount,
    1.63 +                                            int popframe_extra_args,
    1.64 +                                            int moncount,
    1.65 +                                            int caller_actual_parameters,
    1.66 +                                            int callee_param_count,
    1.67 +                                            int callee_locals,
    1.68 +                                            frame* caller,
    1.69 +                                            frame* interpreter_frame,
    1.70 +                                            bool is_top_frame,
    1.71 +                                            bool is_bottom_frame) {
    1.72 +  // The frame interpreter_frame is guaranteed to be the right size,
    1.73 +  // as determined by a previous call to the size_activation() method.
    1.74 +  // It is also guaranteed to be walkable even though it is in a
    1.75 +  // skeletal state
    1.76 +
    1.77 +  int max_locals = method->max_locals() * Interpreter::stackElementWords;
    1.78 +  int extra_locals = (method->max_locals() - method->size_of_parameters()) *
    1.79 +    Interpreter::stackElementWords;
    1.80 +
    1.81 +#ifdef ASSERT
    1.82 +  if (!EnableInvokeDynamic) {
    1.83 +    // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences?
    1.84 +    // Probably, since deoptimization doesn't work yet.
    1.85 +    assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
    1.86 +  }
    1.87 +  assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)");
    1.88 +#endif
    1.89 +
    1.90 +  interpreter_frame->interpreter_frame_set_method(method);
    1.91 +  // NOTE the difference in using sender_sp and
    1.92 +  // interpreter_frame_sender_sp interpreter_frame_sender_sp is
    1.93 +  // the original sp of the caller (the unextended_sp) and
    1.94 +  // sender_sp is fp+8/16 (32bit/64bit) XXX
    1.95 +  intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
    1.96 +
    1.97 +#ifdef ASSERT
    1.98 +  if (caller->is_interpreted_frame()) {
    1.99 +    assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
   1.100 +  }
   1.101 +#endif
   1.102 +
   1.103 +  interpreter_frame->interpreter_frame_set_locals(locals);
   1.104 +  BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
   1.105 +  BasicObjectLock* monbot = montop - moncount;
   1.106 +  interpreter_frame->interpreter_frame_set_monitor_end(monbot);
   1.107 +
   1.108 +  // Set last_sp
   1.109 +  intptr_t*  esp = (intptr_t*) monbot -
   1.110 +    tempcount*Interpreter::stackElementWords -
   1.111 +    popframe_extra_args;
   1.112 +  interpreter_frame->interpreter_frame_set_last_sp(esp);
   1.113 +
   1.114 +  // All frames but the initial (oldest) interpreter frame we fill in have
   1.115 +  // a value for sender_sp that allows walking the stack but isn't
   1.116 +  // truly correct. Correct the value here.
   1.117 +  if (extra_locals != 0 &&
   1.118 +      interpreter_frame->sender_sp() ==
   1.119 +      interpreter_frame->interpreter_frame_sender_sp()) {
   1.120 +    interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
   1.121 +                                                       extra_locals);
   1.122 +  }
   1.123 +  *interpreter_frame->interpreter_frame_cache_addr() =
   1.124 +    method->constants()->cache();
   1.125 +}
   1.126 +
   1.127 +#endif // CC_INTERP

mercurial