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