Tue, 26 Jul 2016 17:06:17 +0800
Add multiply word to GPR instruction (mul) in MIPS assembler.
aoqi@1 | 1 | /* |
aoqi@1 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@1 | 3 | * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved. |
aoqi@1 | 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@1 | 5 | * |
aoqi@1 | 6 | * This code is free software; you can redistribute it and/or modify it |
aoqi@1 | 7 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@1 | 8 | * published by the Free Software Foundation. |
aoqi@1 | 9 | * |
aoqi@1 | 10 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@1 | 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@1 | 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@1 | 13 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@1 | 14 | * accompanied this code). |
aoqi@1 | 15 | * |
aoqi@1 | 16 | * You should have received a copy of the GNU General Public License version |
aoqi@1 | 17 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@1 | 18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@1 | 19 | * |
aoqi@1 | 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@1 | 21 | * or visit www.oracle.com if you need additional information or have any |
aoqi@1 | 22 | * questions. |
aoqi@1 | 23 | * |
aoqi@1 | 24 | */ |
aoqi@1 | 25 | |
aoqi@1 | 26 | #ifndef CPU_MIPS_VM_FRAME_MIPS_INLINE_HPP |
aoqi@1 | 27 | #define CPU_MIPS_VM_FRAME_MIPS_INLINE_HPP |
aoqi@1 | 28 | |
aoqi@1 | 29 | #include "code/codeCache.hpp" |
aoqi@1 | 30 | |
aoqi@1 | 31 | // Inline functions for Loongson frames: |
aoqi@1 | 32 | |
aoqi@1 | 33 | // Constructors: |
aoqi@1 | 34 | |
aoqi@1 | 35 | inline frame::frame() { |
aoqi@1 | 36 | _pc = NULL; |
aoqi@1 | 37 | _sp = NULL; |
aoqi@1 | 38 | _unextended_sp = NULL; |
aoqi@1 | 39 | _fp = NULL; |
aoqi@1 | 40 | _cb = NULL; |
aoqi@1 | 41 | _deopt_state = unknown; |
aoqi@1 | 42 | } |
aoqi@1 | 43 | |
aoqi@1 | 44 | inline frame:: frame(intptr_t* sp, intptr_t* fp, address pc) { |
aoqi@1 | 45 | _sp = sp; |
aoqi@1 | 46 | _unextended_sp = sp; |
aoqi@1 | 47 | _fp = fp; |
aoqi@1 | 48 | _pc = pc; |
aoqi@1 | 49 | assert(pc != NULL, "no pc?"); |
aoqi@1 | 50 | _cb = CodeCache::find_blob(pc); |
aoqi@1 | 51 | adjust_unextended_sp(); |
aoqi@1 | 52 | address original_pc = nmethod::get_deopt_original_pc(this); |
aoqi@1 | 53 | if (original_pc != NULL) { |
aoqi@1 | 54 | _pc = original_pc; |
aoqi@1 | 55 | _deopt_state = is_deoptimized; |
aoqi@1 | 56 | } else { |
aoqi@1 | 57 | _deopt_state = not_deoptimized; |
aoqi@1 | 58 | } |
aoqi@1 | 59 | } |
aoqi@1 | 60 | |
aoqi@1 | 61 | inline frame:: frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) { |
aoqi@1 | 62 | _sp = sp; |
aoqi@1 | 63 | _unextended_sp = unextended_sp; |
aoqi@1 | 64 | _fp = fp; |
aoqi@1 | 65 | _pc = pc; |
aoqi@1 | 66 | assert(pc != NULL, "no pc?"); |
aoqi@1 | 67 | _cb = CodeCache::find_blob(pc); |
aoqi@1 | 68 | adjust_unextended_sp(); |
aoqi@1 | 69 | address original_pc = nmethod::get_deopt_original_pc(this); |
aoqi@1 | 70 | if (original_pc != NULL) { |
aoqi@1 | 71 | _pc = original_pc; |
aoqi@1 | 72 | _deopt_state = is_deoptimized; |
aoqi@1 | 73 | } else { |
aoqi@1 | 74 | _deopt_state = not_deoptimized; |
aoqi@1 | 75 | } |
aoqi@1 | 76 | } |
aoqi@1 | 77 | |
aoqi@1 | 78 | inline frame::frame(intptr_t* sp, intptr_t* fp) { |
aoqi@1 | 79 | _sp = sp; |
aoqi@1 | 80 | _unextended_sp = sp; |
aoqi@1 | 81 | _fp = fp; |
aoqi@1 | 82 | _pc = (address)(sp[-1]); |
aoqi@1 | 83 | |
aoqi@1 | 84 | // Here's a sticky one. This constructor can be called via AsyncGetCallTrace |
aoqi@1 | 85 | // when last_Java_sp is non-null but the pc fetched is junk. If we are truly |
aoqi@1 | 86 | // unlucky the junk value could be to a zombied method and we'll die on the |
aoqi@1 | 87 | // find_blob call. This is also why we can have no asserts on the validity |
aoqi@1 | 88 | // of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler |
aoqi@1 | 89 | // -> pd_last_frame should use a specialized version of pd_last_frame which could |
aoqi@1 | 90 | // call a specilaized frame constructor instead of this one. |
aoqi@1 | 91 | // Then we could use the assert below. However this assert is of somewhat dubious |
aoqi@1 | 92 | // value. |
aoqi@1 | 93 | // assert(_pc != NULL, "no pc?"); |
aoqi@1 | 94 | |
aoqi@1 | 95 | _cb = CodeCache::find_blob(_pc); |
aoqi@1 | 96 | adjust_unextended_sp(); |
aoqi@1 | 97 | address original_pc = nmethod::get_deopt_original_pc(this); |
aoqi@1 | 98 | if (original_pc != NULL) { |
aoqi@1 | 99 | _pc = original_pc; |
aoqi@1 | 100 | _deopt_state = is_deoptimized; |
aoqi@1 | 101 | } else { |
aoqi@1 | 102 | _deopt_state = not_deoptimized; |
aoqi@1 | 103 | } |
aoqi@1 | 104 | } |
aoqi@1 | 105 | |
aoqi@1 | 106 | // Accessors |
aoqi@1 | 107 | |
aoqi@1 | 108 | inline bool frame::equal(frame other) const { |
aoqi@1 | 109 | bool ret = sp() == other.sp() |
aoqi@1 | 110 | && unextended_sp() == other.unextended_sp() |
aoqi@1 | 111 | && fp() == other.fp() |
aoqi@1 | 112 | && pc() == other.pc(); |
aoqi@1 | 113 | assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction"); |
aoqi@1 | 114 | return ret; |
aoqi@1 | 115 | } |
aoqi@1 | 116 | |
aoqi@1 | 117 | // Return unique id for this frame. The id must have a value where we can distinguish |
aoqi@1 | 118 | // identity and younger/older relationship. NULL represents an invalid (incomparable) |
aoqi@1 | 119 | // frame. |
aoqi@1 | 120 | inline intptr_t* frame::id(void) const { return unextended_sp(); } |
aoqi@1 | 121 | |
aoqi@1 | 122 | // Relationals on frames based |
aoqi@1 | 123 | // Return true if the frame is younger (more recent activation) than the frame represented by id |
aoqi@1 | 124 | inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); |
aoqi@1 | 125 | return this->id() < id ; } |
aoqi@1 | 126 | |
aoqi@1 | 127 | // Return true if the frame is older (less recent activation) than the frame represented by id |
aoqi@1 | 128 | inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); |
aoqi@1 | 129 | return this->id() > id ; } |
aoqi@1 | 130 | |
aoqi@1 | 131 | |
aoqi@1 | 132 | |
aoqi@1 | 133 | inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); } |
aoqi@1 | 134 | inline void frame::set_link(intptr_t* addr) { *(intptr_t **)addr_at(link_offset) = addr; } |
aoqi@1 | 135 | |
aoqi@1 | 136 | |
aoqi@1 | 137 | inline intptr_t* frame::unextended_sp() const { return _unextended_sp; } |
aoqi@1 | 138 | |
aoqi@1 | 139 | // Return address: |
aoqi@1 | 140 | |
aoqi@1 | 141 | inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); } |
aoqi@1 | 142 | inline address frame::sender_pc() const { return *sender_pc_addr(); } |
aoqi@1 | 143 | |
aoqi@1 | 144 | // return address of param, zero origin index. |
aoqi@1 | 145 | inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); } |
aoqi@1 | 146 | |
aoqi@1 | 147 | #ifdef CC_INTERP |
aoqi@1 | 148 | |
aoqi@1 | 149 | inline interpreterState frame::get_interpreterState() const { |
aoqi@1 | 150 | return ((interpreterState)addr_at( -sizeof(BytecodeInterpreter)/wordSize )); |
aoqi@1 | 151 | } |
aoqi@1 | 152 | |
aoqi@1 | 153 | inline intptr_t* frame::sender_sp() const { |
aoqi@1 | 154 | // Hmm this seems awfully expensive QQQ, is this really called with interpreted frames? |
aoqi@1 | 155 | if (is_interpreted_frame()) { |
aoqi@1 | 156 | assert(false, "should never happen"); |
aoqi@1 | 157 | return get_interpreterState()->sender_sp(); |
aoqi@1 | 158 | } else { |
aoqi@1 | 159 | return addr_at(sender_sp_offset); |
aoqi@1 | 160 | } |
aoqi@1 | 161 | } |
aoqi@1 | 162 | |
aoqi@1 | 163 | inline intptr_t** frame::interpreter_frame_locals_addr() const { |
aoqi@1 | 164 | assert(is_interpreted_frame(), "must be interpreted"); |
aoqi@1 | 165 | return &(get_interpreterState()->_locals); |
aoqi@1 | 166 | } |
aoqi@1 | 167 | |
aoqi@1 | 168 | inline intptr_t* frame::interpreter_frame_bcx_addr() const { |
aoqi@1 | 169 | assert(is_interpreted_frame(), "must be interpreted"); |
aoqi@1 | 170 | return (intptr_t*) &(get_interpreterState()->_bcp); |
aoqi@1 | 171 | } |
aoqi@1 | 172 | |
aoqi@1 | 173 | |
aoqi@1 | 174 | // Constant pool cache |
aoqi@1 | 175 | |
aoqi@1 | 176 | inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { |
aoqi@1 | 177 | assert(is_interpreted_frame(), "must be interpreted"); |
aoqi@1 | 178 | return &(get_interpreterState()->_constants); |
aoqi@1 | 179 | } |
aoqi@1 | 180 | |
aoqi@1 | 181 | // Method |
aoqi@1 | 182 | |
aoqi@1 | 183 | inline Method** frame::interpreter_frame_method_addr() const { |
aoqi@1 | 184 | assert(is_interpreted_frame(), "must be interpreted"); |
aoqi@1 | 185 | return &(get_interpreterState()->_method); |
aoqi@1 | 186 | } |
aoqi@1 | 187 | |
aoqi@1 | 188 | inline intptr_t* frame::interpreter_frame_mdx_addr() const { |
aoqi@1 | 189 | assert(is_interpreted_frame(), "must be interpreted"); |
aoqi@1 | 190 | return (intptr_t*) &(get_interpreterState()->_mdx); |
aoqi@1 | 191 | } |
aoqi@1 | 192 | |
aoqi@1 | 193 | // top of expression stack |
aoqi@1 | 194 | inline intptr_t* frame::interpreter_frame_tos_address() const { |
aoqi@1 | 195 | assert(is_interpreted_frame(), "wrong frame type"); |
aoqi@1 | 196 | return get_interpreterState()->_stack + 1; |
aoqi@1 | 197 | } |
aoqi@1 | 198 | |
aoqi@1 | 199 | #else /* asm interpreter */ |
aoqi@1 | 200 | inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); } |
aoqi@1 | 201 | |
aoqi@1 | 202 | inline intptr_t** frame::interpreter_frame_locals_addr() const { |
aoqi@1 | 203 | return (intptr_t**)addr_at(interpreter_frame_locals_offset); |
aoqi@1 | 204 | } |
aoqi@1 | 205 | |
aoqi@1 | 206 | inline intptr_t* frame::interpreter_frame_last_sp() const { |
aoqi@1 | 207 | return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset); |
aoqi@1 | 208 | } |
aoqi@1 | 209 | |
aoqi@1 | 210 | inline intptr_t* frame::interpreter_frame_bcx_addr() const { |
aoqi@1 | 211 | return (intptr_t*)addr_at(interpreter_frame_bcx_offset); |
aoqi@1 | 212 | } |
aoqi@1 | 213 | |
aoqi@1 | 214 | |
aoqi@1 | 215 | inline intptr_t* frame::interpreter_frame_mdx_addr() const { |
aoqi@1 | 216 | return (intptr_t*)addr_at(interpreter_frame_mdx_offset); |
aoqi@1 | 217 | } |
aoqi@1 | 218 | |
aoqi@1 | 219 | |
aoqi@1 | 220 | |
aoqi@1 | 221 | // Constant pool cache |
aoqi@1 | 222 | |
aoqi@1 | 223 | inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { |
aoqi@1 | 224 | return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset); |
aoqi@1 | 225 | } |
aoqi@1 | 226 | |
aoqi@1 | 227 | // Method |
aoqi@1 | 228 | |
aoqi@1 | 229 | inline Method** frame::interpreter_frame_method_addr() const { |
aoqi@1 | 230 | return (Method**)addr_at(interpreter_frame_method_offset); |
aoqi@1 | 231 | } |
aoqi@1 | 232 | |
aoqi@1 | 233 | // top of expression stack |
aoqi@1 | 234 | inline intptr_t* frame::interpreter_frame_tos_address() const { |
aoqi@1 | 235 | intptr_t* last_sp = interpreter_frame_last_sp(); |
aoqi@1 | 236 | if (last_sp == NULL ) { |
aoqi@1 | 237 | return sp(); |
aoqi@1 | 238 | } else { |
aoqi@1 | 239 | // sp() may have been extended by an adapter |
aoqi@1 | 240 | assert(last_sp <= (intptr_t*)interpreter_frame_monitor_end(), "bad tos"); |
aoqi@1 | 241 | return last_sp; |
aoqi@1 | 242 | } |
aoqi@1 | 243 | } |
aoqi@1 | 244 | |
aoqi@1 | 245 | inline oop* frame::interpreter_frame_temp_oop_addr() const { |
aoqi@1 | 246 | return (oop *)(fp() + interpreter_frame_oop_temp_offset); |
aoqi@1 | 247 | } |
aoqi@1 | 248 | |
aoqi@1 | 249 | #endif /* CC_INTERP */ |
aoqi@1 | 250 | |
aoqi@1 | 251 | inline int frame::pd_oop_map_offset_adjustment() const { |
aoqi@1 | 252 | return 0; |
aoqi@1 | 253 | } |
aoqi@1 | 254 | |
aoqi@1 | 255 | inline int frame::interpreter_frame_monitor_size() { |
aoqi@1 | 256 | return BasicObjectLock::size(); |
aoqi@1 | 257 | } |
aoqi@1 | 258 | |
aoqi@1 | 259 | |
aoqi@1 | 260 | // expression stack |
aoqi@1 | 261 | // (the max_stack arguments are used by the GC; see class FrameClosure) |
aoqi@1 | 262 | |
aoqi@1 | 263 | inline intptr_t* frame::interpreter_frame_expression_stack() const { |
aoqi@1 | 264 | intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end(); |
aoqi@1 | 265 | return monitor_end-1; |
aoqi@1 | 266 | } |
aoqi@1 | 267 | |
aoqi@1 | 268 | |
aoqi@1 | 269 | inline jint frame::interpreter_frame_expression_stack_direction() { return -1; } |
aoqi@1 | 270 | |
aoqi@1 | 271 | |
aoqi@1 | 272 | // Entry frames |
aoqi@1 | 273 | /* |
aoqi@1 | 274 | inline JavaCallWrapper* frame::entry_frame_call_wrapper() const { |
aoqi@1 | 275 | return (JavaCallWrapper*)at(entry_frame_call_wrapper_offset); |
aoqi@1 | 276 | } |
aoqi@1 | 277 | */ |
aoqi@1 | 278 | |
aoqi@1 | 279 | // Entry frames |
aoqi@1 | 280 | |
aoqi@1 | 281 | inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const { // Fu: 20130814 |
aoqi@1 | 282 | return (JavaCallWrapper**)addr_at(entry_frame_call_wrapper_offset); |
aoqi@1 | 283 | } |
aoqi@1 | 284 | |
aoqi@1 | 285 | // Compiled frames |
aoqi@1 | 286 | |
aoqi@1 | 287 | inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) { |
aoqi@1 | 288 | return (nof_args - local_index + (local_index < nof_args ? 1: -1)); |
aoqi@1 | 289 | } |
aoqi@1 | 290 | |
aoqi@1 | 291 | inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) { |
aoqi@1 | 292 | return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors); |
aoqi@1 | 293 | } |
aoqi@1 | 294 | |
aoqi@1 | 295 | inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) { |
aoqi@1 | 296 | return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1); |
aoqi@1 | 297 | } |
aoqi@1 | 298 | |
aoqi@1 | 299 | inline bool frame::volatile_across_calls(Register reg) { |
aoqi@1 | 300 | return true; |
aoqi@1 | 301 | } |
aoqi@1 | 302 | |
aoqi@1 | 303 | |
aoqi@1 | 304 | |
aoqi@1 | 305 | inline oop frame::saved_oop_result(RegisterMap* map) const { |
aoqi@1 | 306 | return *((oop*) map->location(V0->as_VMReg())); |
aoqi@1 | 307 | } |
aoqi@1 | 308 | |
aoqi@1 | 309 | inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) { |
aoqi@1 | 310 | *((oop*) map->location(V0->as_VMReg())) = obj; |
aoqi@1 | 311 | } |
aoqi@1 | 312 | |
aoqi@1 | 313 | #endif // CPU_MIPS_VM_FRAME_MIPS_INLINE_HPP |