1 /* 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "ci/ciMethod.hpp" 27 #include "interpreter/interpreter.hpp" 28 #include "runtime/frame.inline.hpp" 29 30 #ifndef CC_INTERP 31 32 // asm based interpreter deoptimization helpers 33 int AbstractInterpreter::size_activation(int max_stack, 34 int temps, 35 int popframe_args, 36 int monitors, 37 int callee_params, 38 int callee_locals, 39 bool is_top_frame) { 40 // Note: This calculation must exactly parallel the frame setup 41 // in AbstractInterpreterGenerator::generate_method_entry. 42 43 // fixed size of an interpreter frame: 44 int overhead = frame::sender_sp_offset - 45 frame::interpreter_frame_initial_sp_offset; 46 // Our locals were accounted for by the caller (or last_frame_adjust 47 // on the transistion) Since the callee parameters already account 48 // for the callee's params we only need to account for the extra 49 // locals. 50 int size = overhead + 51 (callee_locals - callee_params)*Interpreter::stackElementWords + 52 monitors * frame::interpreter_frame_monitor_size() + 53 temps* Interpreter::stackElementWords + popframe_args; 54 55 return size; 56 } 57 58 void AbstractInterpreter::layout_activation(Method* method, 59 int tempcount, 60 int popframe_extra_args, 61 int moncount, 62 int caller_actual_parameters, 63 int callee_param_count, 64 int callee_locals, 65 frame* caller, 66 frame* interpreter_frame, 67 bool is_top_frame, 68 bool is_bottom_frame) { 69 // The frame interpreter_frame is guaranteed to be the right size, 70 // as determined by a previous call to the size_activation() method. 71 // It is also guaranteed to be walkable even though it is in a 72 // skeletal state 73 74 int max_locals = method->max_locals() * Interpreter::stackElementWords; 75 int extra_locals = (method->max_locals() - method->size_of_parameters()) * 76 Interpreter::stackElementWords; 77 78 #ifdef ASSERT 79 if (!EnableInvokeDynamic) { 80 // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences? 81 // Probably, since deoptimization doesn't work yet. 82 assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable"); 83 } 84 assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)"); 85 #endif 86 87 interpreter_frame->interpreter_frame_set_method(method); 88 // NOTE the difference in using sender_sp and 89 // interpreter_frame_sender_sp interpreter_frame_sender_sp is 90 // the original sp of the caller (the unextended_sp) and 91 // sender_sp is fp+8/16 (32bit/64bit) XXX 92 intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1; 93 94 #ifdef ASSERT 95 if (caller->is_interpreted_frame()) { 96 assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement"); 97 } 98 #endif 99 100 interpreter_frame->interpreter_frame_set_locals(locals); 101 BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin(); 102 BasicObjectLock* monbot = montop - moncount; 103 interpreter_frame->interpreter_frame_set_monitor_end(monbot); 104 105 // Set last_sp 106 intptr_t* esp = (intptr_t*) monbot - 107 tempcount*Interpreter::stackElementWords - 108 popframe_extra_args; 109 interpreter_frame->interpreter_frame_set_last_sp(esp); 110 111 // All frames but the initial (oldest) interpreter frame we fill in have 112 // a value for sender_sp that allows walking the stack but isn't 113 // truly correct. Correct the value here. 114 if (extra_locals != 0 && 115 interpreter_frame->sender_sp() == 116 interpreter_frame->interpreter_frame_sender_sp()) { 117 interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() + 118 extra_locals); 119 } 120 *interpreter_frame->interpreter_frame_cache_addr() = 121 method->constants()->cache(); 122 } 123 124 #endif // CC_INTERP