bytecodeInterpreter.hpp revision 2073:b92c45f2bc75
1181053Srwatson/* 2180701Srwatson * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 3170407Srwatson * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4155192Srwatson * 5155192Srwatson * This code is free software; you can redistribute it and/or modify it 6155192Srwatson * under the terms of the GNU General Public License version 2 only, as 7155192Srwatson * published by the Free Software Foundation. 8155192Srwatson * 9155192Srwatson * This code is distributed in the hope that it will be useful, but WITHOUT 10155192Srwatson * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11155192Srwatson * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12155192Srwatson * version 2 for more details (a copy is included in the LICENSE file that 13155192Srwatson * accompanied this code). 14180701Srwatson * 15155192Srwatson * You should have received a copy of the GNU General Public License version 16155192Srwatson * 2 along with this work; if not, write to the Free Software Foundation, 17155192Srwatson * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18155192Srwatson * 19155192Srwatson * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20155192Srwatson * or visit www.oracle.com if you need additional information or have any 21155192Srwatson * questions. 22155192Srwatson * 23155192Srwatson */ 24155192Srwatson 25155192Srwatson#ifndef SHARE_VM_INTERPRETER_BYTECODEINTERPRETER_HPP 26155192Srwatson#define SHARE_VM_INTERPRETER_BYTECODEINTERPRETER_HPP 27155192Srwatson 28155192Srwatson#include "memory/allocation.hpp" 29155192Srwatson#include "oops/methodDataOop.hpp" 30155192Srwatson#include "oops/methodOop.hpp" 31178186Srwatson#include "runtime/basicLock.hpp" 32178186Srwatson#include "runtime/frame.hpp" 33178186Srwatson#include "runtime/globals.hpp" 34155192Srwatson#include "utilities/globalDefinitions.hpp" 35155192Srwatson#ifdef TARGET_ARCH_x86 36155192Srwatson# include "bytes_x86.hpp" 37155192Srwatson#endif 38155192Srwatson#ifdef TARGET_ARCH_sparc 39155192Srwatson# include "bytes_sparc.hpp" 40155192Srwatson#endif 41155192Srwatson#ifdef TARGET_ARCH_zero 42155192Srwatson# include "bytes_zero.hpp" 43155192Srwatson#endif 44155192Srwatson#ifdef TARGET_ARCH_arm 45155192Srwatson# include "bytes_arm.hpp" 46164033Srwatson#endif 47155192Srwatson#ifdef TARGET_ARCH_ppc 48155192Srwatson# include "bytes_ppc.hpp" 49155192Srwatson#endif 50155192Srwatson 51155192Srwatson#ifdef CC_INTERP 52155192Srwatson 53171144Srwatson// CVM definitions find hotspot equivalents... 54155192Srwatson 55155192Srwatsonunion VMJavaVal64 { 56155192Srwatson jlong l; 57155192Srwatson jdouble d; 58155192Srwatson uint32_t v[2]; 59155192Srwatson}; 60155192Srwatson 61155192Srwatson 62155192Srwatsontypedef class BytecodeInterpreter* interpreterState; 63155406Srwatson 64156291Srwatsonstruct call_message { 65155406Srwatson class methodOopDesc* _callee; /* method to call during call_method request */ 66155406Srwatson address _callee_entry_point; /* address to jump to for call_method request */ 67155192Srwatson int _bcp_advance; /* size of the invoke bytecode operation */ 68155192Srwatson}; 69155192Srwatson 70155192Srwatsonstruct osr_message { 71155192Srwatson address _osr_buf; /* the osr buffer */ 72155192Srwatson address _osr_entry; /* the entry to the osr method */ 73155406Srwatson}; 74155406Srwatson 75156888Srwatsonstruct osr_result { 76170407Srwatson nmethod* nm; /* osr nmethod */ 77155192Srwatson address return_addr; /* osr blob return address */ 78155192Srwatson}; 79155192Srwatson 80155192Srwatson// Result returned to frame manager 81171144Srwatsonunion frame_manager_message { 82171144Srwatson call_message _to_call; /* describes callee */ 83171144Srwatson Bytecodes::Code _return_kind; /* i_return, a_return, ... */ 84155192Srwatson osr_message _osr; /* describes the osr */ 85170196Srwatson osr_result _osr_result; /* result of OSR request */ 86170196Srwatson}; 87170196Srwatson 88155192Srwatsonclass BytecodeInterpreter : StackObj { 89155192Srwatsonfriend class SharedRuntime; 90156889Srwatsonfriend class AbstractInterpreterGenerator; 91156889Srwatsonfriend class CppInterpreterGenerator; 92155192Srwatsonfriend class InterpreterGenerator; 93155192Srwatsonfriend class InterpreterMacroAssembler; 94162176Srwatsonfriend class frame; 95162176Srwatsonfriend class VMStructs; 96155192Srwatson 97156889Srwatsonpublic: 98156889Srwatson enum messages { 99161813Swsalamon no_request = 0, // unused 100161813Swsalamon initialize, // Perform one time interpreter initializations (assumes all switches set) 101155192Srwatson // status message to C++ interpreter 102155192Srwatson method_entry, // initial method entry to interpreter 103155192Srwatson method_resume, // frame manager response to return_from_method request (assuming a frame to resume) 104155192Srwatson deopt_resume, // returning from a native call into a deopted frame 105156889Srwatson deopt_resume2, // deopt resume as a result of a PopFrame 106155192Srwatson got_monitors, // frame manager response to more_monitors request 107155192Srwatson rethrow_exception, // unwinding and throwing exception 108170691Srwatson // requests to frame manager from C++ interpreter 109155192Srwatson call_method, // request for new frame from interpreter, manager responds with method_entry 110156889Srwatson return_from_method, // request from interpreter to unwind, manager responds with method_continue 111155192Srwatson more_monitors, // need a new monitor 112155192Srwatson throwing_exception, // unwind stack and rethrow 113155192Srwatson popping_frame, // unwind call and retry call 114155192Srwatson do_osr // request this invocation be OSR's 115156889Srwatson }; 116155192Srwatson 117155192Srwatsonprivate: 118155192Srwatson JavaThread* _thread; // the vm's java thread pointer 119155192Srwatson address _bcp; // instruction pointer 120155192Srwatson intptr_t* _locals; // local variable pointer 121156889Srwatson constantPoolCacheOop _constants; // constant pool cache 122155192Srwatson methodOop _method; // method being executed 123155192Srwatson DataLayout* _mdx; // compiler profiling data for current bytecode 124170196Srwatson intptr_t* _stack; // expression stack 125170196Srwatson messages _msg; // frame manager <-> interpreter message 126170196Srwatson frame_manager_message _result; // result to frame manager 127170196Srwatson interpreterState _prev_link; // previous interpreter state 128170196Srwatson oop _oop_temp; // mirror for interpreted native, null otherwise 129170196Srwatson intptr_t* _stack_base; // base of expression stack 130155192Srwatson intptr_t* _stack_limit; // limit of expression stack 131156889Srwatson BasicObjectLock* _monitor_base; // base of monitors on the native stack 132156889Srwatson 133156889Srwatson 134155192Srwatsonpublic: 135155192Srwatson // Constructor is only used by the initialization step. All other instances are created 136155192Srwatson // by the frame manager. 137155192Srwatson BytecodeInterpreter(messages msg); 138156889Srwatson 139155192Srwatson// 140155192Srwatson// Deoptimization support 141170196Srwatson// 142170196Srwatsonstatic void layout_interpreterState(interpreterState to_fill, 143155192Srwatson frame* caller, 144159261Srwatson frame* interpreter_frame, 145155192Srwatson methodOop method, 146155192Srwatson intptr_t* locals, 147159261Srwatson intptr_t* stack, 148159261Srwatson intptr_t* stack_base, 149159261Srwatson intptr_t* monitor_base, 150155192Srwatson intptr_t* frame_bottom, 151159261Srwatson bool top_frame); 152155192Srwatson 153156889Srwatson/* 154156889Srwatson * Generic 32-bit wide "Java slot" definition. This type occurs 155170196Srwatson * in operand stacks, Java locals, object fields, constant pools. 156170196Srwatson */ 157155192Srwatsonunion VMJavaVal32 { 158156889Srwatson jint i; 159155192Srwatson jfloat f; 160155192Srwatson class oopDesc* r; 161184856Scsjp uint32_t raw; 162184856Scsjp}; 163184856Scsjp 164184856Scsjp/* 165184856Scsjp * Generic 64-bit Java value definition 166184856Scsjp */ 167184856Scsjpunion VMJavaVal64 { 168184856Scsjp jlong l; 169184856Scsjp jdouble d; 170184856Scsjp uint32_t v[2]; 171184856Scsjp}; 172184856Scsjp 173184856Scsjp/* 174184856Scsjp * Generic 32-bit wide "Java slot" definition. This type occurs 175184856Scsjp * in Java locals, object fields, constant pools, and 176184856Scsjp * operand stacks (as a CVMStackVal32). 177184856Scsjp */ 178184856Scsjptypedef union VMSlotVal32 { 179184856Scsjp VMJavaVal32 j; /* For "Java" values */ 180184856Scsjp address a; /* a return created by jsr or jsr_w */ 181184856Scsjp} VMSlotVal32; 182184856Scsjp 183184856Scsjp 184184856Scsjp/* 185184856Scsjp * Generic 32-bit wide stack slot definition. 186184856Scsjp */ 187184856Scsjpunion VMStackVal32 { 188184856Scsjp VMJavaVal32 j; /* For "Java" values */ 189184856Scsjp VMSlotVal32 s; /* any value from a "slot" or locals[] */ 190184856Scsjp}; 191184856Scsjp 192184856Scsjpinline JavaThread* thread() { return _thread; } 193184856Scsjp 194184856Scsjpinline address bcp() { return _bcp; } 195184856Scsjpinline void set_bcp(address new_bcp) { _bcp = new_bcp; } 196184856Scsjp 197184856Scsjpinline intptr_t* locals() { return _locals; } 198184856Scsjp 199184856Scsjpinline constantPoolCacheOop constants() { return _constants; } 200155406Srwatsoninline methodOop method() { return _method; } 201155192Srwatsoninline DataLayout* mdx() { return _mdx; } 202155406Srwatsoninline void set_mdx(DataLayout *new_mdx) { _mdx = new_mdx; } 203155406Srwatson 204155406Srwatsoninline messages msg() { return _msg; } 205155406Srwatsoninline void set_msg(messages new_msg) { _msg = new_msg; } 206155406Srwatson 207155406Srwatsoninline methodOop callee() { return _result._to_call._callee; } 208155406Srwatsoninline void set_callee(methodOop new_callee) { _result._to_call._callee = new_callee; } 209155406Srwatsoninline void set_callee_entry_point(address entry) { _result._to_call._callee_entry_point = entry; } 210155406Srwatsoninline void set_osr_buf(address buf) { _result._osr._osr_buf = buf; } 211155406Srwatsoninline void set_osr_entry(address entry) { _result._osr._osr_entry = entry; } 212155406Srwatsoninline int bcp_advance() { return _result._to_call._bcp_advance; } 213155406Srwatsoninline void set_bcp_advance(int count) { _result._to_call._bcp_advance = count; } 214155406Srwatson 215155406Srwatsoninline void set_return_kind(Bytecodes::Code kind) { _result._return_kind = kind; } 216155406Srwatson 217155406Srwatsoninline interpreterState prev() { return _prev_link; } 218155406Srwatson 219155406Srwatsoninline intptr_t* stack() { return _stack; } 220155406Srwatsoninline void set_stack(intptr_t* new_stack) { _stack = new_stack; } 221155406Srwatson 222155406Srwatson 223170407Srwatsoninline intptr_t* stack_base() { return _stack_base; } 224170407Srwatsoninline intptr_t* stack_limit() { return _stack_limit; } 225155406Srwatson 226170407Srwatsoninline BasicObjectLock* monitor_base() { return _monitor_base; } 227170407Srwatson 228155406Srwatson/* 229155406Srwatson * 64-bit Arithmetic: 230155406Srwatson * 231155192Srwatson * The functions below follow the semantics of the 232155406Srwatson * ladd, land, ldiv, lmul, lor, lxor, and lrem bytecodes, 233155192Srwatson * respectively. 234155406Srwatson */ 235155192Srwatson 236155406Srwatsonstatic jlong VMlongAdd(jlong op1, jlong op2); 237155406Srwatsonstatic jlong VMlongAnd(jlong op1, jlong op2); 238155406Srwatsonstatic jlong VMlongDiv(jlong op1, jlong op2); 239155406Srwatsonstatic jlong VMlongMul(jlong op1, jlong op2); 240155192Srwatsonstatic jlong VMlongOr (jlong op1, jlong op2); 241155406Srwatsonstatic jlong VMlongSub(jlong op1, jlong op2); 242155192Srwatsonstatic jlong VMlongXor(jlong op1, jlong op2); 243155406Srwatsonstatic jlong VMlongRem(jlong op1, jlong op2); 244155192Srwatson 245155406Srwatson/* 246155192Srwatson * Shift: 247161813Swsalamon * 248161813Swsalamon * The functions below follow the semantics of the 249161813Swsalamon * lushr, lshl, and lshr bytecodes, respectively. 250161813Swsalamon */ 251155192Srwatson 252155192Srwatsonstatic jlong VMlongUshr(jlong op1, jint op2); 253155192Srwatsonstatic jlong VMlongShl (jlong op1, jint op2); 254155192Srwatsonstatic jlong VMlongShr (jlong op1, jint op2); 255155192Srwatson 256155192Srwatson/* 257155192Srwatson * Unary: 258155192Srwatson * 259155192Srwatson * Return the negation of "op" (-op), according to 260155192Srwatson * the semantics of the lneg bytecode. 261155192Srwatson */ 262155192Srwatson 263155192Srwatsonstatic jlong VMlongNeg(jlong op); 264155192Srwatson 265155192Srwatson/* 266155192Srwatson * Return the complement of "op" (~op) 267161813Swsalamon */ 268161813Swsalamon 269155192Srwatsonstatic jlong VMlongNot(jlong op); 270170196Srwatson 271156889Srwatson 272173142Srwatson/* 273173142Srwatson * Comparisons to 0: 274155192Srwatson */ 275155192Srwatson 276155192Srwatsonstatic int32_t VMlongLtz(jlong op); /* op <= 0 */ 277155192Srwatsonstatic int32_t VMlongGez(jlong op); /* op >= 0 */ 278155192Srwatsonstatic int32_t VMlongEqz(jlong op); /* op == 0 */ 279155192Srwatson 280155192Srwatson/* 281155192Srwatson * Between operands: 282155192Srwatson */ 283184856Scsjp 284184856Scsjpstatic int32_t VMlongEq(jlong op1, jlong op2); /* op1 == op2 */ 285184856Scsjpstatic int32_t VMlongNe(jlong op1, jlong op2); /* op1 != op2 */ 286155192Srwatsonstatic int32_t VMlongGe(jlong op1, jlong op2); /* op1 >= op2 */ 287184856Scsjpstatic int32_t VMlongLe(jlong op1, jlong op2); /* op1 <= op2 */ 288159261Srwatsonstatic int32_t VMlongLt(jlong op1, jlong op2); /* op1 < op2 */ 289159261Srwatsonstatic int32_t VMlongGt(jlong op1, jlong op2); /* op1 > op2 */ 290155192Srwatson 291155192Srwatson/* 292159266Srwatson * Comparisons (returning an jint value: 0, 1, or -1) 293155406Srwatson * 294155406Srwatson * Between operands: 295155406Srwatson * 296155192Srwatson * Compare "op1" and "op2" according to the semantics of the 297155192Srwatson * "lcmp" bytecode. 298155192Srwatson */ 299155192Srwatson 300155192Srwatsonstatic int32_t VMlongCompare(jlong op1, jlong op2); 301155192Srwatson 302155192Srwatson/* 303155192Srwatson * Convert int to long, according to "i2l" bytecode semantics 304155192Srwatson */ 305156888Srwatsonstatic jlong VMint2Long(jint val); 306156888Srwatson 307155192Srwatson/* 308155192Srwatson * Convert long to int, according to "l2i" bytecode semantics 309177253Srwatson */ 310155192Srwatsonstatic jint VMlong2Int(jlong val); 311155192Srwatson 312155192Srwatson/* 313155192Srwatson * Convert long to float, according to "l2f" bytecode semantics 314155192Srwatson */ 315179517Srwatsonstatic jfloat VMlong2Float(jlong val); 316179517Srwatson 317179517Srwatson/* 318155192Srwatson * Convert long to double, according to "l2d" bytecode semantics 319155192Srwatson */ 320155192Srwatsonstatic jdouble VMlong2Double(jlong val); 321155192Srwatson 322155192Srwatson/* 323155192Srwatson * Java floating-point float value manipulation. 324155192Srwatson * 325155192Srwatson * The result argument is, once again, an lvalue. 326155192Srwatson * 327155192Srwatson * Arithmetic: 328155192Srwatson * 329169896Srwatson * The functions below follow the semantics of the 330155192Srwatson * fadd, fsub, fmul, fdiv, and frem bytecodes, 331155192Srwatson * respectively. 332155192Srwatson */ 333155192Srwatson 334155192Srwatsonstatic jfloat VMfloatAdd(jfloat op1, jfloat op2); 335155192Srwatsonstatic jfloat VMfloatSub(jfloat op1, jfloat op2); 336155192Srwatsonstatic jfloat VMfloatMul(jfloat op1, jfloat op2); 337155192Srwatsonstatic jfloat VMfloatDiv(jfloat op1, jfloat op2); 338155192Srwatsonstatic jfloat VMfloatRem(jfloat op1, jfloat op2); 339155192Srwatson 340155192Srwatson/* 341155192Srwatson * Unary: 342155192Srwatson * 343155192Srwatson * Return the negation of "op" (-op), according to 344155192Srwatson * the semantics of the fneg bytecode. 345155192Srwatson */ 346155192Srwatson 347155192Srwatsonstatic jfloat VMfloatNeg(jfloat op); 348155192Srwatson 349155192Srwatson/* 350155406Srwatson * Comparisons (returning an int value: 0, 1, or -1) 351155406Srwatson * 352155406Srwatson * Between operands: 353155406Srwatson * 354155406Srwatson * Compare "op1" and "op2" according to the semantics of the 355155192Srwatson * "fcmpl" (direction is -1) or "fcmpg" (direction is 1) bytecodes. 356155192Srwatson */ 357165604Srwatson 358165604Srwatsonstatic int32_t VMfloatCompare(jfloat op1, jfloat op2, 359165604Srwatson int32_t direction); 360155192Srwatson/* 361155406Srwatson * Conversion: 362155406Srwatson */ 363155192Srwatson 364155192Srwatson/* 365155192Srwatson * Convert float to double, according to "f2d" bytecode semantics 366155192Srwatson */ 367155192Srwatson 368155192Srwatsonstatic jdouble VMfloat2Double(jfloat op); 369155192Srwatson 370155192Srwatson/* 371156888Srwatson ****************************************** 372156888Srwatson * Java double floating-point manipulation. 373156888Srwatson ****************************************** 374156888Srwatson * 375156888Srwatson * The result argument is, once again, an lvalue. 376156888Srwatson * 377156888Srwatson * Conversions: 378155192Srwatson */ 379155192Srwatson 380155192Srwatson/* 381159269Srwatson * Convert double to int, according to "d2i" bytecode semantics 382159269Srwatson */ 383159269Srwatson 384155192Srwatsonstatic jint VMdouble2Int(jdouble val); 385155192Srwatson 386155192Srwatson/* 387155192Srwatson * Convert double to float, according to "d2f" bytecode semantics 388155192Srwatson */ 389155192Srwatson 390155192Srwatsonstatic jfloat VMdouble2Float(jdouble val); 391170196Srwatson 392170196Srwatson/* 393155192Srwatson * Convert int to double, according to "i2d" bytecode semantics 394155192Srwatson */ 395155192Srwatson 396155192Srwatsonstatic jdouble VMint2Double(jint val); 397155192Srwatson 398156889Srwatson/* 399155192Srwatson * Arithmetic: 400155192Srwatson * 401155192Srwatson * The functions below follow the semantics of the 402155192Srwatson * dadd, dsub, ddiv, dmul, and drem bytecodes, respectively. 403155192Srwatson */ 404155192Srwatson 405155192Srwatsonstatic jdouble VMdoubleAdd(jdouble op1, jdouble op2); 406170196Srwatsonstatic jdouble VMdoubleSub(jdouble op1, jdouble op2); 407170196Srwatsonstatic jdouble VMdoubleDiv(jdouble op1, jdouble op2); 408170196Srwatsonstatic jdouble VMdoubleMul(jdouble op1, jdouble op2); 409170196Srwatsonstatic jdouble VMdoubleRem(jdouble op1, jdouble op2); 410155192Srwatson 411176690Srwatson/* 412155192Srwatson * Unary: 413155192Srwatson * 414155192Srwatson * Return the negation of "op" (-op), according to 415155192Srwatson * the semantics of the dneg bytecode. 416176690Srwatson */ 417155192Srwatson 418155192Srwatsonstatic jdouble VMdoubleNeg(jdouble op); 419155192Srwatson 420155192Srwatson/* 421170585Srwatson * Comparisons (returning an int32_t value: 0, 1, or -1) 422155192Srwatson * 423155192Srwatson * Between operands: 424155192Srwatson * 425155192Srwatson * Compare "op1" and "op2" according to the semantics of the 426159269Srwatson * "dcmpl" (direction is -1) or "dcmpg" (direction is 1) bytecodes. 427159269Srwatson */ 428159269Srwatson 429155192Srwatsonstatic int32_t VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction); 430159269Srwatson 431159269Srwatson/* 432159269Srwatson * Copy two typeless 32-bit words from one location to another. 433159269Srwatson * This is semantically equivalent to: 434159269Srwatson * 435159269Srwatson * to[0] = from[0]; 436162380Scsjp * to[1] = from[1]; 437162380Scsjp * 438155192Srwatson * but this interface is provided for those platforms that could 439155192Srwatson * optimize this into a single 64-bit transfer. 440155192Srwatson */ 441159275Srwatson 442155192Srwatsonstatic void VMmemCopy64(uint32_t to[2], const uint32_t from[2]); 443155192Srwatson 444155192Srwatson 445155192Srwatson// Arithmetic operations 446155192Srwatson 447155192Srwatson/* 448155192Srwatson * Java arithmetic methods. 449155192Srwatson * The functions below follow the semantics of the 450155192Srwatson * iadd, isub, imul, idiv, irem, iand, ior, ixor, 451155192Srwatson * and ineg bytecodes, respectively. 452155192Srwatson */ 453170196Srwatson 454155192Srwatsonstatic jint VMintAdd(jint op1, jint op2); 455155192Srwatsonstatic jint VMintSub(jint op1, jint op2); 456155192Srwatsonstatic jint VMintMul(jint op1, jint op2); 457159275Srwatsonstatic jint VMintDiv(jint op1, jint op2); 458155192Srwatsonstatic jint VMintRem(jint op1, jint op2); 459155192Srwatsonstatic jint VMintAnd(jint op1, jint op2); 460156889Srwatsonstatic jint VMintOr (jint op1, jint op2); 461155192Srwatsonstatic jint VMintXor(jint op1, jint op2); 462170182Srwatson 463170182Srwatson/* 464155192Srwatson * Shift Operation: 465170182Srwatson * The functions below follow the semantics of the 466159261Srwatson * iushr, ishl, and ishr bytecodes, respectively. 467155192Srwatson */ 468155192Srwatson 469155192Srwatsonstatic juint VMintUshr(jint op, jint num); 470155192Srwatsonstatic jint VMintShl (jint op, jint num); 471159261Srwatsonstatic jint VMintShr (jint op, jint num); 472155192Srwatson 473155192Srwatson/* 474155192Srwatson * Unary Operation: 475155192Srwatson * 476155192Srwatson * Return the negation of "op" (-op), according to 477155192Srwatson * the semantics of the ineg bytecode. 478155192Srwatson */ 479155192Srwatson 480155192Srwatsonstatic jint VMintNeg(jint op); 481155192Srwatson 482155192Srwatson/* 483155192Srwatson * Int Conversions: 484155192Srwatson */ 485159269Srwatson 486159269Srwatson/* 487159269Srwatson * Convert int to float, according to "i2f" bytecode semantics 488155192Srwatson */ 489155192Srwatson 490155192Srwatsonstatic jfloat VMint2Float(jint val); 491155192Srwatson 492155192Srwatson/* 493155192Srwatson * Convert int to byte, according to "i2b" bytecode semantics 494155192Srwatson */ 495155192Srwatson 496162950Srwatsonstatic jbyte VMint2Byte(jint val); 497162950Srwatson 498155192Srwatson/* 499155192Srwatson * Convert int to char, according to "i2c" bytecode semantics 500155192Srwatson */ 501155192Srwatson 502159269Srwatsonstatic jchar VMint2Char(jint val); 503159269Srwatson 504155192Srwatson/* 505155192Srwatson * Convert int to short, according to "i2s" bytecode semantics 506155192Srwatson */ 507155192Srwatson 508155192Srwatsonstatic jshort VMint2Short(jint val); 509155192Srwatson 510170407Srwatson/*========================================================================= 511159269Srwatson * Bytecode interpreter operations 512155192Srwatson *=======================================================================*/ 513155192Srwatson 514170407Srwatsonstatic void dup(intptr_t *tos); 515156889Srwatsonstatic void dup2(intptr_t *tos); 516155192Srwatsonstatic void dup_x1(intptr_t *tos); /* insert top word two down */ 517170196Srwatsonstatic void dup_x2(intptr_t *tos); /* insert top word three down */ 518170196Srwatsonstatic void dup2_x1(intptr_t *tos); /* insert top 2 slots three down */ 519155192Srwatsonstatic void dup2_x2(intptr_t *tos); /* insert top 2 slots four down */ 520159269Srwatsonstatic void swap(intptr_t *tos); /* swap top two elements */ 521159269Srwatson 522155192Srwatson// umm don't like this method modifies its object 523155192Srwatson 524155192Srwatson// The Interpreter used when 525155192Srwatsonstatic void run(interpreterState istate); 526155192Srwatson// The interpreter used if JVMTI needs interpreter events 527165604Srwatsonstatic void runWithChecks(interpreterState istate); 528155192Srwatsonstatic void End_Of_Interpreter(void); 529155192Srwatson 530155192Srwatson// Inline static functions for Java Stack and Local manipulation 531155192Srwatson 532155192Srwatsonstatic address stack_slot(intptr_t *tos, int offset); 533155192Srwatsonstatic jint stack_int(intptr_t *tos, int offset); 534164033Srwatsonstatic jfloat stack_float(intptr_t *tos, int offset); 535164033Srwatsonstatic oop stack_object(intptr_t *tos, int offset); 536155192Srwatsonstatic jdouble stack_double(intptr_t *tos, int offset); 537155192Srwatsonstatic jlong stack_long(intptr_t *tos, int offset); 538155192Srwatson 539159269Srwatson// only used for value types 540159269Srwatsonstatic void set_stack_slot(intptr_t *tos, address value, int offset); 541159269Srwatsonstatic void set_stack_int(intptr_t *tos, int value, int offset); 542159269Srwatsonstatic void set_stack_float(intptr_t *tos, jfloat value, int offset); 543155192Srwatsonstatic void set_stack_object(intptr_t *tos, oop value, int offset); 544155192Srwatson 545155192Srwatson// needs to be platform dep for the 32 bit platforms. 546155192Srwatsonstatic void set_stack_double(intptr_t *tos, jdouble value, int offset); 547155192Srwatsonstatic void set_stack_long(intptr_t *tos, jlong value, int offset); 548155192Srwatson 549155192Srwatsonstatic void set_stack_double_from_addr(intptr_t *tos, address addr, int offset); 550155192Srwatsonstatic void set_stack_long_from_addr(intptr_t *tos, address addr, int offset); 551155192Srwatson 552155192Srwatson// Locals 553155192Srwatson 554155192Srwatsonstatic address locals_slot(intptr_t* locals, int offset); 555155192Srwatsonstatic jint locals_int(intptr_t* locals, int offset); 556155192Srwatsonstatic jfloat locals_float(intptr_t* locals, int offset); 557170196Srwatsonstatic oop locals_object(intptr_t* locals, int offset); 558170196Srwatsonstatic jdouble locals_double(intptr_t* locals, int offset); 559170196Srwatsonstatic jlong locals_long(intptr_t* locals, int offset); 560170196Srwatson 561170196Srwatsonstatic address locals_long_at(intptr_t* locals, int offset); 562155192Srwatsonstatic address locals_double_at(intptr_t* locals, int offset); 563155192Srwatson 564155192Srwatsonstatic void set_locals_slot(intptr_t *locals, address value, int offset); 565155192Srwatsonstatic void set_locals_int(intptr_t *locals, jint value, int offset); 566155192Srwatsonstatic void set_locals_float(intptr_t *locals, jfloat value, int offset); 567155192Srwatsonstatic void set_locals_object(intptr_t *locals, oop value, int offset); 568155192Srwatsonstatic void set_locals_double(intptr_t *locals, jdouble value, int offset); 569155192Srwatsonstatic void set_locals_long(intptr_t *locals, jlong value, int offset); 570155192Srwatsonstatic void set_locals_double_from_addr(intptr_t *locals, 571155192Srwatson address addr, int offset); 572155192Srwatsonstatic void set_locals_long_from_addr(intptr_t *locals, 573170407Srwatson address addr, int offset); 574155192Srwatson 575155192Srwatsonstatic void astore(intptr_t* topOfStack, int stack_offset, 576170407Srwatson intptr_t* locals, int locals_offset); 577155192Srwatson 578155192Srwatson// Support for dup and swap 579155195Srwatsonstatic void copy_stack_slot(intptr_t *tos, int from_offset, int to_offset); 580170407Srwatson 581155195Srwatson#ifndef PRODUCT 582155195Srwatsonstatic const char* C_msg(BytecodeInterpreter::messages msg); 583155195Srwatsonvoid print(); 584155195Srwatson#endif // PRODUCT 585155353Srwatson 586170407Srwatson // Platform fields/methods 587155353Srwatson#ifdef TARGET_ARCH_x86 588155353Srwatson# include "bytecodeInterpreter_x86.hpp" 589170407Srwatson#endif 590155353Srwatson#ifdef TARGET_ARCH_sparc 591155353Srwatson# include "bytecodeInterpreter_sparc.hpp" 592156889Srwatson#endif 593162950Srwatson#ifdef TARGET_ARCH_zero 594162950Srwatson# include "bytecodeInterpreter_zero.hpp" 595155192Srwatson#endif 596155192Srwatson#ifdef TARGET_ARCH_arm 597170407Srwatson# include "bytecodeInterpreter_arm.hpp" 598155192Srwatson#endif 599155192Srwatson#ifdef TARGET_ARCH_ppc 600170585Srwatson# include "bytecodeInterpreter_ppc.hpp" 601175763Scsjp#endif 602155192Srwatson 603155192Srwatson 604155192Srwatson}; // BytecodeInterpreter 605170407Srwatson 606155192Srwatson#endif // CC_INTERP 607155192Srwatson 608170407Srwatson#endif // SHARE_VM_INTERPRETER_BYTECODEINTERPRETER_HPP 609175763Scsjp