1 /*
  2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright 2007 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_NATIVEINST_ZERO_HPP
 27 #define CPU_ZERO_NATIVEINST_ZERO_HPP
 28 
 29 #include "asm/assembler.hpp"
 30 #include "runtime/icache.hpp"
 31 #include "runtime/os.hpp"
 32 
 33 // We have interfaces for the following instructions:
 34 // - NativeInstruction
 35 // - - NativeCall
 36 // - - NativeMovConstReg
 37 // - - NativeMovConstRegPatching
 38 // - - NativeJump
 39 // - - NativeIllegalOpCode
 40 // - - NativeReturn
 41 // - - NativeReturnX (return with argument)
 42 // - - NativePushConst
 43 // - - NativeTstRegMem
 44 
 45 // The base class for different kinds of native instruction abstractions.
 46 // Provides the primitive operations to manipulate code relative to this.
 47 
 48 class NativeInstruction {
 49  public:
 50   bool is_jump() {
 51     ShouldNotCallThis();
 52     return false;
 53   }
 54 
 55   bool is_safepoint_poll() {
 56     ShouldNotCallThis();
 57     return false;
 58   }
 59 };
 60 
 61 inline NativeInstruction* nativeInstruction_at(address address) {
 62   ShouldNotCallThis();
 63   return NULL;
 64 }
 65 
 66 class NativeCall : public NativeInstruction {
 67  public:
 68   enum zero_specific_constants {
 69     instruction_size = 0 // not used within the interpreter
 70   };
 71 
 72   address instruction_address() const {
 73     ShouldNotCallThis();
 74     return NULL;
 75   }
 76 
 77   address next_instruction_address() const {
 78     ShouldNotCallThis();
 79     return NULL;
 80   }
 81 
 82   address return_address() const {
 83     ShouldNotCallThis();
 84     return NULL;
 85   }
 86 
 87   address destination() const {
 88     ShouldNotCallThis();
 89     return NULL;
 90   }
 91 
 92   void set_destination_mt_safe(address dest) {
 93     ShouldNotCallThis();
 94   }
 95 
 96   void verify_alignment() {
 97     ShouldNotCallThis();
 98   }
 99 
100   void verify() {
101     ShouldNotCallThis();
102   }
103 
104   static bool is_call_before(address return_address) {
105     ShouldNotCallThis();
106     return false;
107   }
108 };
109 
110 inline NativeCall* nativeCall_before(address return_address) {
111   ShouldNotCallThis();
112   return NULL;
113 }
114 
115 inline NativeCall* nativeCall_at(address address) {
116   ShouldNotCallThis();
117   return NULL;
118 }
119 
120 class NativeMovConstReg : public NativeInstruction {
121  public:
122   address next_instruction_address() const {
123     ShouldNotCallThis();
124     return NULL;
125   }
126 
127   intptr_t data() const {
128     ShouldNotCallThis();
129     return 0;
130   }
131 
132   void set_data(intptr_t x) {
133     ShouldNotCallThis();
134   }
135 };
136 
137 inline NativeMovConstReg* nativeMovConstReg_at(address address) {
138   ShouldNotCallThis();
139   return NULL;
140 }
141 
142 class NativeMovRegMem : public NativeInstruction {
143  public:
144   int offset() const {
145     ShouldNotCallThis();
146     return 0;
147   }
148 
149   void set_offset(intptr_t x) {
150     ShouldNotCallThis();
151   }
152 
153   void add_offset_in_bytes(int add_offset) {
154     ShouldNotCallThis();
155   }
156 };
157 
158 inline NativeMovRegMem* nativeMovRegMem_at(address address) {
159   ShouldNotCallThis();
160   return NULL;
161 }
162 
163 class NativeJump : public NativeInstruction {
164  public:
165   enum zero_specific_constants {
166     instruction_size = 0 // not used within the interpreter
167   };
168 
169   address jump_destination() const {
170     ShouldNotCallThis();
171     return NULL;
172   }
173 
174   void set_jump_destination(address dest) {
175     ShouldNotCallThis();
176   }
177 
178   static void check_verified_entry_alignment(address entry,
179                                              address verified_entry) {
180   }
181 
182   static void patch_verified_entry(address entry,
183                                    address verified_entry,
184                                    address dest);
185 };
186 
187 inline NativeJump* nativeJump_at(address address) {
188   ShouldNotCallThis();
189   return NULL;
190 }
191 
192 class NativeGeneralJump : public NativeInstruction {
193  public:
194   address jump_destination() const {
195     ShouldNotCallThis();
196     return NULL;
197   }
198 
199   static void insert_unconditional(address code_pos, address entry) {
200     ShouldNotCallThis();
201   }
202 
203   static void replace_mt_safe(address instr_addr, address code_buffer) {
204     ShouldNotCallThis();
205   }
206 };
207 
208 inline NativeGeneralJump* nativeGeneralJump_at(address address) {
209   ShouldNotCallThis();
210   return NULL;
211 }
212 
213 #endif // CPU_ZERO_NATIVEINST_ZERO_HPP