< prev index next >

src/hotspot/cpu/arm/nativeInst_arm_64.cpp

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "assembler_arm.inline.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "nativeInst_arm.hpp"

  30 #include "oops/klass.inline.hpp"
  31 #include "oops/oop.inline.hpp"
  32 #include "runtime/handles.hpp"
  33 #include "runtime/sharedRuntime.hpp"
  34 #include "runtime/stubRoutines.hpp"
  35 #include "utilities/ostream.hpp"
  36 #ifdef COMPILER1
  37 #include "c1/c1_Runtime1.hpp"
  38 #endif
  39 
  40 void RawNativeInstruction::verify() {
  41   // make sure code pattern is actually an instruction address
  42   address addr = instruction_address();
  43   if (addr == NULL || ((intptr_t)addr & (instruction_size - 1)) != 0) {
  44     fatal("not an instruction address");
  45   }
  46 }
  47 
  48 void NativeMovRegMem::set_offset(int x) {
  49   int scale = get_offset_scale();
  50   assert((x & right_n_bits(scale)) == 0, "offset should be aligned");
  51   guarantee((x >> 24) == 0, "encoding constraint");


  88     while (ni->is_movk() && i < 3) {
  89       uint hi16 = (ni->encoding() >> 5) & 0xffff;
  90       int shift = ((ni->encoding() >> 21) & 0x3) << 4;
  91       hi |= (intptr_t)hi16 << shift;
  92       ni = ni->next_raw();
  93       ++i;
  94     }
  95     return lo16 | hi;
  96   }
  97 #endif
  98   return (intptr_t)(nativeLdrLiteral_at(instruction_address())->literal_value());
  99 }
 100 
 101 static void raw_set_data(RawNativeInstruction* si, intptr_t x, oop* oop_addr, Metadata** metadata_addr) {
 102 #ifdef COMPILER2
 103   if (si->is_movz()) {
 104     // narrow constant or ic call cached value
 105     uintptr_t nx = 0;
 106     int val_size = 32;
 107     if (oop_addr != NULL) {
 108       narrowOop encoded_oop = oopDesc::encode_heap_oop(*oop_addr);
 109       nx = encoded_oop;
 110     } else if (metadata_addr != NULL) {
 111       assert((*metadata_addr)->is_klass(), "expected Klass");
 112       narrowKlass encoded_k = Klass::encode_klass((Klass *)*metadata_addr);
 113       nx = encoded_k;
 114     } else {
 115       nx = x;
 116       val_size = 64;
 117     }
 118     RawNativeInstruction* ni = si->next_raw();
 119     uint lo16 = nx & 0xffff;
 120     int shift = 16;
 121     int imm16 = 0xffff << 5;
 122     si->set_encoding((si->encoding() & ~imm16) | (lo16 << 5));
 123     while (shift < val_size) {
 124       assert(ni->is_movk(), "movk expected");
 125       assert((((ni->encoding() >> 21) & 0x3) << 4) == shift, "wrong shift");
 126       uint hi16 = (nx >> shift) & 0xffff;
 127       ni->set_encoding((ni->encoding() & ~imm16) | (hi16 << 5));
 128       shift += 16;


 223       address call = reloc->addr();
 224       if (nativeInstruction_at(call)->is_call()) {
 225         if (nativeCall_at(call)->return_address() == return_address) {
 226           return call;
 227         }
 228       }
 229     }
 230   }
 231 
 232   return NULL;
 233 }
 234 
 235 bool NativeCall::is_call_before(address return_address) {
 236   return (call_for(return_address) != NULL);
 237 }
 238 
 239 NativeCall* nativeCall_before(address return_address) {
 240   assert(NativeCall::is_call_before(return_address), "must be");
 241   return nativeCall_at(call_for(return_address));
 242 }
 243 


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "assembler_arm.inline.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "nativeInst_arm.hpp"
  30 #include "compressedOops.inline.hpp"
  31 #include "oops/klass.inline.hpp"
  32 #include "oops/oop.hpp"
  33 #include "runtime/handles.hpp"
  34 #include "runtime/sharedRuntime.hpp"
  35 #include "runtime/stubRoutines.hpp"
  36 #include "utilities/ostream.hpp"
  37 #ifdef COMPILER1
  38 #include "c1/c1_Runtime1.hpp"
  39 #endif
  40 
  41 void RawNativeInstruction::verify() {
  42   // make sure code pattern is actually an instruction address
  43   address addr = instruction_address();
  44   if (addr == NULL || ((intptr_t)addr & (instruction_size - 1)) != 0) {
  45     fatal("not an instruction address");
  46   }
  47 }
  48 
  49 void NativeMovRegMem::set_offset(int x) {
  50   int scale = get_offset_scale();
  51   assert((x & right_n_bits(scale)) == 0, "offset should be aligned");
  52   guarantee((x >> 24) == 0, "encoding constraint");


  89     while (ni->is_movk() && i < 3) {
  90       uint hi16 = (ni->encoding() >> 5) & 0xffff;
  91       int shift = ((ni->encoding() >> 21) & 0x3) << 4;
  92       hi |= (intptr_t)hi16 << shift;
  93       ni = ni->next_raw();
  94       ++i;
  95     }
  96     return lo16 | hi;
  97   }
  98 #endif
  99   return (intptr_t)(nativeLdrLiteral_at(instruction_address())->literal_value());
 100 }
 101 
 102 static void raw_set_data(RawNativeInstruction* si, intptr_t x, oop* oop_addr, Metadata** metadata_addr) {
 103 #ifdef COMPILER2
 104   if (si->is_movz()) {
 105     // narrow constant or ic call cached value
 106     uintptr_t nx = 0;
 107     int val_size = 32;
 108     if (oop_addr != NULL) {
 109       narrowOop encoded_oop = CompressedOops::encode(*oop_addr);
 110       nx = encoded_oop;
 111     } else if (metadata_addr != NULL) {
 112       assert((*metadata_addr)->is_klass(), "expected Klass");
 113       narrowKlass encoded_k = Klass::encode_klass((Klass *)*metadata_addr);
 114       nx = encoded_k;
 115     } else {
 116       nx = x;
 117       val_size = 64;
 118     }
 119     RawNativeInstruction* ni = si->next_raw();
 120     uint lo16 = nx & 0xffff;
 121     int shift = 16;
 122     int imm16 = 0xffff << 5;
 123     si->set_encoding((si->encoding() & ~imm16) | (lo16 << 5));
 124     while (shift < val_size) {
 125       assert(ni->is_movk(), "movk expected");
 126       assert((((ni->encoding() >> 21) & 0x3) << 4) == shift, "wrong shift");
 127       uint hi16 = (nx >> shift) & 0xffff;
 128       ni->set_encoding((ni->encoding() & ~imm16) | (hi16 << 5));
 129       shift += 16;


 224       address call = reloc->addr();
 225       if (nativeInstruction_at(call)->is_call()) {
 226         if (nativeCall_at(call)->return_address() == return_address) {
 227           return call;
 228         }
 229       }
 230     }
 231   }
 232 
 233   return NULL;
 234 }
 235 
 236 bool NativeCall::is_call_before(address return_address) {
 237   return (call_for(return_address) != NULL);
 238 }
 239 
 240 NativeCall* nativeCall_before(address return_address) {
 241   assert(NativeCall::is_call_before(return_address), "must be");
 242   return nativeCall_at(call_for(return_address));
 243 }

< prev index next >