1 /*
   2  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2007, 2008 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 // Platform specific for C++ based Interpreter
  27 
  28 #if defined(PPC) || defined(SPARC) || defined(IA64)
  29 #define LOTS_OF_REGS   // Use plenty of registers
  30 #else
  31 #undef LOTS_OF_REGS    // Loser platforms
  32 #endif
  33 
  34  private:
  35   interpreterState _self_link;
  36 
  37  public:
  38   inline void set_locals(intptr_t* new_locals) {
  39     _locals = new_locals;
  40   }
  41   inline void set_method(methodOop new_method) {
  42     _method = new_method;
  43   }
  44   inline interpreterState self_link() {
  45     return _self_link;
  46   }
  47   inline void set_self_link(interpreterState new_self_link) {
  48     _self_link = new_self_link;
  49   }
  50   inline interpreterState prev_link() {
  51     return _prev_link;
  52   }
  53   inline void set_prev_link(interpreterState new_prev_link) {
  54     _prev_link = new_prev_link;
  55   }
  56   inline void set_stack_limit(intptr_t* new_stack_limit) {
  57     _stack_limit = new_stack_limit;
  58   }
  59   inline void set_stack_base(intptr_t* new_stack_base) {
  60     _stack_base = new_stack_base;
  61   }
  62   inline void set_monitor_base(BasicObjectLock *new_monitor_base) {
  63     _monitor_base = new_monitor_base;
  64   }
  65   inline void set_thread(JavaThread* new_thread) {
  66     _thread = new_thread;
  67   }
  68   inline void set_constants(constantPoolCacheOop new_constants) {
  69     _constants = new_constants;
  70   }
  71   inline oop oop_temp() {
  72     return _oop_temp;
  73   }
  74   inline oop *oop_temp_addr() {
  75     return &_oop_temp;
  76   }
  77   inline void set_oop_temp(oop new_oop_temp) {
  78     _oop_temp = new_oop_temp;
  79   }
  80   inline address callee_entry_point() {
  81     return _result._to_call._callee_entry_point;
  82   }
  83   inline address osr_buf() {
  84     return _result._osr._osr_buf;
  85   }
  86   inline address osr_entry() {
  87     return _result._osr._osr_entry;
  88   }
  89 
  90  public:
  91   const char *name_of_field_at_address(address addr);
  92 
  93 // The frame manager handles this
  94 #define SET_LAST_JAVA_FRAME()
  95 #define RESET_LAST_JAVA_FRAME()
  96 
  97 // ZeroStack Implementation
  98 
  99 #undef STACK_INT
 100 #undef STACK_FLOAT
 101 #undef STACK_ADDR
 102 #undef STACK_OBJECT
 103 #undef STACK_DOUBLE
 104 #undef STACK_LONG
 105 
 106 #define GET_STACK_SLOT(offset)    (*((intptr_t*) &topOfStack[-(offset)]))
 107 #define STACK_SLOT(offset)    ((address) &topOfStack[-(offset)])
 108 #define STACK_ADDR(offset)    (*((address *) &topOfStack[-(offset)]))
 109 #define STACK_INT(offset)     (*((jint*) &topOfStack[-(offset)]))
 110 #define STACK_FLOAT(offset)   (*((jfloat *) &topOfStack[-(offset)]))
 111 #define STACK_OBJECT(offset)  (*((oop *) &topOfStack [-(offset)]))
 112 #define STACK_DOUBLE(offset)  (((VMJavaVal64*) &topOfStack[-(offset)])->d)
 113 #define STACK_LONG(offset)    (((VMJavaVal64 *) &topOfStack[-(offset)])->l)
 114 
 115 #define SET_STACK_SLOT(value, offset)   (*(intptr_t*)&topOfStack[-(offset)] = *(intptr_t*)(value))
 116 #define SET_STACK_ADDR(value, offset)   (*((address *)&topOfStack[-(offset)]) = (value))
 117 #define SET_STACK_INT(value, offset)    (*((jint *)&topOfStack[-(offset)]) = (value))
 118 #define SET_STACK_FLOAT(value, offset)  (*((jfloat *)&topOfStack[-(offset)]) = (value))
 119 #define SET_STACK_OBJECT(value, offset) (*((oop *)&topOfStack[-(offset)]) = (value))
 120 #define SET_STACK_DOUBLE(value, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->d = (value))
 121 #define SET_STACK_DOUBLE_FROM_ADDR(addr, offset) (((VMJavaVal64*)&topOfStack[-(offset)])->d =  \
 122                                                  ((VMJavaVal64*)(addr))->d)
 123 #define SET_STACK_LONG(value, offset)   (((VMJavaVal64*)&topOfStack[-(offset)])->l = (value))
 124 #define SET_STACK_LONG_FROM_ADDR(addr, offset)   (((VMJavaVal64*)&topOfStack[-(offset)])->l =  \
 125                                                  ((VMJavaVal64*)(addr))->l)
 126 // JavaLocals implementation
 127 
 128 #define LOCALS_SLOT(offset)    ((intptr_t*)&locals[-(offset)])
 129 #define LOCALS_ADDR(offset)    ((address)locals[-(offset)])
 130 #define LOCALS_INT(offset)     (*((jint*)&locals[-(offset)]))
 131 #define LOCALS_FLOAT(offset)   (*((jfloat*)&locals[-(offset)]))
 132 #define LOCALS_OBJECT(offset)  ((oop)locals[-(offset)])
 133 #define LOCALS_DOUBLE(offset)  (((VMJavaVal64*)&locals[-((offset) + 1)])->d)
 134 #define LOCALS_LONG(offset)    (((VMJavaVal64*)&locals[-((offset) + 1)])->l)
 135 #define LOCALS_LONG_AT(offset) (((address)&locals[-((offset) + 1)]))
 136 #define LOCALS_DOUBLE_AT(offset) (((address)&locals[-((offset) + 1)]))
 137 
 138 #define SET_LOCALS_SLOT(value, offset)    (*(intptr_t*)&locals[-(offset)] = *(intptr_t *)(value))
 139 #define SET_LOCALS_ADDR(value, offset)    (*((address *)&locals[-(offset)]) = (value))
 140 #define SET_LOCALS_INT(value, offset)     (*((jint *)&locals[-(offset)]) = (value))
 141 #define SET_LOCALS_FLOAT(value, offset)   (*((jfloat *)&locals[-(offset)]) = (value))
 142 #define SET_LOCALS_OBJECT(value, offset)  (*((oop *)&locals[-(offset)]) = (value))
 143 #define SET_LOCALS_DOUBLE(value, offset)  (((VMJavaVal64*)&locals[-((offset)+1)])->d = (value))
 144 #define SET_LOCALS_LONG(value, offset)    (((VMJavaVal64*)&locals[-((offset)+1)])->l = (value))
 145 #define SET_LOCALS_DOUBLE_FROM_ADDR(addr, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->d = \
 146                                                   ((VMJavaVal64*)(addr))->d)
 147 #define SET_LOCALS_LONG_FROM_ADDR(addr, offset) (((VMJavaVal64*)&locals[-((offset)+1)])->l = \
 148                                                 ((VMJavaVal64*)(addr))->l)