src/cpu/ppc/vm/cppInterpreter_ppc.cpp

changeset 6723
0bf37f737702
parent 6660
63c5920a038d
child 6876
710a3c8b516e
equal deleted inserted replaced
6721:ad51f24671c2 6723:0bf37f737702
1 1
2 /* 2 /*
3 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
4 * Copyright 2012, 2013 SAP AG. All rights reserved. 4 * Copyright 2012, 2014 SAP AG. All rights reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * 6 *
7 * This code is free software; you can redistribute it and/or modify it 7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as 8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
2946 intptr_t* last_Java_fp) { 2946 intptr_t* last_Java_fp) {
2947 istate->_last_Java_pc = last_Java_pc; 2947 istate->_last_Java_pc = last_Java_pc;
2948 istate->_last_Java_fp = last_Java_fp; 2948 istate->_last_Java_fp = last_Java_fp;
2949 } 2949 }
2950 2950
2951 int AbstractInterpreter::layout_activation(Method* method, 2951 // Computes monitor_size and top_frame_size in bytes.
2952 int temps, // Number of slots on java expression stack in use. 2952 static void frame_size_helper(int max_stack,
2953 int popframe_args, 2953 int monitors,
2954 int monitors, // Number of active monitors. 2954 int& monitor_size,
2955 int caller_actual_parameters, 2955 int& top_frame_size) {
2956 int callee_params,// Number of slots for callee parameters. 2956 monitor_size = frame::interpreter_frame_monitor_size_in_bytes() * monitors;
2957 int callee_locals,// Number of slots for locals. 2957 top_frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
2958 frame* caller, 2958 + monitor_size
2959 frame* interpreter_frame, 2959 + max_stack * Interpreter::stackElementSize
2960 bool is_top_frame, 2960 + 2 * Interpreter::stackElementSize,
2961 bool is_bottom_frame) { 2961 frame::alignment_in_bytes)
2962 + frame::top_ijava_frame_abi_size;
2963 }
2964
2965 // Returns number of stackElementWords needed for the interpreter frame with the
2966 // given sections.
2967 int AbstractInterpreter::size_activation(int max_stack,
2968 int temps,
2969 int extra_args,
2970 int monitors,
2971 int callee_params,
2972 int callee_locals,
2973 bool is_top_frame) {
2974 int monitor_size = 0;
2975 int top_frame_size = 0;
2976 frame_size_helper(max_stack, monitors, monitor_size, top_frame_size);
2977
2978 int frame_size;
2979 if (is_top_frame) {
2980 frame_size = top_frame_size;
2981 } else {
2982 frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
2983 + monitor_size
2984 + (temps - callee_params + callee_locals) * Interpreter::stackElementSize
2985 + 2 * Interpreter::stackElementSize,
2986 frame::alignment_in_bytes)
2987 + frame::parent_ijava_frame_abi_size;
2988 assert(extra_args == 0, "non-zero for top_frame only");
2989 }
2990
2991 return frame_size / Interpreter::stackElementSize;
2992 }
2993
2994 void AbstractInterpreter::layout_activation(Method* method,
2995 int temps, // Number of slots on java expression stack in use.
2996 int popframe_args,
2997 int monitors, // Number of active monitors.
2998 int caller_actual_parameters,
2999 int callee_params,// Number of slots for callee parameters.
3000 int callee_locals,// Number of slots for locals.
3001 frame* caller,
3002 frame* interpreter_frame,
3003 bool is_top_frame,
3004 bool is_bottom_frame) {
2962 3005
2963 // NOTE this code must exactly mimic what 3006 // NOTE this code must exactly mimic what
2964 // InterpreterGenerator::generate_compute_interpreter_state() does 3007 // InterpreterGenerator::generate_compute_interpreter_state() does
2965 // as far as allocating an interpreter frame. However there is an 3008 // as far as allocating an interpreter frame. However there is an
2966 // exception. With the C++ based interpreter only the top most frame 3009 // exception. With the C++ based interpreter only the top most frame
2967 // has a full sized expression stack. The 16 byte slop factor is 3010 // has a full sized expression stack. The 16 byte slop factor is
2968 // both the abi scratch area and a place to hold a result from a 3011 // both the abi scratch area and a place to hold a result from a
2969 // callee on its way to the callers stack. 3012 // callee on its way to the callers stack.
2970 3013
2971 int monitor_size = frame::interpreter_frame_monitor_size_in_bytes() * monitors; 3014 int monitor_size = 0;
2972 int frame_size; 3015 int top_frame_size = 0;
2973 int top_frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes() 3016 frame_size_helper(method->max_stack(), monitors, monitor_size, top_frame_size);
2974 + monitor_size 3017
2975 + (method->max_stack() *Interpreter::stackElementWords * BytesPerWord) 3018 intptr_t sp = (intptr_t)interpreter_frame->sp();
2976 + 2*BytesPerWord, 3019 intptr_t fp = *(intptr_t *)sp;
2977 frame::alignment_in_bytes) 3020 assert(fp == (intptr_t)caller->sp(), "fp must match");
2978 + frame::top_ijava_frame_abi_size; 3021 interpreterState cur_state =
2979 if (is_top_frame) { 3022 (interpreterState)(fp - frame::interpreter_frame_cinterpreterstate_size_in_bytes());
2980 frame_size = top_frame_size; 3023
3024 // Now fill in the interpreterState object.
3025
3026 intptr_t* locals;
3027 if (caller->is_interpreted_frame()) {
3028 // Locals must agree with the caller because it will be used to set the
3029 // caller's tos when we return.
3030 interpreterState prev = caller->get_interpreterState();
3031 // Calculate start of "locals" for MH calls. For MH calls, the
3032 // current method() (= MH target) and prev->callee() (=
3033 // MH.invoke*()) are different and especially have different
3034 // signatures. To pop the argumentsof the caller, we must use
3035 // the prev->callee()->size_of_arguments() because that's what
3036 // the caller actually pushed. Currently, for synthetic MH
3037 // calls (deoptimized from inlined MH calls), detected by
3038 // is_method_handle_invoke(), we use the callee's arguments
3039 // because here, the caller's and callee's signature match.
3040 if (true /*!caller->is_at_mh_callsite()*/) {
3041 locals = prev->stack() + method->size_of_parameters();
3042 } else {
3043 // Normal MH call.
3044 locals = prev->stack() + prev->callee()->size_of_parameters();
3045 }
2981 } else { 3046 } else {
2982 frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes() 3047 bool is_deopted;
2983 + monitor_size 3048 locals = (intptr_t*) (fp + ((method->max_locals() - 1) * BytesPerWord) +
2984 + ((temps - callee_params + callee_locals) * 3049 frame::parent_ijava_frame_abi_size);
2985 Interpreter::stackElementWords * BytesPerWord) 3050 }
2986 + 2*BytesPerWord, 3051
2987 frame::alignment_in_bytes) 3052 intptr_t* monitor_base = (intptr_t*) cur_state;
2988 + frame::parent_ijava_frame_abi_size; 3053 intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
2989 assert(popframe_args==0, "non-zero for top_frame only"); 3054
2990 } 3055 // Provide pop_frame capability on PPC64, add popframe_args.
2991 3056 // +1 because stack is always prepushed.
2992 // If we actually have a frame to layout we must now fill in all the pieces. 3057 intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (temps + popframe_args + 1) * BytesPerWord);
2993 if (interpreter_frame != NULL) { 3058
2994 3059 BytecodeInterpreter::layout_interpreterState(cur_state,
2995 intptr_t sp = (intptr_t)interpreter_frame->sp(); 3060 caller,
2996 intptr_t fp = *(intptr_t *)sp; 3061 interpreter_frame,
2997 assert(fp == (intptr_t)caller->sp(), "fp must match"); 3062 method,
2998 interpreterState cur_state = 3063 locals,
2999 (interpreterState)(fp - frame::interpreter_frame_cinterpreterstate_size_in_bytes()); 3064 stack,
3000 3065 stack_base,
3001 // Now fill in the interpreterState object. 3066 monitor_base,
3002 3067 (intptr_t*)(((intptr_t)fp) - top_frame_size),
3003 intptr_t* locals; 3068 is_top_frame);
3004 if (caller->is_interpreted_frame()) { 3069
3005 // Locals must agree with the caller because it will be used to set the 3070 BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address,
3006 // caller's tos when we return. 3071 interpreter_frame->fp());
3007 interpreterState prev = caller->get_interpreterState();
3008 // Calculate start of "locals" for MH calls. For MH calls, the
3009 // current method() (= MH target) and prev->callee() (=
3010 // MH.invoke*()) are different and especially have different
3011 // signatures. To pop the argumentsof the caller, we must use
3012 // the prev->callee()->size_of_arguments() because that's what
3013 // the caller actually pushed. Currently, for synthetic MH
3014 // calls (deoptimized from inlined MH calls), detected by
3015 // is_method_handle_invoke(), we use the callee's arguments
3016 // because here, the caller's and callee's signature match.
3017 if (true /*!caller->is_at_mh_callsite()*/) {
3018 locals = prev->stack() + method->size_of_parameters();
3019 } else {
3020 // Normal MH call.
3021 locals = prev->stack() + prev->callee()->size_of_parameters();
3022 }
3023 } else {
3024 bool is_deopted;
3025 locals = (intptr_t*) (fp + ((method->max_locals() - 1) * BytesPerWord) +
3026 frame::parent_ijava_frame_abi_size);
3027 }
3028
3029 intptr_t* monitor_base = (intptr_t*) cur_state;
3030 intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
3031
3032 // Provide pop_frame capability on PPC64, add popframe_args.
3033 // +1 because stack is always prepushed.
3034 intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (temps + popframe_args + 1) * BytesPerWord);
3035
3036 BytecodeInterpreter::layout_interpreterState(cur_state,
3037 caller,
3038 interpreter_frame,
3039 method,
3040 locals,
3041 stack,
3042 stack_base,
3043 monitor_base,
3044 (intptr_t*)(((intptr_t)fp)-top_frame_size),
3045 is_top_frame);
3046
3047 BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address,
3048 interpreter_frame->fp());
3049 }
3050 return frame_size/BytesPerWord;
3051 } 3072 }
3052 3073
3053 #endif // CC_INTERP 3074 #endif // CC_INTERP

mercurial