Path: blob/master/src/hotspot/cpu/ppc/abstractInterpreter_ppc.cpp
40930 views
/*1* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2015 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 activation needs in stack slots.55// We must calc this exactly like in generate_fixed_frame.56// Note: This returns the conservative size assuming maximum alignment.57int AbstractInterpreter::size_top_interpreter_activation(Method* method) {58const int max_alignment_size = 2;59const int abi_scratch = frame::abi_reg_args_size;60return method->max_locals() + method->max_stack() +61frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch;62}6364// Returns number of stackElementWords needed for the interpreter frame with the65// given sections.66// This overestimates the stack by one slot in case of alignments.67int AbstractInterpreter::size_activation(int max_stack,68int temps,69int extra_args,70int monitors,71int callee_params,72int callee_locals,73bool is_top_frame) {74// Note: This calculation must exactly parallel the frame setup75// in TemplateInterpreterGenerator::generate_fixed_frame.76assert(Interpreter::stackElementWords == 1, "sanity");77const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize;78const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :79(frame::abi_minframe_size / Interpreter::stackElementSize);80const int size =81max_stack +82(callee_locals - callee_params) +83monitors * frame::interpreter_frame_monitor_size() +84max_alignment_space +85abi_scratch +86frame::ijava_state_size / Interpreter::stackElementSize;8788// Fixed size of an interpreter frame, align to 16-byte.89return (size & -2);90}9192// Fills a sceletal interpreter frame generated during deoptimizations.93//94// Parameters:95//96// interpreter_frame != NULL:97// set up the method, locals, and monitors.98// The frame interpreter_frame, if not NULL, is guaranteed to be the99// right size, as determined by a previous call to this method.100// It is also guaranteed to be walkable even though it is in a skeletal state101//102// is_top_frame == true:103// We're processing the *oldest* interpreter frame!104//105// pop_frame_extra_args:106// If this is != 0 we are returning to a deoptimized frame by popping107// off the callee frame. We want to re-execute the call that called the108// callee interpreted, but since the return to the interpreter would pop109// the arguments off advance the esp by dummy popframe_extra_args slots.110// Popping off those will establish the stack layout as it was before the call.111//112void AbstractInterpreter::layout_activation(Method* method,113int tempcount,114int popframe_extra_args,115int moncount,116int caller_actual_parameters,117int callee_param_count,118int callee_locals_count,119frame* caller,120frame* interpreter_frame,121bool is_top_frame,122bool is_bottom_frame) {123124const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :125(frame::abi_minframe_size / Interpreter::stackElementSize);126127intptr_t* locals_base = (caller->is_interpreted_frame()) ?128caller->interpreter_frame_esp() + caller_actual_parameters :129caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize);130131intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize;132intptr_t* monitor = monitor_base - (moncount * frame::interpreter_frame_monitor_size());133intptr_t* esp_base = monitor - 1;134intptr_t* esp = esp_base - tempcount - popframe_extra_args;135intptr_t* sp = (intptr_t *) (((intptr_t) (esp_base - callee_locals_count + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes);136intptr_t* sender_sp = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;137intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;138139interpreter_frame->interpreter_frame_set_method(method);140interpreter_frame->interpreter_frame_set_mirror(method->method_holder()->java_mirror());141interpreter_frame->interpreter_frame_set_locals(locals_base);142interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());143interpreter_frame->interpreter_frame_set_esp(esp);144interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);145interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);146if (!is_bottom_frame) {147interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);148}149}150151152