bytecodeInterpreter_zero.hpp revision 11020:c0ea2e3ebe83
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  }
44  inline void set_method(Method* new_method) {
45    _method = new_method;
46  }
47  inline void set_mirror(oop new_mirror) {
48    _mirror = new_mirror;
49  }
50  inline interpreterState self_link() {
51    return _self_link;
52  }
53  inline void set_self_link(interpreterState new_self_link) {
54    _self_link = new_self_link;
55  }
56  inline interpreterState prev_link() {
57    return _prev_link;
58  }
59  inline void set_prev_link(interpreterState new_prev_link) {
60    _prev_link = new_prev_link;
61  }
62  inline void set_stack_limit(intptr_t* new_stack_limit) {
63    _stack_limit = new_stack_limit;
64  }
65  inline void set_stack_base(intptr_t* new_stack_base) {
66    _stack_base = new_stack_base;
67  }
68  inline void set_monitor_base(BasicObjectLock *new_monitor_base) {
69    _monitor_base = new_monitor_base;
70  }
71  inline void set_thread(JavaThread* new_thread) {
72    _thread = new_thread;
73  }
74  inline void set_constants(ConstantPoolCache* new_constants) {
75    _constants = new_constants;
76  }
77  inline oop oop_temp() {
78    return _oop_temp;
79  }
80  inline oop *oop_temp_addr() {
81    return &_oop_temp;
82  }
83  inline void set_oop_temp(oop new_oop_temp) {
84    _oop_temp = new_oop_temp;
85  }
86  inline address callee_entry_point() {
87    return _result._to_call._callee_entry_point;
88  }
89  inline address osr_buf() {
90    return _result._osr._osr_buf;
91  }
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