Path: blob/master/src/hotspot/cpu/s390/abstractInterpreter_s390.cpp
40930 views
/*1* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2016 SAP SE. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "interpreter/interpreter.hpp"27#include "oops/constMethod.hpp"28#include "oops/klass.inline.hpp"29#include "oops/method.hpp"30#include "runtime/frame.inline.hpp"31#include "utilities/debug.hpp"32#include "utilities/macros.hpp"3334int AbstractInterpreter::BasicType_as_index(BasicType type) {35int i = 0;36switch (type) {37case T_BOOLEAN: i = 0; break;38case T_CHAR : i = 1; break;39case T_BYTE : i = 2; break;40case T_SHORT : i = 3; break;41case T_INT : i = 4; break;42case T_LONG : i = 5; break;43case T_VOID : i = 6; break;44case T_FLOAT : i = 7; break;45case T_DOUBLE : i = 8; break;46case T_OBJECT : i = 9; break;47case T_ARRAY : i = 9; break;48default : ShouldNotReachHere();49}50assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");51return i;52}5354// How much stack a method top interpreter activation needs in words.55int AbstractInterpreter::size_top_interpreter_activation(Method* method) {5657// We have to size the following 2 frames:58//59// [TOP_IJAVA_FRAME_ABI]60// [ENTRY_FRAME]61//62// This expands to (see frame_s390.hpp):63//64// [TOP_IJAVA_FRAME_ABI]65// [operand stack] > stack66// [monitors] (optional) > monitors67// [IJAVA_STATE] > interpreter_state68// [PARENT_IJAVA_FRAME_ABI]69// [callee's locals w/o arguments] \ locals70// [outgoing arguments] /71// [ENTRY_FRAME_LOCALS]7273int locals = method->max_locals() * BytesPerWord;74int interpreter_state = frame::z_ijava_state_size;7576int stack = method->max_stack() * BytesPerWord;77int monitors = method->is_synchronized() ? frame::interpreter_frame_monitor_size_in_bytes() : 0;7879int total_bytes =80frame::z_top_ijava_frame_abi_size +81stack +82monitors +83interpreter_state +84frame::z_parent_ijava_frame_abi_size +85locals +86frame::z_entry_frame_locals_size;8788return (total_bytes/BytesPerWord);89}9091// Returns number of stackElementWords needed for the interpreter frame with the92// given sections.93// This overestimates the stack by one slot in case of alignments.94int AbstractInterpreter::size_activation(int max_stack,95int temps,96int extra_args,97int monitors,98int callee_params,99int callee_locals,100bool is_top_frame) {101// Note: This calculation must exactly parallel the frame setup102// in AbstractInterpreterGenerator::generate_method_entry.103104assert((Interpreter::stackElementSize == frame::alignment_in_bytes), "must align frame size");105const int abi_scratch = is_top_frame ? (frame::z_top_ijava_frame_abi_size / Interpreter::stackElementSize) :106(frame::z_parent_ijava_frame_abi_size / Interpreter::stackElementSize);107108const int size =109max_stack +110(callee_locals - callee_params) + // Already counted in max_stack().111monitors * frame::interpreter_frame_monitor_size() +112abi_scratch +113frame::z_ijava_state_size / Interpreter::stackElementSize;114115// Fixed size of an interpreter frame.116return size;117}118119// Fills a sceletal interpreter frame generated during deoptimizations.120//121// Parameters:122//123// interpreter_frame != NULL:124// set up the method, locals, and monitors.125// The frame interpreter_frame, if not NULL, is guaranteed to be the126// right size, as determined by a previous call to this method.127// It is also guaranteed to be walkable even though it is in a skeletal state128//129// is_top_frame == true:130// We're processing the *oldest* interpreter frame!131//132// pop_frame_extra_args:133// If this is != 0 we are returning to a deoptimized frame by popping134// off the callee frame. We want to re-execute the call that called the135// callee interpreted, but since the return to the interpreter would pop136// the arguments off advance the esp by dummy popframe_extra_args slots.137// Popping off those will establish the stack layout as it was before the call.138//139140void AbstractInterpreter::layout_activation(Method* method,141int tempcount,142int popframe_extra_args,143int moncount,144int caller_actual_parameters,145int callee_param_count,146int callee_locals_count,147frame* caller,148frame* interpreter_frame,149bool is_top_frame,150bool is_bottom_frame) {151// TOP_IJAVA_FRAME:152//153// 0 [TOP_IJAVA_FRAME_ABI] -+154// 16 [operand stack] | size155// [monitors] (optional) |156// [IJAVA_STATE] -+157// Note: own locals are located in the caller frame.158//159// PARENT_IJAVA_FRAME:160//161// 0 [PARENT_IJAVA_FRAME_ABI] -+162// [callee's locals w/o arguments] |163// [outgoing arguments] | size164// [used part of operand stack w/o arguments] |165// [monitors] (optional) |166// [IJAVA_STATE] -+167//168169// Now we know our caller, calc the exact frame layout and size170// z_ijava_state->locals - i*BytesPerWord points to i-th Java local (i starts at 0).171intptr_t* locals_base = (caller->is_interpreted_frame())172? (caller->interpreter_frame_tos_address() + caller_actual_parameters - 1)173: (caller->sp() + method->max_locals() - 1 +174frame::z_parent_ijava_frame_abi_size / Interpreter::stackElementSize);175176intptr_t* monitor_base = (intptr_t*)((address)interpreter_frame->fp() - frame::z_ijava_state_size);177intptr_t* monitor = monitor_base - (moncount * frame::interpreter_frame_monitor_size());178intptr_t* operand_stack_base = monitor;179intptr_t* tos = operand_stack_base - tempcount - popframe_extra_args;180intptr_t* top_frame_sp =181operand_stack_base - method->max_stack() - frame::z_top_ijava_frame_abi_size / Interpreter::stackElementSize;182intptr_t* sender_sp;183if (caller->is_interpreted_frame()) {184sender_sp = caller->interpreter_frame_top_frame_sp();185} else if (caller->is_compiled_frame()) {186sender_sp = caller->fp() - caller->cb()->frame_size();187// The bottom frame's sender_sp is its caller's unextended_sp.188// It was already set when its skeleton was pushed (see push_skeleton_frames()).189// Note: the unextended_sp is required by nmethod::orig_pc_addr().190assert(is_bottom_frame && (sender_sp == caller->unextended_sp()),191"must initialize sender_sp of bottom skeleton frame when pushing it");192} else {193assert(caller->is_entry_frame(), "is there a new frame type??");194sender_sp = caller->sp(); // Call_stub only uses it's fp.195}196197interpreter_frame->interpreter_frame_set_method(method);198interpreter_frame->interpreter_frame_set_mirror(method->method_holder()->java_mirror());199interpreter_frame->interpreter_frame_set_locals(locals_base);200interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);201*interpreter_frame->interpreter_frame_cache_addr() = method->constants()->cache();202interpreter_frame->interpreter_frame_set_tos_address(tos);203interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);204interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);205}206207208