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