Path: blob/master/src/hotspot/cpu/x86/abstractInterpreter_x86.cpp
41144 views
/*1* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "ci/ciMethod.hpp"26#include "interpreter/interpreter.hpp"27#include "oops/klass.inline.hpp"28#include "runtime/frame.inline.hpp"293031// asm based interpreter deoptimization helpers32int AbstractInterpreter::size_activation(int max_stack,33int temps,34int extra_args,35int monitors,36int callee_params,37int callee_locals,38bool is_top_frame) {39// Note: This calculation must exactly parallel the frame setup40// in TemplateInterpreterGenerator::generate_fixed_frame.4142// fixed size of an interpreter frame:43int overhead = frame::sender_sp_offset -44frame::interpreter_frame_initial_sp_offset;45// Our locals were accounted for by the caller (or last_frame_adjust46// on the transistion) Since the callee parameters already account47// for the callee's params we only need to account for the extra48// locals.49int size = overhead +50(callee_locals - callee_params)*Interpreter::stackElementWords +51monitors * frame::interpreter_frame_monitor_size() +52temps* Interpreter::stackElementWords + extra_args;5354return size;55}5657void AbstractInterpreter::layout_activation(Method* method,58int tempcount,59int popframe_extra_args,60int moncount,61int caller_actual_parameters,62int callee_param_count,63int callee_locals,64frame* caller,65frame* interpreter_frame,66bool is_top_frame,67bool is_bottom_frame) {68// The frame interpreter_frame is guaranteed to be the right size,69// as determined by a previous call to the size_activation() method.70// It is also guaranteed to be walkable even though it is in a71// skeletal state7273int max_locals = method->max_locals() * Interpreter::stackElementWords;74int extra_locals = (method->max_locals() - method->size_of_parameters()) *75Interpreter::stackElementWords;7677#ifdef ASSERT78assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable");79#endif8081interpreter_frame->interpreter_frame_set_method(method);82// NOTE the difference in using sender_sp and83// interpreter_frame_sender_sp interpreter_frame_sender_sp is84// the original sp of the caller (the unextended_sp) and85// sender_sp is fp+8/16 (32bit/64bit) XXX86intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;8788#ifdef ASSERT89if (caller->is_interpreted_frame()) {90assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");91}92#endif9394interpreter_frame->interpreter_frame_set_locals(locals);95BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();96BasicObjectLock* monbot = montop - moncount;97interpreter_frame->interpreter_frame_set_monitor_end(monbot);9899// Set last_sp100intptr_t* esp = (intptr_t*) monbot -101tempcount*Interpreter::stackElementWords -102popframe_extra_args;103interpreter_frame->interpreter_frame_set_last_sp(esp);104105// All frames but the initial (oldest) interpreter frame we fill in have106// a value for sender_sp that allows walking the stack but isn't107// truly correct. Correct the value here.108if (extra_locals != 0 &&109interpreter_frame->sender_sp() ==110interpreter_frame->interpreter_frame_sender_sp()) {111interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +112extra_locals);113}114*interpreter_frame->interpreter_frame_cache_addr() =115method->constants()->cache();116*interpreter_frame->interpreter_frame_mirror_addr() =117method->method_holder()->java_mirror();118}119120#ifndef _LP64121int AbstractInterpreter::BasicType_as_index(BasicType type) {122int i = 0;123switch (type) {124case T_BOOLEAN: i = 0; break;125case T_CHAR : i = 1; break;126case T_BYTE : i = 2; break;127case T_SHORT : i = 3; break;128case T_INT : // fall through129case T_LONG : // fall through130case T_VOID : i = 4; break;131case T_FLOAT : i = 5; break; // have to treat float and double separately for SSE132case T_DOUBLE : i = 6; break;133case T_OBJECT : // fall through134case T_ARRAY : i = 7; break;135default : ShouldNotReachHere();136}137assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");138return i;139}140#else141int AbstractInterpreter::BasicType_as_index(BasicType type) {142int i = 0;143switch (type) {144case T_BOOLEAN: i = 0; break;145case T_CHAR : i = 1; break;146case T_BYTE : i = 2; break;147case T_SHORT : i = 3; break;148case T_INT : i = 4; break;149case T_LONG : i = 5; break;150case T_VOID : i = 6; break;151case T_FLOAT : i = 7; break;152case T_DOUBLE : i = 8; break;153case T_OBJECT : i = 9; break;154case T_ARRAY : i = 9; break;155default : ShouldNotReachHere();156}157assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,158"index out of bounds");159return i;160}161#endif // _LP64162163// How much stack a method activation needs in words.164int AbstractInterpreter::size_top_interpreter_activation(Method* method) {165const int entry_size = frame::interpreter_frame_monitor_size();166167// total overhead size: entry_size + (saved rbp thru expr stack168// bottom). be sure to change this if you add/subtract anything169// to/from the overhead area170const int overhead_size =171-(frame::interpreter_frame_initial_sp_offset) + entry_size;172173#ifndef _LP64174const int stub_code = 4; // see generate_call_stub175#else176const int stub_code = frame::entry_frame_after_call_words;177#endif178179const int method_stack = (method->max_locals() + method->max_stack()) *180Interpreter::stackElementWords;181return (overhead_size + method_stack + stub_code);182}183184185