author | coleenp |
Wed, 14 Aug 2019 10:07:00 -0400 | |
changeset 57745 | 789e967c2731 |
parent 53867 | 87ef165e7bcd |
child 59247 | 56bf71d64d51 |
permissions | -rw-r--r-- |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1 |
/* |
53867
87ef165e7bcd
8219460: ppc: adjust NativeGeneralJump::insert_unconditional to stack allocated MacroAssembler
mbaesken
parents:
52384
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
87ef165e7bcd
8219460: ppc: adjust NativeGeneralJump::insert_unconditional to stack allocated MacroAssembler
mbaesken
parents:
52384
diff
changeset
|
3 |
* Copyright (c) 2012, 2019, SAP SE. All rights reserved. |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
9 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
14 |
* accompanied this code). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
15 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
19 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
22 |
* questions. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
23 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
24 |
*/ |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
25 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
26 |
#include "precompiled.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
27 |
#include "asm/macroAssembler.inline.hpp" |
52384
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
50429
diff
changeset
|
28 |
#include "code/compiledIC.hpp" |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
29 |
#include "memory/resourceArea.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
30 |
#include "nativeInst_ppc.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47520
diff
changeset
|
31 |
#include "oops/compressedOops.inline.hpp" |
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47520
diff
changeset
|
32 |
#include "oops/oop.hpp" |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
33 |
#include "runtime/handles.hpp" |
50429
83aec1d357d4
8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents:
49622
diff
changeset
|
34 |
#include "runtime/orderAccess.hpp" |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
35 |
#include "runtime/sharedRuntime.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
36 |
#include "runtime/stubRoutines.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
37 |
#include "utilities/ostream.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
38 |
#ifdef COMPILER1 |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
39 |
#include "c1/c1_Runtime1.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
40 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
41 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
42 |
// We use an illtrap for marking a method as not_entrant or zombie iff !UseSIGTRAP |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
43 |
// Work around a C++ compiler bug which changes 'this' |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
44 |
bool NativeInstruction::is_sigill_zombie_not_entrant_at(address addr) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
45 |
assert(!UseSIGTRAP, "precondition"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
46 |
if (*(int*)addr != 0 /*illtrap*/) return false; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
47 |
CodeBlob* cb = CodeCache::find_blob_unsafe(addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
48 |
if (cb == NULL || !cb->is_nmethod()) return false; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
49 |
nmethod *nm = (nmethod *)cb; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
50 |
// This method is not_entrant or zombie iff the illtrap instruction is |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
51 |
// located at the verified entry point. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
52 |
return nm->verified_entry_point() == addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
53 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
54 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
55 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
56 |
void NativeInstruction::verify() { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
57 |
// Make sure code pattern is actually an instruction address. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
58 |
address addr = addr_at(0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
59 |
if (addr == 0 || ((intptr_t)addr & 3) != 0) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
60 |
fatal("not an instruction address"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
61 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
62 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
63 |
#endif // ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
64 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
65 |
// Extract call destination from a NativeCall. The call might use a trampoline stub. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
66 |
address NativeCall::destination() const { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
67 |
address addr = (address)this; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
68 |
address destination = Assembler::bxx_destination(addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
69 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
70 |
// Do we use a trampoline stub for this call? |
35085 | 71 |
// Trampoline stubs are located behind the main code. |
72 |
if (destination > addr) { |
|
73 |
// Filter out recursive method invocation (call to verified/unverified entry point). |
|
74 |
CodeBlob* cb = CodeCache::find_blob_unsafe(addr); // Else we get assertion if nmethod is zombie. |
|
75 |
assert(cb && cb->is_nmethod(), "sanity"); |
|
76 |
nmethod *nm = (nmethod *)cb; |
|
77 |
if (nm->stub_contains(destination) && is_NativeCallTrampolineStub_at(destination)) { |
|
78 |
// Yes we do, so get the destination from the trampoline stub. |
|
79 |
const address trampoline_stub_addr = destination; |
|
80 |
destination = NativeCallTrampolineStub_at(trampoline_stub_addr)->destination(nm); |
|
81 |
} |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
82 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
83 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
84 |
return destination; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
85 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
86 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
87 |
// Similar to replace_mt_safe, but just changes the destination. The |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
88 |
// important thing is that free-running threads are able to execute this |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
89 |
// call instruction at all times. Thus, the displacement field must be |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
90 |
// instruction-word-aligned. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
91 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
92 |
// Used in the runtime linkage of calls; see class CompiledIC. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
93 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
94 |
// Add parameter assert_lock to switch off assertion |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
95 |
// during code generation, where no patching lock is needed. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
96 |
void NativeCall::set_destination_mt_safe(address dest, bool assert_lock) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
97 |
assert(!assert_lock || |
52384
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
50429
diff
changeset
|
98 |
(Patching_lock->is_locked() || SafepointSynchronize::is_at_safepoint()) || |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
50429
diff
changeset
|
99 |
CompiledICLocker::is_safe(addr_at(0)), |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
100 |
"concurrent code patching"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
101 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
102 |
ResourceMark rm; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
103 |
int code_size = 1 * BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
104 |
address addr_call = addr_at(0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
105 |
assert(MacroAssembler::is_bl(*(int*)addr_call), "unexpected code at call-site"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
106 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
107 |
CodeBuffer cb(addr_call, code_size + 1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
108 |
MacroAssembler* a = new MacroAssembler(&cb); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
109 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
110 |
// Patch the call. |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
25374
diff
changeset
|
111 |
if (!ReoptimizeCallSequences || !a->is_within_range_of_b(dest, addr_call)) { |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
112 |
address trampoline_stub_addr = get_trampoline(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
113 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
114 |
// We did not find a trampoline stub because the current codeblob |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
115 |
// does not provide this information. The branch will be patched |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
116 |
// later during a final fixup, when all necessary information is |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
117 |
// available. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
118 |
if (trampoline_stub_addr == 0) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
119 |
return; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
120 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
121 |
// Patch the constant in the call's trampoline stub. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
122 |
NativeCallTrampolineStub_at(trampoline_stub_addr)->set_destination(dest); |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
25374
diff
changeset
|
123 |
dest = trampoline_stub_addr; |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
25374
diff
changeset
|
124 |
} |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
125 |
|
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
25374
diff
changeset
|
126 |
OrderAccess::release(); |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
25374
diff
changeset
|
127 |
a->bl(dest); |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
25374
diff
changeset
|
128 |
|
22861 | 129 |
ICache::ppc64_flush_icache_bytes(addr_call, code_size); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
130 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
131 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
132 |
address NativeCall::get_trampoline() { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
133 |
address call_addr = addr_at(0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
134 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
135 |
CodeBlob *code = CodeCache::find_blob(call_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
136 |
assert(code != NULL, "Could not find the containing code blob"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
137 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
138 |
// There are no relocations available when the code gets relocated |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
139 |
// because of CodeBuffer expansion. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
140 |
if (code->relocation_size() == 0) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
141 |
return NULL; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
142 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
143 |
address bl_destination = Assembler::bxx_destination(call_addr); |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
35594
diff
changeset
|
144 |
if (code->contains(bl_destination) && |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
145 |
is_NativeCallTrampolineStub_at(bl_destination)) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
146 |
return bl_destination; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
147 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
148 |
// If the codeBlob is not a nmethod, this is because we get here from the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
149 |
// CodeBlob constructor, which is called within the nmethod constructor. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
150 |
return trampoline_stub_Relocation::get_trampoline_for(call_addr, (nmethod*)code); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
151 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
152 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
153 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
154 |
void NativeCall::verify() { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
155 |
address addr = addr_at(0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
156 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
157 |
if (!NativeCall::is_call_at(addr)) { |
25374
d7fb2af5d53c
8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents:
22867
diff
changeset
|
158 |
tty->print_cr("not a NativeCall at " PTR_FORMAT, p2i(addr)); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
159 |
// TODO: PPC port: Disassembler::decode(addr - 20, addr + 20, tty); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
28187
diff
changeset
|
160 |
fatal("not a NativeCall at " PTR_FORMAT, p2i(addr)); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
161 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
162 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
163 |
#endif // ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
164 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
165 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
166 |
void NativeFarCall::verify() { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
167 |
address addr = addr_at(0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
168 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
169 |
NativeInstruction::verify(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
170 |
if (!NativeFarCall::is_far_call_at(addr)) { |
25374
d7fb2af5d53c
8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents:
22867
diff
changeset
|
171 |
tty->print_cr("not a NativeFarCall at " PTR_FORMAT, p2i(addr)); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
172 |
// TODO: PPC port: Disassembler::decode(addr, 20, 20, tty); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
28187
diff
changeset
|
173 |
fatal("not a NativeFarCall at " PTR_FORMAT, p2i(addr)); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
174 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
175 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
176 |
#endif // ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
177 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
178 |
address NativeMovConstReg::next_instruction_address() const { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
179 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
180 |
CodeBlob* nm = CodeCache::find_blob(instruction_address()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
181 |
assert(!MacroAssembler::is_set_narrow_oop(addr_at(0), nm->content_begin()), "Should not patch narrow oop here"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
182 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
183 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
184 |
if (MacroAssembler::is_load_const_from_method_toc_at(addr_at(0))) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
185 |
return addr_at(load_const_from_method_toc_instruction_size); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
186 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
187 |
return addr_at(load_const_instruction_size); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
188 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
189 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
190 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
191 |
intptr_t NativeMovConstReg::data() const { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
192 |
address addr = addr_at(0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
193 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
194 |
if (MacroAssembler::is_load_const_at(addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
195 |
return MacroAssembler::get_const(addr); |
22861 | 196 |
} |
197 |
||
198 |
CodeBlob* cb = CodeCache::find_blob_unsafe(addr); |
|
199 |
if (MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) { |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
200 |
narrowOop no = (narrowOop)MacroAssembler::get_narrow_oop(addr, cb->content_begin()); |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47520
diff
changeset
|
201 |
return cast_from_oop<intptr_t>(CompressedOops::decode(no)); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
202 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
203 |
assert(MacroAssembler::is_load_const_from_method_toc_at(addr), "must be load_const_from_pool"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
204 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
205 |
address ctable = cb->content_begin(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
206 |
int offset = MacroAssembler::get_offset_of_load_const_from_method_toc_at(addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
207 |
return *(intptr_t *)(ctable + offset); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
208 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
209 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
210 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
211 |
address NativeMovConstReg::set_data_plain(intptr_t data, CodeBlob *cb) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
212 |
address addr = instruction_address(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
213 |
address next_address = NULL; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
214 |
if (!cb) cb = CodeCache::find_blob(addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
215 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
216 |
if (cb != NULL && MacroAssembler::is_load_const_from_method_toc_at(addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
217 |
// A load from the method's TOC (ctable). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
218 |
assert(cb->is_nmethod(), "must be nmethod"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
219 |
const address ctable = cb->content_begin(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
220 |
const int toc_offset = MacroAssembler::get_offset_of_load_const_from_method_toc_at(addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
221 |
*(intptr_t *)(ctable + toc_offset) = data; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
222 |
next_address = addr + BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
223 |
} else if (cb != NULL && |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
224 |
MacroAssembler::is_calculate_address_from_global_toc_at(addr, cb->content_begin())) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
225 |
// A calculation relative to the global TOC. |
22861 | 226 |
if (MacroAssembler::get_address_of_calculate_address_from_global_toc_at(addr, cb->content_begin()) != |
227 |
(address)data) { |
|
47520
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
228 |
const address inst2_addr = addr; |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
229 |
const address inst1_addr = |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
230 |
MacroAssembler::patch_calculate_address_from_global_toc_at(inst2_addr, cb->content_begin(), |
22861 | 231 |
(address)data); |
47520
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
232 |
assert(inst1_addr != NULL && inst1_addr < inst2_addr, "first instruction must be found"); |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
233 |
const int range = inst2_addr - inst1_addr + BytesPerInstWord; |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
234 |
ICache::ppc64_flush_icache_bytes(inst1_addr, range); |
22861 | 235 |
} |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
236 |
next_address = addr + 1 * BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
237 |
} else if (MacroAssembler::is_load_const_at(addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
238 |
// A normal 5 instruction load_const code sequence. |
22861 | 239 |
if (MacroAssembler::get_const(addr) != (long)data) { |
240 |
// This is not mt safe, ok in methods like CodeBuffer::copy_code(). |
|
241 |
MacroAssembler::patch_const(addr, (long)data); |
|
242 |
ICache::ppc64_flush_icache_bytes(addr, load_const_instruction_size); |
|
243 |
} |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
244 |
next_address = addr + 5 * BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
245 |
} else if (MacroAssembler::is_bl(* (int*) addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
246 |
// A single branch-and-link instruction. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
247 |
ResourceMark rm; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
248 |
const int code_size = 1 * BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
249 |
CodeBuffer cb(addr, code_size + 1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
250 |
MacroAssembler* a = new MacroAssembler(&cb); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
251 |
a->bl((address) data); |
22861 | 252 |
ICache::ppc64_flush_icache_bytes(addr, code_size); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
253 |
next_address = addr + code_size; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
254 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
255 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
256 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
257 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
258 |
return next_address; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
259 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
260 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
261 |
void NativeMovConstReg::set_data(intptr_t data) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
262 |
// Store the value into the instruction stream. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
263 |
CodeBlob *cb = CodeCache::find_blob(instruction_address()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
264 |
address next_address = set_data_plain(data, cb); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
265 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
266 |
// Also store the value into an oop_Relocation cell, if any. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
267 |
if (cb && cb->is_nmethod()) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
268 |
RelocIterator iter((nmethod *) cb, instruction_address(), next_address); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
269 |
oop* oop_addr = NULL; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
270 |
Metadata** metadata_addr = NULL; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
271 |
while (iter.next()) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
272 |
if (iter.type() == relocInfo::oop_type) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
273 |
oop_Relocation *r = iter.oop_reloc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
274 |
if (oop_addr == NULL) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
275 |
oop_addr = r->oop_addr(); |
22849
b8670e920530
8028514: PPC64: Fix C++ Interpreter after '7195622: CheckUnhandledOops has limited usefulness now'
simonis
parents:
22824
diff
changeset
|
276 |
*oop_addr = cast_to_oop(data); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
277 |
} else { |
35085 | 278 |
assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
279 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
280 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
281 |
if (iter.type() == relocInfo::metadata_type) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
282 |
metadata_Relocation *r = iter.metadata_reloc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
283 |
if (metadata_addr == NULL) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
284 |
metadata_addr = r->metadata_addr(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
285 |
*metadata_addr = (Metadata*)data; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
286 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
287 |
assert(metadata_addr == r->metadata_addr(), "must be only one set-metadata here"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
288 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
289 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
290 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
291 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
292 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
293 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
294 |
void NativeMovConstReg::set_narrow_oop(narrowOop data, CodeBlob *code /* = NULL */) { |
47520
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
295 |
address inst2_addr = addr_at(0); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
296 |
CodeBlob* cb = (code) ? code : CodeCache::find_blob(instruction_address()); |
47520
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
297 |
if (MacroAssembler::get_narrow_oop(inst2_addr, cb->content_begin()) == (long)data) |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
298 |
return; |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
299 |
const address inst1_addr = |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
300 |
MacroAssembler::patch_set_narrow_oop(inst2_addr, cb->content_begin(), (long)data); |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
301 |
assert(inst1_addr != NULL && inst1_addr < inst2_addr, "first instruction must be found"); |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
302 |
const int range = inst2_addr - inst1_addr + BytesPerInstWord; |
50790528dd25
8187547: PPC64: icache invalidation is incorrect in some places
goetz
parents:
47216
diff
changeset
|
303 |
ICache::ppc64_flush_icache_bytes(inst1_addr, range); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
304 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
305 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
306 |
// Do not use an assertion here. Let clients decide whether they only |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
307 |
// want this when assertions are enabled. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
308 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
309 |
void NativeMovConstReg::verify() { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
310 |
address addr = addr_at(0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
311 |
if (! MacroAssembler::is_load_const_at(addr) && |
22861 | 312 |
! MacroAssembler::is_load_const_from_method_toc_at(addr)) { |
313 |
CodeBlob* cb = CodeCache::find_blob_unsafe(addr); // find_nmethod() asserts if nmethod is zombie. |
|
314 |
if (! (cb != NULL && MacroAssembler::is_calculate_address_from_global_toc_at(addr, cb->content_begin())) && |
|
315 |
! (cb != NULL && MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) && |
|
316 |
! MacroAssembler::is_bl(*((int*) addr))) { |
|
25374
d7fb2af5d53c
8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents:
22867
diff
changeset
|
317 |
tty->print_cr("not a NativeMovConstReg at " PTR_FORMAT, p2i(addr)); |
22861 | 318 |
// TODO: PPC port: Disassembler::decode(addr, 20, 20, tty); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
28187
diff
changeset
|
319 |
fatal("not a NativeMovConstReg at " PTR_FORMAT, p2i(addr)); |
22861 | 320 |
} |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
321 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
322 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
323 |
#endif // ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
324 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
325 |
void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
326 |
ResourceMark rm; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
327 |
int code_size = 1 * BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
328 |
CodeBuffer cb(verified_entry, code_size + 1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
329 |
MacroAssembler* a = new MacroAssembler(&cb); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
330 |
#ifdef COMPILER2 |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
331 |
assert(dest == SharedRuntime::get_handle_wrong_method_stub(), "expected fixed destination of patch"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
332 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
333 |
// Patch this nmethod atomically. Always use illtrap/trap in debug build. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
334 |
if (DEBUG_ONLY(false &&) a->is_within_range_of_b(dest, a->pc())) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
335 |
a->b(dest); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
336 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
337 |
// The signal handler will continue at dest=OptoRuntime::handle_wrong_method_stub(). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
338 |
if (TrapBasedNotEntrantChecks) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
339 |
// We use a special trap for marking a method as not_entrant or zombie. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
340 |
a->trap_zombie_not_entrant(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
341 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
342 |
// We use an illtrap for marking a method as not_entrant or zombie. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
343 |
a->illtrap(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
344 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
345 |
} |
22861 | 346 |
ICache::ppc64_flush_icache_bytes(verified_entry, code_size); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
347 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
348 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
349 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
350 |
void NativeJump::verify() { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
351 |
address addr = addr_at(0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
352 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
353 |
NativeInstruction::verify(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
354 |
if (!NativeJump::is_jump_at(addr)) { |
25374
d7fb2af5d53c
8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents:
22867
diff
changeset
|
355 |
tty->print_cr("not a NativeJump at " PTR_FORMAT, p2i(addr)); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
356 |
// TODO: PPC port: Disassembler::decode(addr, 20, 20, tty); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
28187
diff
changeset
|
357 |
fatal("not a NativeJump at " PTR_FORMAT, p2i(addr)); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
358 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
359 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
360 |
#endif // ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
361 |
|
35085 | 362 |
|
363 |
void NativeGeneralJump::insert_unconditional(address code_pos, address entry) { |
|
364 |
CodeBuffer cb(code_pos, BytesPerInstWord + 1); |
|
53867
87ef165e7bcd
8219460: ppc: adjust NativeGeneralJump::insert_unconditional to stack allocated MacroAssembler
mbaesken
parents:
52384
diff
changeset
|
365 |
MacroAssembler a(&cb); |
87ef165e7bcd
8219460: ppc: adjust NativeGeneralJump::insert_unconditional to stack allocated MacroAssembler
mbaesken
parents:
52384
diff
changeset
|
366 |
a.b(entry); |
35085 | 367 |
ICache::ppc64_flush_icache_bytes(code_pos, NativeGeneralJump::instruction_size); |
368 |
} |
|
369 |
||
370 |
// MT-safe patching of a jmp instruction. |
|
371 |
void NativeGeneralJump::replace_mt_safe(address instr_addr, address code_buffer) { |
|
372 |
// Bytes beyond offset NativeGeneralJump::instruction_size are copied by caller. |
|
373 |
||
374 |
// Finally patch out the jump. |
|
375 |
volatile juint *jump_addr = (volatile juint*)instr_addr; |
|
376 |
// Release not needed because caller uses invalidate_range after copying the remaining bytes. |
|
377 |
//OrderAccess::release_store(jump_addr, *((juint*)code_buffer)); |
|
378 |
*jump_addr = *((juint*)code_buffer); // atomically store code over branch instruction |
|
379 |
ICache::ppc64_flush_icache_bytes(instr_addr, NativeGeneralJump::instruction_size); |
|
380 |
} |
|
381 |
||
382 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
383 |
//------------------------------------------------------------------- |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
384 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
385 |
// Call trampoline stubs. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
386 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
387 |
// Layout and instructions of a call trampoline stub: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
388 |
// 0: load the TOC (part 1) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
389 |
// 4: load the TOC (part 2) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
390 |
// 8: load the call target from the constant pool (part 1) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
391 |
// [12: load the call target from the constant pool (part 2, optional)] |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
392 |
// ..: branch via CTR |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
393 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
394 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
395 |
address NativeCallTrampolineStub::encoded_destination_addr() const { |
35085 | 396 |
address instruction_addr = addr_at(0 * BytesPerInstWord); |
397 |
if (!MacroAssembler::is_ld_largeoffset(instruction_addr)) { |
|
398 |
instruction_addr = addr_at(2 * BytesPerInstWord); |
|
399 |
assert(MacroAssembler::is_ld_largeoffset(instruction_addr), |
|
400 |
"must be a ld with large offset (from the constant pool)"); |
|
401 |
} |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
402 |
return instruction_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
403 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
404 |
|
22867 | 405 |
address NativeCallTrampolineStub::destination(nmethod *nm) const { |
406 |
CodeBlob* cb = nm ? nm : CodeCache::find_blob_unsafe(addr_at(0)); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
407 |
address ctable = cb->content_begin(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
408 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
409 |
return *(address*)(ctable + destination_toc_offset()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
410 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
411 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
412 |
int NativeCallTrampolineStub::destination_toc_offset() const { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
413 |
return MacroAssembler::get_ld_largeoffset_offset(encoded_destination_addr()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
414 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
415 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
416 |
void NativeCallTrampolineStub::set_destination(address new_destination) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
417 |
CodeBlob* cb = CodeCache::find_blob(addr_at(0)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
418 |
address ctable = cb->content_begin(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
419 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
420 |
*(address*)(ctable + destination_toc_offset()) = new_destination; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
421 |
} |