Wed, 27 Nov 2013 16:16:21 -0800
8029015: PPC64 (part 216): opto: trap based null and range checks
Summary: On PPC64 use tdi instruction that does a compare and raises SIGTRAP for NULL and range checks.
Reviewed-by: kvn
goetz@6458 | 1 | /* |
goetz@6458 | 2 | * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
goetz@6458 | 3 | * Copyright 2012, 2013 SAP AG. All rights reserved. |
goetz@6458 | 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
goetz@6458 | 5 | * |
goetz@6458 | 6 | * This code is free software; you can redistribute it and/or modify it |
goetz@6458 | 7 | * under the terms of the GNU General Public License version 2 only, as |
goetz@6458 | 8 | * published by the Free Software Foundation. |
goetz@6458 | 9 | * |
goetz@6458 | 10 | * This code is distributed in the hope that it will be useful, but WITHOUT |
goetz@6458 | 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
goetz@6458 | 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
goetz@6458 | 13 | * version 2 for more details (a copy is included in the LICENSE file that |
goetz@6458 | 14 | * accompanied this code). |
goetz@6458 | 15 | * |
goetz@6458 | 16 | * You should have received a copy of the GNU General Public License version |
goetz@6458 | 17 | * 2 along with this work; if not, write to the Free Software Foundation, |
goetz@6458 | 18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
goetz@6458 | 19 | * |
goetz@6458 | 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
goetz@6458 | 21 | * or visit www.oracle.com if you need additional information or have any |
goetz@6458 | 22 | * questions. |
goetz@6458 | 23 | * |
goetz@6458 | 24 | */ |
goetz@6458 | 25 | |
goetz@6458 | 26 | #ifndef CPU_PPC_VM_FRAME_PPC_INLINE_HPP |
goetz@6458 | 27 | #define CPU_PPC_VM_FRAME_PPC_INLINE_HPP |
goetz@6458 | 28 | |
goetz@6458 | 29 | #ifndef CC_INTERP |
goetz@6458 | 30 | #error "CC_INTERP must be defined on PPC64" |
goetz@6458 | 31 | #endif |
goetz@6458 | 32 | |
goetz@6458 | 33 | // Inline functions for ppc64 frames: |
goetz@6458 | 34 | |
goetz@6458 | 35 | // Find codeblob and set deopt_state. |
goetz@6458 | 36 | inline void frame::find_codeblob_and_set_pc_and_deopt_state(address pc) { |
goetz@6458 | 37 | assert(pc != NULL, "precondition: must have PC"); |
goetz@6458 | 38 | |
goetz@6458 | 39 | _cb = CodeCache::find_blob(pc); |
goetz@6458 | 40 | _pc = pc; // Must be set for get_deopt_original_pc() |
goetz@6458 | 41 | |
goetz@6458 | 42 | _fp = (intptr_t*)own_abi()->callers_sp; |
goetz@6458 | 43 | // Use _fp - frame_size, needs to be done between _cb and _pc initialization |
goetz@6458 | 44 | // and get_deopt_original_pc. |
goetz@6458 | 45 | adjust_unextended_sp(); |
goetz@6458 | 46 | |
goetz@6458 | 47 | address original_pc = nmethod::get_deopt_original_pc(this); |
goetz@6458 | 48 | if (original_pc != NULL) { |
goetz@6458 | 49 | _pc = original_pc; |
goetz@6458 | 50 | _deopt_state = is_deoptimized; |
goetz@6458 | 51 | } else { |
goetz@6458 | 52 | _deopt_state = not_deoptimized; |
goetz@6458 | 53 | } |
goetz@6458 | 54 | |
goetz@6458 | 55 | assert(((uint64_t)_sp & 0xf) == 0, "SP must be 16-byte aligned"); |
goetz@6458 | 56 | } |
goetz@6458 | 57 | |
goetz@6458 | 58 | // Constructors |
goetz@6458 | 59 | |
goetz@6458 | 60 | // Initialize all fields, _unextended_sp will be adjusted in find_codeblob_and_set_pc_and_deopt_state. |
goetz@6458 | 61 | inline frame::frame() : _sp(NULL), _unextended_sp(NULL), _fp(NULL), _cb(NULL), _pc(NULL), _deopt_state(unknown) {} |
goetz@6458 | 62 | |
goetz@6458 | 63 | inline frame::frame(intptr_t* sp) : _sp(sp), _unextended_sp(sp) { |
goetz@6458 | 64 | find_codeblob_and_set_pc_and_deopt_state((address)own_abi()->lr); // also sets _fp and adjusts _unextended_sp |
goetz@6458 | 65 | } |
goetz@6458 | 66 | |
goetz@6458 | 67 | inline frame::frame(intptr_t* sp, address pc) : _sp(sp), _unextended_sp(sp) { |
goetz@6458 | 68 | find_codeblob_and_set_pc_and_deopt_state(pc); // also sets _fp and adjusts _unextended_sp |
goetz@6458 | 69 | } |
goetz@6458 | 70 | |
goetz@6458 | 71 | inline frame::frame(intptr_t* sp, address pc, intptr_t* unextended_sp) : _sp(sp), _unextended_sp(unextended_sp) { |
goetz@6458 | 72 | find_codeblob_and_set_pc_and_deopt_state(pc); // also sets _fp and adjusts _unextended_sp |
goetz@6458 | 73 | } |
goetz@6458 | 74 | |
goetz@6458 | 75 | // Accessors |
goetz@6458 | 76 | |
goetz@6458 | 77 | // Return unique id for this frame. The id must have a value where we |
goetz@6458 | 78 | // can distinguish identity and younger/older relationship. NULL |
goetz@6458 | 79 | // represents an invalid (incomparable) frame. |
goetz@6458 | 80 | inline intptr_t* frame::id(void) const { |
goetz@6458 | 81 | // Use the _unextended_pc as the frame's ID. Because we have no |
goetz@6458 | 82 | // adapters, but resized compiled frames, some of the new code |
goetz@6458 | 83 | // (e.g. JVMTI) wouldn't work if we return the (current) SP of the |
goetz@6458 | 84 | // frame. |
goetz@6458 | 85 | return _unextended_sp; |
goetz@6458 | 86 | } |
goetz@6458 | 87 | |
goetz@6458 | 88 | // Return true if this frame is older (less recent activation) than |
goetz@6458 | 89 | // the frame represented by id. |
goetz@6458 | 90 | inline bool frame::is_older(intptr_t* id) const { |
goetz@6458 | 91 | assert(this->id() != NULL && id != NULL, "NULL frame id"); |
goetz@6458 | 92 | // Stack grows towards smaller addresses on ppc64. |
goetz@6458 | 93 | return this->id() > id; |
goetz@6458 | 94 | } |
goetz@6458 | 95 | |
goetz@6458 | 96 | inline int frame::frame_size(RegisterMap* map) const { |
goetz@6458 | 97 | // Stack grows towards smaller addresses on PPC64: sender is at a higher address. |
goetz@6458 | 98 | return sender_sp() - sp(); |
goetz@6458 | 99 | } |
goetz@6458 | 100 | |
goetz@6458 | 101 | // Return the frame's stack pointer before it has been extended by a |
goetz@6458 | 102 | // c2i adapter. This is needed by deoptimization for ignoring c2i adapter |
goetz@6458 | 103 | // frames. |
goetz@6458 | 104 | inline intptr_t* frame::unextended_sp() const { |
goetz@6458 | 105 | return _unextended_sp; |
goetz@6458 | 106 | } |
goetz@6458 | 107 | |
goetz@6458 | 108 | // All frames have this field. |
goetz@6458 | 109 | inline address frame::sender_pc() const { |
goetz@6458 | 110 | return (address)callers_abi()->lr; |
goetz@6458 | 111 | } |
goetz@6458 | 112 | inline address* frame::sender_pc_addr() const { |
goetz@6458 | 113 | return (address*)&(callers_abi()->lr); |
goetz@6458 | 114 | } |
goetz@6458 | 115 | |
goetz@6458 | 116 | // All frames have this field. |
goetz@6458 | 117 | inline intptr_t* frame::sender_sp() const { |
goetz@6458 | 118 | return (intptr_t*)callers_abi(); |
goetz@6458 | 119 | } |
goetz@6458 | 120 | |
goetz@6458 | 121 | // All frames have this field. |
goetz@6458 | 122 | inline intptr_t* frame::link() const { |
goetz@6458 | 123 | return (intptr_t*)callers_abi()->callers_sp; |
goetz@6458 | 124 | } |
goetz@6458 | 125 | |
goetz@6458 | 126 | inline intptr_t* frame::real_fp() const { |
goetz@6458 | 127 | return fp(); |
goetz@6458 | 128 | } |
goetz@6458 | 129 | |
goetz@6458 | 130 | #ifdef CC_INTERP |
goetz@6458 | 131 | |
goetz@6458 | 132 | inline interpreterState frame::get_interpreterState() const { |
goetz@6458 | 133 | return (interpreterState)(((address)callers_abi()) |
goetz@6458 | 134 | - frame::interpreter_frame_cinterpreterstate_size_in_bytes()); |
goetz@6458 | 135 | } |
goetz@6458 | 136 | |
goetz@6458 | 137 | inline intptr_t** frame::interpreter_frame_locals_addr() const { |
goetz@6458 | 138 | interpreterState istate = get_interpreterState(); |
goetz@6458 | 139 | return (intptr_t**)&istate->_locals; |
goetz@6458 | 140 | } |
goetz@6458 | 141 | |
goetz@6458 | 142 | inline intptr_t* frame::interpreter_frame_bcx_addr() const { |
goetz@6458 | 143 | interpreterState istate = get_interpreterState(); |
goetz@6458 | 144 | return (intptr_t*)&istate->_bcp; |
goetz@6458 | 145 | } |
goetz@6458 | 146 | |
goetz@6458 | 147 | inline intptr_t* frame::interpreter_frame_mdx_addr() const { |
goetz@6458 | 148 | interpreterState istate = get_interpreterState(); |
goetz@6458 | 149 | return (intptr_t*)&istate->_mdx; |
goetz@6458 | 150 | } |
goetz@6458 | 151 | |
goetz@6458 | 152 | inline intptr_t* frame::interpreter_frame_expression_stack() const { |
goetz@6458 | 153 | return (intptr_t*)interpreter_frame_monitor_end() - 1; |
goetz@6458 | 154 | } |
goetz@6458 | 155 | |
goetz@6458 | 156 | inline jint frame::interpreter_frame_expression_stack_direction() { |
goetz@6458 | 157 | return -1; |
goetz@6458 | 158 | } |
goetz@6458 | 159 | |
goetz@6458 | 160 | // top of expression stack |
goetz@6458 | 161 | inline intptr_t* frame::interpreter_frame_tos_address() const { |
goetz@6458 | 162 | interpreterState istate = get_interpreterState(); |
goetz@6458 | 163 | return istate->_stack + 1; |
goetz@6458 | 164 | } |
goetz@6458 | 165 | |
goetz@6458 | 166 | inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const { |
goetz@6458 | 167 | return &interpreter_frame_tos_address()[offset]; |
goetz@6458 | 168 | } |
goetz@6458 | 169 | |
goetz@6458 | 170 | // monitor elements |
goetz@6458 | 171 | |
goetz@6458 | 172 | // in keeping with Intel side: end is lower in memory than begin; |
goetz@6458 | 173 | // and beginning element is oldest element |
goetz@6458 | 174 | // Also begin is one past last monitor. |
goetz@6458 | 175 | |
goetz@6458 | 176 | inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const { |
goetz@6458 | 177 | return get_interpreterState()->monitor_base(); |
goetz@6458 | 178 | } |
goetz@6458 | 179 | |
goetz@6458 | 180 | inline BasicObjectLock* frame::interpreter_frame_monitor_end() const { |
goetz@6458 | 181 | return (BasicObjectLock*)get_interpreterState()->stack_base(); |
goetz@6458 | 182 | } |
goetz@6458 | 183 | |
goetz@6458 | 184 | inline int frame::interpreter_frame_cinterpreterstate_size_in_bytes() { |
goetz@6458 | 185 | // Size of an interpreter object. Not aligned with frame size. |
goetz@6458 | 186 | return round_to(sizeof(BytecodeInterpreter), 8); |
goetz@6458 | 187 | } |
goetz@6458 | 188 | |
goetz@6458 | 189 | inline Method** frame::interpreter_frame_method_addr() const { |
goetz@6458 | 190 | interpreterState istate = get_interpreterState(); |
goetz@6458 | 191 | return &istate->_method; |
goetz@6458 | 192 | } |
goetz@6458 | 193 | |
goetz@6458 | 194 | // Constant pool cache |
goetz@6458 | 195 | |
goetz@6458 | 196 | inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const { |
goetz@6458 | 197 | interpreterState istate = get_interpreterState(); |
goetz@6458 | 198 | return &istate->_constants; // should really use accessor |
goetz@6458 | 199 | } |
goetz@6458 | 200 | |
goetz@6458 | 201 | inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { |
goetz@6458 | 202 | interpreterState istate = get_interpreterState(); |
goetz@6458 | 203 | return &istate->_constants; |
goetz@6458 | 204 | } |
goetz@6458 | 205 | #endif // CC_INTERP |
goetz@6458 | 206 | |
goetz@6458 | 207 | inline int frame::interpreter_frame_monitor_size() { |
goetz@6458 | 208 | // Number of stack slots for a monitor. |
goetz@6458 | 209 | return round_to(BasicObjectLock::size(), // number of stack slots |
goetz@6458 | 210 | WordsPerLong); // number of stack slots for a Java long |
goetz@6458 | 211 | } |
goetz@6458 | 212 | |
goetz@6458 | 213 | inline int frame::interpreter_frame_monitor_size_in_bytes() { |
goetz@6458 | 214 | return frame::interpreter_frame_monitor_size() * wordSize; |
goetz@6458 | 215 | } |
goetz@6458 | 216 | |
goetz@6458 | 217 | // entry frames |
goetz@6458 | 218 | |
goetz@6458 | 219 | inline intptr_t* frame::entry_frame_argument_at(int offset) const { |
goetz@6458 | 220 | // Since an entry frame always calls the interpreter first, the |
goetz@6458 | 221 | // parameters are on the stack and relative to known register in the |
goetz@6458 | 222 | // entry frame. |
goetz@6458 | 223 | intptr_t* tos = (intptr_t*)get_entry_frame_locals()->arguments_tos_address; |
goetz@6458 | 224 | return &tos[offset + 1]; // prepushed tos |
goetz@6458 | 225 | } |
goetz@6458 | 226 | |
goetz@6458 | 227 | inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const { |
goetz@6458 | 228 | return (JavaCallWrapper**)&get_entry_frame_locals()->call_wrapper_address; |
goetz@6458 | 229 | } |
goetz@6458 | 230 | |
goetz@6458 | 231 | inline oop frame::saved_oop_result(RegisterMap* map) const { |
goetz@6458 | 232 | return *((oop*)map->location(R3->as_VMReg())); |
goetz@6458 | 233 | } |
goetz@6458 | 234 | |
goetz@6458 | 235 | inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) { |
goetz@6458 | 236 | *((oop*)map->location(R3->as_VMReg())) = obj; |
goetz@6458 | 237 | } |
goetz@6458 | 238 | |
goetz@6458 | 239 | #endif // CPU_PPC_VM_FRAME_PPC_INLINE_HPP |