jdk

Форк
0
/
relocInfo_arm.cpp 
132 строки · 4.1 Кб
1
/*
2
 * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
 *
5
 * This code is free software; you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.
8
 *
9
 * This code is distributed in the hope that it will be useful, but WITHOUT
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 "asm/assembler.inline.hpp"
27
#include "code/relocInfo.hpp"
28
#include "nativeInst_arm.hpp"
29
#include "oops/compressedOops.inline.hpp"
30
#include "oops/oop.hpp"
31
#include "runtime/safepoint.hpp"
32

33
void Relocation::pd_set_data_value(address x, bool verify_only) {
34

35
  NativeMovConstReg* ni = nativeMovConstReg_at(addr());
36
  if (verify_only) {
37
    guarantee(ni->data() == (intptr_t)x, "instructions must match");
38
  } else {
39
    ni->set_data((intptr_t)x);
40
  }
41
}
42

43
address Relocation::pd_call_destination(address orig_addr) {
44
  address pc = addr();
45

46
  int adj = 0;
47
  if (orig_addr != nullptr) {
48
    // We just moved this call instruction from orig_addr to addr().
49
    // This means that, when relative, its target will appear to have grown by addr() - orig_addr.
50
    adj = orig_addr - pc;
51
  }
52

53
  RawNativeInstruction* ni = rawNativeInstruction_at(pc);
54

55
  if (ni->is_add_lr()) {
56
    // Skip the optional 'add LR, PC, #offset'
57
    // (Allowing the jump support code to handle fat_call)
58
    pc = ni->next_raw_instruction_address();
59
    ni = nativeInstruction_at(pc);
60
  }
61

62
  if (ni->is_bl()) {
63
    // Fat_call are handled by is_jump for the new 'ni',
64
    // requiring only to support is_bl.
65
    return rawNativeCall_at(pc)->destination(adj);
66
  }
67

68
  if (ni->is_jump()) {
69
    return rawNativeJump_at(pc)->jump_destination(adj);
70
  }
71
  ShouldNotReachHere();
72
  return nullptr;
73
}
74

75
void Relocation::pd_set_call_destination(address x) {
76
  address pc = addr();
77
  NativeInstruction* ni = nativeInstruction_at(pc);
78

79
  if (ni->is_add_lr()) {
80
    // Skip the optional 'add LR, PC, #offset'
81
    // (Allowing the jump support code to handle fat_call)
82
    pc = ni->next_raw_instruction_address();
83
    ni = nativeInstruction_at(pc);
84
  }
85

86
  if (ni->is_bl()) {
87
    // Fat_call are handled by is_jump for the new 'ni',
88
    // requiring only to support is_bl.
89
    rawNativeCall_at(pc)->set_destination(x);
90
    return;
91
  }
92

93
  if (ni->is_jump()) { // raw jump
94
    rawNativeJump_at(pc)->set_jump_destination(x);
95
    return;
96
  }
97
  ShouldNotReachHere();
98
}
99

100

101
address* Relocation::pd_address_in_code() {
102
  return (address*)addr();
103
}
104

105
address Relocation::pd_get_address_from_code() {
106
  return *pd_address_in_code();
107
}
108

109
void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
110
}
111

112
void metadata_Relocation::pd_fix_value(address x) {
113
  assert(! addr_in_const(), "Do not use");
114
  if (!VM_Version::supports_movw()) {
115
    set_value(x);
116
#ifdef ASSERT
117
  } else {
118
    // the movw/movt data should be correct
119
    NativeMovConstReg* ni = nativeMovConstReg_at(addr());
120
    assert(ni->is_movw(), "not a movw");
121
    // The following assert should be correct but the shared code
122
    // currently 'fixes' the metadata instructions before the
123
    // metadata_table is copied in the new method (see
124
    // JDK-8042845). This means that 'x' (which comes from the table)
125
    // does not match the value inlined in the code (which is
126
    // correct). Failure can be temporarily ignored since the code is
127
    // correct and the table is copied shortly afterward.
128
    //
129
    // assert(ni->data() == (int)x, "metadata relocation mismatch");
130
#endif
131
  }
132
}
133

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.