1 /* 2 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. 3 * Copyright 2007, 2008, 2011 Red Hat, Inc. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 #ifndef CPU_ZERO_VM_BYTECODEINTERPRETER_ZERO_HPP 27 #define CPU_ZERO_VM_BYTECODEINTERPRETER_ZERO_HPP 28 29 // Platform specific for C++ based Interpreter 30 31 #if defined(PPC) || defined(SPARC) || defined(IA64) 32 #define LOTS_OF_REGS // Use plenty of registers 33 #else 34 #undef LOTS_OF_REGS // Loser platforms 35 #endif 36 37 private: 38 interpreterState _self_link; 39 40 public: 41 inline void set_locals(intptr_t* new_locals) { 42 _locals = new_locals; 43 } set_method(Method * new_method)44 inline void set_method(Method* new_method) { 45 _method = new_method; 46 } set_mirror(oop new_mirror)47 inline void set_mirror(oop new_mirror) { 48 _mirror = new_mirror; 49 } self_link()50 inline interpreterState self_link() { 51 return _self_link; 52 } set_self_link(interpreterState new_self_link)53 inline void set_self_link(interpreterState new_self_link) { 54 _self_link = new_self_link; 55 } prev_link()56 inline interpreterState prev_link() { 57 return _prev_link; 58 } set_prev_link(interpreterState new_prev_link)59 inline void set_prev_link(interpreterState new_prev_link) { 60 _prev_link = new_prev_link; 61 } set_stack_limit(intptr_t * new_stack_limit)62 inline void set_stack_limit(intptr_t* new_stack_limit) { 63 _stack_limit = new_stack_limit; 64 } set_stack_base(intptr_t * new_stack_base)65 inline void set_stack_base(intptr_t* new_stack_base) { 66 _stack_base = new_stack_base; 67 } set_monitor_base(BasicObjectLock * new_monitor_base)68 inline void set_monitor_base(BasicObjectLock *new_monitor_base) { 69 _monitor_base = new_monitor_base; 70 } set_thread(JavaThread * new_thread)71 inline void set_thread(JavaThread* new_thread) { 72 _thread = new_thread; 73 } set_constants(ConstantPoolCache * new_constants)74 inline void set_constants(ConstantPoolCache* new_constants) { 75 _constants = new_constants; 76 } oop_temp()77 inline oop oop_temp() { 78 return _oop_temp; 79 } oop_temp_addr()80 inline oop *oop_temp_addr() { 81 return &_oop_temp; 82 } set_oop_temp(oop new_oop_temp)83 inline void set_oop_temp(oop new_oop_temp) { 84 _oop_temp = new_oop_temp; 85 } callee_entry_point()86 inline address callee_entry_point() { 87 return _result._to_call._callee_entry_point; 88 } osr_buf()89 inline address osr_buf() { 90 return _result._osr._osr_buf; 91 } osr_entry()92 inline address osr_entry() { 93 return _result._osr._osr_entry; 94 } 95 96 public: 97 const char *name_of_field_at_address(address addr); 98 99 // The frame manager handles this 100 #define SET_LAST_JAVA_FRAME() 101 #define RESET_LAST_JAVA_FRAME() 102 103 // ZeroStack Implementation 104 105 #undef STACK_INT 106 #undef STACK_FLOAT 107 #undef STACK_ADDR 108 #undef STACK_OBJECT 109 #undef STACK_DOUBLE 110 #undef STACK_LONG 111 112 #define GET_STACK_SLOT(offset) (*((intptr_t*) &topOfStack[-(offset)])) 113 #define STACK_SLOT(offset) ((address) &topOfStack[-(offset)]) 114 #define STACK_ADDR(offset) (*((address *) &topOfStack[-(offset)])) 115 #define STACK_INT(offset) (*((jint*) &topOfStack[-(offset)])) 116 #define STACK_FLOAT(offset) (*((jfloat *) &topOfStack[-(offset)])) 117 #define STACK_OBJECT(offset) (*((oop *) &topOfStack [-(offset)])) 118 #define STACK_DOUBLE(offset) (((VMJavaVal64*) &topOfStack[-(offset)])->d) 119 #define STACK_LONG(offset) (((VMJavaVal64 *) &topOfStack[-(offset)])->l) 120 121 #define SET_STACK_SLOT(value, offset) (*(intptr_t*)&topOfStack[-(offset)] = *(intptr_t*)(value)) 122 #define SET_STACK_ADDR(value, offset) (*((address *)&topOfStack[-(offset)]) = (value)) 123 #define SET_STACK_INT(value, offset) (*((jint *)&topOfStack[-(offset)]) = (value)) 124 #define SET_STACK_FLOAT(value, offset) (*((jfloat *)&topOfStack[-(offset)]) = (value)) 125 #define SET_STACK_OBJECT(value, offset) (*((oop *)&topOfStack[-(offset)]) = (value)) 126 #define SET_STACK_DOUBLE(value, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->d = (value)) 127 #define SET_STACK_DOUBLE_FROM_ADDR(addr, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->d = \ 128 ((VMJavaVal64*)(addr))->d) 129 #define SET_STACK_LONG(value, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->l = (value)) 130 #define SET_STACK_LONG_FROM_ADDR(addr, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->l = \ 131 ((VMJavaVal64*)(addr))->l) 132 // JavaLocals implementation 133 134 #define LOCALS_SLOT(offset) ((intptr_t*)&locals[-(offset)]) 135 #define LOCALS_ADDR(offset) ((address)locals[-(offset)]) 136 #define LOCALS_INT(offset) (*((jint*)&locals[-(offset)])) 137 #define LOCALS_FLOAT(offset) (*((jfloat*)&locals[-(offset)])) 138 #define LOCALS_OBJECT(offset) (cast_to_oop(locals[-(offset)])) 139 #define LOCALS_DOUBLE(offset) (((VMJavaVal64*)&locals[-((offset) + 1)])->d) 140 #define LOCALS_LONG(offset) (((VMJavaVal64*)&locals[-((offset) + 1)])->l) 141 #define LOCALS_LONG_AT(offset) (((address)&locals[-((offset) + 1)])) 142 #define LOCALS_DOUBLE_AT(offset) (((address)&locals[-((offset) + 1)])) 143 144 #define SET_LOCALS_SLOT(value, offset) (*(intptr_t*)&locals[-(offset)] = *(intptr_t *)(value)) 145 #define SET_LOCALS_ADDR(value, offset) (*((address *)&locals[-(offset)]) = (value)) 146 #define SET_LOCALS_INT(value, offset) (*((jint *)&locals[-(offset)]) = (value)) 147 #define SET_LOCALS_FLOAT(value, offset) (*((jfloat *)&locals[-(offset)]) = (value)) 148 #define SET_LOCALS_OBJECT(value, offset) (*((oop *)&locals[-(offset)]) = (value)) 149 #define SET_LOCALS_DOUBLE(value, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->d = (value)) 150 #define SET_LOCALS_LONG(value, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->l = (value)) 151 #define SET_LOCALS_DOUBLE_FROM_ADDR(addr, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->d = \ 152 ((VMJavaVal64*)(addr))->d) 153 #define SET_LOCALS_LONG_FROM_ADDR(addr, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->l = \ 154 ((VMJavaVal64*)(addr))->l) 155 156 // VMSlots implementation 157 158 #define VMSLOTS_SLOT(offset) ((intptr_t*)&vmslots[(offset)]) 159 #define VMSLOTS_ADDR(offset) ((address)vmslots[(offset)]) 160 #define VMSLOTS_INT(offset) (*((jint*)&vmslots[(offset)])) 161 #define VMSLOTS_FLOAT(offset) (*((jfloat*)&vmslots[(offset)])) 162 #define VMSLOTS_OBJECT(offset) ((oop)vmslots[(offset)]) 163 #define VMSLOTS_DOUBLE(offset) (((VMJavaVal64*)&vmslots[(offset) - 1])->d) 164 #define VMSLOTS_LONG(offset) (((VMJavaVal64*)&vmslots[(offset) - 1])->l) 165 166 #define SET_VMSLOTS_SLOT(value, offset) (*(intptr_t*)&vmslots[(offset)] = *(intptr_t *)(value)) 167 #define SET_VMSLOTS_ADDR(value, offset) (*((address *)&vmslots[(offset)]) = (value)) 168 #define SET_VMSLOTS_INT(value, offset) (*((jint *)&vmslots[(offset)]) = (value)) 169 #define SET_VMSLOTS_FLOAT(value, offset) (*((jfloat *)&vmslots[(offset)]) = (value)) 170 #define SET_VMSLOTS_OBJECT(value, offset) (*((oop *)&vmslots[(offset)]) = (value)) 171 #define SET_VMSLOTS_DOUBLE(value, offset) (((VMJavaVal64*)&vmslots[(offset) - 1])->d = (value)) 172 #define SET_VMSLOTS_LONG(value, offset) (((VMJavaVal64*)&vmslots[(offset) - 1])->l = (value)) 173 174 #endif // CPU_ZERO_VM_BYTECODEINTERPRETER_ZERO_HPP 175