src/hotspot/cpu/arm/relocInfo_arm.cpp
changeset 52351 0ecb4e520110
parent 50429 83aec1d357d4
child 59290 97d13893ec3c
equal deleted inserted replaced
52317:3c981e581f93 52351:0ecb4e520110
    33 #include "runtime/safepoint.hpp"
    33 #include "runtime/safepoint.hpp"
    34 
    34 
    35 void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
    35 void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
    36 
    36 
    37   NativeMovConstReg* ni = nativeMovConstReg_at(addr());
    37   NativeMovConstReg* ni = nativeMovConstReg_at(addr());
    38 #if defined(AARCH64) && defined(COMPILER2)
       
    39   if (ni->is_movz()) {
       
    40     assert(type() == relocInfo::oop_type, "!");
       
    41     if (verify_only) {
       
    42       uintptr_t d = ni->data();
       
    43       guarantee((d >> 32) == 0, "not narrow oop");
       
    44       narrowOop no = d;
       
    45       oop o = CompressedOops::decode(no);
       
    46       guarantee(cast_from_oop<intptr_t>(o) == (intptr_t)x, "instructions must match");
       
    47     } else {
       
    48       ni->set_data((intptr_t)x);
       
    49     }
       
    50     return;
       
    51   }
       
    52 #endif
       
    53   if (verify_only) {
    38   if (verify_only) {
    54     guarantee(ni->data() == (intptr_t)(x + o), "instructions must match");
    39     guarantee(ni->data() == (intptr_t)(x + o), "instructions must match");
    55   } else {
    40   } else {
    56     ni->set_data((intptr_t)(x + o));
    41     ni->set_data((intptr_t)(x + o));
    57   }
    42   }
    67     adj = orig_addr - pc;
    52     adj = orig_addr - pc;
    68   }
    53   }
    69 
    54 
    70   RawNativeInstruction* ni = rawNativeInstruction_at(pc);
    55   RawNativeInstruction* ni = rawNativeInstruction_at(pc);
    71 
    56 
    72 #if (!defined(AARCH64))
    57   if (ni->is_add_lr()) {
    73   if (NOT_AARCH64(ni->is_add_lr()) AARCH64_ONLY(ni->is_adr_aligned_lr())) {
    58     // Skip the optional 'add LR, PC, #offset'
    74     // On arm32, skip the optional 'add LR, PC, #offset'
       
    75     // (Allowing the jump support code to handle fat_call)
    59     // (Allowing the jump support code to handle fat_call)
    76     pc = ni->next_raw_instruction_address();
    60     pc = ni->next_raw_instruction_address();
    77     ni = nativeInstruction_at(pc);
    61     ni = nativeInstruction_at(pc);
    78   }
    62   }
    79 #endif
       
    80 
    63 
    81   if (AARCH64_ONLY(ni->is_call()) NOT_AARCH64(ni->is_bl())) {
    64   if (ni->is_bl()) {
    82     // For arm32, fat_call are handled by is_jump for the new 'ni',
    65     // Fat_call are handled by is_jump for the new 'ni',
    83     // requiring only to support is_bl.
    66     // requiring only to support is_bl.
    84     //
       
    85     // For AARCH64, skipping a leading adr is not sufficient
       
    86     // to reduce calls to a simple bl.
       
    87     return rawNativeCall_at(pc)->destination(adj);
    67     return rawNativeCall_at(pc)->destination(adj);
    88   }
    68   }
    89 
    69 
    90   if (ni->is_jump()) {
    70   if (ni->is_jump()) {
    91     return rawNativeJump_at(pc)->jump_destination(adj);
    71     return rawNativeJump_at(pc)->jump_destination(adj);
    96 
    76 
    97 void Relocation::pd_set_call_destination(address x) {
    77 void Relocation::pd_set_call_destination(address x) {
    98   address pc = addr();
    78   address pc = addr();
    99   NativeInstruction* ni = nativeInstruction_at(pc);
    79   NativeInstruction* ni = nativeInstruction_at(pc);
   100 
    80 
   101 #if (!defined(AARCH64))
    81   if (ni->is_add_lr()) {
   102   if (NOT_AARCH64(ni->is_add_lr()) AARCH64_ONLY(ni->is_adr_aligned_lr())) {
    82     // Skip the optional 'add LR, PC, #offset'
   103     // On arm32, skip the optional 'add LR, PC, #offset'
       
   104     // (Allowing the jump support code to handle fat_call)
    83     // (Allowing the jump support code to handle fat_call)
   105     pc = ni->next_raw_instruction_address();
    84     pc = ni->next_raw_instruction_address();
   106     ni = nativeInstruction_at(pc);
    85     ni = nativeInstruction_at(pc);
   107   }
    86   }
   108 #endif
       
   109 
    87 
   110   if (AARCH64_ONLY(ni->is_call()) NOT_AARCH64(ni->is_bl())) {
    88   if (ni->is_bl()) {
   111     // For arm32, fat_call are handled by is_jump for the new 'ni',
    89     // Fat_call are handled by is_jump for the new 'ni',
   112     // requiring only to support is_bl.
    90     // requiring only to support is_bl.
   113     //
       
   114     // For AARCH64, skipping a leading adr is not sufficient
       
   115     // to reduce calls to a simple bl.
       
   116     rawNativeCall_at(pc)->set_destination(x);
    91     rawNativeCall_at(pc)->set_destination(x);
   117     return;
    92     return;
   118   }
    93   }
   119 
    94 
   120   if (ni->is_jump()) { // raw jump
    95   if (ni->is_jump()) { // raw jump
   136 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
   111 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
   137 }
   112 }
   138 
   113 
   139 void metadata_Relocation::pd_fix_value(address x) {
   114 void metadata_Relocation::pd_fix_value(address x) {
   140   assert(! addr_in_const(), "Do not use");
   115   assert(! addr_in_const(), "Do not use");
   141 #ifdef AARCH64
       
   142 #ifdef COMPILER2
       
   143   NativeMovConstReg* ni = nativeMovConstReg_at(addr());
       
   144   if (ni->is_mov_slow()) {
       
   145     return;
       
   146   }
       
   147 #endif
       
   148   set_value(x);
       
   149 #else
       
   150   if (!VM_Version::supports_movw()) {
   116   if (!VM_Version::supports_movw()) {
   151     set_value(x);
   117     set_value(x);
   152 #ifdef ASSERT
   118 #ifdef ASSERT
   153   } else {
   119   } else {
   154     // the movw/movt data should be correct
   120     // the movw/movt data should be correct
   163     // correct and the table is copied shortly afterward.
   129     // correct and the table is copied shortly afterward.
   164     //
   130     //
   165     // assert(ni->data() == (int)x, "metadata relocation mismatch");
   131     // assert(ni->data() == (int)x, "metadata relocation mismatch");
   166 #endif
   132 #endif
   167   }
   133   }
   168 #endif // !AARCH64
       
   169 }
   134 }