Wed, 27 Apr 2016 01:25:04 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #ifndef SHARE_VM_INTERPRETER_BYTECODEINTERPRETER_HPP |
aoqi@0 | 26 | #define SHARE_VM_INTERPRETER_BYTECODEINTERPRETER_HPP |
aoqi@0 | 27 | |
aoqi@0 | 28 | #include "memory/allocation.hpp" |
aoqi@0 | 29 | #include "oops/methodData.hpp" |
aoqi@0 | 30 | #include "oops/method.hpp" |
aoqi@0 | 31 | #include "runtime/basicLock.hpp" |
aoqi@0 | 32 | #include "runtime/frame.hpp" |
aoqi@0 | 33 | #include "runtime/globals.hpp" |
aoqi@0 | 34 | #include "utilities/globalDefinitions.hpp" |
aoqi@0 | 35 | #ifdef TARGET_ARCH_x86 |
aoqi@0 | 36 | # include "bytes_x86.hpp" |
aoqi@0 | 37 | #endif |
aoqi@0 | 38 | #ifdef TARGET_ARCH_sparc |
aoqi@0 | 39 | # include "bytes_sparc.hpp" |
aoqi@0 | 40 | #endif |
aoqi@0 | 41 | #ifdef TARGET_ARCH_zero |
aoqi@0 | 42 | # include "bytes_zero.hpp" |
aoqi@0 | 43 | #endif |
aoqi@0 | 44 | #ifdef TARGET_ARCH_arm |
aoqi@0 | 45 | # include "bytes_arm.hpp" |
aoqi@0 | 46 | #endif |
aoqi@0 | 47 | #ifdef TARGET_ARCH_ppc |
aoqi@0 | 48 | # include "bytes_ppc.hpp" |
aoqi@0 | 49 | #endif |
aoqi@0 | 50 | |
aoqi@0 | 51 | #ifdef CC_INTERP |
aoqi@0 | 52 | |
aoqi@0 | 53 | // JavaStack Implementation |
aoqi@0 | 54 | #define MORE_STACK(count) \ |
aoqi@0 | 55 | (topOfStack -= ((count) * Interpreter::stackElementWords)) |
aoqi@0 | 56 | |
aoqi@0 | 57 | // CVM definitions find hotspot equivalents... |
aoqi@0 | 58 | |
aoqi@0 | 59 | union VMJavaVal64 { |
aoqi@0 | 60 | jlong l; |
aoqi@0 | 61 | jdouble d; |
aoqi@0 | 62 | uint32_t v[2]; |
aoqi@0 | 63 | }; |
aoqi@0 | 64 | |
aoqi@0 | 65 | |
aoqi@0 | 66 | typedef class BytecodeInterpreter* interpreterState; |
aoqi@0 | 67 | |
aoqi@0 | 68 | struct call_message { |
aoqi@0 | 69 | class Method* _callee; // method to call during call_method request |
aoqi@0 | 70 | address _callee_entry_point; // address to jump to for call_method request |
aoqi@0 | 71 | int _bcp_advance; // size of the invoke bytecode operation |
aoqi@0 | 72 | }; |
aoqi@0 | 73 | |
aoqi@0 | 74 | struct osr_message { |
aoqi@0 | 75 | address _osr_buf; // the osr buffer |
aoqi@0 | 76 | address _osr_entry; // the entry to the osr method |
aoqi@0 | 77 | }; |
aoqi@0 | 78 | |
aoqi@0 | 79 | struct osr_result { |
aoqi@0 | 80 | nmethod* nm; // osr nmethod |
aoqi@0 | 81 | address return_addr; // osr blob return address |
aoqi@0 | 82 | }; |
aoqi@0 | 83 | |
aoqi@0 | 84 | // Result returned to frame manager |
aoqi@0 | 85 | union frame_manager_message { |
aoqi@0 | 86 | call_message _to_call; // describes callee |
aoqi@0 | 87 | osr_message _osr; // describes the osr |
aoqi@0 | 88 | osr_result _osr_result; // result of OSR request |
aoqi@0 | 89 | }; |
aoqi@0 | 90 | |
aoqi@0 | 91 | class BytecodeInterpreter : StackObj { |
aoqi@0 | 92 | friend class SharedRuntime; |
aoqi@0 | 93 | friend class AbstractInterpreterGenerator; |
aoqi@0 | 94 | friend class CppInterpreterGenerator; |
aoqi@0 | 95 | friend class InterpreterGenerator; |
aoqi@0 | 96 | friend class InterpreterMacroAssembler; |
aoqi@0 | 97 | friend class frame; |
aoqi@0 | 98 | friend class VMStructs; |
aoqi@0 | 99 | |
aoqi@0 | 100 | public: |
aoqi@0 | 101 | enum messages { |
aoqi@0 | 102 | no_request = 0, // unused |
aoqi@0 | 103 | initialize, // Perform one time interpreter initializations (assumes all switches set) |
aoqi@0 | 104 | // status message to C++ interpreter |
aoqi@0 | 105 | method_entry, // initial method entry to interpreter |
aoqi@0 | 106 | method_resume, // frame manager response to return_from_method request (assuming a frame to resume) |
aoqi@0 | 107 | deopt_resume, // returning from a native call into a deopted frame |
aoqi@0 | 108 | deopt_resume2, // deopt resume as a result of a PopFrame |
aoqi@0 | 109 | got_monitors, // frame manager response to more_monitors request |
aoqi@0 | 110 | rethrow_exception, // unwinding and throwing exception |
aoqi@0 | 111 | // requests to frame manager from C++ interpreter |
aoqi@0 | 112 | call_method, // request for new frame from interpreter, manager responds with method_entry |
aoqi@0 | 113 | return_from_method, // request from interpreter to unwind, manager responds with method_continue |
aoqi@0 | 114 | more_monitors, // need a new monitor |
aoqi@0 | 115 | throwing_exception, // unwind stack and rethrow |
aoqi@0 | 116 | popping_frame, // unwind call and retry call |
aoqi@0 | 117 | do_osr, // request this invocation be OSR's |
aoqi@0 | 118 | early_return // early return as commanded by jvmti |
aoqi@0 | 119 | }; |
aoqi@0 | 120 | |
aoqi@0 | 121 | private: |
aoqi@0 | 122 | JavaThread* _thread; // the vm's java thread pointer |
aoqi@0 | 123 | address _bcp; // instruction pointer |
aoqi@0 | 124 | intptr_t* _locals; // local variable pointer |
aoqi@0 | 125 | ConstantPoolCache* _constants; // constant pool cache |
aoqi@0 | 126 | Method* _method; // method being executed |
aoqi@0 | 127 | DataLayout* _mdx; // compiler profiling data for current bytecode |
aoqi@0 | 128 | intptr_t* _stack; // expression stack |
aoqi@0 | 129 | messages _msg; // frame manager <-> interpreter message |
aoqi@0 | 130 | frame_manager_message _result; // result to frame manager |
aoqi@0 | 131 | interpreterState _prev_link; // previous interpreter state |
aoqi@0 | 132 | oop _oop_temp; // mirror for interpreted native, null otherwise |
aoqi@0 | 133 | intptr_t* _stack_base; // base of expression stack |
aoqi@0 | 134 | intptr_t* _stack_limit; // limit of expression stack |
aoqi@0 | 135 | BasicObjectLock* _monitor_base; // base of monitors on the native stack |
aoqi@0 | 136 | |
aoqi@0 | 137 | |
aoqi@0 | 138 | public: |
aoqi@0 | 139 | // Constructor is only used by the initialization step. All other instances are created |
aoqi@0 | 140 | // by the frame manager. |
aoqi@0 | 141 | BytecodeInterpreter(messages msg); |
aoqi@0 | 142 | |
aoqi@0 | 143 | // |
aoqi@0 | 144 | // Deoptimization support |
aoqi@0 | 145 | // |
aoqi@0 | 146 | static void layout_interpreterState(interpreterState to_fill, |
aoqi@0 | 147 | frame* caller, |
aoqi@0 | 148 | frame* interpreter_frame, |
aoqi@0 | 149 | Method* method, |
aoqi@0 | 150 | intptr_t* locals, |
aoqi@0 | 151 | intptr_t* stack, |
aoqi@0 | 152 | intptr_t* stack_base, |
aoqi@0 | 153 | intptr_t* monitor_base, |
aoqi@0 | 154 | intptr_t* frame_bottom, |
aoqi@0 | 155 | bool top_frame); |
aoqi@0 | 156 | |
aoqi@0 | 157 | /* |
aoqi@0 | 158 | * Generic 32-bit wide "Java slot" definition. This type occurs |
aoqi@0 | 159 | * in operand stacks, Java locals, object fields, constant pools. |
aoqi@0 | 160 | */ |
aoqi@0 | 161 | union VMJavaVal32 { |
aoqi@0 | 162 | jint i; |
aoqi@0 | 163 | jfloat f; |
aoqi@0 | 164 | class oopDesc* r; |
aoqi@0 | 165 | uint32_t raw; |
aoqi@0 | 166 | }; |
aoqi@0 | 167 | |
aoqi@0 | 168 | /* |
aoqi@0 | 169 | * Generic 64-bit Java value definition |
aoqi@0 | 170 | */ |
aoqi@0 | 171 | union VMJavaVal64 { |
aoqi@0 | 172 | jlong l; |
aoqi@0 | 173 | jdouble d; |
aoqi@0 | 174 | uint32_t v[2]; |
aoqi@0 | 175 | }; |
aoqi@0 | 176 | |
aoqi@0 | 177 | /* |
aoqi@0 | 178 | * Generic 32-bit wide "Java slot" definition. This type occurs |
aoqi@0 | 179 | * in Java locals, object fields, constant pools, and |
aoqi@0 | 180 | * operand stacks (as a CVMStackVal32). |
aoqi@0 | 181 | */ |
aoqi@0 | 182 | typedef union VMSlotVal32 { |
aoqi@0 | 183 | VMJavaVal32 j; /* For "Java" values */ |
aoqi@0 | 184 | address a; /* a return created by jsr or jsr_w */ |
aoqi@0 | 185 | } VMSlotVal32; |
aoqi@0 | 186 | |
aoqi@0 | 187 | |
aoqi@0 | 188 | /* |
aoqi@0 | 189 | * Generic 32-bit wide stack slot definition. |
aoqi@0 | 190 | */ |
aoqi@0 | 191 | union VMStackVal32 { |
aoqi@0 | 192 | VMJavaVal32 j; /* For "Java" values */ |
aoqi@0 | 193 | VMSlotVal32 s; /* any value from a "slot" or locals[] */ |
aoqi@0 | 194 | }; |
aoqi@0 | 195 | |
aoqi@0 | 196 | inline JavaThread* thread() { return _thread; } |
aoqi@0 | 197 | |
aoqi@0 | 198 | inline address bcp() { return _bcp; } |
aoqi@0 | 199 | inline void set_bcp(address new_bcp) { _bcp = new_bcp; } |
aoqi@0 | 200 | |
aoqi@0 | 201 | inline intptr_t* locals() { return _locals; } |
aoqi@0 | 202 | |
aoqi@0 | 203 | inline ConstantPoolCache* constants() { return _constants; } |
aoqi@0 | 204 | inline Method* method() { return _method; } |
aoqi@0 | 205 | inline DataLayout* mdx() { return _mdx; } |
aoqi@0 | 206 | inline void set_mdx(DataLayout *new_mdx) { _mdx = new_mdx; } |
aoqi@0 | 207 | |
aoqi@0 | 208 | inline messages msg() { return _msg; } |
aoqi@0 | 209 | inline void set_msg(messages new_msg) { _msg = new_msg; } |
aoqi@0 | 210 | |
aoqi@0 | 211 | inline Method* callee() { return _result._to_call._callee; } |
aoqi@0 | 212 | inline void set_callee(Method* new_callee) { _result._to_call._callee = new_callee; } |
aoqi@0 | 213 | inline void set_callee_entry_point(address entry) { _result._to_call._callee_entry_point = entry; } |
aoqi@0 | 214 | inline void set_osr_buf(address buf) { _result._osr._osr_buf = buf; } |
aoqi@0 | 215 | inline void set_osr_entry(address entry) { _result._osr._osr_entry = entry; } |
aoqi@0 | 216 | inline int bcp_advance() { return _result._to_call._bcp_advance; } |
aoqi@0 | 217 | inline void set_bcp_advance(int count) { _result._to_call._bcp_advance = count; } |
aoqi@0 | 218 | |
aoqi@0 | 219 | inline interpreterState prev() { return _prev_link; } |
aoqi@0 | 220 | |
aoqi@0 | 221 | inline intptr_t* stack() { return _stack; } |
aoqi@0 | 222 | inline void set_stack(intptr_t* new_stack) { _stack = new_stack; } |
aoqi@0 | 223 | |
aoqi@0 | 224 | |
aoqi@0 | 225 | inline intptr_t* stack_base() { return _stack_base; } |
aoqi@0 | 226 | inline intptr_t* stack_limit() { return _stack_limit; } |
aoqi@0 | 227 | |
aoqi@0 | 228 | inline BasicObjectLock* monitor_base() { return _monitor_base; } |
aoqi@0 | 229 | |
aoqi@0 | 230 | /* |
aoqi@0 | 231 | * 64-bit Arithmetic: |
aoqi@0 | 232 | * |
aoqi@0 | 233 | * The functions below follow the semantics of the |
aoqi@0 | 234 | * ladd, land, ldiv, lmul, lor, lxor, and lrem bytecodes, |
aoqi@0 | 235 | * respectively. |
aoqi@0 | 236 | */ |
aoqi@0 | 237 | |
aoqi@0 | 238 | static jlong VMlongAdd(jlong op1, jlong op2); |
aoqi@0 | 239 | static jlong VMlongAnd(jlong op1, jlong op2); |
aoqi@0 | 240 | static jlong VMlongDiv(jlong op1, jlong op2); |
aoqi@0 | 241 | static jlong VMlongMul(jlong op1, jlong op2); |
aoqi@0 | 242 | static jlong VMlongOr (jlong op1, jlong op2); |
aoqi@0 | 243 | static jlong VMlongSub(jlong op1, jlong op2); |
aoqi@0 | 244 | static jlong VMlongXor(jlong op1, jlong op2); |
aoqi@0 | 245 | static jlong VMlongRem(jlong op1, jlong op2); |
aoqi@0 | 246 | |
aoqi@0 | 247 | /* |
aoqi@0 | 248 | * Shift: |
aoqi@0 | 249 | * |
aoqi@0 | 250 | * The functions below follow the semantics of the |
aoqi@0 | 251 | * lushr, lshl, and lshr bytecodes, respectively. |
aoqi@0 | 252 | */ |
aoqi@0 | 253 | |
aoqi@0 | 254 | static jlong VMlongUshr(jlong op1, jint op2); |
aoqi@0 | 255 | static jlong VMlongShl (jlong op1, jint op2); |
aoqi@0 | 256 | static jlong VMlongShr (jlong op1, jint op2); |
aoqi@0 | 257 | |
aoqi@0 | 258 | /* |
aoqi@0 | 259 | * Unary: |
aoqi@0 | 260 | * |
aoqi@0 | 261 | * Return the negation of "op" (-op), according to |
aoqi@0 | 262 | * the semantics of the lneg bytecode. |
aoqi@0 | 263 | */ |
aoqi@0 | 264 | |
aoqi@0 | 265 | static jlong VMlongNeg(jlong op); |
aoqi@0 | 266 | |
aoqi@0 | 267 | /* |
aoqi@0 | 268 | * Return the complement of "op" (~op) |
aoqi@0 | 269 | */ |
aoqi@0 | 270 | |
aoqi@0 | 271 | static jlong VMlongNot(jlong op); |
aoqi@0 | 272 | |
aoqi@0 | 273 | |
aoqi@0 | 274 | /* |
aoqi@0 | 275 | * Comparisons to 0: |
aoqi@0 | 276 | */ |
aoqi@0 | 277 | |
aoqi@0 | 278 | static int32_t VMlongLtz(jlong op); /* op <= 0 */ |
aoqi@0 | 279 | static int32_t VMlongGez(jlong op); /* op >= 0 */ |
aoqi@0 | 280 | static int32_t VMlongEqz(jlong op); /* op == 0 */ |
aoqi@0 | 281 | |
aoqi@0 | 282 | /* |
aoqi@0 | 283 | * Between operands: |
aoqi@0 | 284 | */ |
aoqi@0 | 285 | |
aoqi@0 | 286 | static int32_t VMlongEq(jlong op1, jlong op2); /* op1 == op2 */ |
aoqi@0 | 287 | static int32_t VMlongNe(jlong op1, jlong op2); /* op1 != op2 */ |
aoqi@0 | 288 | static int32_t VMlongGe(jlong op1, jlong op2); /* op1 >= op2 */ |
aoqi@0 | 289 | static int32_t VMlongLe(jlong op1, jlong op2); /* op1 <= op2 */ |
aoqi@0 | 290 | static int32_t VMlongLt(jlong op1, jlong op2); /* op1 < op2 */ |
aoqi@0 | 291 | static int32_t VMlongGt(jlong op1, jlong op2); /* op1 > op2 */ |
aoqi@0 | 292 | |
aoqi@0 | 293 | /* |
aoqi@0 | 294 | * Comparisons (returning an jint value: 0, 1, or -1) |
aoqi@0 | 295 | * |
aoqi@0 | 296 | * Between operands: |
aoqi@0 | 297 | * |
aoqi@0 | 298 | * Compare "op1" and "op2" according to the semantics of the |
aoqi@0 | 299 | * "lcmp" bytecode. |
aoqi@0 | 300 | */ |
aoqi@0 | 301 | |
aoqi@0 | 302 | static int32_t VMlongCompare(jlong op1, jlong op2); |
aoqi@0 | 303 | |
aoqi@0 | 304 | /* |
aoqi@0 | 305 | * Convert int to long, according to "i2l" bytecode semantics |
aoqi@0 | 306 | */ |
aoqi@0 | 307 | static jlong VMint2Long(jint val); |
aoqi@0 | 308 | |
aoqi@0 | 309 | /* |
aoqi@0 | 310 | * Convert long to int, according to "l2i" bytecode semantics |
aoqi@0 | 311 | */ |
aoqi@0 | 312 | static jint VMlong2Int(jlong val); |
aoqi@0 | 313 | |
aoqi@0 | 314 | /* |
aoqi@0 | 315 | * Convert long to float, according to "l2f" bytecode semantics |
aoqi@0 | 316 | */ |
aoqi@0 | 317 | static jfloat VMlong2Float(jlong val); |
aoqi@0 | 318 | |
aoqi@0 | 319 | /* |
aoqi@0 | 320 | * Convert long to double, according to "l2d" bytecode semantics |
aoqi@0 | 321 | */ |
aoqi@0 | 322 | static jdouble VMlong2Double(jlong val); |
aoqi@0 | 323 | |
aoqi@0 | 324 | /* |
aoqi@0 | 325 | * Java floating-point float value manipulation. |
aoqi@0 | 326 | * |
aoqi@0 | 327 | * The result argument is, once again, an lvalue. |
aoqi@0 | 328 | * |
aoqi@0 | 329 | * Arithmetic: |
aoqi@0 | 330 | * |
aoqi@0 | 331 | * The functions below follow the semantics of the |
aoqi@0 | 332 | * fadd, fsub, fmul, fdiv, and frem bytecodes, |
aoqi@0 | 333 | * respectively. |
aoqi@0 | 334 | */ |
aoqi@0 | 335 | |
aoqi@0 | 336 | static jfloat VMfloatAdd(jfloat op1, jfloat op2); |
aoqi@0 | 337 | static jfloat VMfloatSub(jfloat op1, jfloat op2); |
aoqi@0 | 338 | static jfloat VMfloatMul(jfloat op1, jfloat op2); |
aoqi@0 | 339 | static jfloat VMfloatDiv(jfloat op1, jfloat op2); |
aoqi@0 | 340 | static jfloat VMfloatRem(jfloat op1, jfloat op2); |
aoqi@0 | 341 | |
aoqi@0 | 342 | /* |
aoqi@0 | 343 | * Unary: |
aoqi@0 | 344 | * |
aoqi@0 | 345 | * Return the negation of "op" (-op), according to |
aoqi@0 | 346 | * the semantics of the fneg bytecode. |
aoqi@0 | 347 | */ |
aoqi@0 | 348 | |
aoqi@0 | 349 | static jfloat VMfloatNeg(jfloat op); |
aoqi@0 | 350 | |
aoqi@0 | 351 | /* |
aoqi@0 | 352 | * Comparisons (returning an int value: 0, 1, or -1) |
aoqi@0 | 353 | * |
aoqi@0 | 354 | * Between operands: |
aoqi@0 | 355 | * |
aoqi@0 | 356 | * Compare "op1" and "op2" according to the semantics of the |
aoqi@0 | 357 | * "fcmpl" (direction is -1) or "fcmpg" (direction is 1) bytecodes. |
aoqi@0 | 358 | */ |
aoqi@0 | 359 | |
aoqi@0 | 360 | static int32_t VMfloatCompare(jfloat op1, jfloat op2, |
aoqi@0 | 361 | int32_t direction); |
aoqi@0 | 362 | /* |
aoqi@0 | 363 | * Conversion: |
aoqi@0 | 364 | */ |
aoqi@0 | 365 | |
aoqi@0 | 366 | /* |
aoqi@0 | 367 | * Convert float to double, according to "f2d" bytecode semantics |
aoqi@0 | 368 | */ |
aoqi@0 | 369 | |
aoqi@0 | 370 | static jdouble VMfloat2Double(jfloat op); |
aoqi@0 | 371 | |
aoqi@0 | 372 | /* |
aoqi@0 | 373 | ****************************************** |
aoqi@0 | 374 | * Java double floating-point manipulation. |
aoqi@0 | 375 | ****************************************** |
aoqi@0 | 376 | * |
aoqi@0 | 377 | * The result argument is, once again, an lvalue. |
aoqi@0 | 378 | * |
aoqi@0 | 379 | * Conversions: |
aoqi@0 | 380 | */ |
aoqi@0 | 381 | |
aoqi@0 | 382 | /* |
aoqi@0 | 383 | * Convert double to int, according to "d2i" bytecode semantics |
aoqi@0 | 384 | */ |
aoqi@0 | 385 | |
aoqi@0 | 386 | static jint VMdouble2Int(jdouble val); |
aoqi@0 | 387 | |
aoqi@0 | 388 | /* |
aoqi@0 | 389 | * Convert double to float, according to "d2f" bytecode semantics |
aoqi@0 | 390 | */ |
aoqi@0 | 391 | |
aoqi@0 | 392 | static jfloat VMdouble2Float(jdouble val); |
aoqi@0 | 393 | |
aoqi@0 | 394 | /* |
aoqi@0 | 395 | * Convert int to double, according to "i2d" bytecode semantics |
aoqi@0 | 396 | */ |
aoqi@0 | 397 | |
aoqi@0 | 398 | static jdouble VMint2Double(jint val); |
aoqi@0 | 399 | |
aoqi@0 | 400 | /* |
aoqi@0 | 401 | * Arithmetic: |
aoqi@0 | 402 | * |
aoqi@0 | 403 | * The functions below follow the semantics of the |
aoqi@0 | 404 | * dadd, dsub, ddiv, dmul, and drem bytecodes, respectively. |
aoqi@0 | 405 | */ |
aoqi@0 | 406 | |
aoqi@0 | 407 | static jdouble VMdoubleAdd(jdouble op1, jdouble op2); |
aoqi@0 | 408 | static jdouble VMdoubleSub(jdouble op1, jdouble op2); |
aoqi@0 | 409 | static jdouble VMdoubleDiv(jdouble op1, jdouble op2); |
aoqi@0 | 410 | static jdouble VMdoubleMul(jdouble op1, jdouble op2); |
aoqi@0 | 411 | static jdouble VMdoubleRem(jdouble op1, jdouble op2); |
aoqi@0 | 412 | |
aoqi@0 | 413 | /* |
aoqi@0 | 414 | * Unary: |
aoqi@0 | 415 | * |
aoqi@0 | 416 | * Return the negation of "op" (-op), according to |
aoqi@0 | 417 | * the semantics of the dneg bytecode. |
aoqi@0 | 418 | */ |
aoqi@0 | 419 | |
aoqi@0 | 420 | static jdouble VMdoubleNeg(jdouble op); |
aoqi@0 | 421 | |
aoqi@0 | 422 | /* |
aoqi@0 | 423 | * Comparisons (returning an int32_t value: 0, 1, or -1) |
aoqi@0 | 424 | * |
aoqi@0 | 425 | * Between operands: |
aoqi@0 | 426 | * |
aoqi@0 | 427 | * Compare "op1" and "op2" according to the semantics of the |
aoqi@0 | 428 | * "dcmpl" (direction is -1) or "dcmpg" (direction is 1) bytecodes. |
aoqi@0 | 429 | */ |
aoqi@0 | 430 | |
aoqi@0 | 431 | static int32_t VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction); |
aoqi@0 | 432 | |
aoqi@0 | 433 | /* |
aoqi@0 | 434 | * Copy two typeless 32-bit words from one location to another. |
aoqi@0 | 435 | * This is semantically equivalent to: |
aoqi@0 | 436 | * |
aoqi@0 | 437 | * to[0] = from[0]; |
aoqi@0 | 438 | * to[1] = from[1]; |
aoqi@0 | 439 | * |
aoqi@0 | 440 | * but this interface is provided for those platforms that could |
aoqi@0 | 441 | * optimize this into a single 64-bit transfer. |
aoqi@0 | 442 | */ |
aoqi@0 | 443 | |
aoqi@0 | 444 | static void VMmemCopy64(uint32_t to[2], const uint32_t from[2]); |
aoqi@0 | 445 | |
aoqi@0 | 446 | |
aoqi@0 | 447 | // Arithmetic operations |
aoqi@0 | 448 | |
aoqi@0 | 449 | /* |
aoqi@0 | 450 | * Java arithmetic methods. |
aoqi@0 | 451 | * The functions below follow the semantics of the |
aoqi@0 | 452 | * iadd, isub, imul, idiv, irem, iand, ior, ixor, |
aoqi@0 | 453 | * and ineg bytecodes, respectively. |
aoqi@0 | 454 | */ |
aoqi@0 | 455 | |
aoqi@0 | 456 | static jint VMintAdd(jint op1, jint op2); |
aoqi@0 | 457 | static jint VMintSub(jint op1, jint op2); |
aoqi@0 | 458 | static jint VMintMul(jint op1, jint op2); |
aoqi@0 | 459 | static jint VMintDiv(jint op1, jint op2); |
aoqi@0 | 460 | static jint VMintRem(jint op1, jint op2); |
aoqi@0 | 461 | static jint VMintAnd(jint op1, jint op2); |
aoqi@0 | 462 | static jint VMintOr (jint op1, jint op2); |
aoqi@0 | 463 | static jint VMintXor(jint op1, jint op2); |
aoqi@0 | 464 | |
aoqi@0 | 465 | /* |
aoqi@0 | 466 | * Shift Operation: |
aoqi@0 | 467 | * The functions below follow the semantics of the |
aoqi@0 | 468 | * iushr, ishl, and ishr bytecodes, respectively. |
aoqi@0 | 469 | */ |
aoqi@0 | 470 | |
aoqi@0 | 471 | static juint VMintUshr(jint op, jint num); |
aoqi@0 | 472 | static jint VMintShl (jint op, jint num); |
aoqi@0 | 473 | static jint VMintShr (jint op, jint num); |
aoqi@0 | 474 | |
aoqi@0 | 475 | /* |
aoqi@0 | 476 | * Unary Operation: |
aoqi@0 | 477 | * |
aoqi@0 | 478 | * Return the negation of "op" (-op), according to |
aoqi@0 | 479 | * the semantics of the ineg bytecode. |
aoqi@0 | 480 | */ |
aoqi@0 | 481 | |
aoqi@0 | 482 | static jint VMintNeg(jint op); |
aoqi@0 | 483 | |
aoqi@0 | 484 | /* |
aoqi@0 | 485 | * Int Conversions: |
aoqi@0 | 486 | */ |
aoqi@0 | 487 | |
aoqi@0 | 488 | /* |
aoqi@0 | 489 | * Convert int to float, according to "i2f" bytecode semantics |
aoqi@0 | 490 | */ |
aoqi@0 | 491 | |
aoqi@0 | 492 | static jfloat VMint2Float(jint val); |
aoqi@0 | 493 | |
aoqi@0 | 494 | /* |
aoqi@0 | 495 | * Convert int to byte, according to "i2b" bytecode semantics |
aoqi@0 | 496 | */ |
aoqi@0 | 497 | |
aoqi@0 | 498 | static jbyte VMint2Byte(jint val); |
aoqi@0 | 499 | |
aoqi@0 | 500 | /* |
aoqi@0 | 501 | * Convert int to char, according to "i2c" bytecode semantics |
aoqi@0 | 502 | */ |
aoqi@0 | 503 | |
aoqi@0 | 504 | static jchar VMint2Char(jint val); |
aoqi@0 | 505 | |
aoqi@0 | 506 | /* |
aoqi@0 | 507 | * Convert int to short, according to "i2s" bytecode semantics |
aoqi@0 | 508 | */ |
aoqi@0 | 509 | |
aoqi@0 | 510 | static jshort VMint2Short(jint val); |
aoqi@0 | 511 | |
aoqi@0 | 512 | /*========================================================================= |
aoqi@0 | 513 | * Bytecode interpreter operations |
aoqi@0 | 514 | *=======================================================================*/ |
aoqi@0 | 515 | |
aoqi@0 | 516 | static void dup(intptr_t *tos); |
aoqi@0 | 517 | static void dup2(intptr_t *tos); |
aoqi@0 | 518 | static void dup_x1(intptr_t *tos); /* insert top word two down */ |
aoqi@0 | 519 | static void dup_x2(intptr_t *tos); /* insert top word three down */ |
aoqi@0 | 520 | static void dup2_x1(intptr_t *tos); /* insert top 2 slots three down */ |
aoqi@0 | 521 | static void dup2_x2(intptr_t *tos); /* insert top 2 slots four down */ |
aoqi@0 | 522 | static void swap(intptr_t *tos); /* swap top two elements */ |
aoqi@0 | 523 | |
aoqi@0 | 524 | // umm don't like this method modifies its object |
aoqi@0 | 525 | |
aoqi@0 | 526 | // The Interpreter used when |
aoqi@0 | 527 | static void run(interpreterState istate); |
aoqi@0 | 528 | // The interpreter used if JVMTI needs interpreter events |
aoqi@0 | 529 | static void runWithChecks(interpreterState istate); |
aoqi@0 | 530 | static void End_Of_Interpreter(void); |
aoqi@0 | 531 | |
aoqi@0 | 532 | // Inline static functions for Java Stack and Local manipulation |
aoqi@0 | 533 | |
aoqi@0 | 534 | static address stack_slot(intptr_t *tos, int offset); |
aoqi@0 | 535 | static jint stack_int(intptr_t *tos, int offset); |
aoqi@0 | 536 | static jfloat stack_float(intptr_t *tos, int offset); |
aoqi@0 | 537 | static oop stack_object(intptr_t *tos, int offset); |
aoqi@0 | 538 | static jdouble stack_double(intptr_t *tos, int offset); |
aoqi@0 | 539 | static jlong stack_long(intptr_t *tos, int offset); |
aoqi@0 | 540 | |
aoqi@0 | 541 | // only used for value types |
aoqi@0 | 542 | static void set_stack_slot(intptr_t *tos, address value, int offset); |
aoqi@0 | 543 | static void set_stack_int(intptr_t *tos, int value, int offset); |
aoqi@0 | 544 | static void set_stack_float(intptr_t *tos, jfloat value, int offset); |
aoqi@0 | 545 | static void set_stack_object(intptr_t *tos, oop value, int offset); |
aoqi@0 | 546 | |
aoqi@0 | 547 | // needs to be platform dep for the 32 bit platforms. |
aoqi@0 | 548 | static void set_stack_double(intptr_t *tos, jdouble value, int offset); |
aoqi@0 | 549 | static void set_stack_long(intptr_t *tos, jlong value, int offset); |
aoqi@0 | 550 | |
aoqi@0 | 551 | static void set_stack_double_from_addr(intptr_t *tos, address addr, int offset); |
aoqi@0 | 552 | static void set_stack_long_from_addr(intptr_t *tos, address addr, int offset); |
aoqi@0 | 553 | |
aoqi@0 | 554 | // Locals |
aoqi@0 | 555 | |
aoqi@0 | 556 | static address locals_slot(intptr_t* locals, int offset); |
aoqi@0 | 557 | static jint locals_int(intptr_t* locals, int offset); |
aoqi@0 | 558 | static jfloat locals_float(intptr_t* locals, int offset); |
aoqi@0 | 559 | static oop locals_object(intptr_t* locals, int offset); |
aoqi@0 | 560 | static jdouble locals_double(intptr_t* locals, int offset); |
aoqi@0 | 561 | static jlong locals_long(intptr_t* locals, int offset); |
aoqi@0 | 562 | |
aoqi@0 | 563 | static address locals_long_at(intptr_t* locals, int offset); |
aoqi@0 | 564 | static address locals_double_at(intptr_t* locals, int offset); |
aoqi@0 | 565 | |
aoqi@0 | 566 | static void set_locals_slot(intptr_t *locals, address value, int offset); |
aoqi@0 | 567 | static void set_locals_int(intptr_t *locals, jint value, int offset); |
aoqi@0 | 568 | static void set_locals_float(intptr_t *locals, jfloat value, int offset); |
aoqi@0 | 569 | static void set_locals_object(intptr_t *locals, oop value, int offset); |
aoqi@0 | 570 | static void set_locals_double(intptr_t *locals, jdouble value, int offset); |
aoqi@0 | 571 | static void set_locals_long(intptr_t *locals, jlong value, int offset); |
aoqi@0 | 572 | static void set_locals_double_from_addr(intptr_t *locals, |
aoqi@0 | 573 | address addr, int offset); |
aoqi@0 | 574 | static void set_locals_long_from_addr(intptr_t *locals, |
aoqi@0 | 575 | address addr, int offset); |
aoqi@0 | 576 | |
aoqi@0 | 577 | static void astore(intptr_t* topOfStack, int stack_offset, |
aoqi@0 | 578 | intptr_t* locals, int locals_offset); |
aoqi@0 | 579 | |
aoqi@0 | 580 | // Support for dup and swap |
aoqi@0 | 581 | static void copy_stack_slot(intptr_t *tos, int from_offset, int to_offset); |
aoqi@0 | 582 | |
aoqi@0 | 583 | #ifndef PRODUCT |
aoqi@0 | 584 | static const char* C_msg(BytecodeInterpreter::messages msg); |
aoqi@0 | 585 | void print(); |
aoqi@0 | 586 | #endif // PRODUCT |
aoqi@0 | 587 | |
aoqi@0 | 588 | // Platform fields/methods |
aoqi@0 | 589 | #ifdef TARGET_ARCH_x86 |
aoqi@0 | 590 | # include "bytecodeInterpreter_x86.hpp" |
aoqi@0 | 591 | #endif |
aoqi@0 | 592 | #ifdef TARGET_ARCH_sparc |
aoqi@0 | 593 | # include "bytecodeInterpreter_sparc.hpp" |
aoqi@0 | 594 | #endif |
aoqi@0 | 595 | #ifdef TARGET_ARCH_zero |
aoqi@0 | 596 | # include "bytecodeInterpreter_zero.hpp" |
aoqi@0 | 597 | #endif |
aoqi@0 | 598 | #ifdef TARGET_ARCH_arm |
aoqi@0 | 599 | # include "bytecodeInterpreter_arm.hpp" |
aoqi@0 | 600 | #endif |
aoqi@0 | 601 | #ifdef TARGET_ARCH_ppc |
aoqi@0 | 602 | # include "bytecodeInterpreter_ppc.hpp" |
aoqi@0 | 603 | #endif |
aoqi@0 | 604 | |
aoqi@0 | 605 | |
aoqi@0 | 606 | }; // BytecodeInterpreter |
aoqi@0 | 607 | |
aoqi@0 | 608 | #endif // CC_INTERP |
aoqi@0 | 609 | |
aoqi@0 | 610 | #endif // SHARE_VM_INTERPRETER_BYTECODEINTERPRETER_HPP |