author | coleenp |
Tue, 14 Mar 2017 14:07:24 -0400 | |
changeset 46327 | 91576389a517 |
parent 43969 | ae5c415036b0 |
parent 46317 | 5f88747fe29e |
child 46338 | e84b501fa52e |
permissions | -rw-r--r-- |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1 |
/* |
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
3 |
* Copyright (c) 2012, 2017, 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" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
28 |
#include "compiler/disassembler.hpp" |
30764 | 29 |
#include "gc/shared/cardTableModRefBS.hpp" |
30 |
#include "gc/shared/collectedHeap.inline.hpp" |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
31 |
#include "interpreter/interpreter.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
32 |
#include "memory/resourceArea.hpp" |
35085 | 33 |
#include "nativeInst_ppc.hpp" |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
34 |
#include "prims/methodHandles.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
35 |
#include "runtime/biasedLocking.hpp" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
25374
diff
changeset
|
36 |
#include "runtime/icache.hpp" |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
37 |
#include "runtime/interfaceSupport.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
38 |
#include "runtime/objectMonitor.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
39 |
#include "runtime/os.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
40 |
#include "runtime/sharedRuntime.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
41 |
#include "runtime/stubRoutines.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
42 |
#include "utilities/macros.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
43 |
#if INCLUDE_ALL_GCS |
30764 | 44 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
45 |
#include "gc/g1/g1SATBCardTableModRefBS.hpp" |
|
46 |
#include "gc/g1/heapRegion.hpp" |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
47 |
#endif // INCLUDE_ALL_GCS |
36303
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
48 |
#ifdef COMPILER2 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
49 |
#include "opto/intrinsicnode.hpp" |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
50 |
#endif |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
51 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
52 |
#ifdef PRODUCT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
53 |
#define BLOCK_COMMENT(str) // nothing |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
54 |
#else |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
55 |
#define BLOCK_COMMENT(str) block_comment(str) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
56 |
#endif |
31861 | 57 |
#define BIND(label) bind(label); BLOCK_COMMENT(#label ":") |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
58 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
59 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
60 |
// On RISC, there's no benefit to verifying instruction boundaries. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
61 |
bool AbstractAssembler::pd_check_instruction_mark() { return false; } |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
62 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
63 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
64 |
void MacroAssembler::ld_largeoffset_unchecked(Register d, int si31, Register a, int emit_filler_nop) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
65 |
assert(Assembler::is_simm(si31, 31) && si31 >= 0, "si31 out of range"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
66 |
if (Assembler::is_simm(si31, 16)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
67 |
ld(d, si31, a); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
68 |
if (emit_filler_nop) nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
69 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
70 |
const int hi = MacroAssembler::largeoffset_si16_si16_hi(si31); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
71 |
const int lo = MacroAssembler::largeoffset_si16_si16_lo(si31); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
72 |
addis(d, a, hi); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
73 |
ld(d, lo, d); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
74 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
75 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
76 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
77 |
void MacroAssembler::ld_largeoffset(Register d, int si31, Register a, int emit_filler_nop) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
78 |
assert_different_registers(d, a); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
79 |
ld_largeoffset_unchecked(d, si31, a, emit_filler_nop); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
80 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
81 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
82 |
void MacroAssembler::load_sized_value(Register dst, RegisterOrConstant offs, Register base, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
83 |
size_t size_in_bytes, bool is_signed) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
84 |
switch (size_in_bytes) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
85 |
case 8: ld(dst, offs, base); break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
86 |
case 4: is_signed ? lwa(dst, offs, base) : lwz(dst, offs, base); break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
87 |
case 2: is_signed ? lha(dst, offs, base) : lhz(dst, offs, base); break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
88 |
case 1: lbz(dst, offs, base); if (is_signed) extsb(dst, dst); break; // lba doesn't exist :( |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
89 |
default: ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
90 |
} |
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 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
93 |
void MacroAssembler::store_sized_value(Register dst, RegisterOrConstant offs, Register base, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
94 |
size_t size_in_bytes) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
95 |
switch (size_in_bytes) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
96 |
case 8: std(dst, offs, base); break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
97 |
case 4: stw(dst, offs, base); break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
98 |
case 2: sth(dst, offs, base); break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
99 |
case 1: stb(dst, offs, base); break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
100 |
default: ShouldNotReachHere(); |
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 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
103 |
|
22861 | 104 |
void MacroAssembler::align(int modulus, int max, int rem) { |
105 |
int padding = (rem + modulus - (offset() % modulus)) % modulus; |
|
106 |
if (padding > max) return; |
|
107 |
for (int c = (padding >> 2); c > 0; --c) { nop(); } |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
108 |
} |
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 |
// Issue instructions that calculate given TOC from global TOC. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
111 |
void MacroAssembler::calculate_address_from_global_toc(Register dst, address addr, bool hi16, bool lo16, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
112 |
bool add_relocation, bool emit_dummy_addr) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
113 |
int offset = -1; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
114 |
if (emit_dummy_addr) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
115 |
offset = -128; // dummy address |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
116 |
} else if (addr != (address)(intptr_t)-1) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
117 |
offset = MacroAssembler::offset_to_global_toc(addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
118 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
119 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
120 |
if (hi16) { |
35085 | 121 |
addis(dst, R29_TOC, MacroAssembler::largeoffset_si16_si16_hi(offset)); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
122 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
123 |
if (lo16) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
124 |
if (add_relocation) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
125 |
// Relocate at the addi to avoid confusion with a load from the method's TOC. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
126 |
relocate(internal_word_Relocation::spec(addr)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
127 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
128 |
addi(dst, dst, MacroAssembler::largeoffset_si16_si16_lo(offset)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
129 |
} |
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 |
int MacroAssembler::patch_calculate_address_from_global_toc_at(address a, address bound, address addr) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
133 |
const int offset = MacroAssembler::offset_to_global_toc(addr); |
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 |
const address inst2_addr = a; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
136 |
const int inst2 = *(int *)inst2_addr; |
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 |
// The relocation points to the second instruction, the addi, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
139 |
// and the addi reads and writes the same register dst. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
140 |
const int dst = inv_rt_field(inst2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
141 |
assert(is_addi(inst2) && inv_ra_field(inst2) == dst, "must be addi reading and writing dst"); |
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 |
// Now, find the preceding addis which writes to dst. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
144 |
int inst1 = 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
145 |
address inst1_addr = inst2_addr - BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
146 |
while (inst1_addr >= bound) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
147 |
inst1 = *(int *) inst1_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
148 |
if (is_addis(inst1) && inv_rt_field(inst1) == dst) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
149 |
// Stop, found the addis which writes dst. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
150 |
break; |
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 |
inst1_addr -= BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
153 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
154 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
155 |
assert(is_addis(inst1) && inv_ra_field(inst1) == 29 /* R29 */, "source must be global TOC"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
156 |
set_imm((int *)inst1_addr, MacroAssembler::largeoffset_si16_si16_hi(offset)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
157 |
set_imm((int *)inst2_addr, MacroAssembler::largeoffset_si16_si16_lo(offset)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
158 |
return (int)((intptr_t)addr - (intptr_t)inst1_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
159 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
160 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
161 |
address MacroAssembler::get_address_of_calculate_address_from_global_toc_at(address a, address bound) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
162 |
const address inst2_addr = a; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
163 |
const int inst2 = *(int *)inst2_addr; |
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 |
// The relocation points to the second instruction, the addi, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
166 |
// and the addi reads and writes the same register dst. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
167 |
const int dst = inv_rt_field(inst2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
168 |
assert(is_addi(inst2) && inv_ra_field(inst2) == dst, "must be addi reading and writing dst"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
169 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
170 |
// Now, find the preceding addis which writes to dst. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
171 |
int inst1 = 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
172 |
address inst1_addr = inst2_addr - BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
173 |
while (inst1_addr >= bound) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
174 |
inst1 = *(int *) inst1_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
175 |
if (is_addis(inst1) && inv_rt_field(inst1) == dst) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
176 |
// stop, found the addis which writes dst |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
177 |
break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
178 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
179 |
inst1_addr -= BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
180 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
181 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
182 |
assert(is_addis(inst1) && inv_ra_field(inst1) == 29 /* R29 */, "source must be global TOC"); |
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 |
int offset = (get_imm(inst1_addr, 0) << 16) + get_imm(inst2_addr, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
185 |
// -1 is a special case |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
186 |
if (offset == -1) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
187 |
return (address)(intptr_t)-1; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
188 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
189 |
return global_toc() + offset; |
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 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
192 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
193 |
#ifdef _LP64 |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
194 |
// Patch compressed oops or klass constants. |
22861 | 195 |
// Assembler sequence is |
196 |
// 1) compressed oops: |
|
197 |
// lis rx = const.hi |
|
198 |
// ori rx = rx | const.lo |
|
199 |
// 2) compressed klass: |
|
200 |
// lis rx = const.hi |
|
201 |
// clrldi rx = rx & 0xFFFFffff // clearMS32b, optional |
|
202 |
// ori rx = rx | const.lo |
|
203 |
// Clrldi will be passed by. |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
204 |
int MacroAssembler::patch_set_narrow_oop(address a, address bound, narrowOop data) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
205 |
assert(UseCompressedOops, "Should only patch compressed oops"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
206 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
207 |
const address inst2_addr = a; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
208 |
const int inst2 = *(int *)inst2_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
209 |
|
22861 | 210 |
// The relocation points to the second instruction, the ori, |
211 |
// and the ori reads and writes the same register dst. |
|
212 |
const int dst = inv_rta_field(inst2); |
|
22867 | 213 |
assert(is_ori(inst2) && inv_rs_field(inst2) == dst, "must be ori reading and writing dst"); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
214 |
// Now, find the preceding addis which writes to dst. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
215 |
int inst1 = 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
216 |
address inst1_addr = inst2_addr - BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
217 |
bool inst1_found = false; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
218 |
while (inst1_addr >= bound) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
219 |
inst1 = *(int *)inst1_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
220 |
if (is_lis(inst1) && inv_rs_field(inst1) == dst) { inst1_found = true; break; } |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
221 |
inst1_addr -= BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
222 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
223 |
assert(inst1_found, "inst is not lis"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
224 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
225 |
int xc = (data >> 16) & 0xffff; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
226 |
int xd = (data >> 0) & 0xffff; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
227 |
|
22861 | 228 |
set_imm((int *)inst1_addr, (short)(xc)); // see enc_load_con_narrow_hi/_lo |
22867 | 229 |
set_imm((int *)inst2_addr, (xd)); // unsigned int |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
230 |
return (int)((intptr_t)inst2_addr - (intptr_t)inst1_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
231 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
232 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
233 |
// Get compressed oop or klass constant. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
234 |
narrowOop MacroAssembler::get_narrow_oop(address a, address bound) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
235 |
assert(UseCompressedOops, "Should only patch compressed oops"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
236 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
237 |
const address inst2_addr = a; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
238 |
const int inst2 = *(int *)inst2_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
239 |
|
22861 | 240 |
// The relocation points to the second instruction, the ori, |
241 |
// and the ori reads and writes the same register dst. |
|
242 |
const int dst = inv_rta_field(inst2); |
|
22867 | 243 |
assert(is_ori(inst2) && inv_rs_field(inst2) == dst, "must be ori reading and writing dst"); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
244 |
// Now, find the preceding lis which writes to dst. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
245 |
int inst1 = 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
246 |
address inst1_addr = inst2_addr - BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
247 |
bool inst1_found = false; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
248 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
249 |
while (inst1_addr >= bound) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
250 |
inst1 = *(int *) inst1_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
251 |
if (is_lis(inst1) && inv_rs_field(inst1) == dst) { inst1_found = true; break;} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
252 |
inst1_addr -= BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
253 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
254 |
assert(inst1_found, "inst is not lis"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
255 |
|
22861 | 256 |
uint xl = ((unsigned int) (get_imm(inst2_addr, 0) & 0xffff)); |
257 |
uint xh = (((get_imm(inst1_addr, 0)) & 0xffff) << 16); |
|
258 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
259 |
return (int) (xl | xh); |
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 |
#endif // _LP64 |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
262 |
|
35085 | 263 |
// Returns true if successful. |
264 |
bool MacroAssembler::load_const_from_method_toc(Register dst, AddressLiteral& a, |
|
265 |
Register toc, bool fixed_size) { |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
266 |
int toc_offset = 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
267 |
// Use RelocationHolder::none for the constant pool entry, otherwise |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
268 |
// we will end up with a failing NativeCall::verify(x) where x is |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
269 |
// the address of the constant pool entry. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
270 |
// FIXME: We should insert relocation information for oops at the constant |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
271 |
// pool entries instead of inserting it at the loads; patching of a constant |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
272 |
// pool entry should be less expensive. |
35085 | 273 |
address const_address = address_constant((address)a.value(), RelocationHolder::none); |
274 |
if (const_address == NULL) { return false; } // allocation failure |
|
22861 | 275 |
// Relocate at the pc of the load. |
276 |
relocate(a.rspec()); |
|
35085 | 277 |
toc_offset = (int)(const_address - code()->consts()->start()); |
278 |
ld_largeoffset_unchecked(dst, toc_offset, toc, fixed_size); |
|
279 |
return true; |
|
22824
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 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
282 |
bool MacroAssembler::is_load_const_from_method_toc_at(address a) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
283 |
const address inst1_addr = a; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
284 |
const int inst1 = *(int *)inst1_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
285 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
286 |
// The relocation points to the ld or the addis. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
287 |
return (is_ld(inst1)) || |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
288 |
(is_addis(inst1) && inv_ra_field(inst1) != 0); |
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 |
int MacroAssembler::get_offset_of_load_const_from_method_toc_at(address a) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
292 |
assert(is_load_const_from_method_toc_at(a), "must be load_const_from_method_toc"); |
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 |
const address inst1_addr = a; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
295 |
const int inst1 = *(int *)inst1_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
296 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
297 |
if (is_ld(inst1)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
298 |
return inv_d1_field(inst1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
299 |
} else if (is_addis(inst1)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
300 |
const int dst = inv_rt_field(inst1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
301 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
302 |
// Now, find the succeeding ld which reads and writes to dst. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
303 |
address inst2_addr = inst1_addr + BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
304 |
int inst2 = 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
305 |
while (true) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
306 |
inst2 = *(int *) inst2_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
307 |
if (is_ld(inst2) && inv_ra_field(inst2) == dst && inv_rt_field(inst2) == dst) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
308 |
// Stop, found the ld which reads and writes dst. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
309 |
break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
310 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
311 |
inst2_addr += BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
312 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
313 |
return (inv_d1_field(inst1) << 16) + inv_d1_field(inst2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
314 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
315 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
316 |
return 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
317 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
318 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
319 |
// Get the constant from a `load_const' sequence. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
320 |
long MacroAssembler::get_const(address a) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
321 |
assert(is_load_const_at(a), "not a load of a constant"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
322 |
const int *p = (const int*) a; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
323 |
unsigned long x = (((unsigned long) (get_imm(a,0) & 0xffff)) << 48); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
324 |
if (is_ori(*(p+1))) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
325 |
x |= (((unsigned long) (get_imm(a,1) & 0xffff)) << 32); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
326 |
x |= (((unsigned long) (get_imm(a,3) & 0xffff)) << 16); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
327 |
x |= (((unsigned long) (get_imm(a,4) & 0xffff))); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
328 |
} else if (is_lis(*(p+1))) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
329 |
x |= (((unsigned long) (get_imm(a,2) & 0xffff)) << 32); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
330 |
x |= (((unsigned long) (get_imm(a,1) & 0xffff)) << 16); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
331 |
x |= (((unsigned long) (get_imm(a,3) & 0xffff))); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
332 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
333 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
334 |
return (long) 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
335 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
336 |
return (long) x; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
337 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
338 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
339 |
// Patch the 64 bit constant of a `load_const' sequence. This is a low |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
340 |
// level procedure. It neither flushes the instruction cache nor is it |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
341 |
// mt safe. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
342 |
void MacroAssembler::patch_const(address a, long x) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
343 |
assert(is_load_const_at(a), "not a load of a constant"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
344 |
int *p = (int*) a; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
345 |
if (is_ori(*(p+1))) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
346 |
set_imm(0 + p, (x >> 48) & 0xffff); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
347 |
set_imm(1 + p, (x >> 32) & 0xffff); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
348 |
set_imm(3 + p, (x >> 16) & 0xffff); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
349 |
set_imm(4 + p, x & 0xffff); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
350 |
} else if (is_lis(*(p+1))) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
351 |
set_imm(0 + p, (x >> 48) & 0xffff); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
352 |
set_imm(2 + p, (x >> 32) & 0xffff); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
353 |
set_imm(1 + p, (x >> 16) & 0xffff); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
354 |
set_imm(3 + p, x & 0xffff); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
355 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
356 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
357 |
} |
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 |
AddressLiteral MacroAssembler::allocate_metadata_address(Metadata* obj) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
361 |
assert(oop_recorder() != NULL, "this assembler needs a Recorder"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
362 |
int index = oop_recorder()->allocate_metadata_index(obj); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
363 |
RelocationHolder rspec = metadata_Relocation::spec(index); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
364 |
return AddressLiteral((address)obj, rspec); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
365 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
366 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
367 |
AddressLiteral MacroAssembler::constant_metadata_address(Metadata* obj) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
368 |
assert(oop_recorder() != NULL, "this assembler needs a Recorder"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
369 |
int index = oop_recorder()->find_index(obj); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
370 |
RelocationHolder rspec = metadata_Relocation::spec(index); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
371 |
return AddressLiteral((address)obj, rspec); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
372 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
373 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
374 |
AddressLiteral MacroAssembler::allocate_oop_address(jobject obj) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
375 |
assert(oop_recorder() != NULL, "this assembler needs an OopRecorder"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
376 |
int oop_index = oop_recorder()->allocate_oop_index(obj); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
377 |
return AddressLiteral(address(obj), oop_Relocation::spec(oop_index)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
378 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
379 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
380 |
AddressLiteral MacroAssembler::constant_oop_address(jobject obj) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
381 |
assert(oop_recorder() != NULL, "this assembler needs an OopRecorder"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
382 |
int oop_index = oop_recorder()->find_index(obj); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
383 |
return AddressLiteral(address(obj), oop_Relocation::spec(oop_index)); |
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 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
386 |
RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
387 |
Register tmp, int offset) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
388 |
intptr_t value = *delayed_value_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
389 |
if (value != 0) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
390 |
return RegisterOrConstant(value + offset); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
391 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
392 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
393 |
// Load indirectly to solve generation ordering problem. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
394 |
// static address, no relocation |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
395 |
int simm16_offset = load_const_optimized(tmp, delayed_value_addr, noreg, true); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
396 |
ld(tmp, simm16_offset, tmp); // must be aligned ((xa & 3) == 0) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
397 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
398 |
if (offset != 0) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
399 |
addi(tmp, tmp, offset); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
400 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
401 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
402 |
return RegisterOrConstant(tmp); |
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 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
405 |
#ifndef PRODUCT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
406 |
void MacroAssembler::pd_print_patched_instruction(address branch) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
407 |
Unimplemented(); // TODO: PPC port |
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 |
#endif // ndef PRODUCT |
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 |
// Conditional far branch for destinations encodable in 24+2 bits. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
412 |
void MacroAssembler::bc_far(int boint, int biint, Label& dest, int optimize) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
413 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
414 |
// If requested by flag optimize, relocate the bc_far as a |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
415 |
// runtime_call and prepare for optimizing it when the code gets |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
416 |
// relocated. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
417 |
if (optimize == bc_far_optimize_on_relocate) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
418 |
relocate(relocInfo::runtime_call_type); |
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 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
421 |
// variant 2: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
422 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
423 |
// b!cxx SKIP |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
424 |
// bxx DEST |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
425 |
// SKIP: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
426 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
427 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
428 |
const int opposite_boint = add_bhint_to_boint(opposite_bhint(inv_boint_bhint(boint)), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
429 |
opposite_bcond(inv_boint_bcond(boint))); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
430 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
431 |
// We emit two branches. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
432 |
// First, a conditional branch which jumps around the far branch. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
433 |
const address not_taken_pc = pc() + 2 * BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
434 |
const address bc_pc = pc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
435 |
bc(opposite_boint, biint, not_taken_pc); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
436 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
437 |
const int bc_instr = *(int*)bc_pc; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
438 |
assert(not_taken_pc == (address)inv_bd_field(bc_instr, (intptr_t)bc_pc), "postcondition"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
439 |
assert(opposite_boint == inv_bo_field(bc_instr), "postcondition"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
440 |
assert(boint == add_bhint_to_boint(opposite_bhint(inv_boint_bhint(inv_bo_field(bc_instr))), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
441 |
opposite_bcond(inv_boint_bcond(inv_bo_field(bc_instr)))), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
442 |
"postcondition"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
443 |
assert(biint == inv_bi_field(bc_instr), "postcondition"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
444 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
445 |
// Second, an unconditional far branch which jumps to dest. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
446 |
// Note: target(dest) remembers the current pc (see CodeSection::target) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
447 |
// and returns the current pc if the label is not bound yet; when |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
448 |
// the label gets bound, the unconditional far branch will be patched. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
449 |
const address target_pc = target(dest); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
450 |
const address b_pc = pc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
451 |
b(target_pc); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
452 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
453 |
assert(not_taken_pc == pc(), "postcondition"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
454 |
assert(dest.is_bound() || target_pc == b_pc, "postcondition"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
455 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
456 |
|
35085 | 457 |
// 1 or 2 instructions |
458 |
void MacroAssembler::bc_far_optimized(int boint, int biint, Label& dest) { |
|
459 |
if (dest.is_bound() && is_within_range_of_bcxx(target(dest), pc())) { |
|
460 |
bc(boint, biint, dest); |
|
461 |
} else { |
|
462 |
bc_far(boint, biint, dest, MacroAssembler::bc_far_optimize_on_relocate); |
|
463 |
} |
|
464 |
} |
|
465 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
466 |
bool MacroAssembler::is_bc_far_at(address instruction_addr) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
467 |
return is_bc_far_variant1_at(instruction_addr) || |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
468 |
is_bc_far_variant2_at(instruction_addr) || |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
469 |
is_bc_far_variant3_at(instruction_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
470 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
471 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
472 |
address MacroAssembler::get_dest_of_bc_far_at(address instruction_addr) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
473 |
if (is_bc_far_variant1_at(instruction_addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
474 |
const address instruction_1_addr = instruction_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
475 |
const int instruction_1 = *(int*)instruction_1_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
476 |
return (address)inv_bd_field(instruction_1, (intptr_t)instruction_1_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
477 |
} else if (is_bc_far_variant2_at(instruction_addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
478 |
const address instruction_2_addr = instruction_addr + 4; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
479 |
return bxx_destination(instruction_2_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
480 |
} else if (is_bc_far_variant3_at(instruction_addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
481 |
return instruction_addr + 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
482 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
483 |
// variant 4 ??? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
484 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
485 |
return NULL; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
486 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
487 |
void MacroAssembler::set_dest_of_bc_far_at(address instruction_addr, address dest) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
488 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
489 |
if (is_bc_far_variant3_at(instruction_addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
490 |
// variant 3, far cond branch to the next instruction, already patched to nops: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
491 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
492 |
// nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
493 |
// endgroup |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
494 |
// SKIP/DEST: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
495 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
496 |
return; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
497 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
498 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
499 |
// first, extract boint and biint from the current branch |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
500 |
int boint = 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
501 |
int biint = 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
502 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
503 |
ResourceMark rm; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
504 |
const int code_size = 2 * BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
505 |
CodeBuffer buf(instruction_addr, code_size); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
506 |
MacroAssembler masm(&buf); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
507 |
if (is_bc_far_variant2_at(instruction_addr) && dest == instruction_addr + 8) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
508 |
// Far branch to next instruction: Optimize it by patching nops (produce variant 3). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
509 |
masm.nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
510 |
masm.endgroup(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
511 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
512 |
if (is_bc_far_variant1_at(instruction_addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
513 |
// variant 1, the 1st instruction contains the destination address: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
514 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
515 |
// bcxx DEST |
35085 | 516 |
// nop |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
517 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
518 |
const int instruction_1 = *(int*)(instruction_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
519 |
boint = inv_bo_field(instruction_1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
520 |
biint = inv_bi_field(instruction_1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
521 |
} else if (is_bc_far_variant2_at(instruction_addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
522 |
// variant 2, the 2nd instruction contains the destination address: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
523 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
524 |
// b!cxx SKIP |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
525 |
// bxx DEST |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
526 |
// SKIP: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
527 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
528 |
const int instruction_1 = *(int*)(instruction_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
529 |
boint = add_bhint_to_boint(opposite_bhint(inv_boint_bhint(inv_bo_field(instruction_1))), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
530 |
opposite_bcond(inv_boint_bcond(inv_bo_field(instruction_1)))); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
531 |
biint = inv_bi_field(instruction_1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
532 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
533 |
// variant 4??? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
534 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
535 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
536 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
537 |
// second, set the new branch destination and optimize the code |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
538 |
if (dest != instruction_addr + 4 && // the bc_far is still unbound! |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
539 |
masm.is_within_range_of_bcxx(dest, instruction_addr)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
540 |
// variant 1: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
541 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
542 |
// bcxx DEST |
35085 | 543 |
// nop |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
544 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
545 |
masm.bc(boint, biint, dest); |
35085 | 546 |
masm.nop(); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
547 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
548 |
// variant 2: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
549 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
550 |
// b!cxx SKIP |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
551 |
// bxx DEST |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
552 |
// SKIP: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
553 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
554 |
const int opposite_boint = add_bhint_to_boint(opposite_bhint(inv_boint_bhint(boint)), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
555 |
opposite_bcond(inv_boint_bcond(boint))); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
556 |
const address not_taken_pc = masm.pc() + 2 * BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
557 |
masm.bc(opposite_boint, biint, not_taken_pc); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
558 |
masm.b(dest); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
559 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
560 |
} |
22861 | 561 |
ICache::ppc64_flush_icache_bytes(instruction_addr, code_size); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
562 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
563 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
564 |
// Emit a NOT mt-safe patchable 64 bit absolute call/jump. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
565 |
void MacroAssembler::bxx64_patchable(address dest, relocInfo::relocType rt, bool link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
566 |
// get current pc |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
567 |
uint64_t start_pc = (uint64_t) pc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
568 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
569 |
const address pc_of_bl = (address) (start_pc + (6*BytesPerInstWord)); // bl is last |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
570 |
const address pc_of_b = (address) (start_pc + (0*BytesPerInstWord)); // b is first |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
571 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
572 |
// relocate here |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
573 |
if (rt != relocInfo::none) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
574 |
relocate(rt); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
575 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
576 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
577 |
if ( ReoptimizeCallSequences && |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
578 |
(( link && is_within_range_of_b(dest, pc_of_bl)) || |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
579 |
(!link && is_within_range_of_b(dest, pc_of_b)))) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
580 |
// variant 2: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
581 |
// Emit an optimized, pc-relative call/jump. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
582 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
583 |
if (link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
584 |
// some padding |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
585 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
586 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
587 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
588 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
589 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
590 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
591 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
592 |
// do the call |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
593 |
assert(pc() == pc_of_bl, "just checking"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
594 |
bl(dest, relocInfo::none); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
595 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
596 |
// do the jump |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
597 |
assert(pc() == pc_of_b, "just checking"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
598 |
b(dest, relocInfo::none); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
599 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
600 |
// some padding |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
601 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
602 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
603 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
604 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
605 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
606 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
607 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
608 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
609 |
// Assert that we can identify the emitted call/jump. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
610 |
assert(is_bxx64_patchable_variant2_at((address)start_pc, link), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
611 |
"can't identify emitted call"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
612 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
613 |
// variant 1: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
614 |
mr(R0, R11); // spill R11 -> R0. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
615 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
616 |
// Load the destination address into CTR, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
617 |
// calculate destination relative to global toc. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
618 |
calculate_address_from_global_toc(R11, dest, true, true, false); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
619 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
620 |
mtctr(R11); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
621 |
mr(R11, R0); // spill R11 <- R0. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
622 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
623 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
624 |
// do the call/jump |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
625 |
if (link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
626 |
bctrl(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
627 |
} else{ |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
628 |
bctr(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
629 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
630 |
// Assert that we can identify the emitted call/jump. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
631 |
assert(is_bxx64_patchable_variant1b_at((address)start_pc, link), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
632 |
"can't identify emitted call"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
633 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
634 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
635 |
// Assert that we can identify the emitted call/jump. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
636 |
assert(is_bxx64_patchable_at((address)start_pc, link), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
637 |
"can't identify emitted call"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
638 |
assert(get_dest_of_bxx64_patchable_at((address)start_pc, link) == dest, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
639 |
"wrong encoding of dest address"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
640 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
641 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
642 |
// Identify a bxx64_patchable instruction. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
643 |
bool MacroAssembler::is_bxx64_patchable_at(address instruction_addr, bool link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
644 |
return is_bxx64_patchable_variant1b_at(instruction_addr, link) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
645 |
//|| is_bxx64_patchable_variant1_at(instruction_addr, link) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
646 |
|| is_bxx64_patchable_variant2_at(instruction_addr, link); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
647 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
648 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
649 |
// Does the call64_patchable instruction use a pc-relative encoding of |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
650 |
// the call destination? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
651 |
bool MacroAssembler::is_bxx64_patchable_pcrelative_at(address instruction_addr, bool link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
652 |
// variant 2 is pc-relative |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
653 |
return is_bxx64_patchable_variant2_at(instruction_addr, link); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
654 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
655 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
656 |
// Identify variant 1. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
657 |
bool MacroAssembler::is_bxx64_patchable_variant1_at(address instruction_addr, bool link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
658 |
unsigned int* instr = (unsigned int*) instruction_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
659 |
return (link ? is_bctrl(instr[6]) : is_bctr(instr[6])) // bctr[l] |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
660 |
&& is_mtctr(instr[5]) // mtctr |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
661 |
&& is_load_const_at(instruction_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
662 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
663 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
664 |
// Identify variant 1b: load destination relative to global toc. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
665 |
bool MacroAssembler::is_bxx64_patchable_variant1b_at(address instruction_addr, bool link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
666 |
unsigned int* instr = (unsigned int*) instruction_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
667 |
return (link ? is_bctrl(instr[6]) : is_bctr(instr[6])) // bctr[l] |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
668 |
&& is_mtctr(instr[3]) // mtctr |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
669 |
&& is_calculate_address_from_global_toc_at(instruction_addr + 2*BytesPerInstWord, instruction_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
670 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
671 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
672 |
// Identify variant 2. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
673 |
bool MacroAssembler::is_bxx64_patchable_variant2_at(address instruction_addr, bool link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
674 |
unsigned int* instr = (unsigned int*) instruction_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
675 |
if (link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
676 |
return is_bl (instr[6]) // bl dest is last |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
677 |
&& is_nop(instr[0]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
678 |
&& is_nop(instr[1]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
679 |
&& is_nop(instr[2]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
680 |
&& is_nop(instr[3]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
681 |
&& is_nop(instr[4]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
682 |
&& is_nop(instr[5]); // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
683 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
684 |
return is_b (instr[0]) // b dest is first |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
685 |
&& is_nop(instr[1]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
686 |
&& is_nop(instr[2]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
687 |
&& is_nop(instr[3]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
688 |
&& is_nop(instr[4]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
689 |
&& is_nop(instr[5]) // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
690 |
&& is_nop(instr[6]); // nop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
691 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
692 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
693 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
694 |
// Set dest address of a bxx64_patchable instruction. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
695 |
void MacroAssembler::set_dest_of_bxx64_patchable_at(address instruction_addr, address dest, bool link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
696 |
ResourceMark rm; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
697 |
int code_size = MacroAssembler::bxx64_patchable_size; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
698 |
CodeBuffer buf(instruction_addr, code_size); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
699 |
MacroAssembler masm(&buf); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
700 |
masm.bxx64_patchable(dest, relocInfo::none, link); |
22861 | 701 |
ICache::ppc64_flush_icache_bytes(instruction_addr, code_size); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
702 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
703 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
704 |
// Get dest address of a bxx64_patchable instruction. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
705 |
address MacroAssembler::get_dest_of_bxx64_patchable_at(address instruction_addr, bool link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
706 |
if (is_bxx64_patchable_variant1_at(instruction_addr, link)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
707 |
return (address) (unsigned long) get_const(instruction_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
708 |
} else if (is_bxx64_patchable_variant2_at(instruction_addr, link)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
709 |
unsigned int* instr = (unsigned int*) instruction_addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
710 |
if (link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
711 |
const int instr_idx = 6; // bl is last |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
712 |
int branchoffset = branch_destination(instr[instr_idx], 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
713 |
return instruction_addr + branchoffset + instr_idx*BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
714 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
715 |
const int instr_idx = 0; // b is first |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
716 |
int branchoffset = branch_destination(instr[instr_idx], 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
717 |
return instruction_addr + branchoffset + instr_idx*BytesPerInstWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
718 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
719 |
// Load dest relative to global toc. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
720 |
} else if (is_bxx64_patchable_variant1b_at(instruction_addr, link)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
721 |
return get_address_of_calculate_address_from_global_toc_at(instruction_addr + 2*BytesPerInstWord, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
722 |
instruction_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
723 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
724 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
725 |
return NULL; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
726 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
727 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
728 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
729 |
// Uses ordering which corresponds to ABI: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
730 |
// _savegpr0_14: std r14,-144(r1) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
731 |
// _savegpr0_15: std r15,-136(r1) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
732 |
// _savegpr0_16: std r16,-128(r1) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
733 |
void MacroAssembler::save_nonvolatile_gprs(Register dst, int offset) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
734 |
std(R14, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
735 |
std(R15, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
736 |
std(R16, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
737 |
std(R17, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
738 |
std(R18, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
739 |
std(R19, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
740 |
std(R20, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
741 |
std(R21, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
742 |
std(R22, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
743 |
std(R23, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
744 |
std(R24, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
745 |
std(R25, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
746 |
std(R26, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
747 |
std(R27, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
748 |
std(R28, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
749 |
std(R29, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
750 |
std(R30, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
751 |
std(R31, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
752 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
753 |
stfd(F14, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
754 |
stfd(F15, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
755 |
stfd(F16, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
756 |
stfd(F17, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
757 |
stfd(F18, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
758 |
stfd(F19, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
759 |
stfd(F20, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
760 |
stfd(F21, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
761 |
stfd(F22, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
762 |
stfd(F23, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
763 |
stfd(F24, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
764 |
stfd(F25, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
765 |
stfd(F26, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
766 |
stfd(F27, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
767 |
stfd(F28, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
768 |
stfd(F29, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
769 |
stfd(F30, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
770 |
stfd(F31, offset, dst); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
771 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
772 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
773 |
// Uses ordering which corresponds to ABI: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
774 |
// _restgpr0_14: ld r14,-144(r1) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
775 |
// _restgpr0_15: ld r15,-136(r1) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
776 |
// _restgpr0_16: ld r16,-128(r1) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
777 |
void MacroAssembler::restore_nonvolatile_gprs(Register src, int offset) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
778 |
ld(R14, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
779 |
ld(R15, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
780 |
ld(R16, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
781 |
ld(R17, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
782 |
ld(R18, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
783 |
ld(R19, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
784 |
ld(R20, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
785 |
ld(R21, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
786 |
ld(R22, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
787 |
ld(R23, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
788 |
ld(R24, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
789 |
ld(R25, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
790 |
ld(R26, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
791 |
ld(R27, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
792 |
ld(R28, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
793 |
ld(R29, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
794 |
ld(R30, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
795 |
ld(R31, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
796 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
797 |
// FP registers |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
798 |
lfd(F14, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
799 |
lfd(F15, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
800 |
lfd(F16, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
801 |
lfd(F17, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
802 |
lfd(F18, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
803 |
lfd(F19, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
804 |
lfd(F20, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
805 |
lfd(F21, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
806 |
lfd(F22, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
807 |
lfd(F23, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
808 |
lfd(F24, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
809 |
lfd(F25, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
810 |
lfd(F26, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
811 |
lfd(F27, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
812 |
lfd(F28, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
813 |
lfd(F29, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
814 |
lfd(F30, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
815 |
lfd(F31, offset, src); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
816 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
817 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
818 |
// For verify_oops. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
819 |
void MacroAssembler::save_volatile_gprs(Register dst, int offset) { |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
820 |
std(R2, offset, dst); offset += 8; |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
821 |
std(R3, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
822 |
std(R4, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
823 |
std(R5, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
824 |
std(R6, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
825 |
std(R7, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
826 |
std(R8, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
827 |
std(R9, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
828 |
std(R10, offset, dst); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
829 |
std(R11, offset, dst); offset += 8; |
35085 | 830 |
std(R12, offset, dst); offset += 8; |
831 |
||
832 |
stfd(F0, offset, dst); offset += 8; |
|
833 |
stfd(F1, offset, dst); offset += 8; |
|
834 |
stfd(F2, offset, dst); offset += 8; |
|
835 |
stfd(F3, offset, dst); offset += 8; |
|
836 |
stfd(F4, offset, dst); offset += 8; |
|
837 |
stfd(F5, offset, dst); offset += 8; |
|
838 |
stfd(F6, offset, dst); offset += 8; |
|
839 |
stfd(F7, offset, dst); offset += 8; |
|
840 |
stfd(F8, offset, dst); offset += 8; |
|
841 |
stfd(F9, offset, dst); offset += 8; |
|
842 |
stfd(F10, offset, dst); offset += 8; |
|
843 |
stfd(F11, offset, dst); offset += 8; |
|
844 |
stfd(F12, offset, dst); offset += 8; |
|
845 |
stfd(F13, offset, dst); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
846 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
847 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
848 |
// For verify_oops. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
849 |
void MacroAssembler::restore_volatile_gprs(Register src, int offset) { |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
850 |
ld(R2, offset, src); offset += 8; |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
851 |
ld(R3, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
852 |
ld(R4, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
853 |
ld(R5, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
854 |
ld(R6, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
855 |
ld(R7, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
856 |
ld(R8, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
857 |
ld(R9, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
858 |
ld(R10, offset, src); offset += 8; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
859 |
ld(R11, offset, src); offset += 8; |
35085 | 860 |
ld(R12, offset, src); offset += 8; |
861 |
||
862 |
lfd(F0, offset, src); offset += 8; |
|
863 |
lfd(F1, offset, src); offset += 8; |
|
864 |
lfd(F2, offset, src); offset += 8; |
|
865 |
lfd(F3, offset, src); offset += 8; |
|
866 |
lfd(F4, offset, src); offset += 8; |
|
867 |
lfd(F5, offset, src); offset += 8; |
|
868 |
lfd(F6, offset, src); offset += 8; |
|
869 |
lfd(F7, offset, src); offset += 8; |
|
870 |
lfd(F8, offset, src); offset += 8; |
|
871 |
lfd(F9, offset, src); offset += 8; |
|
872 |
lfd(F10, offset, src); offset += 8; |
|
873 |
lfd(F11, offset, src); offset += 8; |
|
874 |
lfd(F12, offset, src); offset += 8; |
|
875 |
lfd(F13, offset, src); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
876 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
877 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
878 |
void MacroAssembler::save_LR_CR(Register tmp) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
879 |
mfcr(tmp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
880 |
std(tmp, _abi(cr), R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
881 |
mflr(tmp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
882 |
std(tmp, _abi(lr), R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
883 |
// Tmp must contain lr on exit! (see return_addr and prolog in ppc64.ad) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
884 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
885 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
886 |
void MacroAssembler::restore_LR_CR(Register tmp) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
887 |
assert(tmp != R1_SP, "must be distinct"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
888 |
ld(tmp, _abi(lr), R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
889 |
mtlr(tmp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
890 |
ld(tmp, _abi(cr), R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
891 |
mtcr(tmp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
892 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
893 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
894 |
address MacroAssembler::get_PC_trash_LR(Register result) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
895 |
Label L; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
896 |
bl(L); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
897 |
bind(L); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
898 |
address lr_pc = pc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
899 |
mflr(result); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
900 |
return lr_pc; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
901 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
902 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
903 |
void MacroAssembler::resize_frame(Register offset, Register tmp) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
904 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
905 |
assert_different_registers(offset, tmp, R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
906 |
andi_(tmp, offset, frame::alignment_in_bytes-1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
907 |
asm_assert_eq("resize_frame: unaligned", 0x204); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
908 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
909 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
910 |
// tmp <- *(SP) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
911 |
ld(tmp, _abi(callers_sp), R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
912 |
// addr <- SP + offset; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
913 |
// *(addr) <- tmp; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
914 |
// SP <- addr |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
915 |
stdux(tmp, R1_SP, offset); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
916 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
917 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
918 |
void MacroAssembler::resize_frame(int offset, Register tmp) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
919 |
assert(is_simm(offset, 16), "too big an offset"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
920 |
assert_different_registers(tmp, R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
921 |
assert((offset & (frame::alignment_in_bytes-1))==0, "resize_frame: unaligned"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
922 |
// tmp <- *(SP) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
923 |
ld(tmp, _abi(callers_sp), R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
924 |
// addr <- SP + offset; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
925 |
// *(addr) <- tmp; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
926 |
// SP <- addr |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
927 |
stdu(tmp, offset, R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
928 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
929 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
930 |
void MacroAssembler::resize_frame_absolute(Register addr, Register tmp1, Register tmp2) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
931 |
// (addr == tmp1) || (addr == tmp2) is allowed here! |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
932 |
assert(tmp1 != tmp2, "must be distinct"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
933 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
934 |
// compute offset w.r.t. current stack pointer |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
935 |
// tmp_1 <- addr - SP (!) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
936 |
subf(tmp1, R1_SP, addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
937 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
938 |
// atomically update SP keeping back link. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
939 |
resize_frame(tmp1/* offset */, tmp2/* tmp */); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
940 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
941 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
942 |
void MacroAssembler::push_frame(Register bytes, Register tmp) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
943 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
944 |
assert(bytes != R0, "r0 not allowed here"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
945 |
andi_(R0, bytes, frame::alignment_in_bytes-1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
946 |
asm_assert_eq("push_frame(Reg, Reg): unaligned", 0x203); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
947 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
948 |
neg(tmp, bytes); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
949 |
stdux(R1_SP, R1_SP, tmp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
950 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
951 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
952 |
// Push a frame of size `bytes'. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
953 |
void MacroAssembler::push_frame(unsigned int bytes, Register tmp) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
954 |
long offset = align_addr(bytes, frame::alignment_in_bytes); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
955 |
if (is_simm(-offset, 16)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
956 |
stdu(R1_SP, -offset, R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
957 |
} else { |
35085 | 958 |
load_const_optimized(tmp, -offset); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
959 |
stdux(R1_SP, R1_SP, tmp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
960 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
961 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
962 |
|
23211 | 963 |
// Push a frame of size `bytes' plus abi_reg_args on top. |
964 |
void MacroAssembler::push_frame_reg_args(unsigned int bytes, Register tmp) { |
|
965 |
push_frame(bytes + frame::abi_reg_args_size, tmp); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
966 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
967 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
968 |
// Setup up a new C frame with a spill area for non-volatile GPRs and |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
969 |
// additional space for local variables. |
23211 | 970 |
void MacroAssembler::push_frame_reg_args_nonvolatiles(unsigned int bytes, |
971 |
Register tmp) { |
|
972 |
push_frame(bytes + frame::abi_reg_args_size + frame::spill_nonvolatiles_size, tmp); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
973 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
974 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
975 |
// Pop current C frame. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
976 |
void MacroAssembler::pop_frame() { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
977 |
ld(R1_SP, _abi(callers_sp), R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
978 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
979 |
|
23211 | 980 |
#if defined(ABI_ELFv2) |
981 |
address MacroAssembler::branch_to(Register r_function_entry, bool and_link) { |
|
982 |
// TODO(asmundak): make sure the caller uses R12 as function descriptor |
|
983 |
// most of the times. |
|
984 |
if (R12 != r_function_entry) { |
|
985 |
mr(R12, r_function_entry); |
|
986 |
} |
|
987 |
mtctr(R12); |
|
988 |
// Do a call or a branch. |
|
989 |
if (and_link) { |
|
990 |
bctrl(); |
|
991 |
} else { |
|
992 |
bctr(); |
|
993 |
} |
|
994 |
_last_calls_return_pc = pc(); |
|
995 |
||
996 |
return _last_calls_return_pc; |
|
997 |
} |
|
998 |
||
999 |
// Call a C function via a function descriptor and use full C |
|
1000 |
// calling conventions. Updates and returns _last_calls_return_pc. |
|
1001 |
address MacroAssembler::call_c(Register r_function_entry) { |
|
1002 |
return branch_to(r_function_entry, /*and_link=*/true); |
|
1003 |
} |
|
1004 |
||
1005 |
// For tail calls: only branch, don't link, so callee returns to caller of this function. |
|
1006 |
address MacroAssembler::call_c_and_return_to_caller(Register r_function_entry) { |
|
1007 |
return branch_to(r_function_entry, /*and_link=*/false); |
|
1008 |
} |
|
1009 |
||
1010 |
address MacroAssembler::call_c(address function_entry, relocInfo::relocType rt) { |
|
1011 |
load_const(R12, function_entry, R0); |
|
1012 |
return branch_to(R12, /*and_link=*/true); |
|
1013 |
} |
|
1014 |
||
1015 |
#else |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1016 |
// Generic version of a call to C function via a function descriptor |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1017 |
// with variable support for C calling conventions (TOC, ENV, etc.). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1018 |
// Updates and returns _last_calls_return_pc. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1019 |
address MacroAssembler::branch_to(Register function_descriptor, bool and_link, bool save_toc_before_call, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1020 |
bool restore_toc_after_call, bool load_toc_of_callee, bool load_env_of_callee) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1021 |
// we emit standard ptrgl glue code here |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1022 |
assert((function_descriptor != R0), "function_descriptor cannot be R0"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1023 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1024 |
// retrieve necessary entries from the function descriptor |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1025 |
ld(R0, in_bytes(FunctionDescriptor::entry_offset()), function_descriptor); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1026 |
mtctr(R0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1027 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1028 |
if (load_toc_of_callee) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1029 |
ld(R2_TOC, in_bytes(FunctionDescriptor::toc_offset()), function_descriptor); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1030 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1031 |
if (load_env_of_callee) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1032 |
ld(R11, in_bytes(FunctionDescriptor::env_offset()), function_descriptor); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1033 |
} else if (load_toc_of_callee) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1034 |
li(R11, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1035 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1036 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1037 |
// do a call or a branch |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1038 |
if (and_link) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1039 |
bctrl(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1040 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1041 |
bctr(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1042 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1043 |
_last_calls_return_pc = pc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1044 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1045 |
return _last_calls_return_pc; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1046 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1047 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1048 |
// Call a C function via a function descriptor and use full C calling |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1049 |
// conventions. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1050 |
// We don't use the TOC in generated code, so there is no need to save |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1051 |
// and restore its value. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1052 |
address MacroAssembler::call_c(Register fd) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1053 |
return branch_to(fd, /*and_link=*/true, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1054 |
/*save toc=*/false, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1055 |
/*restore toc=*/false, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1056 |
/*load toc=*/true, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1057 |
/*load env=*/true); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1058 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1059 |
|
22861 | 1060 |
address MacroAssembler::call_c_and_return_to_caller(Register fd) { |
1061 |
return branch_to(fd, /*and_link=*/false, |
|
1062 |
/*save toc=*/false, |
|
1063 |
/*restore toc=*/false, |
|
1064 |
/*load toc=*/true, |
|
1065 |
/*load env=*/true); |
|
1066 |
} |
|
1067 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1068 |
address MacroAssembler::call_c(const FunctionDescriptor* fd, relocInfo::relocType rt) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1069 |
if (rt != relocInfo::none) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1070 |
// this call needs to be relocatable |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1071 |
if (!ReoptimizeCallSequences |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1072 |
|| (rt != relocInfo::runtime_call_type && rt != relocInfo::none) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1073 |
|| fd == NULL // support code-size estimation |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1074 |
|| !fd->is_friend_function() |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1075 |
|| fd->entry() == NULL) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1076 |
// it's not a friend function as defined by class FunctionDescriptor, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1077 |
// so do a full call-c here. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1078 |
load_const(R11, (address)fd, R0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1079 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1080 |
bool has_env = (fd != NULL && fd->env() != NULL); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1081 |
return branch_to(R11, /*and_link=*/true, |
22867 | 1082 |
/*save toc=*/false, |
1083 |
/*restore toc=*/false, |
|
1084 |
/*load toc=*/true, |
|
1085 |
/*load env=*/has_env); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1086 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1087 |
// It's a friend function. Load the entry point and don't care about |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1088 |
// toc and env. Use an optimizable call instruction, but ensure the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1089 |
// same code-size as in the case of a non-friend function. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1090 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1091 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1092 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1093 |
bl64_patchable(fd->entry(), rt); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1094 |
_last_calls_return_pc = pc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1095 |
return _last_calls_return_pc; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1096 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1097 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1098 |
// This call does not need to be relocatable, do more aggressive |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1099 |
// optimizations. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1100 |
if (!ReoptimizeCallSequences |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1101 |
|| !fd->is_friend_function()) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1102 |
// It's not a friend function as defined by class FunctionDescriptor, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1103 |
// so do a full call-c here. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1104 |
load_const(R11, (address)fd, R0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1105 |
return branch_to(R11, /*and_link=*/true, |
22867 | 1106 |
/*save toc=*/false, |
1107 |
/*restore toc=*/false, |
|
1108 |
/*load toc=*/true, |
|
1109 |
/*load env=*/true); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1110 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1111 |
// it's a friend function, load the entry point and don't care about |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1112 |
// toc and env. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1113 |
address dest = fd->entry(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1114 |
if (is_within_range_of_b(dest, pc())) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1115 |
bl(dest); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1116 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1117 |
bl64_patchable(dest, rt); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1118 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1119 |
_last_calls_return_pc = pc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1120 |
return _last_calls_return_pc; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1121 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1122 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1123 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1124 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1125 |
// Call a C function. All constants needed reside in TOC. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1126 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1127 |
// Read the address to call from the TOC. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1128 |
// Read env from TOC, if fd specifies an env. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1129 |
// Read new TOC from TOC. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1130 |
address MacroAssembler::call_c_using_toc(const FunctionDescriptor* fd, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1131 |
relocInfo::relocType rt, Register toc) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1132 |
if (!ReoptimizeCallSequences |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1133 |
|| (rt != relocInfo::runtime_call_type && rt != relocInfo::none) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1134 |
|| !fd->is_friend_function()) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1135 |
// It's not a friend function as defined by class FunctionDescriptor, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1136 |
// so do a full call-c here. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1137 |
assert(fd->entry() != NULL, "function must be linked"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1138 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1139 |
AddressLiteral fd_entry(fd->entry()); |
35085 | 1140 |
bool success = load_const_from_method_toc(R11, fd_entry, toc, /*fixed_size*/ true); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1141 |
mtctr(R11); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1142 |
if (fd->env() == NULL) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1143 |
li(R11, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1144 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1145 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1146 |
AddressLiteral fd_env(fd->env()); |
35085 | 1147 |
success = success && load_const_from_method_toc(R11, fd_env, toc, /*fixed_size*/ true); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1148 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1149 |
AddressLiteral fd_toc(fd->toc()); |
35085 | 1150 |
// Set R2_TOC (load from toc) |
1151 |
success = success && load_const_from_method_toc(R2_TOC, fd_toc, toc, /*fixed_size*/ true); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1152 |
bctrl(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1153 |
_last_calls_return_pc = pc(); |
35085 | 1154 |
if (!success) { return NULL; } |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1155 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1156 |
// It's a friend function, load the entry point and don't care about |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1157 |
// toc and env. Use an optimizable call instruction, but ensure the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1158 |
// same code-size as in the case of a non-friend function. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1159 |
nop(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1160 |
bl64_patchable(fd->entry(), rt); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1161 |
_last_calls_return_pc = pc(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1162 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1163 |
return _last_calls_return_pc; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1164 |
} |
23492 | 1165 |
#endif // ABI_ELFv2 |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1166 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1167 |
void MacroAssembler::call_VM_base(Register oop_result, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1168 |
Register last_java_sp, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1169 |
address entry_point, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1170 |
bool check_exceptions) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1171 |
BLOCK_COMMENT("call_VM {"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1172 |
// Determine last_java_sp register. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1173 |
if (!last_java_sp->is_valid()) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1174 |
last_java_sp = R1_SP; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1175 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1176 |
set_top_ijava_frame_at_SP_as_last_Java_frame(last_java_sp, R11_scratch1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1177 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1178 |
// ARG1 must hold thread address. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1179 |
mr(R3_ARG1, R16_thread); |
23211 | 1180 |
#if defined(ABI_ELFv2) |
1181 |
address return_pc = call_c(entry_point, relocInfo::none); |
|
1182 |
#else |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1183 |
address return_pc = call_c((FunctionDescriptor*)entry_point, relocInfo::none); |
23211 | 1184 |
#endif |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1185 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1186 |
reset_last_Java_frame(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1187 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1188 |
// Check for pending exceptions. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1189 |
if (check_exceptions) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1190 |
// We don't check for exceptions here. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1191 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1192 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1193 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1194 |
// Get oop result if there is one and reset the value in the thread. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1195 |
if (oop_result->is_valid()) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1196 |
get_vm_result(oop_result); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1197 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1198 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1199 |
_last_calls_return_pc = return_pc; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1200 |
BLOCK_COMMENT("} call_VM"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1201 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1202 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1203 |
void MacroAssembler::call_VM_leaf_base(address entry_point) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1204 |
BLOCK_COMMENT("call_VM_leaf {"); |
23211 | 1205 |
#if defined(ABI_ELFv2) |
1206 |
call_c(entry_point, relocInfo::none); |
|
1207 |
#else |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1208 |
call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, entry_point), relocInfo::none); |
23211 | 1209 |
#endif |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1210 |
BLOCK_COMMENT("} call_VM_leaf"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1211 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1212 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1213 |
void MacroAssembler::call_VM(Register oop_result, address entry_point, bool check_exceptions) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1214 |
call_VM_base(oop_result, noreg, entry_point, check_exceptions); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1215 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1216 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1217 |
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1218 |
bool check_exceptions) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1219 |
// R3_ARG1 is reserved for the thread. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1220 |
mr_if_needed(R4_ARG2, arg_1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1221 |
call_VM(oop_result, entry_point, check_exceptions); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1222 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1223 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1224 |
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1225 |
bool check_exceptions) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1226 |
// R3_ARG1 is reserved for the thread |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1227 |
mr_if_needed(R4_ARG2, arg_1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1228 |
assert(arg_2 != R4_ARG2, "smashed argument"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1229 |
mr_if_needed(R5_ARG3, arg_2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1230 |
call_VM(oop_result, entry_point, check_exceptions); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1231 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1232 |
|
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1233 |
void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1234 |
bool check_exceptions) { |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1235 |
// R3_ARG1 is reserved for the thread |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1236 |
mr_if_needed(R4_ARG2, arg_1); |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1237 |
assert(arg_2 != R4_ARG2, "smashed argument"); |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1238 |
mr_if_needed(R5_ARG3, arg_2); |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1239 |
mr_if_needed(R6_ARG4, arg_3); |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1240 |
call_VM(oop_result, entry_point, check_exceptions); |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1241 |
} |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
1242 |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1243 |
void MacroAssembler::call_VM_leaf(address entry_point) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1244 |
call_VM_leaf_base(entry_point); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1245 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1246 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1247 |
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1248 |
mr_if_needed(R3_ARG1, arg_1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1249 |
call_VM_leaf(entry_point); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1250 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1251 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1252 |
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1253 |
mr_if_needed(R3_ARG1, arg_1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1254 |
assert(arg_2 != R3_ARG1, "smashed argument"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1255 |
mr_if_needed(R4_ARG2, arg_2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1256 |
call_VM_leaf(entry_point); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1257 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1258 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1259 |
void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2, Register arg_3) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1260 |
mr_if_needed(R3_ARG1, arg_1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1261 |
assert(arg_2 != R3_ARG1, "smashed argument"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1262 |
mr_if_needed(R4_ARG2, arg_2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1263 |
assert(arg_3 != R3_ARG1 && arg_3 != R4_ARG2, "smashed argument"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1264 |
mr_if_needed(R5_ARG3, arg_3); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1265 |
call_VM_leaf(entry_point); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1266 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1267 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1268 |
// Check whether instruction is a read access to the polling page |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1269 |
// which was emitted by load_from_polling_page(..). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1270 |
bool MacroAssembler::is_load_from_polling_page(int instruction, void* ucontext, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1271 |
address* polling_address_ptr) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1272 |
if (!is_ld(instruction)) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1273 |
return false; // It's not a ld. Fail. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1274 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1275 |
int rt = inv_rt_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1276 |
int ra = inv_ra_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1277 |
int ds = inv_ds_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1278 |
if (!(ds == 0 && ra != 0 && rt == 0)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1279 |
return false; // It's not a ld(r0, X, ra). Fail. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1280 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1281 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1282 |
if (!ucontext) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1283 |
// Set polling address. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1284 |
if (polling_address_ptr != NULL) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1285 |
*polling_address_ptr = NULL; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1286 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1287 |
return true; // No ucontext given. Can't check value of ra. Assume true. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1288 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1289 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1290 |
#ifdef LINUX |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1291 |
// Ucontext given. Check that register ra contains the address of |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1292 |
// the safepoing polling page. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1293 |
ucontext_t* uc = (ucontext_t*) ucontext; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1294 |
// Set polling address. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1295 |
address addr = (address)uc->uc_mcontext.regs->gpr[ra] + (ssize_t)ds; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1296 |
if (polling_address_ptr != NULL) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1297 |
*polling_address_ptr = addr; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1298 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1299 |
return os::is_poll_address(addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1300 |
#else |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1301 |
// Not on Linux, ucontext must be NULL. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1302 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1303 |
return false; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1304 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1305 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1306 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1307 |
bool MacroAssembler::is_memory_serialization(int instruction, JavaThread* thread, void* ucontext) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1308 |
#ifdef LINUX |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1309 |
ucontext_t* uc = (ucontext_t*) ucontext; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1310 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1311 |
if (is_stwx(instruction) || is_stwux(instruction)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1312 |
int ra = inv_ra_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1313 |
int rb = inv_rb_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1314 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1315 |
// look up content of ra and rb in ucontext |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1316 |
address ra_val=(address)uc->uc_mcontext.regs->gpr[ra]; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1317 |
long rb_val=(long)uc->uc_mcontext.regs->gpr[rb]; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1318 |
return os::is_memory_serialize_page(thread, ra_val+rb_val); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1319 |
} else if (is_stw(instruction) || is_stwu(instruction)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1320 |
int ra = inv_ra_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1321 |
int d1 = inv_d1_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1322 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1323 |
// look up content of ra in ucontext |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1324 |
address ra_val=(address)uc->uc_mcontext.regs->gpr[ra]; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1325 |
return os::is_memory_serialize_page(thread, ra_val+d1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1326 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1327 |
return false; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1328 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1329 |
#else |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1330 |
// workaround not needed on !LINUX :-) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1331 |
ShouldNotCallThis(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1332 |
return false; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1333 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1334 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1335 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1336 |
void MacroAssembler::bang_stack_with_offset(int offset) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1337 |
// When increasing the stack, the old stack pointer will be written |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1338 |
// to the new top of stack according to the PPC64 abi. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1339 |
// Therefore, stack banging is not necessary when increasing |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1340 |
// the stack by <= os::vm_page_size() bytes. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1341 |
// When increasing the stack by a larger amount, this method is |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1342 |
// called repeatedly to bang the intermediate pages. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1343 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1344 |
// Stack grows down, caller passes positive offset. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1345 |
assert(offset > 0, "must bang with positive offset"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1346 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1347 |
long stdoffset = -offset; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1348 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1349 |
if (is_simm(stdoffset, 16)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1350 |
// Signed 16 bit offset, a simple std is ok. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1351 |
if (UseLoadInstructionsForStackBangingPPC64) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1352 |
ld(R0, (int)(signed short)stdoffset, R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1353 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1354 |
std(R0,(int)(signed short)stdoffset, R1_SP); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1355 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1356 |
} else if (is_simm(stdoffset, 31)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1357 |
const int hi = MacroAssembler::largeoffset_si16_si16_hi(stdoffset); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1358 |
const int lo = MacroAssembler::largeoffset_si16_si16_lo(stdoffset); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1359 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1360 |
Register tmp = R11; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1361 |
addis(tmp, R1_SP, hi); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1362 |
if (UseLoadInstructionsForStackBangingPPC64) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1363 |
ld(R0, lo, tmp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1364 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1365 |
std(R0, lo, tmp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1366 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1367 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1368 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1369 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1370 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1371 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1372 |
// If instruction is a stack bang of the form |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1373 |
// std R0, x(Ry), (see bang_stack_with_offset()) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1374 |
// stdu R1_SP, x(R1_SP), (see push_frame(), resize_frame()) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1375 |
// or stdux R1_SP, Rx, R1_SP (see push_frame(), resize_frame()) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1376 |
// return the banged address. Otherwise, return 0. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1377 |
address MacroAssembler::get_stack_bang_address(int instruction, void *ucontext) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1378 |
#ifdef LINUX |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1379 |
ucontext_t* uc = (ucontext_t*) ucontext; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1380 |
int rs = inv_rs_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1381 |
int ra = inv_ra_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1382 |
if ( (is_ld(instruction) && rs == 0 && UseLoadInstructionsForStackBangingPPC64) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1383 |
|| (is_std(instruction) && rs == 0 && !UseLoadInstructionsForStackBangingPPC64) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1384 |
|| (is_stdu(instruction) && rs == 1)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1385 |
int ds = inv_ds_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1386 |
// return banged address |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1387 |
return ds+(address)uc->uc_mcontext.regs->gpr[ra]; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1388 |
} else if (is_stdux(instruction) && rs == 1) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1389 |
int rb = inv_rb_field(instruction); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1390 |
address sp = (address)uc->uc_mcontext.regs->gpr[1]; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1391 |
long rb_val = (long)uc->uc_mcontext.regs->gpr[rb]; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1392 |
return ra != 1 || rb_val >= 0 ? NULL // not a stack bang |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1393 |
: sp + rb_val; // banged address |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1394 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1395 |
return NULL; // not a stack bang |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1396 |
#else |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1397 |
// workaround not needed on !LINUX :-) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1398 |
ShouldNotCallThis(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1399 |
return NULL; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1400 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1401 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1402 |
|
38931
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1403 |
void MacroAssembler::reserved_stack_check(Register return_pc) { |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1404 |
// Test if reserved zone needs to be enabled. |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1405 |
Label no_reserved_zone_enabling; |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1406 |
|
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1407 |
ld_ptr(R0, JavaThread::reserved_stack_activation_offset(), R16_thread); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1408 |
cmpld(CCR0, R1_SP, R0); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1409 |
blt_predict_taken(CCR0, no_reserved_zone_enabling); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1410 |
|
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1411 |
// Enable reserved zone again, throw stack overflow exception. |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1412 |
push_frame_reg_args(0, R0); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1413 |
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), R16_thread); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1414 |
pop_frame(); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1415 |
mtlr(return_pc); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1416 |
load_const_optimized(R0, StubRoutines::throw_delayed_StackOverflowError_entry()); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1417 |
mtctr(R0); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1418 |
bctr(); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1419 |
|
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1420 |
should_not_reach_here(); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1421 |
|
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1422 |
bind(no_reserved_zone_enabling); |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1423 |
} |
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38685
diff
changeset
|
1424 |
|
39444
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1425 |
void MacroAssembler::getandsetd(Register dest_current_value, Register exchange_value, Register addr_base, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1426 |
bool cmpxchgx_hint) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1427 |
Label retry; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1428 |
bind(retry); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1429 |
ldarx(dest_current_value, addr_base, cmpxchgx_hint); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1430 |
stdcx_(exchange_value, addr_base); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1431 |
if (UseStaticBranchPredictionInCompareAndSwapPPC64) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1432 |
bne_predict_not_taken(CCR0, retry); // StXcx_ sets CCR0. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1433 |
} else { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1434 |
bne( CCR0, retry); // StXcx_ sets CCR0. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1435 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1436 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1437 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1438 |
void MacroAssembler::getandaddd(Register dest_current_value, Register inc_value, Register addr_base, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1439 |
Register tmp, bool cmpxchgx_hint) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1440 |
Label retry; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1441 |
bind(retry); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1442 |
ldarx(dest_current_value, addr_base, cmpxchgx_hint); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1443 |
add(tmp, dest_current_value, inc_value); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1444 |
stdcx_(tmp, addr_base); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1445 |
if (UseStaticBranchPredictionInCompareAndSwapPPC64) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1446 |
bne_predict_not_taken(CCR0, retry); // StXcx_ sets CCR0. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1447 |
} else { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1448 |
bne( CCR0, retry); // StXcx_ sets CCR0. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1449 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1450 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1451 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1452 |
// Word/sub-word atomic helper functions |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1453 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1454 |
// Temps and addr_base are killed if size < 4 and processor does not support respective instructions. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1455 |
// Only signed types are supported with size < 4. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1456 |
// Atomic add always kills tmp1. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1457 |
void MacroAssembler::atomic_get_and_modify_generic(Register dest_current_value, Register exchange_value, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1458 |
Register addr_base, Register tmp1, Register tmp2, Register tmp3, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1459 |
bool cmpxchgx_hint, bool is_add, int size) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1460 |
// Sub-word instructions are available since Power 8. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1461 |
// For older processors, instruction_type != size holds, and we |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1462 |
// emulate the sub-word instructions by constructing a 4-byte value |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1463 |
// that leaves the other bytes unchanged. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1464 |
const int instruction_type = VM_Version::has_lqarx() ? size : 4; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1465 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1466 |
Label retry; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1467 |
Register shift_amount = noreg, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1468 |
val32 = dest_current_value, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1469 |
modval = is_add ? tmp1 : exchange_value; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1470 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1471 |
if (instruction_type != size) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1472 |
assert_different_registers(tmp1, tmp2, tmp3, dest_current_value, exchange_value, addr_base); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1473 |
modval = tmp1; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1474 |
shift_amount = tmp2; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1475 |
val32 = tmp3; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1476 |
// Need some preperation: Compute shift amount, align address. Note: shorts must be 2 byte aligned. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1477 |
#ifdef VM_LITTLE_ENDIAN |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1478 |
rldic(shift_amount, addr_base, 3, 64-5); // (dest & 3) * 8; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1479 |
clrrdi(addr_base, addr_base, 2); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1480 |
#else |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1481 |
xori(shift_amount, addr_base, (size == 1) ? 3 : 2); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1482 |
clrrdi(addr_base, addr_base, 2); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1483 |
rldic(shift_amount, shift_amount, 3, 64-5); // byte: ((3-dest) & 3) * 8; short: ((1-dest/2) & 1) * 16; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1484 |
#endif |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1485 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1486 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1487 |
// atomic emulation loop |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1488 |
bind(retry); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1489 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1490 |
switch (instruction_type) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1491 |
case 4: lwarx(val32, addr_base, cmpxchgx_hint); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1492 |
case 2: lharx(val32, addr_base, cmpxchgx_hint); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1493 |
case 1: lbarx(val32, addr_base, cmpxchgx_hint); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1494 |
default: ShouldNotReachHere(); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1495 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1496 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1497 |
if (instruction_type != size) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1498 |
srw(dest_current_value, val32, shift_amount); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1499 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1500 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1501 |
if (is_add) { add(modval, dest_current_value, exchange_value); } |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1502 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1503 |
if (instruction_type != size) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1504 |
// Transform exchange value such that the replacement can be done by one xor instruction. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1505 |
xorr(modval, dest_current_value, is_add ? modval : exchange_value); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1506 |
clrldi(modval, modval, (size == 1) ? 56 : 48); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1507 |
slw(modval, modval, shift_amount); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1508 |
xorr(modval, val32, modval); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1509 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1510 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1511 |
switch (instruction_type) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1512 |
case 4: stwcx_(modval, addr_base); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1513 |
case 2: sthcx_(modval, addr_base); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1514 |
case 1: stbcx_(modval, addr_base); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1515 |
default: ShouldNotReachHere(); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1516 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1517 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1518 |
if (UseStaticBranchPredictionInCompareAndSwapPPC64) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1519 |
bne_predict_not_taken(CCR0, retry); // StXcx_ sets CCR0. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1520 |
} else { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1521 |
bne( CCR0, retry); // StXcx_ sets CCR0. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1522 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1523 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1524 |
// l?arx zero-extends, but Java wants byte/short values sign-extended. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1525 |
if (size == 1) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1526 |
extsb(dest_current_value, dest_current_value); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1527 |
} else if (size == 2) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1528 |
extsh(dest_current_value, dest_current_value); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1529 |
}; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1530 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1531 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1532 |
// Temps, addr_base and exchange_value are killed if size < 4 and processor does not support respective instructions. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1533 |
// Only signed types are supported with size < 4. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1534 |
void MacroAssembler::cmpxchg_loop_body(ConditionRegister flag, Register dest_current_value, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1535 |
Register compare_value, Register exchange_value, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1536 |
Register addr_base, Register tmp1, Register tmp2, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1537 |
Label &retry, Label &failed, bool cmpxchgx_hint, int size) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1538 |
// Sub-word instructions are available since Power 8. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1539 |
// For older processors, instruction_type != size holds, and we |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1540 |
// emulate the sub-word instructions by constructing a 4-byte value |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1541 |
// that leaves the other bytes unchanged. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1542 |
const int instruction_type = VM_Version::has_lqarx() ? size : 4; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1543 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1544 |
Register shift_amount = noreg, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1545 |
val32 = dest_current_value, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1546 |
modval = exchange_value; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1547 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1548 |
if (instruction_type != size) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1549 |
assert_different_registers(tmp1, tmp2, dest_current_value, compare_value, exchange_value, addr_base); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1550 |
shift_amount = tmp1; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1551 |
val32 = tmp2; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1552 |
modval = tmp2; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1553 |
// Need some preperation: Compute shift amount, align address. Note: shorts must be 2 byte aligned. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1554 |
#ifdef VM_LITTLE_ENDIAN |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1555 |
rldic(shift_amount, addr_base, 3, 64-5); // (dest & 3) * 8; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1556 |
clrrdi(addr_base, addr_base, 2); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1557 |
#else |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1558 |
xori(shift_amount, addr_base, (size == 1) ? 3 : 2); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1559 |
clrrdi(addr_base, addr_base, 2); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1560 |
rldic(shift_amount, shift_amount, 3, 64-5); // byte: ((3-dest) & 3) * 8; short: ((1-dest/2) & 1) * 16; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1561 |
#endif |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1562 |
// Transform exchange value such that the replacement can be done by one xor instruction. |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1563 |
xorr(exchange_value, compare_value, exchange_value); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1564 |
clrldi(exchange_value, exchange_value, (size == 1) ? 56 : 48); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1565 |
slw(exchange_value, exchange_value, shift_amount); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1566 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1567 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1568 |
// atomic emulation loop |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1569 |
bind(retry); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1570 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1571 |
switch (instruction_type) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1572 |
case 4: lwarx(val32, addr_base, cmpxchgx_hint); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1573 |
case 2: lharx(val32, addr_base, cmpxchgx_hint); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1574 |
case 1: lbarx(val32, addr_base, cmpxchgx_hint); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1575 |
default: ShouldNotReachHere(); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1576 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1577 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1578 |
if (instruction_type != size) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1579 |
srw(dest_current_value, val32, shift_amount); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1580 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1581 |
if (size == 1) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1582 |
extsb(dest_current_value, dest_current_value); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1583 |
} else if (size == 2) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1584 |
extsh(dest_current_value, dest_current_value); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1585 |
}; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1586 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1587 |
cmpw(flag, dest_current_value, compare_value); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1588 |
if (UseStaticBranchPredictionInCompareAndSwapPPC64) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1589 |
bne_predict_not_taken(flag, failed); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1590 |
} else { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1591 |
bne( flag, failed); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1592 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1593 |
// branch to done => (flag == ne), (dest_current_value != compare_value) |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1594 |
// fall through => (flag == eq), (dest_current_value == compare_value) |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1595 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1596 |
if (instruction_type != size) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1597 |
xorr(modval, val32, exchange_value); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1598 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1599 |
|
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1600 |
switch (instruction_type) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1601 |
case 4: stwcx_(modval, addr_base); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1602 |
case 2: sthcx_(modval, addr_base); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1603 |
case 1: stbcx_(modval, addr_base); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1604 |
default: ShouldNotReachHere(); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1605 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1606 |
} |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1607 |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1608 |
// CmpxchgX sets condition register to cmpX(current, compare). |
39444
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1609 |
void MacroAssembler::cmpxchg_generic(ConditionRegister flag, Register dest_current_value, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1610 |
Register compare_value, Register exchange_value, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1611 |
Register addr_base, Register tmp1, Register tmp2, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1612 |
int semantics, bool cmpxchgx_hint, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1613 |
Register int_flag_success, bool contention_hint, bool weak, int size) { |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1614 |
Label retry; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1615 |
Label failed; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1616 |
Label done; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1617 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1618 |
// Save one branch if result is returned via register and |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1619 |
// result register is different from the other ones. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1620 |
bool use_result_reg = (int_flag_success != noreg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1621 |
bool preset_result_reg = (int_flag_success != dest_current_value && int_flag_success != compare_value && |
39444
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1622 |
int_flag_success != exchange_value && int_flag_success != addr_base && |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1623 |
int_flag_success != tmp1 && int_flag_success != tmp2); |
38685
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1624 |
assert(!weak || flag == CCR0, "weak only supported with CCR0"); |
39444
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1625 |
assert(size == 1 || size == 2 || size == 4, "unsupported"); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1626 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1627 |
if (use_result_reg && preset_result_reg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1628 |
li(int_flag_success, 0); // preset (assume cas failed) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1629 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1630 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1631 |
// Add simple guard in order to reduce risk of starving under high contention (recommended by IBM). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1632 |
if (contention_hint) { // Don't try to reserve if cmp fails. |
39444
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1633 |
switch (size) { |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1634 |
case 1: lbz(dest_current_value, 0, addr_base); extsb(dest_current_value, dest_current_value); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1635 |
case 2: lha(dest_current_value, 0, addr_base); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1636 |
case 4: lwz(dest_current_value, 0, addr_base); break; |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1637 |
default: ShouldNotReachHere(); |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1638 |
} |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1639 |
cmpw(flag, dest_current_value, compare_value); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1640 |
bne(flag, failed); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1641 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1642 |
|
35085 | 1643 |
// release/fence semantics |
1644 |
if (semantics & MemBarRel) { |
|
1645 |
release(); |
|
1646 |
} |
|
1647 |
||
39444
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1648 |
cmpxchg_loop_body(flag, dest_current_value, compare_value, exchange_value, addr_base, tmp1, tmp2, |
2eae9b74c1f3
8159976: PPC64: Add missing intrinsics for sub-word atomics
mdoerr
parents:
38931
diff
changeset
|
1649 |
retry, failed, cmpxchgx_hint, size); |
38685
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1650 |
if (!weak || use_result_reg) { |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1651 |
if (UseStaticBranchPredictionInCompareAndSwapPPC64) { |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1652 |
bne_predict_not_taken(CCR0, weak ? failed : retry); // StXcx_ sets CCR0. |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1653 |
} else { |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1654 |
bne( CCR0, weak ? failed : retry); // StXcx_ sets CCR0. |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1655 |
} |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1656 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1657 |
// fall through => (flag == eq), (dest_current_value == compare_value), (swapped) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1658 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1659 |
// Result in register (must do this at the end because int_flag_success can be the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1660 |
// same register as one above). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1661 |
if (use_result_reg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1662 |
li(int_flag_success, 1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1663 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1664 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1665 |
if (semantics & MemBarFenceAfter) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1666 |
fence(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1667 |
} else if (semantics & MemBarAcq) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1668 |
isync(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1669 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1670 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1671 |
if (use_result_reg && !preset_result_reg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1672 |
b(done); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1673 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1674 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1675 |
bind(failed); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1676 |
if (use_result_reg && !preset_result_reg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1677 |
li(int_flag_success, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1678 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1679 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1680 |
bind(done); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1681 |
// (flag == ne) => (dest_current_value != compare_value), (!swapped) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1682 |
// (flag == eq) => (dest_current_value == compare_value), ( swapped) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1683 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1684 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1685 |
// Preforms atomic compare exchange: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1686 |
// if (compare_value == *addr_base) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1687 |
// *addr_base = exchange_value |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1688 |
// int_flag_success = 1; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1689 |
// else |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1690 |
// int_flag_success = 0; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1691 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1692 |
// ConditionRegister flag = cmp(compare_value, *addr_base) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1693 |
// Register dest_current_value = *addr_base |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1694 |
// Register compare_value Used to compare with value in memory |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1695 |
// Register exchange_value Written to memory if compare_value == *addr_base |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1696 |
// Register addr_base The memory location to compareXChange |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1697 |
// Register int_flag_success Set to 1 if exchange_value was written to *addr_base |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1698 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1699 |
// To avoid the costly compare exchange the value is tested beforehand. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1700 |
// Several special cases exist to avoid that unnecessary information is generated. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1701 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1702 |
void MacroAssembler::cmpxchgd(ConditionRegister flag, |
30303 | 1703 |
Register dest_current_value, RegisterOrConstant compare_value, Register exchange_value, |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1704 |
Register addr_base, int semantics, bool cmpxchgx_hint, |
38685
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1705 |
Register int_flag_success, Label* failed_ext, bool contention_hint, bool weak) { |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1706 |
Label retry; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1707 |
Label failed_int; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1708 |
Label& failed = (failed_ext != NULL) ? *failed_ext : failed_int; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1709 |
Label done; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1710 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1711 |
// Save one branch if result is returned via register and result register is different from the other ones. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1712 |
bool use_result_reg = (int_flag_success!=noreg); |
30303 | 1713 |
bool preset_result_reg = (int_flag_success!=dest_current_value && int_flag_success!=compare_value.register_or_noreg() && |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1714 |
int_flag_success!=exchange_value && int_flag_success!=addr_base); |
38685
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1715 |
assert(!weak || flag == CCR0, "weak only supported with CCR0"); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1716 |
assert(int_flag_success == noreg || failed_ext == NULL, "cannot have both"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1717 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1718 |
if (use_result_reg && preset_result_reg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1719 |
li(int_flag_success, 0); // preset (assume cas failed) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1720 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1721 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1722 |
// Add simple guard in order to reduce risk of starving under high contention (recommended by IBM). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1723 |
if (contention_hint) { // Don't try to reserve if cmp fails. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1724 |
ld(dest_current_value, 0, addr_base); |
30303 | 1725 |
cmpd(flag, compare_value, dest_current_value); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1726 |
bne(flag, failed); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1727 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1728 |
|
35085 | 1729 |
// release/fence semantics |
1730 |
if (semantics & MemBarRel) { |
|
1731 |
release(); |
|
1732 |
} |
|
1733 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1734 |
// atomic emulation loop |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1735 |
bind(retry); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1736 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1737 |
ldarx(dest_current_value, addr_base, cmpxchgx_hint); |
30303 | 1738 |
cmpd(flag, compare_value, dest_current_value); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1739 |
if (UseStaticBranchPredictionInCompareAndSwapPPC64) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1740 |
bne_predict_not_taken(flag, failed); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1741 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1742 |
bne( flag, failed); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1743 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1744 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1745 |
stdcx_(exchange_value, addr_base); |
38685
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1746 |
if (!weak || use_result_reg || failed_ext) { |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1747 |
if (UseStaticBranchPredictionInCompareAndSwapPPC64) { |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1748 |
bne_predict_not_taken(CCR0, weak ? failed : retry); // stXcx_ sets CCR0 |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1749 |
} else { |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1750 |
bne( CCR0, weak ? failed : retry); // stXcx_ sets CCR0 |
e34308190947
8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents:
38074
diff
changeset
|
1751 |
} |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1752 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1753 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1754 |
// result in register (must do this at the end because int_flag_success can be the same register as one above) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1755 |
if (use_result_reg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1756 |
li(int_flag_success, 1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1757 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1758 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1759 |
if (semantics & MemBarFenceAfter) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1760 |
fence(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1761 |
} else if (semantics & MemBarAcq) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1762 |
isync(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1763 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1764 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1765 |
if (use_result_reg && !preset_result_reg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1766 |
b(done); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1767 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1768 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1769 |
bind(failed_int); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1770 |
if (use_result_reg && !preset_result_reg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1771 |
li(int_flag_success, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1772 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1773 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1774 |
bind(done); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1775 |
// (flag == ne) => (dest_current_value != compare_value), (!swapped) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1776 |
// (flag == eq) => (dest_current_value == compare_value), ( swapped) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1777 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1778 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1779 |
// Look up the method for a megamorphic invokeinterface call. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1780 |
// The target method is determined by <intf_klass, itable_index>. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1781 |
// The receiver klass is in recv_klass. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1782 |
// On success, the result will be in method_result, and execution falls through. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1783 |
// On failure, execution transfers to the given label. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1784 |
void MacroAssembler::lookup_interface_method(Register recv_klass, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1785 |
Register intf_klass, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1786 |
RegisterOrConstant itable_index, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1787 |
Register method_result, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1788 |
Register scan_temp, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1789 |
Register sethi_temp, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1790 |
Label& L_no_such_interface) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1791 |
assert_different_registers(recv_klass, intf_klass, method_result, scan_temp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1792 |
assert(itable_index.is_constant() || itable_index.as_register() == method_result, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1793 |
"caller must use same register for non-constant itable index as for method"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1794 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1795 |
// Compute start of first itableOffsetEntry (which is at the end of the vtable). |
35899 | 1796 |
int vtable_base = in_bytes(Klass::vtable_start_offset()); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1797 |
int itentry_off = itableMethodEntry::method_offset_in_bytes(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1798 |
int logMEsize = exact_log2(itableMethodEntry::size() * wordSize); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1799 |
int scan_step = itableOffsetEntry::size() * wordSize; |
35871
607bf949dfb3
8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents:
35232
diff
changeset
|
1800 |
int log_vte_size= exact_log2(vtableEntry::size_in_bytes()); |
607bf949dfb3
8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents:
35232
diff
changeset
|
1801 |
|
35899 | 1802 |
lwz(scan_temp, in_bytes(Klass::vtable_length_offset()), recv_klass); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1803 |
// %%% We should store the aligned, prescaled offset in the klassoop. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1804 |
// Then the next several instructions would fold away. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1805 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1806 |
sldi(scan_temp, scan_temp, log_vte_size); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1807 |
addi(scan_temp, scan_temp, vtable_base); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1808 |
add(scan_temp, recv_klass, scan_temp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1809 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1810 |
// Adjust recv_klass by scaled itable_index, so we can free itable_index. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1811 |
if (itable_index.is_register()) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1812 |
Register itable_offset = itable_index.as_register(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1813 |
sldi(itable_offset, itable_offset, logMEsize); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1814 |
if (itentry_off) addi(itable_offset, itable_offset, itentry_off); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1815 |
add(recv_klass, itable_offset, recv_klass); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1816 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1817 |
long itable_offset = (long)itable_index.as_constant(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1818 |
load_const_optimized(sethi_temp, (itable_offset<<logMEsize)+itentry_off); // static address, no relocation |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1819 |
add(recv_klass, sethi_temp, recv_klass); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1820 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1821 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1822 |
// for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1823 |
// if (scan->interface() == intf) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1824 |
// result = (klass + scan->offset() + itable_index); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1825 |
// } |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1826 |
// } |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1827 |
Label search, found_method; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1828 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1829 |
for (int peel = 1; peel >= 0; peel--) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1830 |
// %%%% Could load both offset and interface in one ldx, if they were |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1831 |
// in the opposite order. This would save a load. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1832 |
ld(method_result, itableOffsetEntry::interface_offset_in_bytes(), scan_temp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1833 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1834 |
// Check that this entry is non-null. A null entry means that |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1835 |
// the receiver class doesn't implement the interface, and wasn't the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1836 |
// same as when the caller was compiled. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1837 |
cmpd(CCR0, method_result, intf_klass); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1838 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1839 |
if (peel) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1840 |
beq(CCR0, found_method); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1841 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1842 |
bne(CCR0, search); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1843 |
// (invert the test to fall through to found_method...) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1844 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1845 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1846 |
if (!peel) break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1847 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1848 |
bind(search); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1849 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1850 |
cmpdi(CCR0, method_result, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1851 |
beq(CCR0, L_no_such_interface); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1852 |
addi(scan_temp, scan_temp, scan_step); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1853 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1854 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1855 |
bind(found_method); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1856 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1857 |
// Got a hit. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1858 |
int ito_offset = itableOffsetEntry::offset_offset_in_bytes(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1859 |
lwz(scan_temp, ito_offset, scan_temp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1860 |
ldx(method_result, scan_temp, recv_klass); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1861 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1862 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1863 |
// virtual method calling |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1864 |
void MacroAssembler::lookup_virtual_method(Register recv_klass, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1865 |
RegisterOrConstant vtable_index, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1866 |
Register method_result) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1867 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1868 |
assert_different_registers(recv_klass, method_result, vtable_index.register_or_noreg()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1869 |
|
35899 | 1870 |
const int base = in_bytes(Klass::vtable_start_offset()); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1871 |
assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1872 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1873 |
if (vtable_index.is_register()) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1874 |
sldi(vtable_index.as_register(), vtable_index.as_register(), LogBytesPerWord); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1875 |
add(recv_klass, vtable_index.as_register(), recv_klass); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1876 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1877 |
addi(recv_klass, recv_klass, vtable_index.as_constant() << LogBytesPerWord); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1878 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1879 |
ld(R19_method, base + vtableEntry::method_offset_in_bytes(), recv_klass); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1880 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1881 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1882 |
/////////////////////////////////////////// subtype checking //////////////////////////////////////////// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1883 |
void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1884 |
Register super_klass, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1885 |
Register temp1_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1886 |
Register temp2_reg, |
35085 | 1887 |
Label* L_success, |
1888 |
Label* L_failure, |
|
1889 |
Label* L_slow_path, |
|
1890 |
RegisterOrConstant super_check_offset) { |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1891 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1892 |
const Register check_cache_offset = temp1_reg; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1893 |
const Register cached_super = temp2_reg; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1894 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1895 |
assert_different_registers(sub_klass, super_klass, check_cache_offset, cached_super); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1896 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1897 |
int sco_offset = in_bytes(Klass::super_check_offset_offset()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1898 |
int sc_offset = in_bytes(Klass::secondary_super_cache_offset()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1899 |
|
35085 | 1900 |
bool must_load_sco = (super_check_offset.constant_or_zero() == -1); |
1901 |
bool need_slow_path = (must_load_sco || super_check_offset.constant_or_zero() == sco_offset); |
|
1902 |
||
1903 |
Label L_fallthrough; |
|
1904 |
int label_nulls = 0; |
|
1905 |
if (L_success == NULL) { L_success = &L_fallthrough; label_nulls++; } |
|
1906 |
if (L_failure == NULL) { L_failure = &L_fallthrough; label_nulls++; } |
|
1907 |
if (L_slow_path == NULL) { L_slow_path = &L_fallthrough; label_nulls++; } |
|
1908 |
assert(label_nulls <= 1 || |
|
1909 |
(L_slow_path == &L_fallthrough && label_nulls <= 2 && !need_slow_path), |
|
1910 |
"at most one NULL in the batch, usually"); |
|
1911 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1912 |
// If the pointers are equal, we are done (e.g., String[] elements). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1913 |
// This self-check enables sharing of secondary supertype arrays among |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1914 |
// non-primary types such as array-of-interface. Otherwise, each such |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1915 |
// type would need its own customized SSA. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1916 |
// We move this check to the front of the fast path because many |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1917 |
// type checks are in fact trivially successful in this manner, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1918 |
// so we get a nicely predicted branch right at the start of the check. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1919 |
cmpd(CCR0, sub_klass, super_klass); |
35085 | 1920 |
beq(CCR0, *L_success); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1921 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1922 |
// Check the supertype display: |
35085 | 1923 |
if (must_load_sco) { |
1924 |
// The super check offset is always positive... |
|
42068
18c8a4d5998e
8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents:
41334
diff
changeset
|
1925 |
lwz(check_cache_offset, sco_offset, super_klass); |
35085 | 1926 |
super_check_offset = RegisterOrConstant(check_cache_offset); |
1927 |
// super_check_offset is register. |
|
1928 |
assert_different_registers(sub_klass, super_klass, cached_super, super_check_offset.as_register()); |
|
1929 |
} |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1930 |
// The loaded value is the offset from KlassOopDesc. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1931 |
|
35085 | 1932 |
ld(cached_super, super_check_offset, sub_klass); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1933 |
cmpd(CCR0, cached_super, super_klass); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1934 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1935 |
// This check has worked decisively for primary supers. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1936 |
// Secondary supers are sought in the super_cache ('super_cache_addr'). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1937 |
// (Secondary supers are interfaces and very deeply nested subtypes.) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1938 |
// This works in the same check above because of a tricky aliasing |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1939 |
// between the super_cache and the primary super display elements. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1940 |
// (The 'super_check_addr' can address either, as the case requires.) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1941 |
// Note that the cache is updated below if it does not help us find |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1942 |
// what we need immediately. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1943 |
// So if it was a primary super, we can just fail immediately. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1944 |
// Otherwise, it's the slow path for us (no success at this point). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1945 |
|
35085 | 1946 |
#define FINAL_JUMP(label) if (&(label) != &L_fallthrough) { b(label); } |
1947 |
||
1948 |
if (super_check_offset.is_register()) { |
|
1949 |
beq(CCR0, *L_success); |
|
1950 |
cmpwi(CCR0, super_check_offset.as_register(), sc_offset); |
|
1951 |
if (L_failure == &L_fallthrough) { |
|
1952 |
beq(CCR0, *L_slow_path); |
|
1953 |
} else { |
|
1954 |
bne(CCR0, *L_failure); |
|
1955 |
FINAL_JUMP(*L_slow_path); |
|
1956 |
} |
|
1957 |
} else { |
|
1958 |
if (super_check_offset.as_constant() == sc_offset) { |
|
1959 |
// Need a slow path; fast failure is impossible. |
|
1960 |
if (L_slow_path == &L_fallthrough) { |
|
1961 |
beq(CCR0, *L_success); |
|
1962 |
} else { |
|
1963 |
bne(CCR0, *L_slow_path); |
|
1964 |
FINAL_JUMP(*L_success); |
|
1965 |
} |
|
1966 |
} else { |
|
1967 |
// No slow path; it's a fast decision. |
|
1968 |
if (L_failure == &L_fallthrough) { |
|
1969 |
beq(CCR0, *L_success); |
|
1970 |
} else { |
|
1971 |
bne(CCR0, *L_failure); |
|
1972 |
FINAL_JUMP(*L_success); |
|
1973 |
} |
|
1974 |
} |
|
1975 |
} |
|
1976 |
||
1977 |
bind(L_fallthrough); |
|
1978 |
#undef FINAL_JUMP |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1979 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1980 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1981 |
void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1982 |
Register super_klass, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1983 |
Register temp1_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1984 |
Register temp2_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1985 |
Label* L_success, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1986 |
Register result_reg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1987 |
const Register array_ptr = temp1_reg; // current value from cache array |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1988 |
const Register temp = temp2_reg; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1989 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1990 |
assert_different_registers(sub_klass, super_klass, array_ptr, temp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1991 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1992 |
int source_offset = in_bytes(Klass::secondary_supers_offset()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1993 |
int target_offset = in_bytes(Klass::secondary_super_cache_offset()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1994 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1995 |
int length_offset = Array<Klass*>::length_offset_in_bytes(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1996 |
int base_offset = Array<Klass*>::base_offset_in_bytes(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1997 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1998 |
Label hit, loop, failure, fallthru; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1999 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2000 |
ld(array_ptr, source_offset, sub_klass); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2001 |
|
35085 | 2002 |
// TODO: PPC port: assert(4 == arrayOopDesc::length_length_in_bytes(), "precondition violated."); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2003 |
lwz(temp, length_offset, array_ptr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2004 |
cmpwi(CCR0, temp, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2005 |
beq(CCR0, result_reg!=noreg ? failure : fallthru); // length 0 |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2006 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2007 |
mtctr(temp); // load ctr |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2008 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2009 |
bind(loop); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2010 |
// Oops in table are NO MORE compressed. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2011 |
ld(temp, base_offset, array_ptr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2012 |
cmpd(CCR0, temp, super_klass); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2013 |
beq(CCR0, hit); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2014 |
addi(array_ptr, array_ptr, BytesPerWord); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2015 |
bdnz(loop); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2016 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2017 |
bind(failure); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2018 |
if (result_reg!=noreg) li(result_reg, 1); // load non-zero result (indicates a miss) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2019 |
b(fallthru); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2020 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2021 |
bind(hit); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2022 |
std(super_klass, target_offset, sub_klass); // save result to cache |
35085 | 2023 |
if (result_reg != noreg) { li(result_reg, 0); } // load zero result (indicates a hit) |
2024 |
if (L_success != NULL) { b(*L_success); } |
|
2025 |
else if (result_reg == noreg) { blr(); } // return with CR0.eq if neither label nor result reg provided |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2026 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2027 |
bind(fallthru); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2028 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2029 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2030 |
// Try fast path, then go to slow one if not successful |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2031 |
void MacroAssembler::check_klass_subtype(Register sub_klass, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2032 |
Register super_klass, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2033 |
Register temp1_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2034 |
Register temp2_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2035 |
Label& L_success) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2036 |
Label L_failure; |
35085 | 2037 |
check_klass_subtype_fast_path(sub_klass, super_klass, temp1_reg, temp2_reg, &L_success, &L_failure); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2038 |
check_klass_subtype_slow_path(sub_klass, super_klass, temp1_reg, temp2_reg, &L_success); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2039 |
bind(L_failure); // Fallthru if not successful. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2040 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2041 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2042 |
void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2043 |
Register temp_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2044 |
Label& wrong_method_type) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2045 |
assert_different_registers(mtype_reg, mh_reg, temp_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2046 |
// Compare method type against that of the receiver. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2047 |
load_heap_oop_not_null(temp_reg, delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg), mh_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2048 |
cmpd(CCR0, temp_reg, mtype_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2049 |
bne(CCR0, wrong_method_type); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2050 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2051 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2052 |
RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2053 |
Register temp_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2054 |
int extra_slot_offset) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2055 |
// cf. TemplateTable::prepare_invoke(), if (load_receiver). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2056 |
int stackElementSize = Interpreter::stackElementSize; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2057 |
int offset = extra_slot_offset * stackElementSize; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2058 |
if (arg_slot.is_constant()) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2059 |
offset += arg_slot.as_constant() * stackElementSize; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2060 |
return offset; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2061 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2062 |
assert(temp_reg != noreg, "must specify"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2063 |
sldi(temp_reg, arg_slot.as_register(), exact_log2(stackElementSize)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2064 |
if (offset != 0) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2065 |
addi(temp_reg, temp_reg, offset); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2066 |
return temp_reg; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2067 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2068 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2069 |
|
35085 | 2070 |
// Supports temp2_reg = R0. |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2071 |
void MacroAssembler::biased_locking_enter(ConditionRegister cr_reg, Register obj_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2072 |
Register mark_reg, Register temp_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2073 |
Register temp2_reg, Label& done, Label* slow_case) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2074 |
assert(UseBiasedLocking, "why call this otherwise?"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2075 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2076 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2077 |
assert_different_registers(obj_reg, mark_reg, temp_reg, temp2_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2078 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2079 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2080 |
Label cas_label; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2081 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2082 |
// Branch to done if fast path fails and no slow_case provided. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2083 |
Label *slow_case_int = (slow_case != NULL) ? slow_case : &done; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2084 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2085 |
// Biased locking |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2086 |
// See whether the lock is currently biased toward our thread and |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2087 |
// whether the epoch is still valid |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2088 |
// Note that the runtime guarantees sufficient alignment of JavaThread |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2089 |
// pointers to allow age to be placed into low bits |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2090 |
assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2091 |
"biased locking makes assumptions about bit layout"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2092 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2093 |
if (PrintBiasedLockingStatistics) { |
35085 | 2094 |
load_const(temp2_reg, (address) BiasedLocking::total_entry_count_addr(), temp_reg); |
2095 |
lwzx(temp_reg, temp2_reg); |
|
2096 |
addi(temp_reg, temp_reg, 1); |
|
2097 |
stwx(temp_reg, temp2_reg); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2098 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2099 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2100 |
andi(temp_reg, mark_reg, markOopDesc::biased_lock_mask_in_place); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2101 |
cmpwi(cr_reg, temp_reg, markOopDesc::biased_lock_pattern); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2102 |
bne(cr_reg, cas_label); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2103 |
|
23492 | 2104 |
load_klass(temp_reg, obj_reg); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2105 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2106 |
load_const_optimized(temp2_reg, ~((int) markOopDesc::age_mask_in_place)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2107 |
ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2108 |
orr(temp_reg, R16_thread, temp_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2109 |
xorr(temp_reg, mark_reg, temp_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2110 |
andr(temp_reg, temp_reg, temp2_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2111 |
cmpdi(cr_reg, temp_reg, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2112 |
if (PrintBiasedLockingStatistics) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2113 |
Label l; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2114 |
bne(cr_reg, l); |
35085 | 2115 |
load_const(temp2_reg, (address) BiasedLocking::biased_lock_entry_count_addr()); |
2116 |
lwzx(mark_reg, temp2_reg); |
|
2117 |
addi(mark_reg, mark_reg, 1); |
|
2118 |
stwx(mark_reg, temp2_reg); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2119 |
// restore mark_reg |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2120 |
ld(mark_reg, oopDesc::mark_offset_in_bytes(), obj_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2121 |
bind(l); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2122 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2123 |
beq(cr_reg, done); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2124 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2125 |
Label try_revoke_bias; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2126 |
Label try_rebias; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2127 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2128 |
// At this point we know that the header has the bias pattern and |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2129 |
// that we are not the bias owner in the current epoch. We need to |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2130 |
// figure out more details about the state of the header in order to |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2131 |
// know what operations can be legally performed on the object's |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2132 |
// header. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2133 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2134 |
// If the low three bits in the xor result aren't clear, that means |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2135 |
// the prototype header is no longer biased and we have to revoke |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2136 |
// the bias on this object. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2137 |
andi(temp2_reg, temp_reg, markOopDesc::biased_lock_mask_in_place); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2138 |
cmpwi(cr_reg, temp2_reg, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2139 |
bne(cr_reg, try_revoke_bias); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2140 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2141 |
// Biasing is still enabled for this data type. See whether the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2142 |
// epoch of the current bias is still valid, meaning that the epoch |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2143 |
// bits of the mark word are equal to the epoch bits of the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2144 |
// prototype header. (Note that the prototype header's epoch bits |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2145 |
// only change at a safepoint.) If not, attempt to rebias the object |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2146 |
// toward the current thread. Note that we must be absolutely sure |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2147 |
// that the current epoch is invalid in order to do this because |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2148 |
// otherwise the manipulations it performs on the mark word are |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2149 |
// illegal. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2150 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2151 |
int shift_amount = 64 - markOopDesc::epoch_shift; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2152 |
// rotate epoch bits to right (little) end and set other bits to 0 |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2153 |
// [ big part | epoch | little part ] -> [ 0..0 | epoch ] |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2154 |
rldicl_(temp2_reg, temp_reg, shift_amount, 64 - markOopDesc::epoch_bits); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2155 |
// branch if epoch bits are != 0, i.e. they differ, because the epoch has been incremented |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2156 |
bne(CCR0, try_rebias); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2157 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2158 |
// The epoch of the current bias is still valid but we know nothing |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2159 |
// about the owner; it might be set or it might be clear. Try to |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2160 |
// acquire the bias of the object using an atomic operation. If this |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2161 |
// fails we will go in to the runtime to revoke the object's bias. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2162 |
// Note that we first construct the presumed unbiased header so we |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2163 |
// don't accidentally blow away another thread's valid bias. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2164 |
andi(mark_reg, mark_reg, (markOopDesc::biased_lock_mask_in_place | |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2165 |
markOopDesc::age_mask_in_place | |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2166 |
markOopDesc::epoch_mask_in_place)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2167 |
orr(temp_reg, R16_thread, mark_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2168 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2169 |
assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2170 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2171 |
// CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2172 |
cmpxchgd(/*flag=*/cr_reg, /*current_value=*/temp2_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2173 |
/*compare_value=*/mark_reg, /*exchange_value=*/temp_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2174 |
/*where=*/obj_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2175 |
MacroAssembler::MemBarAcq, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2176 |
MacroAssembler::cmpxchgx_hint_acquire_lock(), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2177 |
noreg, slow_case_int); // bail out if failed |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2178 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2179 |
// If the biasing toward our thread failed, this means that |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2180 |
// another thread succeeded in biasing it toward itself and we |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2181 |
// need to revoke that bias. The revocation will occur in the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2182 |
// interpreter runtime in the slow case. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2183 |
if (PrintBiasedLockingStatistics) { |
35085 | 2184 |
load_const(temp2_reg, (address) BiasedLocking::anonymously_biased_lock_entry_count_addr(), temp_reg); |
2185 |
lwzx(temp_reg, temp2_reg); |
|
2186 |
addi(temp_reg, temp_reg, 1); |
|
2187 |
stwx(temp_reg, temp2_reg); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2188 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2189 |
b(done); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2190 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2191 |
bind(try_rebias); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2192 |
// At this point we know the epoch has expired, meaning that the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2193 |
// current "bias owner", if any, is actually invalid. Under these |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2194 |
// circumstances _only_, we are allowed to use the current header's |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2195 |
// value as the comparison value when doing the cas to acquire the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2196 |
// bias in the current epoch. In other words, we allow transfer of |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2197 |
// the bias from one thread to another directly in this situation. |
35085 | 2198 |
load_klass(temp_reg, obj_reg); |
2199 |
andi(temp2_reg, mark_reg, markOopDesc::age_mask_in_place); |
|
2200 |
orr(temp2_reg, R16_thread, temp2_reg); |
|
2201 |
ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg); |
|
2202 |
orr(temp_reg, temp2_reg, temp_reg); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2203 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2204 |
assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2205 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2206 |
cmpxchgd(/*flag=*/cr_reg, /*current_value=*/temp2_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2207 |
/*compare_value=*/mark_reg, /*exchange_value=*/temp_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2208 |
/*where=*/obj_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2209 |
MacroAssembler::MemBarAcq, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2210 |
MacroAssembler::cmpxchgx_hint_acquire_lock(), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2211 |
noreg, slow_case_int); // bail out if failed |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2212 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2213 |
// If the biasing toward our thread failed, this means that |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2214 |
// another thread succeeded in biasing it toward itself and we |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2215 |
// need to revoke that bias. The revocation will occur in the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2216 |
// interpreter runtime in the slow case. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2217 |
if (PrintBiasedLockingStatistics) { |
35085 | 2218 |
load_const(temp2_reg, (address) BiasedLocking::rebiased_lock_entry_count_addr(), temp_reg); |
2219 |
lwzx(temp_reg, temp2_reg); |
|
2220 |
addi(temp_reg, temp_reg, 1); |
|
2221 |
stwx(temp_reg, temp2_reg); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2222 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2223 |
b(done); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2224 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2225 |
bind(try_revoke_bias); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2226 |
// The prototype mark in the klass doesn't have the bias bit set any |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2227 |
// more, indicating that objects of this data type are not supposed |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2228 |
// to be biased any more. We are going to try to reset the mark of |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2229 |
// this object to the prototype value and fall through to the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2230 |
// CAS-based locking scheme. Note that if our CAS fails, it means |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2231 |
// that another thread raced us for the privilege of revoking the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2232 |
// bias of this particular object, so it's okay to continue in the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2233 |
// normal locking code. |
23492 | 2234 |
load_klass(temp_reg, obj_reg); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2235 |
ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2236 |
andi(temp2_reg, mark_reg, markOopDesc::age_mask_in_place); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2237 |
orr(temp_reg, temp_reg, temp2_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2238 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2239 |
assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2240 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2241 |
// CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2242 |
cmpxchgd(/*flag=*/cr_reg, /*current_value=*/temp2_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2243 |
/*compare_value=*/mark_reg, /*exchange_value=*/temp_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2244 |
/*where=*/obj_reg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2245 |
MacroAssembler::MemBarAcq, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2246 |
MacroAssembler::cmpxchgx_hint_acquire_lock()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2247 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2248 |
// reload markOop in mark_reg before continuing with lightweight locking |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2249 |
ld(mark_reg, oopDesc::mark_offset_in_bytes(), obj_reg); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2250 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2251 |
// Fall through to the normal CAS-based lock, because no matter what |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2252 |
// the result of the above CAS, some thread must have succeeded in |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2253 |
// removing the bias bit from the object's header. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2254 |
if (PrintBiasedLockingStatistics) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2255 |
Label l; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2256 |
bne(cr_reg, l); |
35085 | 2257 |
load_const(temp2_reg, (address) BiasedLocking::revoked_lock_entry_count_addr(), temp_reg); |
2258 |
lwzx(temp_reg, temp2_reg); |
|
2259 |
addi(temp_reg, temp_reg, 1); |
|
2260 |
stwx(temp_reg, temp2_reg); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2261 |
bind(l); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2262 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2263 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2264 |
bind(cas_label); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2265 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2266 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2267 |
void MacroAssembler::biased_locking_exit (ConditionRegister cr_reg, Register mark_addr, Register temp_reg, Label& done) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2268 |
// Check for biased locking unlock case, which is a no-op |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2269 |
// Note: we do not have to check the thread ID for two reasons. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2270 |
// First, the interpreter checks for IllegalMonitorStateException at |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2271 |
// a higher level. Second, if the bias was revoked while we held the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2272 |
// lock, the object could not be rebiased toward another thread, so |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2273 |
// the bias bit would be clear. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2274 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2275 |
ld(temp_reg, 0, mark_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2276 |
andi(temp_reg, temp_reg, markOopDesc::biased_lock_mask_in_place); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2277 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2278 |
cmpwi(cr_reg, temp_reg, markOopDesc::biased_lock_pattern); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2279 |
beq(cr_reg, done); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2280 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2281 |
|
35085 | 2282 |
// allocation (for C1) |
2283 |
void MacroAssembler::eden_allocate( |
|
2284 |
Register obj, // result: pointer to object after successful allocation |
|
2285 |
Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise |
|
2286 |
int con_size_in_bytes, // object size in bytes if known at compile time |
|
2287 |
Register t1, // temp register |
|
2288 |
Register t2, // temp register |
|
2289 |
Label& slow_case // continuation point if fast allocation fails |
|
2290 |
) { |
|
2291 |
b(slow_case); |
|
2292 |
} |
|
2293 |
||
2294 |
void MacroAssembler::tlab_allocate( |
|
2295 |
Register obj, // result: pointer to object after successful allocation |
|
2296 |
Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise |
|
2297 |
int con_size_in_bytes, // object size in bytes if known at compile time |
|
2298 |
Register t1, // temp register |
|
2299 |
Label& slow_case // continuation point if fast allocation fails |
|
2300 |
) { |
|
2301 |
// make sure arguments make sense |
|
2302 |
assert_different_registers(obj, var_size_in_bytes, t1); |
|
2303 |
assert(0 <= con_size_in_bytes && is_simm13(con_size_in_bytes), "illegal object size"); |
|
2304 |
assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment"); |
|
2305 |
||
2306 |
const Register new_top = t1; |
|
2307 |
//verify_tlab(); not implemented |
|
2308 |
||
2309 |
ld(obj, in_bytes(JavaThread::tlab_top_offset()), R16_thread); |
|
2310 |
ld(R0, in_bytes(JavaThread::tlab_end_offset()), R16_thread); |
|
2311 |
if (var_size_in_bytes == noreg) { |
|
2312 |
addi(new_top, obj, con_size_in_bytes); |
|
2313 |
} else { |
|
2314 |
add(new_top, obj, var_size_in_bytes); |
|
2315 |
} |
|
2316 |
cmpld(CCR0, new_top, R0); |
|
2317 |
bc_far_optimized(Assembler::bcondCRbiIs1, bi0(CCR0, Assembler::greater), slow_case); |
|
2318 |
||
2319 |
#ifdef ASSERT |
|
2320 |
// make sure new free pointer is properly aligned |
|
2321 |
{ |
|
2322 |
Label L; |
|
2323 |
andi_(R0, new_top, MinObjAlignmentInBytesMask); |
|
2324 |
beq(CCR0, L); |
|
2325 |
stop("updated TLAB free is not properly aligned", 0x934); |
|
2326 |
bind(L); |
|
2327 |
} |
|
2328 |
#endif // ASSERT |
|
2329 |
||
2330 |
// update the tlab top pointer |
|
2331 |
std(new_top, in_bytes(JavaThread::tlab_top_offset()), R16_thread); |
|
2332 |
//verify_tlab(); not implemented |
|
2333 |
} |
|
2334 |
void MacroAssembler::tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case) { |
|
2335 |
unimplemented("tlab_refill"); |
|
2336 |
} |
|
2337 |
void MacroAssembler::incr_allocated_bytes(RegisterOrConstant size_in_bytes, Register t1, Register t2) { |
|
2338 |
unimplemented("incr_allocated_bytes"); |
|
2339 |
} |
|
2340 |
||
2341 |
address MacroAssembler::emit_trampoline_stub(int destination_toc_offset, |
|
2342 |
int insts_call_instruction_offset, Register Rtoc) { |
|
2343 |
// Start the stub. |
|
2344 |
address stub = start_a_stub(64); |
|
2345 |
if (stub == NULL) { return NULL; } // CodeCache full: bail out |
|
2346 |
||
2347 |
// Create a trampoline stub relocation which relates this trampoline stub |
|
2348 |
// with the call instruction at insts_call_instruction_offset in the |
|
2349 |
// instructions code-section. |
|
2350 |
relocate(trampoline_stub_Relocation::spec(code()->insts()->start() + insts_call_instruction_offset)); |
|
2351 |
const int stub_start_offset = offset(); |
|
2352 |
||
2353 |
// For java_to_interp stubs we use R11_scratch1 as scratch register |
|
2354 |
// and in call trampoline stubs we use R12_scratch2. This way we |
|
2355 |
// can distinguish them (see is_NativeCallTrampolineStub_at()). |
|
2356 |
Register reg_scratch = R12_scratch2; |
|
2357 |
||
2358 |
// Now, create the trampoline stub's code: |
|
2359 |
// - load the TOC |
|
2360 |
// - load the call target from the constant pool |
|
2361 |
// - call |
|
2362 |
if (Rtoc == noreg) { |
|
2363 |
calculate_address_from_global_toc(reg_scratch, method_toc()); |
|
2364 |
Rtoc = reg_scratch; |
|
2365 |
} |
|
2366 |
||
2367 |
ld_largeoffset_unchecked(reg_scratch, destination_toc_offset, Rtoc, false); |
|
2368 |
mtctr(reg_scratch); |
|
2369 |
bctr(); |
|
2370 |
||
2371 |
const address stub_start_addr = addr_at(stub_start_offset); |
|
2372 |
||
2373 |
// Assert that the encoded destination_toc_offset can be identified and that it is correct. |
|
2374 |
assert(destination_toc_offset == NativeCallTrampolineStub_at(stub_start_addr)->destination_toc_offset(), |
|
2375 |
"encoded offset into the constant pool must match"); |
|
2376 |
// Trampoline_stub_size should be good. |
|
2377 |
assert((uint)(offset() - stub_start_offset) <= trampoline_stub_size, "should be good size"); |
|
2378 |
assert(is_NativeCallTrampolineStub_at(stub_start_addr), "doesn't look like a trampoline"); |
|
2379 |
||
2380 |
// End the stub. |
|
2381 |
end_a_stub(); |
|
2382 |
return stub; |
|
2383 |
} |
|
2384 |
||
30303 | 2385 |
// TM on PPC64. |
2386 |
void MacroAssembler::atomic_inc_ptr(Register addr, Register result, int simm16) { |
|
2387 |
Label retry; |
|
2388 |
bind(retry); |
|
2389 |
ldarx(result, addr, /*hint*/ false); |
|
2390 |
addi(result, result, simm16); |
|
2391 |
stdcx_(result, addr); |
|
2392 |
if (UseStaticBranchPredictionInCompareAndSwapPPC64) { |
|
2393 |
bne_predict_not_taken(CCR0, retry); // stXcx_ sets CCR0 |
|
2394 |
} else { |
|
2395 |
bne( CCR0, retry); // stXcx_ sets CCR0 |
|
2396 |
} |
|
2397 |
} |
|
2398 |
||
2399 |
void MacroAssembler::atomic_ori_int(Register addr, Register result, int uimm16) { |
|
2400 |
Label retry; |
|
2401 |
bind(retry); |
|
2402 |
lwarx(result, addr, /*hint*/ false); |
|
2403 |
ori(result, result, uimm16); |
|
2404 |
stwcx_(result, addr); |
|
2405 |
if (UseStaticBranchPredictionInCompareAndSwapPPC64) { |
|
2406 |
bne_predict_not_taken(CCR0, retry); // stXcx_ sets CCR0 |
|
2407 |
} else { |
|
2408 |
bne( CCR0, retry); // stXcx_ sets CCR0 |
|
2409 |
} |
|
2410 |
} |
|
2411 |
||
2412 |
#if INCLUDE_RTM_OPT |
|
2413 |
||
2414 |
// Update rtm_counters based on abort status |
|
2415 |
// input: abort_status |
|
2416 |
// rtm_counters (RTMLockingCounters*) |
|
2417 |
void MacroAssembler::rtm_counters_update(Register abort_status, Register rtm_counters_Reg) { |
|
2418 |
// Mapping to keep PreciseRTMLockingStatistics similar to x86. |
|
2419 |
// x86 ppc (! means inverted, ? means not the same) |
|
2420 |
// 0 31 Set if abort caused by XABORT instruction. |
|
2421 |
// 1 ! 7 If set, the transaction may succeed on a retry. This bit is always clear if bit 0 is set. |
|
2422 |
// 2 13 Set if another logical processor conflicted with a memory address that was part of the transaction that aborted. |
|
2423 |
// 3 10 Set if an internal buffer overflowed. |
|
2424 |
// 4 ?12 Set if a debug breakpoint was hit. |
|
2425 |
// 5 ?32 Set if an abort occurred during execution of a nested transaction. |
|
2426 |
const int tm_failure_bit[] = {Assembler::tm_tabort, // Note: Seems like signal handler sets this, too. |
|
2427 |
Assembler::tm_failure_persistent, // inverted: transient |
|
2428 |
Assembler::tm_trans_cf, |
|
2429 |
Assembler::tm_footprint_of, |
|
2430 |
Assembler::tm_non_trans_cf, |
|
2431 |
Assembler::tm_suspended}; |
|
2432 |
const bool tm_failure_inv[] = {false, true, false, false, false, false}; |
|
2433 |
assert(sizeof(tm_failure_bit)/sizeof(int) == RTMLockingCounters::ABORT_STATUS_LIMIT, "adapt mapping!"); |
|
2434 |
||
2435 |
const Register addr_Reg = R0; |
|
2436 |
// Keep track of offset to where rtm_counters_Reg had pointed to. |
|
2437 |
int counters_offs = RTMLockingCounters::abort_count_offset(); |
|
2438 |
addi(addr_Reg, rtm_counters_Reg, counters_offs); |
|
2439 |
const Register temp_Reg = rtm_counters_Reg; |
|
2440 |
||
2441 |
//atomic_inc_ptr(addr_Reg, temp_Reg); We don't increment atomically |
|
2442 |
ldx(temp_Reg, addr_Reg); |
|
2443 |
addi(temp_Reg, temp_Reg, 1); |
|
2444 |
stdx(temp_Reg, addr_Reg); |
|
2445 |
||
2446 |
if (PrintPreciseRTMLockingStatistics) { |
|
2447 |
int counters_offs_delta = RTMLockingCounters::abortX_count_offset() - counters_offs; |
|
2448 |
||
2449 |
//mftexasr(abort_status); done by caller |
|
2450 |
for (int i = 0; i < RTMLockingCounters::ABORT_STATUS_LIMIT; i++) { |
|
2451 |
counters_offs += counters_offs_delta; |
|
2452 |
li(temp_Reg, counters_offs_delta); // can't use addi with R0 |
|
2453 |
add(addr_Reg, addr_Reg, temp_Reg); // point to next counter |
|
2454 |
counters_offs_delta = sizeof(uintx); |
|
2455 |
||
2456 |
Label check_abort; |
|
2457 |
rldicr_(temp_Reg, abort_status, tm_failure_bit[i], 0); |
|
2458 |
if (tm_failure_inv[i]) { |
|
2459 |
bne(CCR0, check_abort); |
|
2460 |
} else { |
|
2461 |
beq(CCR0, check_abort); |
|
2462 |
} |
|
2463 |
//atomic_inc_ptr(addr_Reg, temp_Reg); We don't increment atomically |
|
2464 |
ldx(temp_Reg, addr_Reg); |
|
2465 |
addi(temp_Reg, temp_Reg, 1); |
|
2466 |
stdx(temp_Reg, addr_Reg); |
|
2467 |
bind(check_abort); |
|
2468 |
} |
|
2469 |
} |
|
2470 |
li(temp_Reg, -counters_offs); // can't use addi with R0 |
|
2471 |
add(rtm_counters_Reg, addr_Reg, temp_Reg); // restore |
|
2472 |
} |
|
2473 |
||
2474 |
// Branch if (random & (count-1) != 0), count is 2^n |
|
2475 |
// tmp and CR0 are killed |
|
2476 |
void MacroAssembler::branch_on_random_using_tb(Register tmp, int count, Label& brLabel) { |
|
2477 |
mftb(tmp); |
|
2478 |
andi_(tmp, tmp, count-1); |
|
2479 |
bne(CCR0, brLabel); |
|
2480 |
} |
|
2481 |
||
2482 |
// Perform abort ratio calculation, set no_rtm bit if high ratio. |
|
2483 |
// input: rtm_counters_Reg (RTMLockingCounters* address) - KILLED |
|
2484 |
void MacroAssembler::rtm_abort_ratio_calculation(Register rtm_counters_Reg, |
|
2485 |
RTMLockingCounters* rtm_counters, |
|
2486 |
Metadata* method_data) { |
|
2487 |
Label L_done, L_check_always_rtm1, L_check_always_rtm2; |
|
2488 |
||
2489 |
if (RTMLockingCalculationDelay > 0) { |
|
2490 |
// Delay calculation. |
|
2491 |
ld(rtm_counters_Reg, (RegisterOrConstant)(intptr_t)RTMLockingCounters::rtm_calculation_flag_addr()); |
|
2492 |
cmpdi(CCR0, rtm_counters_Reg, 0); |
|
2493 |
beq(CCR0, L_done); |
|
2494 |
load_const_optimized(rtm_counters_Reg, (address)rtm_counters, R0); // reload |
|
2495 |
} |
|
2496 |
// Abort ratio calculation only if abort_count > RTMAbortThreshold. |
|
2497 |
// Aborted transactions = abort_count * 100 |
|
2498 |
// All transactions = total_count * RTMTotalCountIncrRate |
|
2499 |
// Set no_rtm bit if (Aborted transactions >= All transactions * RTMAbortRatio) |
|
2500 |
ld(R0, RTMLockingCounters::abort_count_offset(), rtm_counters_Reg); |
|
2501 |
cmpdi(CCR0, R0, RTMAbortThreshold); |
|
2502 |
blt(CCR0, L_check_always_rtm2); |
|
2503 |
mulli(R0, R0, 100); |
|
2504 |
||
2505 |
const Register tmpReg = rtm_counters_Reg; |
|
2506 |
ld(tmpReg, RTMLockingCounters::total_count_offset(), rtm_counters_Reg); |
|
2507 |
mulli(tmpReg, tmpReg, RTMTotalCountIncrRate); |
|
2508 |
mulli(tmpReg, tmpReg, RTMAbortRatio); |
|
2509 |
cmpd(CCR0, R0, tmpReg); |
|
2510 |
blt(CCR0, L_check_always_rtm1); // jump to reload |
|
2511 |
if (method_data != NULL) { |
|
2512 |
// Set rtm_state to "no rtm" in MDO. |
|
2513 |
// Not using a metadata relocation. Method and Class Loader are kept alive anyway. |
|
2514 |
// (See nmethod::metadata_do and CodeBuffer::finalize_oop_references.) |
|
2515 |
load_const(R0, (address)method_data + MethodData::rtm_state_offset_in_bytes(), tmpReg); |
|
2516 |
atomic_ori_int(R0, tmpReg, NoRTM); |
|
2517 |
} |
|
2518 |
b(L_done); |
|
2519 |
||
2520 |
bind(L_check_always_rtm1); |
|
2521 |
load_const_optimized(rtm_counters_Reg, (address)rtm_counters, R0); // reload |
|
2522 |
bind(L_check_always_rtm2); |
|
2523 |
ld(tmpReg, RTMLockingCounters::total_count_offset(), rtm_counters_Reg); |
|
2524 |
cmpdi(CCR0, tmpReg, RTMLockingThreshold / RTMTotalCountIncrRate); |
|
2525 |
blt(CCR0, L_done); |
|
2526 |
if (method_data != NULL) { |
|
2527 |
// Set rtm_state to "always rtm" in MDO. |
|
2528 |
// Not using a metadata relocation. See above. |
|
2529 |
load_const(R0, (address)method_data + MethodData::rtm_state_offset_in_bytes(), tmpReg); |
|
2530 |
atomic_ori_int(R0, tmpReg, UseRTM); |
|
2531 |
} |
|
2532 |
bind(L_done); |
|
2533 |
} |
|
2534 |
||
2535 |
// Update counters and perform abort ratio calculation. |
|
2536 |
// input: abort_status_Reg |
|
2537 |
void MacroAssembler::rtm_profiling(Register abort_status_Reg, Register temp_Reg, |
|
2538 |
RTMLockingCounters* rtm_counters, |
|
2539 |
Metadata* method_data, |
|
2540 |
bool profile_rtm) { |
|
2541 |
||
2542 |
assert(rtm_counters != NULL, "should not be NULL when profiling RTM"); |
|
2543 |
// Update rtm counters based on state at abort. |
|
2544 |
// Reads abort_status_Reg, updates flags. |
|
2545 |
assert_different_registers(abort_status_Reg, temp_Reg); |
|
2546 |
load_const_optimized(temp_Reg, (address)rtm_counters, R0); |
|
2547 |
rtm_counters_update(abort_status_Reg, temp_Reg); |
|
2548 |
if (profile_rtm) { |
|
2549 |
assert(rtm_counters != NULL, "should not be NULL when profiling RTM"); |
|
2550 |
rtm_abort_ratio_calculation(temp_Reg, rtm_counters, method_data); |
|
2551 |
} |
|
2552 |
} |
|
2553 |
||
2554 |
// Retry on abort if abort's status indicates non-persistent failure. |
|
2555 |
// inputs: retry_count_Reg |
|
2556 |
// : abort_status_Reg |
|
2557 |
// output: retry_count_Reg decremented by 1 |
|
2558 |
void MacroAssembler::rtm_retry_lock_on_abort(Register retry_count_Reg, Register abort_status_Reg, |
|
2559 |
Label& retryLabel, Label* checkRetry) { |
|
2560 |
Label doneRetry; |
|
2561 |
rldicr_(R0, abort_status_Reg, tm_failure_persistent, 0); |
|
2562 |
bne(CCR0, doneRetry); |
|
2563 |
if (checkRetry) { bind(*checkRetry); } |
|
2564 |
addic_(retry_count_Reg, retry_count_Reg, -1); |
|
2565 |
blt(CCR0, doneRetry); |
|
2566 |
smt_yield(); // Can't use wait(). No permission (SIGILL). |
|
2567 |
b(retryLabel); |
|
2568 |
bind(doneRetry); |
|
2569 |
} |
|
2570 |
||
2571 |
// Spin and retry if lock is busy. |
|
43428
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2572 |
// inputs: owner_addr_Reg (monitor address) |
30303 | 2573 |
// : retry_count_Reg |
2574 |
// output: retry_count_Reg decremented by 1 |
|
2575 |
// CTR is killed |
|
2576 |
void MacroAssembler::rtm_retry_lock_on_busy(Register retry_count_Reg, Register owner_addr_Reg, Label& retryLabel) { |
|
2577 |
Label SpinLoop, doneRetry; |
|
2578 |
addic_(retry_count_Reg, retry_count_Reg, -1); |
|
2579 |
blt(CCR0, doneRetry); |
|
43428
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2580 |
|
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2581 |
if (RTMSpinLoopCount > 1) { |
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2582 |
li(R0, RTMSpinLoopCount); |
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2583 |
mtctr(R0); |
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2584 |
} |
30303 | 2585 |
|
2586 |
bind(SpinLoop); |
|
2587 |
smt_yield(); // Can't use waitrsv(). No permission (SIGILL). |
|
43428
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2588 |
|
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2589 |
if (RTMSpinLoopCount > 1) { |
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2590 |
bdz(retryLabel); |
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2591 |
ld(R0, 0, owner_addr_Reg); |
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2592 |
cmpdi(CCR0, R0, 0); |
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2593 |
bne(CCR0, SpinLoop); |
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2594 |
} |
3dccc891c216
8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents:
42661
diff
changeset
|
2595 |
|
30303 | 2596 |
b(retryLabel); |
2597 |
||
2598 |
bind(doneRetry); |
|
2599 |
} |
|
2600 |
||
2601 |
// Use RTM for normal stack locks. |
|
2602 |
// Input: objReg (object to lock) |
|
2603 |
void MacroAssembler::rtm_stack_locking(ConditionRegister flag, |
|
2604 |
Register obj, Register mark_word, Register tmp, |
|
2605 |
Register retry_on_abort_count_Reg, |
|
2606 |
RTMLockingCounters* stack_rtm_counters, |
|
2607 |
Metadata* method_data, bool profile_rtm, |
|
2608 |
Label& DONE_LABEL, Label& IsInflated) { |
|
2609 |
assert(UseRTMForStackLocks, "why call this otherwise?"); |
|
2610 |
assert(!UseBiasedLocking, "Biased locking is not supported with RTM locking"); |
|
2611 |
Label L_rtm_retry, L_decrement_retry, L_on_abort; |
|
2612 |
||
2613 |
if (RTMRetryCount > 0) { |
|
2614 |
load_const_optimized(retry_on_abort_count_Reg, RTMRetryCount); // Retry on abort |
|
2615 |
bind(L_rtm_retry); |
|
2616 |
} |
|
2617 |
andi_(R0, mark_word, markOopDesc::monitor_value); // inflated vs stack-locked|neutral|biased |
|
2618 |
bne(CCR0, IsInflated); |
|
2619 |
||
2620 |
if (PrintPreciseRTMLockingStatistics || profile_rtm) { |
|
2621 |
Label L_noincrement; |
|
2622 |
if (RTMTotalCountIncrRate > 1) { |
|
2623 |
branch_on_random_using_tb(tmp, (int)RTMTotalCountIncrRate, L_noincrement); |
|
2624 |
} |
|
2625 |
assert(stack_rtm_counters != NULL, "should not be NULL when profiling RTM"); |
|
2626 |
load_const_optimized(tmp, (address)stack_rtm_counters->total_count_addr(), R0); |
|
2627 |
//atomic_inc_ptr(tmp, /*temp, will be reloaded*/mark_word); We don't increment atomically |
|
2628 |
ldx(mark_word, tmp); |
|
2629 |
addi(mark_word, mark_word, 1); |
|
2630 |
stdx(mark_word, tmp); |
|
2631 |
bind(L_noincrement); |
|
2632 |
} |
|
2633 |
tbegin_(); |
|
2634 |
beq(CCR0, L_on_abort); |
|
2635 |
ld(mark_word, oopDesc::mark_offset_in_bytes(), obj); // Reload in transaction, conflicts need to be tracked. |
|
2636 |
andi(R0, mark_word, markOopDesc::biased_lock_mask_in_place); // look at 3 lock bits |
|
2637 |
cmpwi(flag, R0, markOopDesc::unlocked_value); // bits = 001 unlocked |
|
2638 |
beq(flag, DONE_LABEL); // all done if unlocked |
|
2639 |
||
2640 |
if (UseRTMXendForLockBusy) { |
|
2641 |
tend_(); |
|
2642 |
b(L_decrement_retry); |
|
2643 |
} else { |
|
2644 |
tabort_(); |
|
2645 |
} |
|
2646 |
bind(L_on_abort); |
|
2647 |
const Register abort_status_Reg = tmp; |
|
2648 |
mftexasr(abort_status_Reg); |
|
2649 |
if (PrintPreciseRTMLockingStatistics || profile_rtm) { |
|
2650 |
rtm_profiling(abort_status_Reg, /*temp*/mark_word, stack_rtm_counters, method_data, profile_rtm); |
|
2651 |
} |
|
2652 |
ld(mark_word, oopDesc::mark_offset_in_bytes(), obj); // reload |
|
2653 |
if (RTMRetryCount > 0) { |
|
2654 |
// Retry on lock abort if abort status is not permanent. |
|
2655 |
rtm_retry_lock_on_abort(retry_on_abort_count_Reg, abort_status_Reg, L_rtm_retry, &L_decrement_retry); |
|
2656 |
} else { |
|
2657 |
bind(L_decrement_retry); |
|
2658 |
} |
|
2659 |
} |
|
2660 |
||
2661 |
// Use RTM for inflating locks |
|
2662 |
// inputs: obj (object to lock) |
|
2663 |
// mark_word (current header - KILLED) |
|
2664 |
// boxReg (on-stack box address (displaced header location) - KILLED) |
|
2665 |
void MacroAssembler::rtm_inflated_locking(ConditionRegister flag, |
|
2666 |
Register obj, Register mark_word, Register boxReg, |
|
2667 |
Register retry_on_busy_count_Reg, Register retry_on_abort_count_Reg, |
|
2668 |
RTMLockingCounters* rtm_counters, |
|
2669 |
Metadata* method_data, bool profile_rtm, |
|
2670 |
Label& DONE_LABEL) { |
|
2671 |
assert(UseRTMLocking, "why call this otherwise?"); |
|
2672 |
Label L_rtm_retry, L_decrement_retry, L_on_abort; |
|
2673 |
// Clean monitor_value bit to get valid pointer. |
|
2674 |
int owner_offset = ObjectMonitor::owner_offset_in_bytes() - markOopDesc::monitor_value; |
|
2675 |
||
2676 |
// Store non-null, using boxReg instead of (intptr_t)markOopDesc::unused_mark(). |
|
2677 |
std(boxReg, BasicLock::displaced_header_offset_in_bytes(), boxReg); |
|
2678 |
const Register tmpReg = boxReg; |
|
2679 |
const Register owner_addr_Reg = mark_word; |
|
2680 |
addi(owner_addr_Reg, mark_word, owner_offset); |
|
2681 |
||
2682 |
if (RTMRetryCount > 0) { |
|
2683 |
load_const_optimized(retry_on_busy_count_Reg, RTMRetryCount); // Retry on lock busy. |
|
2684 |
load_const_optimized(retry_on_abort_count_Reg, RTMRetryCount); // Retry on abort. |
|
2685 |
bind(L_rtm_retry); |
|
2686 |
} |
|
2687 |
if (PrintPreciseRTMLockingStatistics || profile_rtm) { |
|
2688 |
Label L_noincrement; |
|
2689 |
if (RTMTotalCountIncrRate > 1) { |
|
2690 |
branch_on_random_using_tb(R0, (int)RTMTotalCountIncrRate, L_noincrement); |
|
2691 |
} |
|
2692 |
assert(rtm_counters != NULL, "should not be NULL when profiling RTM"); |
|
2693 |
load_const(R0, (address)rtm_counters->total_count_addr(), tmpReg); |
|
2694 |
//atomic_inc_ptr(R0, tmpReg); We don't increment atomically |
|
2695 |
ldx(tmpReg, R0); |
|
2696 |
addi(tmpReg, tmpReg, 1); |
|
2697 |
stdx(tmpReg, R0); |
|
2698 |
bind(L_noincrement); |
|
2699 |
} |
|
2700 |
tbegin_(); |
|
2701 |
beq(CCR0, L_on_abort); |
|
2702 |
// We don't reload mark word. Will only be reset at safepoint. |
|
2703 |
ld(R0, 0, owner_addr_Reg); // Load in transaction, conflicts need to be tracked. |
|
2704 |
cmpdi(flag, R0, 0); |
|
2705 |
beq(flag, DONE_LABEL); |
|
2706 |
||
2707 |
if (UseRTMXendForLockBusy) { |
|
2708 |
tend_(); |
|
2709 |
b(L_decrement_retry); |
|
2710 |
} else { |
|
2711 |
tabort_(); |
|
2712 |
} |
|
2713 |
bind(L_on_abort); |
|
2714 |
const Register abort_status_Reg = tmpReg; |
|
2715 |
mftexasr(abort_status_Reg); |
|
2716 |
if (PrintPreciseRTMLockingStatistics || profile_rtm) { |
|
2717 |
rtm_profiling(abort_status_Reg, /*temp*/ owner_addr_Reg, rtm_counters, method_data, profile_rtm); |
|
2718 |
// Restore owner_addr_Reg |
|
2719 |
ld(mark_word, oopDesc::mark_offset_in_bytes(), obj); |
|
2720 |
#ifdef ASSERT |
|
2721 |
andi_(R0, mark_word, markOopDesc::monitor_value); |
|
2722 |
asm_assert_ne("must be inflated", 0xa754); // Deflating only allowed at safepoint. |
|
2723 |
#endif |
|
2724 |
addi(owner_addr_Reg, mark_word, owner_offset); |
|
2725 |
} |
|
2726 |
if (RTMRetryCount > 0) { |
|
2727 |
// Retry on lock abort if abort status is not permanent. |
|
2728 |
rtm_retry_lock_on_abort(retry_on_abort_count_Reg, abort_status_Reg, L_rtm_retry); |
|
2729 |
} |
|
2730 |
||
2731 |
// Appears unlocked - try to swing _owner from null to non-null. |
|
2732 |
cmpxchgd(flag, /*current val*/ R0, (intptr_t)0, /*new val*/ R16_thread, owner_addr_Reg, |
|
2733 |
MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, |
|
2734 |
MacroAssembler::cmpxchgx_hint_acquire_lock(), noreg, &L_decrement_retry, true); |
|
2735 |
||
2736 |
if (RTMRetryCount > 0) { |
|
2737 |
// success done else retry |
|
2738 |
b(DONE_LABEL); |
|
2739 |
bind(L_decrement_retry); |
|
2740 |
// Spin and retry if lock is busy. |
|
2741 |
rtm_retry_lock_on_busy(retry_on_busy_count_Reg, owner_addr_Reg, L_rtm_retry); |
|
2742 |
} else { |
|
2743 |
bind(L_decrement_retry); |
|
2744 |
} |
|
2745 |
} |
|
2746 |
||
2747 |
#endif // INCLUDE_RTM_OPT |
|
2748 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2749 |
// "The box" is the space on the stack where we copy the object mark. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2750 |
void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register oop, Register box, |
30303 | 2751 |
Register temp, Register displaced_header, Register current_header, |
2752 |
bool try_bias, |
|
2753 |
RTMLockingCounters* rtm_counters, |
|
2754 |
RTMLockingCounters* stack_rtm_counters, |
|
2755 |
Metadata* method_data, |
|
2756 |
bool use_rtm, bool profile_rtm) { |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2757 |
assert_different_registers(oop, box, temp, displaced_header, current_header); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2758 |
assert(flag != CCR0, "bad condition register"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2759 |
Label cont; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2760 |
Label object_has_monitor; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2761 |
Label cas_failed; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2762 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2763 |
// Load markOop from object into displaced_header. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2764 |
ld(displaced_header, oopDesc::mark_offset_in_bytes(), oop); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2765 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2766 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2767 |
// Always do locking in runtime. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2768 |
if (EmitSync & 0x01) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2769 |
cmpdi(flag, oop, 0); // Oop can't be 0 here => always false. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2770 |
return; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2771 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2772 |
|
30303 | 2773 |
if (try_bias) { |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2774 |
biased_locking_enter(flag, oop, displaced_header, temp, current_header, cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2775 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2776 |
|
30303 | 2777 |
#if INCLUDE_RTM_OPT |
2778 |
if (UseRTMForStackLocks && use_rtm) { |
|
2779 |
rtm_stack_locking(flag, oop, displaced_header, temp, /*temp*/ current_header, |
|
2780 |
stack_rtm_counters, method_data, profile_rtm, |
|
2781 |
cont, object_has_monitor); |
|
2782 |
} |
|
2783 |
#endif // INCLUDE_RTM_OPT |
|
2784 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2785 |
// Handle existing monitor. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2786 |
if ((EmitSync & 0x02) == 0) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2787 |
// The object has an existing monitor iff (mark & monitor_value) != 0. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2788 |
andi_(temp, displaced_header, markOopDesc::monitor_value); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2789 |
bne(CCR0, object_has_monitor); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2790 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2791 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2792 |
// Set displaced_header to be (markOop of object | UNLOCK_VALUE). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2793 |
ori(displaced_header, displaced_header, markOopDesc::unlocked_value); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2794 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2795 |
// Load Compare Value application register. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2796 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2797 |
// Initialize the box. (Must happen before we update the object mark!) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2798 |
std(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2799 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2800 |
// Must fence, otherwise, preceding store(s) may float below cmpxchg. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2801 |
// Compare object markOop with mark and if equal exchange scratch1 with object markOop. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2802 |
cmpxchgd(/*flag=*/flag, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2803 |
/*current_value=*/current_header, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2804 |
/*compare_value=*/displaced_header, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2805 |
/*exchange_value=*/box, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2806 |
/*where=*/oop, |
35085 | 2807 |
MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2808 |
MacroAssembler::cmpxchgx_hint_acquire_lock(), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2809 |
noreg, |
35085 | 2810 |
&cas_failed, |
2811 |
/*check without membar and ldarx first*/true); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2812 |
assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2813 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2814 |
// If the compare-and-exchange succeeded, then we found an unlocked |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2815 |
// object and we have now locked it. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2816 |
b(cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2817 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2818 |
bind(cas_failed); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2819 |
// We did not see an unlocked object so try the fast recursive case. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2820 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2821 |
// Check if the owner is self by comparing the value in the markOop of object |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2822 |
// (current_header) with the stack pointer. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2823 |
sub(current_header, current_header, R1_SP); |
35085 | 2824 |
load_const_optimized(temp, ~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2825 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2826 |
and_(R0/*==0?*/, current_header, temp); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2827 |
// If condition is true we are cont and hence we can store 0 as the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2828 |
// displaced header in the box, which indicates that it is a recursive lock. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2829 |
mcrf(flag,CCR0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2830 |
std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), box); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2831 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2832 |
// Handle existing monitor. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2833 |
if ((EmitSync & 0x02) == 0) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2834 |
b(cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2835 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2836 |
bind(object_has_monitor); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2837 |
// The object's monitor m is unlocked iff m->owner == NULL, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2838 |
// otherwise m->owner may contain a thread or a stack address. |
30303 | 2839 |
|
2840 |
#if INCLUDE_RTM_OPT |
|
2841 |
// Use the same RTM locking code in 32- and 64-bit VM. |
|
2842 |
if (use_rtm) { |
|
2843 |
rtm_inflated_locking(flag, oop, displaced_header, box, temp, /*temp*/ current_header, |
|
2844 |
rtm_counters, method_data, profile_rtm, cont); |
|
2845 |
} else { |
|
2846 |
#endif // INCLUDE_RTM_OPT |
|
2847 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2848 |
// Try to CAS m->owner from NULL to current thread. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2849 |
addi(temp, displaced_header, ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2850 |
cmpxchgd(/*flag=*/flag, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2851 |
/*current_value=*/current_header, |
30303 | 2852 |
/*compare_value=*/(intptr_t)0, |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2853 |
/*exchange_value=*/R16_thread, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2854 |
/*where=*/temp, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2855 |
MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2856 |
MacroAssembler::cmpxchgx_hint_acquire_lock()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2857 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2858 |
// Store a non-null value into the box. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2859 |
std(box, BasicLock::displaced_header_offset_in_bytes(), box); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2860 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2861 |
# ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2862 |
bne(flag, cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2863 |
// We have acquired the monitor, check some invariants. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2864 |
addi(/*monitor=*/temp, temp, -ObjectMonitor::owner_offset_in_bytes()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2865 |
// Invariant 1: _recursions should be 0. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2866 |
//assert(ObjectMonitor::recursions_size_in_bytes() == 8, "unexpected size"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2867 |
asm_assert_mem8_is_zero(ObjectMonitor::recursions_offset_in_bytes(), temp, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2868 |
"monitor->_recursions should be 0", -1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2869 |
// Invariant 2: OwnerIsThread shouldn't be 0. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2870 |
//assert(ObjectMonitor::OwnerIsThread_size_in_bytes() == 4, "unexpected size"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2871 |
//asm_assert_mem4_isnot_zero(ObjectMonitor::OwnerIsThread_offset_in_bytes(), temp, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2872 |
// "monitor->OwnerIsThread shouldn't be 0", -1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2873 |
# endif |
30303 | 2874 |
|
2875 |
#if INCLUDE_RTM_OPT |
|
2876 |
} // use_rtm() |
|
2877 |
#endif |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2878 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2879 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2880 |
bind(cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2881 |
// flag == EQ indicates success |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2882 |
// flag == NE indicates failure |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2883 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2884 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2885 |
void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Register oop, Register box, |
30303 | 2886 |
Register temp, Register displaced_header, Register current_header, |
2887 |
bool try_bias, bool use_rtm) { |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2888 |
assert_different_registers(oop, box, temp, displaced_header, current_header); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2889 |
assert(flag != CCR0, "bad condition register"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2890 |
Label cont; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2891 |
Label object_has_monitor; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2892 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2893 |
// Always do locking in runtime. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2894 |
if (EmitSync & 0x01) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2895 |
cmpdi(flag, oop, 0); // Oop can't be 0 here => always false. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2896 |
return; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2897 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2898 |
|
30303 | 2899 |
if (try_bias) { |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2900 |
biased_locking_exit(flag, oop, current_header, cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2901 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2902 |
|
30303 | 2903 |
#if INCLUDE_RTM_OPT |
2904 |
if (UseRTMForStackLocks && use_rtm) { |
|
2905 |
assert(!UseBiasedLocking, "Biased locking is not supported with RTM locking"); |
|
2906 |
Label L_regular_unlock; |
|
2907 |
ld(current_header, oopDesc::mark_offset_in_bytes(), oop); // fetch markword |
|
2908 |
andi(R0, current_header, markOopDesc::biased_lock_mask_in_place); // look at 3 lock bits |
|
2909 |
cmpwi(flag, R0, markOopDesc::unlocked_value); // bits = 001 unlocked |
|
2910 |
bne(flag, L_regular_unlock); // else RegularLock |
|
2911 |
tend_(); // otherwise end... |
|
2912 |
b(cont); // ... and we're done |
|
2913 |
bind(L_regular_unlock); |
|
2914 |
} |
|
2915 |
#endif |
|
2916 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2917 |
// Find the lock address and load the displaced header from the stack. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2918 |
ld(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2919 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2920 |
// If the displaced header is 0, we have a recursive unlock. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2921 |
cmpdi(flag, displaced_header, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2922 |
beq(flag, cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2923 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2924 |
// Handle existing monitor. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2925 |
if ((EmitSync & 0x02) == 0) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2926 |
// The object has an existing monitor iff (mark & monitor_value) != 0. |
30303 | 2927 |
RTM_OPT_ONLY( if (!(UseRTMForStackLocks && use_rtm)) ) // skip load if already done |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2928 |
ld(current_header, oopDesc::mark_offset_in_bytes(), oop); |
30303 | 2929 |
andi_(R0, current_header, markOopDesc::monitor_value); |
2930 |
bne(CCR0, object_has_monitor); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2931 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2932 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2933 |
// Check if it is still a light weight lock, this is is true if we see |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2934 |
// the stack address of the basicLock in the markOop of the object. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2935 |
// Cmpxchg sets flag to cmpd(current_header, box). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2936 |
cmpxchgd(/*flag=*/flag, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2937 |
/*current_value=*/current_header, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2938 |
/*compare_value=*/box, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2939 |
/*exchange_value=*/displaced_header, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2940 |
/*where=*/oop, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2941 |
MacroAssembler::MemBarRel, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2942 |
MacroAssembler::cmpxchgx_hint_release_lock(), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2943 |
noreg, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2944 |
&cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2945 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2946 |
assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2947 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2948 |
// Handle existing monitor. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2949 |
if ((EmitSync & 0x02) == 0) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2950 |
b(cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2951 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2952 |
bind(object_has_monitor); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2953 |
addi(current_header, current_header, -markOopDesc::monitor_value); // monitor |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2954 |
ld(temp, ObjectMonitor::owner_offset_in_bytes(), current_header); |
30303 | 2955 |
|
2956 |
// It's inflated. |
|
2957 |
#if INCLUDE_RTM_OPT |
|
2958 |
if (use_rtm) { |
|
2959 |
Label L_regular_inflated_unlock; |
|
2960 |
// Clean monitor_value bit to get valid pointer |
|
2961 |
cmpdi(flag, temp, 0); |
|
2962 |
bne(flag, L_regular_inflated_unlock); |
|
2963 |
tend_(); |
|
2964 |
b(cont); |
|
2965 |
bind(L_regular_inflated_unlock); |
|
2966 |
} |
|
2967 |
#endif |
|
2968 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2969 |
ld(displaced_header, ObjectMonitor::recursions_offset_in_bytes(), current_header); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2970 |
xorr(temp, R16_thread, temp); // Will be 0 if we are the owner. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2971 |
orr(temp, temp, displaced_header); // Will be 0 if there are 0 recursions. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2972 |
cmpdi(flag, temp, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2973 |
bne(flag, cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2974 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2975 |
ld(temp, ObjectMonitor::EntryList_offset_in_bytes(), current_header); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2976 |
ld(displaced_header, ObjectMonitor::cxq_offset_in_bytes(), current_header); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2977 |
orr(temp, temp, displaced_header); // Will be 0 if both are 0. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2978 |
cmpdi(flag, temp, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2979 |
bne(flag, cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2980 |
release(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2981 |
std(temp, ObjectMonitor::owner_offset_in_bytes(), current_header); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2982 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2983 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2984 |
bind(cont); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2985 |
// flag == EQ indicates success |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2986 |
// flag == NE indicates failure |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2987 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2988 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2989 |
// Write serialization page so VM thread can do a pseudo remote membar. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2990 |
// We use the current thread pointer to calculate a thread specific |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2991 |
// offset to write to within the page. This minimizes bus traffic |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2992 |
// due to cache line collision. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2993 |
void MacroAssembler::serialize_memory(Register thread, Register tmp1, Register tmp2) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2994 |
srdi(tmp2, thread, os::get_serialize_page_shift_count()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2995 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2996 |
int mask = os::vm_page_size() - sizeof(int); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2997 |
if (Assembler::is_simm(mask, 16)) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2998 |
andi(tmp2, tmp2, mask); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
2999 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3000 |
lis(tmp1, (int)((signed short) (mask >> 16))); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3001 |
ori(tmp1, tmp1, mask & 0x0000ffff); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3002 |
andr(tmp2, tmp2, tmp1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3003 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3004 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3005 |
load_const(tmp1, (long) os::get_memory_serialize_page()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3006 |
release(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3007 |
stwx(R0, tmp1, tmp2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3008 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3009 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3010 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3011 |
// GC barrier helper macros |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3012 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3013 |
// Write the card table byte if needed. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3014 |
void MacroAssembler::card_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp) { |
29325 | 3015 |
CardTableModRefBS* bs = |
3016 |
barrier_set_cast<CardTableModRefBS>(Universe::heap()->barrier_set()); |
|
32596
8feecdee3156
8072817: CardTableExtension kind() should be BarrierSet::CardTableExtension
kbarrett
parents:
31861
diff
changeset
|
3017 |
assert(bs->kind() == BarrierSet::CardTableForRS || |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3018 |
bs->kind() == BarrierSet::CardTableExtension, "wrong barrier"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3019 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3020 |
cmpdi(CCR0, Rnew_val, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3021 |
asm_assert_ne("null oop not allowed", 0x321); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3022 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3023 |
card_table_write(bs->byte_map_base, Rtmp, Rstore_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3024 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3025 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3026 |
// Write the card table byte. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3027 |
void MacroAssembler::card_table_write(jbyte* byte_map_base, Register Rtmp, Register Robj) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3028 |
assert_different_registers(Robj, Rtmp, R0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3029 |
load_const_optimized(Rtmp, (address)byte_map_base, R0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3030 |
srdi(Robj, Robj, CardTableModRefBS::card_shift); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3031 |
li(R0, 0); // dirty |
22867 | 3032 |
if (UseConcMarkSweepGC) membar(Assembler::StoreStore); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3033 |
stbx(R0, Rtmp, Robj); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3034 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3035 |
|
23492 | 3036 |
#if INCLUDE_ALL_GCS |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3037 |
// General G1 pre-barrier generator. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3038 |
// Goal: record the previous value if it is not null. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3039 |
void MacroAssembler::g1_write_barrier_pre(Register Robj, RegisterOrConstant offset, Register Rpre_val, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3040 |
Register Rtmp1, Register Rtmp2, bool needs_frame) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3041 |
Label runtime, filtered; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3042 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3043 |
// Is marking active? |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3044 |
if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) { |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3045 |
lwz(Rtmp1, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3046 |
} else { |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3047 |
guarantee(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption"); |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3048 |
lbz(Rtmp1, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active()), R16_thread); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3049 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3050 |
cmpdi(CCR0, Rtmp1, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3051 |
beq(CCR0, filtered); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3052 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3053 |
// Do we need to load the previous value? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3054 |
if (Robj != noreg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3055 |
// Load the previous value... |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3056 |
if (UseCompressedOops) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3057 |
lwz(Rpre_val, offset, Robj); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3058 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3059 |
ld(Rpre_val, offset, Robj); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3060 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3061 |
// Previous value has been loaded into Rpre_val. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3062 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3063 |
assert(Rpre_val != noreg, "must have a real register"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3064 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3065 |
// Is the previous value null? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3066 |
cmpdi(CCR0, Rpre_val, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3067 |
beq(CCR0, filtered); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3068 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3069 |
if (Robj != noreg && UseCompressedOops) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3070 |
decode_heap_oop_not_null(Rpre_val); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3071 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3072 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3073 |
// OK, it's not filtered, so we'll need to call enqueue. In the normal |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3074 |
// case, pre_val will be a scratch G-reg, but there are some cases in |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3075 |
// which it's an O-reg. In the first case, do a normal call. In the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3076 |
// latter, do a save here and call the frameless version. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3077 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3078 |
// Can we store original value in the thread's buffer? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3079 |
// Is index == 0? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3080 |
// (The index field is typed as size_t.) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3081 |
const Register Rbuffer = Rtmp1, Rindex = Rtmp2; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3082 |
|
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3083 |
ld(Rindex, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index()), R16_thread); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3084 |
cmpdi(CCR0, Rindex, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3085 |
beq(CCR0, runtime); // If index == 0, goto runtime. |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3086 |
ld(Rbuffer, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_buf()), R16_thread); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3087 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3088 |
addi(Rindex, Rindex, -wordSize); // Decrement index. |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3089 |
std(Rindex, in_bytes(JavaThread::satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index()), R16_thread); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3090 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3091 |
// Record the previous value. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3092 |
stdx(Rpre_val, Rbuffer, Rindex); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3093 |
b(filtered); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3094 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3095 |
bind(runtime); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3096 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3097 |
// VM call need frame to access(write) O register. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3098 |
if (needs_frame) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3099 |
save_LR_CR(Rtmp1); |
23211 | 3100 |
push_frame_reg_args(0, Rtmp2); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3101 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3102 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3103 |
if (Rpre_val->is_volatile() && Robj == noreg) mr(R31, Rpre_val); // Save pre_val across C call if it was preloaded. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3104 |
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), Rpre_val, R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3105 |
if (Rpre_val->is_volatile() && Robj == noreg) mr(Rpre_val, R31); // restore |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3106 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3107 |
if (needs_frame) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3108 |
pop_frame(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3109 |
restore_LR_CR(Rtmp1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3110 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3111 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3112 |
bind(filtered); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3113 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3114 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3115 |
// General G1 post-barrier generator |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3116 |
// Store cross-region card. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3117 |
void MacroAssembler::g1_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp1, Register Rtmp2, Register Rtmp3, Label *filtered_ext) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3118 |
Label runtime, filtered_int; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3119 |
Label& filtered = (filtered_ext != NULL) ? *filtered_ext : filtered_int; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3120 |
assert_different_registers(Rstore_addr, Rnew_val, Rtmp1, Rtmp2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3121 |
|
29325 | 3122 |
G1SATBCardTableLoggingModRefBS* bs = |
3123 |
barrier_set_cast<G1SATBCardTableLoggingModRefBS>(Universe::heap()->barrier_set()); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3124 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3125 |
// Does store cross heap regions? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3126 |
if (G1RSBarrierRegionFilter) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3127 |
xorr(Rtmp1, Rstore_addr, Rnew_val); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3128 |
srdi_(Rtmp1, Rtmp1, HeapRegion::LogOfHRGrainBytes); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3129 |
beq(CCR0, filtered); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3130 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3131 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3132 |
// Crosses regions, storing NULL? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3133 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3134 |
cmpdi(CCR0, Rnew_val, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3135 |
asm_assert_ne("null oop not allowed (G1)", 0x322); // Checked by caller on PPC64, so following branch is obsolete: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3136 |
//beq(CCR0, filtered); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3137 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3138 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3139 |
// Storing region crossing non-NULL, is card already dirty? |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3140 |
assert(sizeof(*bs->byte_map_base) == sizeof(jbyte), "adjust this code"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3141 |
const Register Rcard_addr = Rtmp1; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3142 |
Register Rbase = Rtmp2; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3143 |
load_const_optimized(Rbase, (address)bs->byte_map_base, /*temp*/ Rtmp3); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3144 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3145 |
srdi(Rcard_addr, Rstore_addr, CardTableModRefBS::card_shift); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3146 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3147 |
// Get the address of the card. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3148 |
lbzx(/*card value*/ Rtmp3, Rbase, Rcard_addr); |
23492 | 3149 |
cmpwi(CCR0, Rtmp3, (int)G1SATBCardTableModRefBS::g1_young_card_val()); |
3150 |
beq(CCR0, filtered); |
|
3151 |
||
3152 |
membar(Assembler::StoreLoad); |
|
3153 |
lbzx(/*card value*/ Rtmp3, Rbase, Rcard_addr); // Reload after membar. |
|
3154 |
cmpwi(CCR0, Rtmp3 /* card value */, CardTableModRefBS::dirty_card_val()); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3155 |
beq(CCR0, filtered); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3156 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3157 |
// Storing a region crossing, non-NULL oop, card is clean. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3158 |
// Dirty card and log. |
23492 | 3159 |
li(Rtmp3, CardTableModRefBS::dirty_card_val()); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3160 |
//release(); // G1: oops are allowed to get visible after dirty marking. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3161 |
stbx(Rtmp3, Rbase, Rcard_addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3162 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3163 |
add(Rcard_addr, Rbase, Rcard_addr); // This is the address which needs to get enqueued. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3164 |
Rbase = noreg; // end of lifetime |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3165 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3166 |
const Register Rqueue_index = Rtmp2, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3167 |
Rqueue_buf = Rtmp3; |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3168 |
ld(Rqueue_index, in_bytes(JavaThread::dirty_card_queue_offset() + DirtyCardQueue::byte_offset_of_index()), R16_thread); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3169 |
cmpdi(CCR0, Rqueue_index, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3170 |
beq(CCR0, runtime); // index == 0 then jump to runtime |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3171 |
ld(Rqueue_buf, in_bytes(JavaThread::dirty_card_queue_offset() + DirtyCardQueue::byte_offset_of_buf()), R16_thread); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3172 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3173 |
addi(Rqueue_index, Rqueue_index, -wordSize); // decrement index |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33198
diff
changeset
|
3174 |
std(Rqueue_index, in_bytes(JavaThread::dirty_card_queue_offset() + DirtyCardQueue::byte_offset_of_index()), R16_thread); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3175 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3176 |
stdx(Rcard_addr, Rqueue_buf, Rqueue_index); // store card |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3177 |
b(filtered); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3178 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3179 |
bind(runtime); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3180 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3181 |
// Save the live input values. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3182 |
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), Rcard_addr, R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3183 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3184 |
bind(filtered_int); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3185 |
} |
23492 | 3186 |
#endif // INCLUDE_ALL_GCS |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3187 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3188 |
// Values for last_Java_pc, and last_Java_sp must comply to the rules |
27012 | 3189 |
// in frame_ppc.hpp. |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3190 |
void MacroAssembler::set_last_Java_frame(Register last_Java_sp, Register last_Java_pc) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3191 |
// Always set last_Java_pc and flags first because once last_Java_sp |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3192 |
// is visible has_last_Java_frame is true and users will look at the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3193 |
// rest of the fields. (Note: flags should always be zero before we |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3194 |
// get here so doesn't need to be set.) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3195 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3196 |
// Verify that last_Java_pc was zeroed on return to Java |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3197 |
asm_assert_mem8_is_zero(in_bytes(JavaThread::last_Java_pc_offset()), R16_thread, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3198 |
"last_Java_pc not zeroed before leaving Java", 0x200); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3199 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3200 |
// When returning from calling out from Java mode the frame anchor's |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3201 |
// last_Java_pc will always be set to NULL. It is set here so that |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3202 |
// if we are doing a call to native (not VM) that we capture the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3203 |
// known pc and don't have to rely on the native call having a |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3204 |
// standard frame linkage where we can find the pc. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3205 |
if (last_Java_pc != noreg) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3206 |
std(last_Java_pc, in_bytes(JavaThread::last_Java_pc_offset()), R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3207 |
|
22861 | 3208 |
// Set last_Java_sp last. |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3209 |
std(last_Java_sp, in_bytes(JavaThread::last_Java_sp_offset()), R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3210 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3211 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3212 |
void MacroAssembler::reset_last_Java_frame(void) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3213 |
asm_assert_mem8_isnot_zero(in_bytes(JavaThread::last_Java_sp_offset()), |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3214 |
R16_thread, "SP was not set, still zero", 0x202); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3215 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3216 |
BLOCK_COMMENT("reset_last_Java_frame {"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3217 |
li(R0, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3218 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3219 |
// _last_Java_sp = 0 |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3220 |
std(R0, in_bytes(JavaThread::last_Java_sp_offset()), R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3221 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3222 |
// _last_Java_pc = 0 |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3223 |
std(R0, in_bytes(JavaThread::last_Java_pc_offset()), R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3224 |
BLOCK_COMMENT("} reset_last_Java_frame"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3225 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3226 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3227 |
void MacroAssembler::set_top_ijava_frame_at_SP_as_last_Java_frame(Register sp, Register tmp1) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3228 |
assert_different_registers(sp, tmp1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3229 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3230 |
// sp points to a TOP_IJAVA_FRAME, retrieve frame's PC via |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3231 |
// TOP_IJAVA_FRAME_ABI. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3232 |
// FIXME: assert that we really have a TOP_IJAVA_FRAME here! |
23221 | 3233 |
address entry = pc(); |
3234 |
load_const_optimized(tmp1, entry); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3235 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3236 |
set_last_Java_frame(/*sp=*/sp, /*pc=*/tmp1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3237 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3238 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3239 |
void MacroAssembler::get_vm_result(Register oop_result) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3240 |
// Read: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3241 |
// R16_thread |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3242 |
// R16_thread->in_bytes(JavaThread::vm_result_offset()) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3243 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3244 |
// Updated: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3245 |
// oop_result |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3246 |
// R16_thread->in_bytes(JavaThread::vm_result_offset()) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3247 |
|
30303 | 3248 |
verify_thread(); |
3249 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3250 |
ld(oop_result, in_bytes(JavaThread::vm_result_offset()), R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3251 |
li(R0, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3252 |
std(R0, in_bytes(JavaThread::vm_result_offset()), R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3253 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3254 |
verify_oop(oop_result); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3255 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3256 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3257 |
void MacroAssembler::get_vm_result_2(Register metadata_result) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3258 |
// Read: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3259 |
// R16_thread |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3260 |
// R16_thread->in_bytes(JavaThread::vm_result_2_offset()) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3261 |
// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3262 |
// Updated: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3263 |
// metadata_result |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3264 |
// R16_thread->in_bytes(JavaThread::vm_result_2_offset()) |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3265 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3266 |
ld(metadata_result, in_bytes(JavaThread::vm_result_2_offset()), R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3267 |
li(R0, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3268 |
std(R0, in_bytes(JavaThread::vm_result_2_offset()), R16_thread); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3269 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3270 |
|
30303 | 3271 |
Register MacroAssembler::encode_klass_not_null(Register dst, Register src) { |
22867 | 3272 |
Register current = (src != noreg) ? src : dst; // Klass is in dst if no src provided. |
22843
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3273 |
if (Universe::narrow_klass_base() != 0) { |
23492 | 3274 |
// Use dst as temp if it is free. |
30303 | 3275 |
sub_const_optimized(dst, current, Universe::narrow_klass_base(), R0); |
22867 | 3276 |
current = dst; |
22843
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3277 |
} |
22867 | 3278 |
if (Universe::narrow_klass_shift() != 0) { |
3279 |
srdi(dst, current, Universe::narrow_klass_shift()); |
|
3280 |
current = dst; |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3281 |
} |
30303 | 3282 |
return current; |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3283 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3284 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3285 |
void MacroAssembler::store_klass(Register dst_oop, Register klass, Register ck) { |
22840
e544827769a7
8027965: Adapt PPC to 8015107: NPG: Use consistent naming for metaspace concepts
goetz
parents:
22829
diff
changeset
|
3286 |
if (UseCompressedClassPointers) { |
30303 | 3287 |
Register compressedKlass = encode_klass_not_null(ck, klass); |
3288 |
stw(compressedKlass, oopDesc::klass_offset_in_bytes(), dst_oop); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3289 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3290 |
std(klass, oopDesc::klass_offset_in_bytes(), dst_oop); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3291 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3292 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3293 |
|
23221 | 3294 |
void MacroAssembler::store_klass_gap(Register dst_oop, Register val) { |
3295 |
if (UseCompressedClassPointers) { |
|
3296 |
if (val == noreg) { |
|
3297 |
val = R0; |
|
3298 |
li(val, 0); |
|
3299 |
} |
|
3300 |
stw(val, oopDesc::klass_gap_offset_in_bytes(), dst_oop); // klass gap if compressed |
|
3301 |
} |
|
3302 |
} |
|
3303 |
||
22843
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3304 |
int MacroAssembler::instr_size_for_decode_klass_not_null() { |
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3305 |
if (!UseCompressedClassPointers) return 0; |
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3306 |
int num_instrs = 1; // shift or move |
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3307 |
if (Universe::narrow_klass_base() != 0) num_instrs = 7; // shift + load const + add |
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3308 |
return num_instrs * BytesPerInstWord; |
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3309 |
} |
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3310 |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3311 |
void MacroAssembler::decode_klass_not_null(Register dst, Register src) { |
27012 | 3312 |
assert(dst != R0, "Dst reg may not be R0, as R0 is used here."); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3313 |
if (src == noreg) src = dst; |
22829 | 3314 |
Register shifted_src = src; |
22843
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3315 |
if (Universe::narrow_klass_shift() != 0 || |
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3316 |
Universe::narrow_klass_base() == 0 && src != dst) { // Move required. |
22829 | 3317 |
shifted_src = dst; |
3318 |
sldi(shifted_src, src, Universe::narrow_klass_shift()); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3319 |
} |
22843
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3320 |
if (Universe::narrow_klass_base() != 0) { |
30303 | 3321 |
add_const_optimized(dst, shifted_src, Universe::narrow_klass_base(), R0); |
22843
b245fac3b6a4
8027968: Adapt PPC to 8024927: Nashorn performance regression with CompressedOops
goetz
parents:
22840
diff
changeset
|
3322 |
} |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3323 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3324 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3325 |
void MacroAssembler::load_klass(Register dst, Register src) { |
22840
e544827769a7
8027965: Adapt PPC to 8015107: NPG: Use consistent naming for metaspace concepts
goetz
parents:
22829
diff
changeset
|
3326 |
if (UseCompressedClassPointers) { |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3327 |
lwz(dst, oopDesc::klass_offset_in_bytes(), src); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3328 |
// Attention: no null check here! |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3329 |
decode_klass_not_null(dst, dst); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3330 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3331 |
ld(dst, oopDesc::klass_offset_in_bytes(), src); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3332 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3333 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3334 |
|
42068
18c8a4d5998e
8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents:
41334
diff
changeset
|
3335 |
void MacroAssembler::load_mirror_from_const_method(Register mirror, Register const_method) { |
18c8a4d5998e
8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents:
41334
diff
changeset
|
3336 |
ld(mirror, in_bytes(ConstMethod::constants_offset()), const_method); |
38074
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
36303
diff
changeset
|
3337 |
ld(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror); |
42068
18c8a4d5998e
8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents:
41334
diff
changeset
|
3338 |
ld(mirror, in_bytes(Klass::java_mirror_offset()), mirror); |
38074
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
36303
diff
changeset
|
3339 |
} |
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
36303
diff
changeset
|
3340 |
|
22861 | 3341 |
// Clear Array |
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3342 |
// For very short arrays. tmp == R0 is allowed. |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3343 |
void MacroAssembler::clear_memory_unrolled(Register base_ptr, int cnt_dwords, Register tmp, int offset) { |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3344 |
if (cnt_dwords > 0) { li(tmp, 0); } |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3345 |
for (int i = 0; i < cnt_dwords; ++i) { std(tmp, offset + i * 8, base_ptr); } |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3346 |
} |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3347 |
|
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3348 |
// Version for constant short array length. Kills base_ptr. tmp == R0 is allowed. |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3349 |
void MacroAssembler::clear_memory_constlen(Register base_ptr, int cnt_dwords, Register tmp) { |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3350 |
if (cnt_dwords < 8) { |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3351 |
clear_memory_unrolled(base_ptr, cnt_dwords, tmp); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3352 |
return; |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3353 |
} |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3354 |
|
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3355 |
Label loop; |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3356 |
const long loopcnt = cnt_dwords >> 1, |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3357 |
remainder = cnt_dwords & 1; |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3358 |
|
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3359 |
li(tmp, loopcnt); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3360 |
mtctr(tmp); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3361 |
li(tmp, 0); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3362 |
bind(loop); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3363 |
std(tmp, 0, base_ptr); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3364 |
std(tmp, 8, base_ptr); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3365 |
addi(base_ptr, base_ptr, 16); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3366 |
bdnz(loop); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3367 |
if (remainder) { std(tmp, 0, base_ptr); } |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3368 |
} |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3369 |
|
22861 | 3370 |
// Kills both input registers. tmp == R0 is allowed. |
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3371 |
void MacroAssembler::clear_memory_doubleword(Register base_ptr, Register cnt_dwords, Register tmp, long const_cnt) { |
22861 | 3372 |
// Procedure for large arrays (uses data cache block zero instruction). |
3373 |
Label startloop, fast, fastloop, small_rest, restloop, done; |
|
35085 | 3374 |
const int cl_size = VM_Version::L1_data_cache_line_size(), |
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3375 |
cl_dwords = cl_size >> 3, |
22861 | 3376 |
cl_dw_addr_bits = exact_log2(cl_dwords), |
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3377 |
dcbz_min = 1, // Min count of dcbz executions, needs to be >0. |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3378 |
min_cnt = ((dcbz_min + 1) << cl_dw_addr_bits) - 1; |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3379 |
|
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3380 |
if (const_cnt >= 0) { |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3381 |
// Constant case. |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3382 |
if (const_cnt < min_cnt) { |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3383 |
clear_memory_constlen(base_ptr, const_cnt, tmp); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3384 |
return; |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3385 |
} |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3386 |
load_const_optimized(cnt_dwords, const_cnt, tmp); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3387 |
} else { |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3388 |
// cnt_dwords already loaded in register. Need to check size. |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3389 |
cmpdi(CCR1, cnt_dwords, min_cnt); // Big enough? (ensure >= dcbz_min lines included). |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3390 |
blt(CCR1, small_rest); |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3391 |
} |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3392 |
rldicl_(tmp, base_ptr, 64-3, 64-cl_dw_addr_bits); // Extract dword offset within first cache line. |
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3393 |
beq(CCR0, fast); // Already 128byte aligned. |
22861 | 3394 |
|
3395 |
subfic(tmp, tmp, cl_dwords); |
|
3396 |
mtctr(tmp); // Set ctr to hit 128byte boundary (0<ctr<cl_dwords). |
|
3397 |
subf(cnt_dwords, tmp, cnt_dwords); // rest. |
|
3398 |
li(tmp, 0); |
|
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3399 |
|
22861 | 3400 |
bind(startloop); // Clear at the beginning to reach 128byte boundary. |
3401 |
std(tmp, 0, base_ptr); // Clear 8byte aligned block. |
|
3402 |
addi(base_ptr, base_ptr, 8); |
|
3403 |
bdnz(startloop); |
|
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3404 |
|
22861 | 3405 |
bind(fast); // Clear 128byte blocks. |
3406 |
srdi(tmp, cnt_dwords, cl_dw_addr_bits); // Loop count for 128byte loop (>0). |
|
3407 |
andi(cnt_dwords, cnt_dwords, cl_dwords-1); // Rest in dwords. |
|
3408 |
mtctr(tmp); // Load counter. |
|
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3409 |
|
22861 | 3410 |
bind(fastloop); |
3411 |
dcbz(base_ptr); // Clear 128byte aligned block. |
|
3412 |
addi(base_ptr, base_ptr, cl_size); |
|
3413 |
bdnz(fastloop); |
|
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3414 |
|
22861 | 3415 |
bind(small_rest); |
3416 |
cmpdi(CCR0, cnt_dwords, 0); // size 0? |
|
3417 |
beq(CCR0, done); // rest == 0 |
|
3418 |
li(tmp, 0); |
|
3419 |
mtctr(cnt_dwords); // Load counter. |
|
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3420 |
|
22861 | 3421 |
bind(restloop); // Clear rest. |
3422 |
std(tmp, 0, base_ptr); // Clear 8byte aligned block. |
|
3423 |
addi(base_ptr, base_ptr, 8); |
|
3424 |
bdnz(restloop); |
|
42661
2343dd675325
8170991: PPC64: Bad code for initialization of short arrays
mdoerr
parents:
42068
diff
changeset
|
3425 |
|
22861 | 3426 |
bind(done); |
3427 |
} |
|
3428 |
||
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3429 |
/////////////////////////////////////////// String intrinsics //////////////////////////////////////////// |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
3430 |
|
36303
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3431 |
#ifdef COMPILER2 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3432 |
// Intrinsics for CompactStrings |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3433 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3434 |
// Compress char[] to byte[] by compressing 16 bytes at once. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3435 |
void MacroAssembler::string_compress_16(Register src, Register dst, Register cnt, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3436 |
Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3437 |
Label& Lfailure) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3438 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3439 |
const Register tmp0 = R0; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3440 |
assert_different_registers(src, dst, cnt, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3441 |
Label Lloop, Lslow; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3442 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3443 |
// Check if cnt >= 8 (= 16 bytes) |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3444 |
lis(tmp1, 0xFF); // tmp1 = 0x00FF00FF00FF00FF |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3445 |
srwi_(tmp2, cnt, 3); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3446 |
beq(CCR0, Lslow); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3447 |
ori(tmp1, tmp1, 0xFF); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3448 |
rldimi(tmp1, tmp1, 32, 0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3449 |
mtctr(tmp2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3450 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3451 |
// 2x unrolled loop |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3452 |
bind(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3453 |
ld(tmp2, 0, src); // _0_1_2_3 (Big Endian) |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3454 |
ld(tmp4, 8, src); // _4_5_6_7 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3455 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3456 |
orr(tmp0, tmp2, tmp4); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3457 |
rldicl(tmp3, tmp2, 6*8, 64-24); // _____1_2 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3458 |
rldimi(tmp2, tmp2, 2*8, 2*8); // _0_2_3_3 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3459 |
rldicl(tmp5, tmp4, 6*8, 64-24); // _____5_6 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3460 |
rldimi(tmp4, tmp4, 2*8, 2*8); // _4_6_7_7 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3461 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3462 |
andc_(tmp0, tmp0, tmp1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3463 |
bne(CCR0, Lfailure); // Not latin1. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3464 |
addi(src, src, 16); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3465 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3466 |
rlwimi(tmp3, tmp2, 0*8, 24, 31);// _____1_3 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3467 |
srdi(tmp2, tmp2, 3*8); // ____0_2_ |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3468 |
rlwimi(tmp5, tmp4, 0*8, 24, 31);// _____5_7 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3469 |
srdi(tmp4, tmp4, 3*8); // ____4_6_ |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3470 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3471 |
orr(tmp2, tmp2, tmp3); // ____0123 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3472 |
orr(tmp4, tmp4, tmp5); // ____4567 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3473 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3474 |
stw(tmp2, 0, dst); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3475 |
stw(tmp4, 4, dst); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3476 |
addi(dst, dst, 8); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3477 |
bdnz(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3478 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3479 |
bind(Lslow); // Fallback to slow version |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3480 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3481 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3482 |
// Compress char[] to byte[]. cnt must be positive int. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3483 |
void MacroAssembler::string_compress(Register src, Register dst, Register cnt, Register tmp, Label& Lfailure) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3484 |
Label Lloop; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3485 |
mtctr(cnt); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3486 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3487 |
bind(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3488 |
lhz(tmp, 0, src); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3489 |
cmplwi(CCR0, tmp, 0xff); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3490 |
bgt(CCR0, Lfailure); // Not latin1. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3491 |
addi(src, src, 2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3492 |
stb(tmp, 0, dst); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3493 |
addi(dst, dst, 1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3494 |
bdnz(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3495 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3496 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3497 |
// Inflate byte[] to char[] by inflating 16 bytes at once. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3498 |
void MacroAssembler::string_inflate_16(Register src, Register dst, Register cnt, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3499 |
Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3500 |
const Register tmp0 = R0; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3501 |
assert_different_registers(src, dst, cnt, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3502 |
Label Lloop, Lslow; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3503 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3504 |
// Check if cnt >= 8 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3505 |
srwi_(tmp2, cnt, 3); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3506 |
beq(CCR0, Lslow); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3507 |
lis(tmp1, 0xFF); // tmp1 = 0x00FF00FF |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3508 |
ori(tmp1, tmp1, 0xFF); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3509 |
mtctr(tmp2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3510 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3511 |
// 2x unrolled loop |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3512 |
bind(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3513 |
lwz(tmp2, 0, src); // ____0123 (Big Endian) |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3514 |
lwz(tmp4, 4, src); // ____4567 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3515 |
addi(src, src, 8); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3516 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3517 |
rldicl(tmp3, tmp2, 7*8, 64-8); // _______2 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3518 |
rlwimi(tmp2, tmp2, 3*8, 16, 23);// ____0113 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3519 |
rldicl(tmp5, tmp4, 7*8, 64-8); // _______6 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3520 |
rlwimi(tmp4, tmp4, 3*8, 16, 23);// ____4557 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3521 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3522 |
andc(tmp0, tmp2, tmp1); // ____0_1_ |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3523 |
rlwimi(tmp2, tmp3, 2*8, 0, 23); // _____2_3 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3524 |
andc(tmp3, tmp4, tmp1); // ____4_5_ |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3525 |
rlwimi(tmp4, tmp5, 2*8, 0, 23); // _____6_7 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3526 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3527 |
rldimi(tmp2, tmp0, 3*8, 0*8); // _0_1_2_3 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3528 |
rldimi(tmp4, tmp3, 3*8, 0*8); // _4_5_6_7 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3529 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3530 |
std(tmp2, 0, dst); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3531 |
std(tmp4, 8, dst); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3532 |
addi(dst, dst, 16); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3533 |
bdnz(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3534 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3535 |
bind(Lslow); // Fallback to slow version |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3536 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3537 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3538 |
// Inflate byte[] to char[]. cnt must be positive int. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3539 |
void MacroAssembler::string_inflate(Register src, Register dst, Register cnt, Register tmp) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3540 |
Label Lloop; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3541 |
mtctr(cnt); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3542 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3543 |
bind(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3544 |
lbz(tmp, 0, src); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3545 |
addi(src, src, 1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3546 |
sth(tmp, 0, dst); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3547 |
addi(dst, dst, 2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3548 |
bdnz(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3549 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3550 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3551 |
void MacroAssembler::string_compare(Register str1, Register str2, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3552 |
Register cnt1, Register cnt2, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3553 |
Register tmp1, Register result, int ae) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3554 |
const Register tmp0 = R0, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3555 |
diff = tmp1; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3556 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3557 |
assert_different_registers(str1, str2, cnt1, cnt2, tmp0, tmp1, result); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3558 |
Label Ldone, Lslow, Lloop, Lreturn_diff; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3559 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3560 |
// Note: Making use of the fact that compareTo(a, b) == -compareTo(b, a) |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3561 |
// we interchange str1 and str2 in the UL case and negate the result. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3562 |
// Like this, str1 is always latin1 encoded, except for the UU case. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3563 |
// In addition, we need 0 (or sign which is 0) extend. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3564 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3565 |
if (ae == StrIntrinsicNode::UU) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3566 |
srwi(cnt1, cnt1, 1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3567 |
} else { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3568 |
clrldi(cnt1, cnt1, 32); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3569 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3570 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3571 |
if (ae != StrIntrinsicNode::LL) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3572 |
srwi(cnt2, cnt2, 1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3573 |
} else { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3574 |
clrldi(cnt2, cnt2, 32); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3575 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3576 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3577 |
// See if the lengths are different, and calculate min in cnt1. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3578 |
// Save diff in case we need it for a tie-breaker. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3579 |
subf_(diff, cnt2, cnt1); // diff = cnt1 - cnt2 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3580 |
// if (diff > 0) { cnt1 = cnt2; } |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3581 |
if (VM_Version::has_isel()) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3582 |
isel(cnt1, CCR0, Assembler::greater, /*invert*/ false, cnt2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3583 |
} else { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3584 |
Label Lskip; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3585 |
blt(CCR0, Lskip); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3586 |
mr(cnt1, cnt2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3587 |
bind(Lskip); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3588 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3589 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3590 |
// Rename registers |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3591 |
Register chr1 = result; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3592 |
Register chr2 = tmp0; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3593 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3594 |
// Compare multiple characters in fast loop (only implemented for same encoding). |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3595 |
int stride1 = 8, stride2 = 8; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3596 |
if (ae == StrIntrinsicNode::LL || ae == StrIntrinsicNode::UU) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3597 |
int log2_chars_per_iter = (ae == StrIntrinsicNode::LL) ? 3 : 2; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3598 |
Label Lfastloop, Lskipfast; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3599 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3600 |
srwi_(tmp0, cnt1, log2_chars_per_iter); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3601 |
beq(CCR0, Lskipfast); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3602 |
rldicl(cnt2, cnt1, 0, 64 - log2_chars_per_iter); // Remaining characters. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3603 |
li(cnt1, 1 << log2_chars_per_iter); // Initialize for failure case: Rescan characters from current iteration. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3604 |
mtctr(tmp0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3605 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3606 |
bind(Lfastloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3607 |
ld(chr1, 0, str1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3608 |
ld(chr2, 0, str2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3609 |
cmpd(CCR0, chr1, chr2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3610 |
bne(CCR0, Lslow); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3611 |
addi(str1, str1, stride1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3612 |
addi(str2, str2, stride2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3613 |
bdnz(Lfastloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3614 |
mr(cnt1, cnt2); // Remaining characters. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3615 |
bind(Lskipfast); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3616 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3617 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3618 |
// Loop which searches the first difference character by character. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3619 |
cmpwi(CCR0, cnt1, 0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3620 |
beq(CCR0, Lreturn_diff); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3621 |
bind(Lslow); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3622 |
mtctr(cnt1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3623 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3624 |
switch (ae) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3625 |
case StrIntrinsicNode::LL: stride1 = 1; stride2 = 1; break; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3626 |
case StrIntrinsicNode::UL: // fallthru (see comment above) |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3627 |
case StrIntrinsicNode::LU: stride1 = 1; stride2 = 2; break; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3628 |
case StrIntrinsicNode::UU: stride1 = 2; stride2 = 2; break; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3629 |
default: ShouldNotReachHere(); break; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3630 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3631 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3632 |
bind(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3633 |
if (stride1 == 1) { lbz(chr1, 0, str1); } else { lhz(chr1, 0, str1); } |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3634 |
if (stride2 == 1) { lbz(chr2, 0, str2); } else { lhz(chr2, 0, str2); } |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3635 |
subf_(result, chr2, chr1); // result = chr1 - chr2 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3636 |
bne(CCR0, Ldone); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3637 |
addi(str1, str1, stride1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3638 |
addi(str2, str2, stride2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3639 |
bdnz(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3640 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3641 |
// If strings are equal up to min length, return the length difference. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3642 |
bind(Lreturn_diff); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3643 |
mr(result, diff); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3644 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3645 |
// Otherwise, return the difference between the first mismatched chars. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3646 |
bind(Ldone); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3647 |
if (ae == StrIntrinsicNode::UL) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3648 |
neg(result, result); // Negate result (see note above). |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3649 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3650 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3651 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3652 |
void MacroAssembler::array_equals(bool is_array_equ, Register ary1, Register ary2, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3653 |
Register limit, Register tmp1, Register result, bool is_byte) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3654 |
const Register tmp0 = R0; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3655 |
assert_different_registers(ary1, ary2, limit, tmp0, tmp1, result); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3656 |
Label Ldone, Lskiploop, Lloop, Lfastloop, Lskipfast; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3657 |
bool limit_needs_shift = false; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3658 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3659 |
if (is_array_equ) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3660 |
const int length_offset = arrayOopDesc::length_offset_in_bytes(); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3661 |
const int base_offset = arrayOopDesc::base_offset_in_bytes(is_byte ? T_BYTE : T_CHAR); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3662 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3663 |
// Return true if the same array. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3664 |
cmpd(CCR0, ary1, ary2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3665 |
beq(CCR0, Lskiploop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3666 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3667 |
// Return false if one of them is NULL. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3668 |
cmpdi(CCR0, ary1, 0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3669 |
cmpdi(CCR1, ary2, 0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3670 |
li(result, 0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3671 |
cror(CCR0, Assembler::equal, CCR1, Assembler::equal); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3672 |
beq(CCR0, Ldone); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3673 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3674 |
// Load the lengths of arrays. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3675 |
lwz(limit, length_offset, ary1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3676 |
lwz(tmp0, length_offset, ary2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3677 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3678 |
// Return false if the two arrays are not equal length. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3679 |
cmpw(CCR0, limit, tmp0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3680 |
bne(CCR0, Ldone); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3681 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3682 |
// Load array addresses. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3683 |
addi(ary1, ary1, base_offset); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3684 |
addi(ary2, ary2, base_offset); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3685 |
} else { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3686 |
limit_needs_shift = !is_byte; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3687 |
li(result, 0); // Assume not equal. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3688 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3689 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3690 |
// Rename registers |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3691 |
Register chr1 = tmp0; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3692 |
Register chr2 = tmp1; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3693 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3694 |
// Compare 8 bytes per iteration in fast loop. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3695 |
const int log2_chars_per_iter = is_byte ? 3 : 2; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3696 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3697 |
srwi_(tmp0, limit, log2_chars_per_iter + (limit_needs_shift ? 1 : 0)); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3698 |
beq(CCR0, Lskipfast); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3699 |
mtctr(tmp0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3700 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3701 |
bind(Lfastloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3702 |
ld(chr1, 0, ary1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3703 |
ld(chr2, 0, ary2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3704 |
addi(ary1, ary1, 8); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3705 |
addi(ary2, ary2, 8); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3706 |
cmpd(CCR0, chr1, chr2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3707 |
bne(CCR0, Ldone); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3708 |
bdnz(Lfastloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3709 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3710 |
bind(Lskipfast); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3711 |
rldicl_(limit, limit, limit_needs_shift ? 64 - 1 : 0, 64 - log2_chars_per_iter); // Remaining characters. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3712 |
beq(CCR0, Lskiploop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3713 |
mtctr(limit); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3714 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3715 |
// Character by character. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3716 |
bind(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3717 |
if (is_byte) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3718 |
lbz(chr1, 0, ary1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3719 |
lbz(chr2, 0, ary2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3720 |
addi(ary1, ary1, 1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3721 |
addi(ary2, ary2, 1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3722 |
} else { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3723 |
lhz(chr1, 0, ary1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3724 |
lhz(chr2, 0, ary2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3725 |
addi(ary1, ary1, 2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3726 |
addi(ary2, ary2, 2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3727 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3728 |
cmpw(CCR0, chr1, chr2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3729 |
bne(CCR0, Ldone); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3730 |
bdnz(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3731 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3732 |
bind(Lskiploop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3733 |
li(result, 1); // All characters are equal. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3734 |
bind(Ldone); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3735 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3736 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3737 |
void MacroAssembler::string_indexof(Register result, Register haystack, Register haycnt, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3738 |
Register needle, ciTypeArray* needle_values, Register needlecnt, int needlecntval, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3739 |
Register tmp1, Register tmp2, Register tmp3, Register tmp4, int ae) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3740 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3741 |
// Ensure 0<needlecnt<=haycnt in ideal graph as prerequisite! |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3742 |
Label L_TooShort, L_Found, L_NotFound, L_End; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3743 |
Register last_addr = haycnt, // Kill haycnt at the beginning. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3744 |
addr = tmp1, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3745 |
n_start = tmp2, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3746 |
ch1 = tmp3, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3747 |
ch2 = R0; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3748 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3749 |
assert(ae != StrIntrinsicNode::LU, "Invalid encoding"); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3750 |
const int h_csize = (ae == StrIntrinsicNode::LL) ? 1 : 2; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3751 |
const int n_csize = (ae == StrIntrinsicNode::UU) ? 2 : 1; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3752 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3753 |
// ************************************************************************************************** |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3754 |
// Prepare for main loop: optimized for needle count >=2, bail out otherwise. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3755 |
// ************************************************************************************************** |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3756 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3757 |
// Compute last haystack addr to use if no match gets found. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3758 |
clrldi(haycnt, haycnt, 32); // Ensure positive int is valid as 64 bit value. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3759 |
addi(addr, haystack, -h_csize); // Accesses use pre-increment. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3760 |
if (needlecntval == 0) { // variable needlecnt |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3761 |
cmpwi(CCR6, needlecnt, 2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3762 |
clrldi(needlecnt, needlecnt, 32); // Ensure positive int is valid as 64 bit value. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3763 |
blt(CCR6, L_TooShort); // Variable needlecnt: handle short needle separately. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3764 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3765 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3766 |
if (n_csize == 2) { lwz(n_start, 0, needle); } else { lhz(n_start, 0, needle); } // Load first 2 characters of needle. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3767 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3768 |
if (needlecntval == 0) { // variable needlecnt |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3769 |
subf(ch1, needlecnt, haycnt); // Last character index to compare is haycnt-needlecnt. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3770 |
addi(needlecnt, needlecnt, -2); // Rest of needle. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3771 |
} else { // constant needlecnt |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3772 |
guarantee(needlecntval != 1, "IndexOf with single-character needle must be handled separately"); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3773 |
assert((needlecntval & 0x7fff) == needlecntval, "wrong immediate"); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3774 |
addi(ch1, haycnt, -needlecntval); // Last character index to compare is haycnt-needlecnt. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3775 |
if (needlecntval > 3) { li(needlecnt, needlecntval - 2); } // Rest of needle. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3776 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3777 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3778 |
if (h_csize == 2) { slwi(ch1, ch1, 1); } // Scale to number of bytes. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3779 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3780 |
if (ae ==StrIntrinsicNode::UL) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3781 |
srwi(tmp4, n_start, 1*8); // ___0 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3782 |
rlwimi(n_start, tmp4, 2*8, 0, 23); // _0_1 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3783 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3784 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3785 |
add(last_addr, haystack, ch1); // Point to last address to compare (haystack+2*(haycnt-needlecnt)). |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3786 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3787 |
// Main Loop (now we have at least 2 characters). |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3788 |
Label L_OuterLoop, L_InnerLoop, L_FinalCheck, L_Comp1, L_Comp2; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3789 |
bind(L_OuterLoop); // Search for 1st 2 characters. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3790 |
Register addr_diff = tmp4; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3791 |
subf(addr_diff, addr, last_addr); // Difference between already checked address and last address to check. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3792 |
addi(addr, addr, h_csize); // This is the new address we want to use for comparing. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3793 |
srdi_(ch2, addr_diff, h_csize); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3794 |
beq(CCR0, L_FinalCheck); // 2 characters left? |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3795 |
mtctr(ch2); // num of characters / 2 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3796 |
bind(L_InnerLoop); // Main work horse (2x unrolled search loop) |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3797 |
if (h_csize == 2) { // Load 2 characters of haystack (ignore alignment). |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3798 |
lwz(ch1, 0, addr); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3799 |
lwz(ch2, 2, addr); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3800 |
} else { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3801 |
lhz(ch1, 0, addr); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3802 |
lhz(ch2, 1, addr); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3803 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3804 |
cmpw(CCR0, ch1, n_start); // Compare 2 characters (1 would be sufficient but try to reduce branches to CompLoop). |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3805 |
cmpw(CCR1, ch2, n_start); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3806 |
beq(CCR0, L_Comp1); // Did we find the needle start? |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3807 |
beq(CCR1, L_Comp2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3808 |
addi(addr, addr, 2 * h_csize); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3809 |
bdnz(L_InnerLoop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3810 |
bind(L_FinalCheck); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3811 |
andi_(addr_diff, addr_diff, h_csize); // Remaining characters not covered by InnerLoop: (num of characters) & 1. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3812 |
beq(CCR0, L_NotFound); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3813 |
if (h_csize == 2) { lwz(ch1, 0, addr); } else { lhz(ch1, 0, addr); } // One position left at which we have to compare. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3814 |
cmpw(CCR1, ch1, n_start); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3815 |
beq(CCR1, L_Comp1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3816 |
bind(L_NotFound); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3817 |
li(result, -1); // not found |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3818 |
b(L_End); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3819 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3820 |
// ************************************************************************************************** |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3821 |
// Special Case: unfortunately, the variable needle case can be called with needlecnt<2 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3822 |
// ************************************************************************************************** |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3823 |
if (needlecntval == 0) { // We have to handle these cases separately. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3824 |
Label L_OneCharLoop; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3825 |
bind(L_TooShort); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3826 |
mtctr(haycnt); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3827 |
if (n_csize == 2) { lhz(n_start, 0, needle); } else { lbz(n_start, 0, needle); } // First character of needle |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3828 |
bind(L_OneCharLoop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3829 |
if (h_csize == 2) { lhzu(ch1, 2, addr); } else { lbzu(ch1, 1, addr); } |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3830 |
cmpw(CCR1, ch1, n_start); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3831 |
beq(CCR1, L_Found); // Did we find the one character needle? |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3832 |
bdnz(L_OneCharLoop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3833 |
li(result, -1); // Not found. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3834 |
b(L_End); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3835 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3836 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3837 |
// ************************************************************************************************** |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3838 |
// Regular Case Part II: compare rest of needle (first 2 characters have been compared already) |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3839 |
// ************************************************************************************************** |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3840 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3841 |
// Compare the rest |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3842 |
bind(L_Comp2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3843 |
addi(addr, addr, h_csize); // First comparison has failed, 2nd one hit. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3844 |
bind(L_Comp1); // Addr points to possible needle start. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3845 |
if (needlecntval != 2) { // Const needlecnt==2? |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3846 |
if (needlecntval != 3) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3847 |
if (needlecntval == 0) { beq(CCR6, L_Found); } // Variable needlecnt==2? |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3848 |
Register n_ind = tmp4, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3849 |
h_ind = n_ind; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3850 |
li(n_ind, 2 * n_csize); // First 2 characters are already compared, use index 2. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3851 |
mtctr(needlecnt); // Decremented by 2, still > 0. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3852 |
Label L_CompLoop; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3853 |
bind(L_CompLoop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3854 |
if (ae ==StrIntrinsicNode::UL) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3855 |
h_ind = ch1; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3856 |
sldi(h_ind, n_ind, 1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3857 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3858 |
if (n_csize == 2) { lhzx(ch2, needle, n_ind); } else { lbzx(ch2, needle, n_ind); } |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3859 |
if (h_csize == 2) { lhzx(ch1, addr, h_ind); } else { lbzx(ch1, addr, h_ind); } |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3860 |
cmpw(CCR1, ch1, ch2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3861 |
bne(CCR1, L_OuterLoop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3862 |
addi(n_ind, n_ind, n_csize); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3863 |
bdnz(L_CompLoop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3864 |
} else { // No loop required if there's only one needle character left. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3865 |
if (n_csize == 2) { lhz(ch2, 2 * 2, needle); } else { lbz(ch2, 2 * 1, needle); } |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3866 |
if (h_csize == 2) { lhz(ch1, 2 * 2, addr); } else { lbz(ch1, 2 * 1, addr); } |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3867 |
cmpw(CCR1, ch1, ch2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3868 |
bne(CCR1, L_OuterLoop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3869 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3870 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3871 |
// Return index ... |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3872 |
bind(L_Found); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3873 |
subf(result, haystack, addr); // relative to haystack, ... |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3874 |
if (h_csize == 2) { srdi(result, result, 1); } // in characters. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3875 |
bind(L_End); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3876 |
} // string_indexof |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3877 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3878 |
void MacroAssembler::string_indexof_char(Register result, Register haystack, Register haycnt, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3879 |
Register needle, jchar needleChar, Register tmp1, Register tmp2, bool is_byte) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3880 |
assert_different_registers(haystack, haycnt, needle, tmp1, tmp2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3881 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3882 |
Label L_InnerLoop, L_FinalCheck, L_Found1, L_Found2, L_NotFound, L_End; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3883 |
Register addr = tmp1, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3884 |
ch1 = tmp2, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3885 |
ch2 = R0; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3886 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3887 |
const int h_csize = is_byte ? 1 : 2; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3888 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3889 |
//4: |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3890 |
srwi_(tmp2, haycnt, 1); // Shift right by exact_log2(UNROLL_FACTOR). |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3891 |
mr(addr, haystack); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3892 |
beq(CCR0, L_FinalCheck); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3893 |
mtctr(tmp2); // Move to count register. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3894 |
//8: |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3895 |
bind(L_InnerLoop); // Main work horse (2x unrolled search loop). |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3896 |
if (!is_byte) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3897 |
lhz(ch1, 0, addr); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3898 |
lhz(ch2, 2, addr); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3899 |
} else { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3900 |
lbz(ch1, 0, addr); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3901 |
lbz(ch2, 1, addr); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3902 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3903 |
(needle != R0) ? cmpw(CCR0, ch1, needle) : cmplwi(CCR0, ch1, (unsigned int)needleChar); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3904 |
(needle != R0) ? cmpw(CCR1, ch2, needle) : cmplwi(CCR1, ch2, (unsigned int)needleChar); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3905 |
beq(CCR0, L_Found1); // Did we find the needle? |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3906 |
beq(CCR1, L_Found2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3907 |
addi(addr, addr, 2 * h_csize); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3908 |
bdnz(L_InnerLoop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3909 |
//16: |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3910 |
bind(L_FinalCheck); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3911 |
andi_(R0, haycnt, 1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3912 |
beq(CCR0, L_NotFound); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3913 |
if (!is_byte) { lhz(ch1, 0, addr); } else { lbz(ch1, 0, addr); } // One position left at which we have to compare. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3914 |
(needle != R0) ? cmpw(CCR1, ch1, needle) : cmplwi(CCR1, ch1, (unsigned int)needleChar); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3915 |
beq(CCR1, L_Found1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3916 |
//21: |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3917 |
bind(L_NotFound); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3918 |
li(result, -1); // Not found. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3919 |
b(L_End); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3920 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3921 |
bind(L_Found2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3922 |
addi(addr, addr, h_csize); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3923 |
//24: |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3924 |
bind(L_Found1); // Return index ... |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3925 |
subf(result, haystack, addr); // relative to haystack, ... |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3926 |
if (!is_byte) { srdi(result, result, 1); } // in characters. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3927 |
bind(L_End); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3928 |
} // string_indexof_char |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3929 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3930 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3931 |
void MacroAssembler::has_negatives(Register src, Register cnt, Register result, |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3932 |
Register tmp1, Register tmp2) { |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3933 |
const Register tmp0 = R0; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3934 |
assert_different_registers(src, result, cnt, tmp0, tmp1, tmp2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3935 |
Label Lfastloop, Lslow, Lloop, Lnoneg, Ldone; |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3936 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3937 |
// Check if cnt >= 8 (= 16 bytes) |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3938 |
lis(tmp1, (int)(short)0x8080); // tmp1 = 0x8080808080808080 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3939 |
srwi_(tmp2, cnt, 4); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3940 |
li(result, 1); // Assume there's a negative byte. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3941 |
beq(CCR0, Lslow); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3942 |
ori(tmp1, tmp1, 0x8080); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3943 |
rldimi(tmp1, tmp1, 32, 0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3944 |
mtctr(tmp2); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3945 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3946 |
// 2x unrolled loop |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3947 |
bind(Lfastloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3948 |
ld(tmp2, 0, src); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3949 |
ld(tmp0, 8, src); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3950 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3951 |
orr(tmp0, tmp2, tmp0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3952 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3953 |
and_(tmp0, tmp0, tmp1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3954 |
bne(CCR0, Ldone); // Found negative byte. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3955 |
addi(src, src, 16); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3956 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3957 |
bdnz(Lfastloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3958 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3959 |
bind(Lslow); // Fallback to slow version |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3960 |
rldicl_(tmp0, cnt, 0, 64-4); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3961 |
beq(CCR0, Lnoneg); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3962 |
mtctr(tmp0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3963 |
bind(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3964 |
lbz(tmp0, 0, src); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3965 |
addi(src, src, 1); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3966 |
andi_(tmp0, tmp0, 0x80); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3967 |
bne(CCR0, Ldone); // Found negative byte. |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3968 |
bdnz(Lloop); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3969 |
bind(Lnoneg); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3970 |
li(result, 0); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3971 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3972 |
bind(Ldone); |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3973 |
} |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3974 |
|
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3975 |
#endif // Compiler2 |
6241574f5982
8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents:
35913
diff
changeset
|
3976 |
|
31861 | 3977 |
// Helpers for Intrinsic Emitters |
3978 |
// |
|
3979 |
// Revert the byte order of a 32bit value in a register |
|
3980 |
// src: 0x44556677 |
|
3981 |
// dst: 0x77665544 |
|
3982 |
// Three steps to obtain the result: |
|
3983 |
// 1) Rotate src (as doubleword) left 5 bytes. That puts the leftmost byte of the src word |
|
3984 |
// into the rightmost byte position. Afterwards, everything left of the rightmost byte is cleared. |
|
3985 |
// This value initializes dst. |
|
3986 |
// 2) Rotate src (as word) left 3 bytes. That puts the rightmost byte of the src word into the leftmost |
|
3987 |
// byte position. Furthermore, byte 5 is rotated into byte 6 position where it is supposed to go. |
|
3988 |
// This value is mask inserted into dst with a [0..23] mask of 1s. |
|
3989 |
// 3) Rotate src (as word) left 1 byte. That puts byte 6 into byte 5 position. |
|
3990 |
// This value is mask inserted into dst with a [8..15] mask of 1s. |
|
3991 |
void MacroAssembler::load_reverse_32(Register dst, Register src) { |
|
3992 |
assert_different_registers(dst, src); |
|
3993 |
||
3994 |
rldicl(dst, src, (4+1)*8, 56); // Rotate byte 4 into position 7 (rightmost), clear all to the left. |
|
3995 |
rlwimi(dst, src, 3*8, 0, 23); // Insert byte 5 into position 6, 7 into 4, leave pos 7 alone. |
|
3996 |
rlwimi(dst, src, 1*8, 8, 15); // Insert byte 6 into position 5, leave the rest alone. |
|
3997 |
} |
|
3998 |
||
3999 |
// Calculate the column addresses of the crc32 lookup table into distinct registers. |
|
4000 |
// This loop-invariant calculation is moved out of the loop body, reducing the loop |
|
4001 |
// body size from 20 to 16 instructions. |
|
4002 |
// Returns the offset that was used to calculate the address of column tc3. |
|
4003 |
// Due to register shortage, setting tc3 may overwrite table. With the return offset |
|
4004 |
// at hand, the original table address can be easily reconstructed. |
|
4005 |
int MacroAssembler::crc32_table_columns(Register table, Register tc0, Register tc1, Register tc2, Register tc3) { |
|
4006 |
||
4007 |
#ifdef VM_LITTLE_ENDIAN |
|
4008 |
// This is what we implement (the DOLIT4 part): |
|
4009 |
// ========================================================================= */ |
|
4010 |
// #define DOLIT4 c ^= *buf4++; \ |
|
4011 |
// c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ |
|
4012 |
// crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] |
|
4013 |
// #define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 |
|
4014 |
// ========================================================================= */ |
|
4015 |
const int ix0 = 3*(4*CRC32_COLUMN_SIZE); |
|
4016 |
const int ix1 = 2*(4*CRC32_COLUMN_SIZE); |
|
4017 |
const int ix2 = 1*(4*CRC32_COLUMN_SIZE); |
|
4018 |
const int ix3 = 0*(4*CRC32_COLUMN_SIZE); |
|
4019 |
#else |
|
4020 |
// This is what we implement (the DOBIG4 part): |
|
4021 |
// ========================================================================= |
|
4022 |
// #define DOBIG4 c ^= *++buf4; \ |
|
4023 |
// c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ |
|
4024 |
// crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] |
|
4025 |
// #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 |
|
4026 |
// ========================================================================= |
|
4027 |
const int ix0 = 4*(4*CRC32_COLUMN_SIZE); |
|
4028 |
const int ix1 = 5*(4*CRC32_COLUMN_SIZE); |
|
4029 |
const int ix2 = 6*(4*CRC32_COLUMN_SIZE); |
|
4030 |
const int ix3 = 7*(4*CRC32_COLUMN_SIZE); |
|
4031 |
#endif |
|
4032 |
assert_different_registers(table, tc0, tc1, tc2); |
|
4033 |
assert(table == tc3, "must be!"); |
|
4034 |
||
35541
cba047a086d5
8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents:
35085
diff
changeset
|
4035 |
addi(tc0, table, ix0); |
cba047a086d5
8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents:
35085
diff
changeset
|
4036 |
addi(tc1, table, ix1); |
cba047a086d5
8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents:
35085
diff
changeset
|
4037 |
addi(tc2, table, ix2); |
31861 | 4038 |
if (ix3 != 0) addi(tc3, table, ix3); |
4039 |
||
4040 |
return ix3; |
|
4041 |
} |
|
4042 |
||
4043 |
/** |
|
4044 |
* uint32_t crc; |
|
4045 |
* timesXtoThe32[crc & 0xFF] ^ (crc >> 8); |
|
4046 |
*/ |
|
4047 |
void MacroAssembler::fold_byte_crc32(Register crc, Register val, Register table, Register tmp) { |
|
4048 |
assert_different_registers(crc, table, tmp); |
|
4049 |
assert_different_registers(val, table); |
|
4050 |
||
4051 |
if (crc == val) { // Must rotate first to use the unmodified value. |
|
4052 |
rlwinm(tmp, val, 2, 24-2, 31-2); // Insert (rightmost) byte 7 of val, shifted left by 2, into byte 6..7 of tmp, clear the rest. |
|
4053 |
// As we use a word (4-byte) instruction, we have to adapt the mask bit positions. |
|
4054 |
srwi(crc, crc, 8); // Unsigned shift, clear leftmost 8 bits. |
|
4055 |
} else { |
|
4056 |
srwi(crc, crc, 8); // Unsigned shift, clear leftmost 8 bits. |
|
4057 |
rlwinm(tmp, val, 2, 24-2, 31-2); // Insert (rightmost) byte 7 of val, shifted left by 2, into byte 6..7 of tmp, clear the rest. |
|
4058 |
} |
|
4059 |
lwzx(tmp, table, tmp); |
|
4060 |
xorr(crc, crc, tmp); |
|
4061 |
} |
|
4062 |
||
4063 |
/** |
|
4064 |
* uint32_t crc; |
|
4065 |
* timesXtoThe32[crc & 0xFF] ^ (crc >> 8); |
|
4066 |
*/ |
|
4067 |
void MacroAssembler::fold_8bit_crc32(Register crc, Register table, Register tmp) { |
|
4068 |
fold_byte_crc32(crc, crc, table, tmp); |
|
4069 |
} |
|
4070 |
||
4071 |
/** |
|
4072 |
* Emits code to update CRC-32 with a byte value according to constants in table. |
|
4073 |
* |
|
4074 |
* @param [in,out]crc Register containing the crc. |
|
4075 |
* @param [in]val Register containing the byte to fold into the CRC. |
|
4076 |
* @param [in]table Register containing the table of crc constants. |
|
4077 |
* |
|
4078 |
* uint32_t crc; |
|
4079 |
* val = crc_table[(val ^ crc) & 0xFF]; |
|
4080 |
* crc = val ^ (crc >> 8); |
|
4081 |
*/ |
|
4082 |
void MacroAssembler::update_byte_crc32(Register crc, Register val, Register table) { |
|
4083 |
BLOCK_COMMENT("update_byte_crc32:"); |
|
4084 |
xorr(val, val, crc); |
|
4085 |
fold_byte_crc32(crc, val, table, val); |
|
4086 |
} |
|
4087 |
||
4088 |
/** |
|
4089 |
* @param crc register containing existing CRC (32-bit) |
|
4090 |
* @param buf register pointing to input byte buffer (byte*) |
|
4091 |
* @param len register containing number of bytes |
|
4092 |
* @param table register pointing to CRC table |
|
4093 |
*/ |
|
4094 |
void MacroAssembler::update_byteLoop_crc32(Register crc, Register buf, Register len, Register table, |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4095 |
Register data, bool loopAlignment) { |
31861 | 4096 |
assert_different_registers(crc, buf, len, table, data); |
4097 |
||
4098 |
Label L_mainLoop, L_done; |
|
4099 |
const int mainLoop_stepping = 1; |
|
4100 |
const int mainLoop_alignment = loopAlignment ? 32 : 4; // (InputForNewCode > 4 ? InputForNewCode : 32) : 4; |
|
4101 |
||
4102 |
// Process all bytes in a single-byte loop. |
|
35541
cba047a086d5
8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents:
35085
diff
changeset
|
4103 |
clrldi_(len, len, 32); // Enforce 32 bit. Anything to do? |
31861 | 4104 |
beq(CCR0, L_done); |
4105 |
||
35541
cba047a086d5
8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents:
35085
diff
changeset
|
4106 |
mtctr(len); |
31861 | 4107 |
align(mainLoop_alignment); |
4108 |
BIND(L_mainLoop); |
|
4109 |
lbz(data, 0, buf); // Byte from buffer, zero-extended. |
|
4110 |
addi(buf, buf, mainLoop_stepping); // Advance buffer position. |
|
4111 |
update_byte_crc32(crc, data, table); |
|
4112 |
bdnz(L_mainLoop); // Iterate. |
|
4113 |
||
4114 |
bind(L_done); |
|
4115 |
} |
|
4116 |
||
4117 |
/** |
|
4118 |
* Emits code to update CRC-32 with a 4-byte value according to constants in table |
|
4119 |
* Implementation according to jdk/src/share/native/java/util/zip/zlib-1.2.8/crc32.c |
|
4120 |
*/ |
|
4121 |
// A not on the lookup table address(es): |
|
4122 |
// The lookup table consists of two sets of four columns each. |
|
4123 |
// The columns {0..3} are used for little-endian machines. |
|
4124 |
// The columns {4..7} are used for big-endian machines. |
|
4125 |
// To save the effort of adding the column offset to the table address each time |
|
4126 |
// a table element is looked up, it is possible to pass the pre-calculated |
|
4127 |
// column addresses. |
|
4128 |
// Uses R9..R12 as work register. Must be saved/restored by caller, if necessary. |
|
4129 |
void MacroAssembler::update_1word_crc32(Register crc, Register buf, Register table, int bufDisp, int bufInc, |
|
4130 |
Register t0, Register t1, Register t2, Register t3, |
|
4131 |
Register tc0, Register tc1, Register tc2, Register tc3) { |
|
4132 |
assert_different_registers(crc, t3); |
|
4133 |
||
4134 |
// XOR crc with next four bytes of buffer. |
|
4135 |
lwz(t3, bufDisp, buf); |
|
4136 |
if (bufInc != 0) { |
|
4137 |
addi(buf, buf, bufInc); |
|
4138 |
} |
|
4139 |
xorr(t3, t3, crc); |
|
4140 |
||
4141 |
// Chop crc into 4 single-byte pieces, shifted left 2 bits, to form the table indices. |
|
4142 |
rlwinm(t0, t3, 2, 24-2, 31-2); // ((t1 >> 0) & 0xff) << 2 |
|
4143 |
rlwinm(t1, t3, 32+(2- 8), 24-2, 31-2); // ((t1 >> 8) & 0xff) << 2 |
|
4144 |
rlwinm(t2, t3, 32+(2-16), 24-2, 31-2); // ((t1 >> 16) & 0xff) << 2 |
|
4145 |
rlwinm(t3, t3, 32+(2-24), 24-2, 31-2); // ((t1 >> 24) & 0xff) << 2 |
|
4146 |
||
4147 |
// Use the pre-calculated column addresses. |
|
4148 |
// Load pre-calculated table values. |
|
4149 |
lwzx(t0, tc0, t0); |
|
4150 |
lwzx(t1, tc1, t1); |
|
4151 |
lwzx(t2, tc2, t2); |
|
4152 |
lwzx(t3, tc3, t3); |
|
4153 |
||
4154 |
// Calculate new crc from table values. |
|
4155 |
xorr(t0, t0, t1); |
|
4156 |
xorr(t2, t2, t3); |
|
4157 |
xorr(crc, t0, t2); // Now crc contains the final checksum value. |
|
4158 |
} |
|
4159 |
||
4160 |
/** |
|
4161 |
* @param crc register containing existing CRC (32-bit) |
|
4162 |
* @param buf register pointing to input byte buffer (byte*) |
|
4163 |
* @param len register containing number of bytes |
|
4164 |
* @param table register pointing to CRC table |
|
4165 |
* |
|
4166 |
* Uses R9..R12 as work register. Must be saved/restored by caller! |
|
4167 |
*/ |
|
4168 |
void MacroAssembler::kernel_crc32_2word(Register crc, Register buf, Register len, Register table, |
|
4169 |
Register t0, Register t1, Register t2, Register t3, |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4170 |
Register tc0, Register tc1, Register tc2, Register tc3, |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4171 |
bool invertCRC) { |
31861 | 4172 |
assert_different_registers(crc, buf, len, table); |
4173 |
||
4174 |
Label L_mainLoop, L_tail; |
|
4175 |
Register tmp = t0; |
|
4176 |
Register data = t0; |
|
4177 |
Register tmp2 = t1; |
|
4178 |
const int mainLoop_stepping = 8; |
|
4179 |
const int tailLoop_stepping = 1; |
|
4180 |
const int log_stepping = exact_log2(mainLoop_stepping); |
|
4181 |
const int mainLoop_alignment = 32; // InputForNewCode > 4 ? InputForNewCode : 32; |
|
4182 |
const int complexThreshold = 2*mainLoop_stepping; |
|
4183 |
||
4184 |
// Don't test for len <= 0 here. This pathological case should not occur anyway. |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4185 |
// Optimizing for it by adding a test and a branch seems to be a waste of CPU cycles |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4186 |
// for all well-behaved cases. The situation itself is detected and handled correctly |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4187 |
// within update_byteLoop_crc32. |
31861 | 4188 |
assert(tailLoop_stepping == 1, "check tailLoop_stepping!"); |
4189 |
||
4190 |
BLOCK_COMMENT("kernel_crc32_2word {"); |
|
4191 |
||
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4192 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4193 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4194 |
} |
31861 | 4195 |
|
4196 |
// Check for short (<mainLoop_stepping) buffer. |
|
4197 |
cmpdi(CCR0, len, complexThreshold); |
|
4198 |
blt(CCR0, L_tail); |
|
4199 |
||
4200 |
// Pre-mainLoop alignment did show a slight (1%) positive effect on performance. |
|
4201 |
// We leave the code in for reference. Maybe we need alignment when we exploit vector instructions. |
|
4202 |
{ |
|
4203 |
// Align buf addr to mainLoop_stepping boundary. |
|
4204 |
neg(tmp2, buf); // Calculate # preLoop iterations for alignment. |
|
4205 |
rldicl(tmp2, tmp2, 0, 64-log_stepping); // Rotate tmp2 0 bits, insert into tmp2, anding with mask with 1s from 62..63. |
|
4206 |
||
4207 |
if (complexThreshold > mainLoop_stepping) { |
|
4208 |
sub(len, len, tmp2); // Remaining bytes for main loop (>=mainLoop_stepping is guaranteed). |
|
4209 |
} else { |
|
4210 |
sub(tmp, len, tmp2); // Remaining bytes for main loop. |
|
4211 |
cmpdi(CCR0, tmp, mainLoop_stepping); |
|
4212 |
blt(CCR0, L_tail); // For less than one mainloop_stepping left, do only tail processing |
|
4213 |
mr(len, tmp); // remaining bytes for main loop (>=mainLoop_stepping is guaranteed). |
|
4214 |
} |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4215 |
update_byteLoop_crc32(crc, buf, tmp2, table, data, false); |
31861 | 4216 |
} |
4217 |
||
4218 |
srdi(tmp2, len, log_stepping); // #iterations for mainLoop |
|
4219 |
andi(len, len, mainLoop_stepping-1); // remaining bytes for tailLoop |
|
4220 |
mtctr(tmp2); |
|
4221 |
||
4222 |
#ifdef VM_LITTLE_ENDIAN |
|
4223 |
Register crc_rv = crc; |
|
4224 |
#else |
|
4225 |
Register crc_rv = tmp; // Load_reverse needs separate registers to work on. |
|
4226 |
// Occupies tmp, but frees up crc. |
|
4227 |
load_reverse_32(crc_rv, crc); // Revert byte order because we are dealing with big-endian data. |
|
4228 |
tmp = crc; |
|
4229 |
#endif |
|
4230 |
||
4231 |
int reconstructTableOffset = crc32_table_columns(table, tc0, tc1, tc2, tc3); |
|
4232 |
||
4233 |
align(mainLoop_alignment); // Octoword-aligned loop address. Shows 2% improvement. |
|
4234 |
BIND(L_mainLoop); |
|
4235 |
update_1word_crc32(crc_rv, buf, table, 0, 0, crc_rv, t1, t2, t3, tc0, tc1, tc2, tc3); |
|
4236 |
update_1word_crc32(crc_rv, buf, table, 4, mainLoop_stepping, crc_rv, t1, t2, t3, tc0, tc1, tc2, tc3); |
|
4237 |
bdnz(L_mainLoop); |
|
4238 |
||
4239 |
#ifndef VM_LITTLE_ENDIAN |
|
4240 |
load_reverse_32(crc, crc_rv); // Revert byte order because we are dealing with big-endian data. |
|
4241 |
tmp = crc_rv; // Tmp uses it's original register again. |
|
4242 |
#endif |
|
4243 |
||
4244 |
// Restore original table address for tailLoop. |
|
4245 |
if (reconstructTableOffset != 0) { |
|
4246 |
addi(table, table, -reconstructTableOffset); |
|
4247 |
} |
|
4248 |
||
4249 |
// Process last few (<complexThreshold) bytes of buffer. |
|
4250 |
BIND(L_tail); |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4251 |
update_byteLoop_crc32(crc, buf, len, table, data, false); |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4252 |
|
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4253 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4254 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4255 |
} |
31861 | 4256 |
BLOCK_COMMENT("} kernel_crc32_2word"); |
4257 |
} |
|
4258 |
||
4259 |
/** |
|
4260 |
* @param crc register containing existing CRC (32-bit) |
|
4261 |
* @param buf register pointing to input byte buffer (byte*) |
|
4262 |
* @param len register containing number of bytes |
|
4263 |
* @param table register pointing to CRC table |
|
4264 |
* |
|
4265 |
* uses R9..R12 as work register. Must be saved/restored by caller! |
|
4266 |
*/ |
|
4267 |
void MacroAssembler::kernel_crc32_1word(Register crc, Register buf, Register len, Register table, |
|
4268 |
Register t0, Register t1, Register t2, Register t3, |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4269 |
Register tc0, Register tc1, Register tc2, Register tc3, |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4270 |
bool invertCRC) { |
31861 | 4271 |
assert_different_registers(crc, buf, len, table); |
4272 |
||
4273 |
Label L_mainLoop, L_tail; |
|
4274 |
Register tmp = t0; |
|
4275 |
Register data = t0; |
|
4276 |
Register tmp2 = t1; |
|
4277 |
const int mainLoop_stepping = 4; |
|
4278 |
const int tailLoop_stepping = 1; |
|
4279 |
const int log_stepping = exact_log2(mainLoop_stepping); |
|
4280 |
const int mainLoop_alignment = 32; // InputForNewCode > 4 ? InputForNewCode : 32; |
|
4281 |
const int complexThreshold = 2*mainLoop_stepping; |
|
4282 |
||
4283 |
// Don't test for len <= 0 here. This pathological case should not occur anyway. |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4284 |
// Optimizing for it by adding a test and a branch seems to be a waste of CPU cycles |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4285 |
// for all well-behaved cases. The situation itself is detected and handled correctly |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4286 |
// within update_byteLoop_crc32. |
31861 | 4287 |
assert(tailLoop_stepping == 1, "check tailLoop_stepping!"); |
4288 |
||
4289 |
BLOCK_COMMENT("kernel_crc32_1word {"); |
|
4290 |
||
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4291 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4292 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4293 |
} |
31861 | 4294 |
|
4295 |
// Check for short (<mainLoop_stepping) buffer. |
|
4296 |
cmpdi(CCR0, len, complexThreshold); |
|
4297 |
blt(CCR0, L_tail); |
|
4298 |
||
4299 |
// Pre-mainLoop alignment did show a slight (1%) positive effect on performance. |
|
4300 |
// We leave the code in for reference. Maybe we need alignment when we exploit vector instructions. |
|
4301 |
{ |
|
4302 |
// Align buf addr to mainLoop_stepping boundary. |
|
4303 |
neg(tmp2, buf); // Calculate # preLoop iterations for alignment. |
|
4304 |
rldicl(tmp2, tmp2, 0, 64-log_stepping); // Rotate tmp2 0 bits, insert into tmp2, anding with mask with 1s from 62..63. |
|
4305 |
||
4306 |
if (complexThreshold > mainLoop_stepping) { |
|
4307 |
sub(len, len, tmp2); // Remaining bytes for main loop (>=mainLoop_stepping is guaranteed). |
|
4308 |
} else { |
|
4309 |
sub(tmp, len, tmp2); // Remaining bytes for main loop. |
|
4310 |
cmpdi(CCR0, tmp, mainLoop_stepping); |
|
4311 |
blt(CCR0, L_tail); // For less than one mainloop_stepping left, do only tail processing |
|
4312 |
mr(len, tmp); // remaining bytes for main loop (>=mainLoop_stepping is guaranteed). |
|
4313 |
} |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4314 |
update_byteLoop_crc32(crc, buf, tmp2, table, data, false); |
31861 | 4315 |
} |
4316 |
||
4317 |
srdi(tmp2, len, log_stepping); // #iterations for mainLoop |
|
4318 |
andi(len, len, mainLoop_stepping-1); // remaining bytes for tailLoop |
|
4319 |
mtctr(tmp2); |
|
4320 |
||
4321 |
#ifdef VM_LITTLE_ENDIAN |
|
4322 |
Register crc_rv = crc; |
|
4323 |
#else |
|
4324 |
Register crc_rv = tmp; // Load_reverse needs separate registers to work on. |
|
4325 |
// Occupies tmp, but frees up crc. |
|
35541
cba047a086d5
8146613: PPC64: C2 does no longer respect int to long conversion for stub calls
mdoerr
parents:
35085
diff
changeset
|
4326 |
load_reverse_32(crc_rv, crc); // Revert byte order because we are dealing with big-endian data. |
31861 | 4327 |
tmp = crc; |
4328 |
#endif |
|
4329 |
||
4330 |
int reconstructTableOffset = crc32_table_columns(table, tc0, tc1, tc2, tc3); |
|
4331 |
||
4332 |
align(mainLoop_alignment); // Octoword-aligned loop address. Shows 2% improvement. |
|
4333 |
BIND(L_mainLoop); |
|
4334 |
update_1word_crc32(crc_rv, buf, table, 0, mainLoop_stepping, crc_rv, t1, t2, t3, tc0, tc1, tc2, tc3); |
|
4335 |
bdnz(L_mainLoop); |
|
4336 |
||
4337 |
#ifndef VM_LITTLE_ENDIAN |
|
4338 |
load_reverse_32(crc, crc_rv); // Revert byte order because we are dealing with big-endian data. |
|
4339 |
tmp = crc_rv; // Tmp uses it's original register again. |
|
4340 |
#endif |
|
4341 |
||
4342 |
// Restore original table address for tailLoop. |
|
4343 |
if (reconstructTableOffset != 0) { |
|
4344 |
addi(table, table, -reconstructTableOffset); |
|
4345 |
} |
|
4346 |
||
4347 |
// Process last few (<complexThreshold) bytes of buffer. |
|
4348 |
BIND(L_tail); |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4349 |
update_byteLoop_crc32(crc, buf, len, table, data, false); |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4350 |
|
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4351 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4352 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4353 |
} |
31861 | 4354 |
BLOCK_COMMENT("} kernel_crc32_1word"); |
4355 |
} |
|
4356 |
||
4357 |
/** |
|
4358 |
* @param crc register containing existing CRC (32-bit) |
|
4359 |
* @param buf register pointing to input byte buffer (byte*) |
|
4360 |
* @param len register containing number of bytes |
|
4361 |
* @param table register pointing to CRC table |
|
4362 |
* |
|
4363 |
* Uses R7_ARG5, R8_ARG6 as work registers. |
|
4364 |
*/ |
|
4365 |
void MacroAssembler::kernel_crc32_1byte(Register crc, Register buf, Register len, Register table, |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4366 |
Register t0, Register t1, Register t2, Register t3, |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4367 |
bool invertCRC) { |
31861 | 4368 |
assert_different_registers(crc, buf, len, table); |
4369 |
||
4370 |
Register data = t0; // Holds the current byte to be folded into crc. |
|
4371 |
||
4372 |
BLOCK_COMMENT("kernel_crc32_1byte {"); |
|
4373 |
||
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4374 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4375 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4376 |
} |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4377 |
|
31861 | 4378 |
// Process all bytes in a single-byte loop. |
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4379 |
update_byteLoop_crc32(crc, buf, len, table, data, true); |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4380 |
|
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4381 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4382 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4383 |
} |
31861 | 4384 |
BLOCK_COMMENT("} kernel_crc32_1byte"); |
4385 |
} |
|
4386 |
||
41334 | 4387 |
/** |
4388 |
* @param crc register containing existing CRC (32-bit) |
|
4389 |
* @param buf register pointing to input byte buffer (byte*) |
|
4390 |
* @param len register containing number of bytes |
|
4391 |
* @param table register pointing to CRC table |
|
4392 |
* @param constants register pointing to CRC table for 128-bit aligned memory |
|
4393 |
* @param barretConstants register pointing to table for barrett reduction |
|
4394 |
* @param t0 volatile register |
|
4395 |
* @param t1 volatile register |
|
4396 |
* @param t2 volatile register |
|
4397 |
* @param t3 volatile register |
|
4398 |
*/ |
|
4399 |
void MacroAssembler::kernel_crc32_1word_vpmsumd(Register crc, Register buf, Register len, Register table, |
|
42068
18c8a4d5998e
8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents:
41334
diff
changeset
|
4400 |
Register constants, Register barretConstants, |
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4401 |
Register t0, Register t1, Register t2, Register t3, Register t4, |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4402 |
bool invertCRC) { |
41334 | 4403 |
assert_different_registers(crc, buf, len, table); |
4404 |
||
4405 |
Label L_alignedHead, L_tail, L_alignTail, L_start, L_end; |
|
4406 |
||
4407 |
Register prealign = t0; |
|
4408 |
Register postalign = t0; |
|
4409 |
||
4410 |
BLOCK_COMMENT("kernel_crc32_1word_vpmsumb {"); |
|
4411 |
||
4412 |
// 1. use kernel_crc32_1word for shorter than 384bit |
|
4413 |
clrldi(len, len, 32); |
|
4414 |
cmpdi(CCR0, len, 384); |
|
4415 |
bge(CCR0, L_start); |
|
4416 |
||
4417 |
Register tc0 = t4; |
|
4418 |
Register tc1 = constants; |
|
4419 |
Register tc2 = barretConstants; |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4420 |
kernel_crc32_1word(crc, buf, len, table,t0, t1, t2, t3, tc0, tc1, tc2, table, invertCRC); |
41334 | 4421 |
b(L_end); |
4422 |
||
4423 |
BIND(L_start); |
|
4424 |
||
4425 |
// 2. ~c |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4426 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4427 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4428 |
} |
41334 | 4429 |
|
4430 |
// 3. calculate from 0 to first 128bit-aligned address |
|
4431 |
clrldi_(prealign, buf, 57); |
|
4432 |
beq(CCR0, L_alignedHead); |
|
4433 |
||
4434 |
subfic(prealign, prealign, 128); |
|
4435 |
||
4436 |
subf(len, prealign, len); |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4437 |
update_byteLoop_crc32(crc, buf, prealign, table, t2, false); |
41334 | 4438 |
|
4439 |
// 4. calculate from first 128bit-aligned address to last 128bit-aligned address |
|
4440 |
BIND(L_alignedHead); |
|
4441 |
||
4442 |
clrldi(postalign, len, 57); |
|
4443 |
subf(len, postalign, len); |
|
4444 |
||
4445 |
// len must be more than 256bit |
|
4446 |
kernel_crc32_1word_aligned(crc, buf, len, constants, barretConstants, t1, t2, t3); |
|
4447 |
||
4448 |
// 5. calculate remaining |
|
4449 |
cmpdi(CCR0, postalign, 0); |
|
4450 |
beq(CCR0, L_tail); |
|
4451 |
||
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4452 |
update_byteLoop_crc32(crc, buf, postalign, table, t2, false); |
41334 | 4453 |
|
4454 |
BIND(L_tail); |
|
4455 |
||
4456 |
// 6. ~c |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4457 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4458 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4459 |
} |
41334 | 4460 |
|
4461 |
BIND(L_end); |
|
4462 |
||
4463 |
BLOCK_COMMENT("} kernel_crc32_1word_vpmsumb"); |
|
4464 |
} |
|
4465 |
||
4466 |
/** |
|
4467 |
* @param crc register containing existing CRC (32-bit) |
|
4468 |
* @param buf register pointing to input byte buffer (byte*) |
|
4469 |
* @param len register containing number of bytes |
|
4470 |
* @param constants register pointing to CRC table for 128-bit aligned memory |
|
4471 |
* @param barretConstants register pointing to table for barrett reduction |
|
4472 |
* @param t0 volatile register |
|
4473 |
* @param t1 volatile register |
|
4474 |
* @param t2 volatile register |
|
4475 |
*/ |
|
4476 |
void MacroAssembler::kernel_crc32_1word_aligned(Register crc, Register buf, Register len, |
|
4477 |
Register constants, Register barretConstants, Register t0, Register t1, Register t2) { |
|
4478 |
Label L_mainLoop, L_tail, L_alignTail, L_barrett_reduction, L_end, L_first_warm_up_done, L_first_cool_down, L_second_cool_down, L_XOR, L_test; |
|
4479 |
Label L_lv0, L_lv1, L_lv2, L_lv3, L_lv4, L_lv5, L_lv6, L_lv7, L_lv8, L_lv9, L_lv10, L_lv11, L_lv12, L_lv13, L_lv14, L_lv15; |
|
4480 |
Label L_1, L_2, L_3, L_4; |
|
4481 |
||
4482 |
Register rLoaded = t0; |
|
4483 |
Register rTmp1 = t1; |
|
4484 |
Register rTmp2 = t2; |
|
4485 |
Register off16 = R22; |
|
4486 |
Register off32 = R23; |
|
4487 |
Register off48 = R24; |
|
4488 |
Register off64 = R25; |
|
4489 |
Register off80 = R26; |
|
4490 |
Register off96 = R27; |
|
4491 |
Register off112 = R28; |
|
4492 |
Register rIdx = R29; |
|
4493 |
Register rMax = R30; |
|
4494 |
Register constantsPos = R31; |
|
4495 |
||
4496 |
VectorRegister mask_32bit = VR24; |
|
4497 |
VectorRegister mask_64bit = VR25; |
|
4498 |
VectorRegister zeroes = VR26; |
|
4499 |
VectorRegister const1 = VR27; |
|
4500 |
VectorRegister const2 = VR28; |
|
4501 |
||
4502 |
// Save non-volatile vector registers (frameless). |
|
4503 |
Register offset = t1; int offsetInt = 0; |
|
4504 |
offsetInt -= 16; li(offset, -16); stvx(VR20, offset, R1_SP); |
|
4505 |
offsetInt -= 16; addi(offset, offset, -16); stvx(VR21, offset, R1_SP); |
|
4506 |
offsetInt -= 16; addi(offset, offset, -16); stvx(VR22, offset, R1_SP); |
|
4507 |
offsetInt -= 16; addi(offset, offset, -16); stvx(VR23, offset, R1_SP); |
|
4508 |
offsetInt -= 16; addi(offset, offset, -16); stvx(VR24, offset, R1_SP); |
|
4509 |
offsetInt -= 16; addi(offset, offset, -16); stvx(VR25, offset, R1_SP); |
|
4510 |
offsetInt -= 16; addi(offset, offset, -16); stvx(VR26, offset, R1_SP); |
|
4511 |
offsetInt -= 16; addi(offset, offset, -16); stvx(VR27, offset, R1_SP); |
|
4512 |
offsetInt -= 16; addi(offset, offset, -16); stvx(VR28, offset, R1_SP); |
|
4513 |
offsetInt -= 8; std(R22, offsetInt, R1_SP); |
|
4514 |
offsetInt -= 8; std(R23, offsetInt, R1_SP); |
|
4515 |
offsetInt -= 8; std(R24, offsetInt, R1_SP); |
|
4516 |
offsetInt -= 8; std(R25, offsetInt, R1_SP); |
|
4517 |
offsetInt -= 8; std(R26, offsetInt, R1_SP); |
|
4518 |
offsetInt -= 8; std(R27, offsetInt, R1_SP); |
|
4519 |
offsetInt -= 8; std(R28, offsetInt, R1_SP); |
|
4520 |
offsetInt -= 8; std(R29, offsetInt, R1_SP); |
|
4521 |
offsetInt -= 8; std(R30, offsetInt, R1_SP); |
|
4522 |
offsetInt -= 8; std(R31, offsetInt, R1_SP); |
|
4523 |
||
4524 |
// Set constants |
|
4525 |
li(off16, 16); |
|
4526 |
li(off32, 32); |
|
4527 |
li(off48, 48); |
|
4528 |
li(off64, 64); |
|
4529 |
li(off80, 80); |
|
4530 |
li(off96, 96); |
|
4531 |
li(off112, 112); |
|
4532 |
||
4533 |
clrldi(crc, crc, 32); |
|
4534 |
||
4535 |
vxor(zeroes, zeroes, zeroes); |
|
4536 |
vspltisw(VR0, -1); |
|
4537 |
||
4538 |
vsldoi(mask_32bit, zeroes, VR0, 4); |
|
4539 |
vsldoi(mask_64bit, zeroes, VR0, -8); |
|
4540 |
||
4541 |
// Get the initial value into v8 |
|
4542 |
vxor(VR8, VR8, VR8); |
|
4543 |
mtvrd(VR8, crc); |
|
4544 |
vsldoi(VR8, zeroes, VR8, -8); // shift into bottom 32 bits |
|
4545 |
||
4546 |
li (rLoaded, 0); |
|
4547 |
||
4548 |
rldicr(rIdx, len, 0, 56); |
|
4549 |
||
4550 |
{ |
|
4551 |
BIND(L_1); |
|
4552 |
// Checksum in blocks of MAX_SIZE (32768) |
|
4553 |
lis(rMax, 0); |
|
4554 |
ori(rMax, rMax, 32768); |
|
4555 |
mr(rTmp2, rMax); |
|
4556 |
cmpd(CCR0, rIdx, rMax); |
|
4557 |
bgt(CCR0, L_2); |
|
4558 |
mr(rMax, rIdx); |
|
4559 |
||
4560 |
BIND(L_2); |
|
4561 |
subf(rIdx, rMax, rIdx); |
|
4562 |
||
4563 |
// our main loop does 128 bytes at a time |
|
4564 |
srdi(rMax, rMax, 7); |
|
4565 |
||
4566 |
/* |
|
4567 |
* Work out the offset into the constants table to start at. Each |
|
4568 |
* constant is 16 bytes, and it is used against 128 bytes of input |
|
4569 |
* data - 128 / 16 = 8 |
|
4570 |
*/ |
|
4571 |
sldi(rTmp1, rMax, 4); |
|
4572 |
srdi(rTmp2, rTmp2, 3); |
|
4573 |
subf(rTmp1, rTmp1, rTmp2); |
|
4574 |
||
4575 |
// We reduce our final 128 bytes in a separate step |
|
4576 |
addi(rMax, rMax, -1); |
|
4577 |
mtctr(rMax); |
|
4578 |
||
4579 |
// Find the start of our constants |
|
4580 |
add(constantsPos, constants, rTmp1); |
|
4581 |
||
4582 |
// zero VR0-v7 which will contain our checksums |
|
4583 |
vxor(VR0, VR0, VR0); |
|
4584 |
vxor(VR1, VR1, VR1); |
|
4585 |
vxor(VR2, VR2, VR2); |
|
4586 |
vxor(VR3, VR3, VR3); |
|
4587 |
vxor(VR4, VR4, VR4); |
|
4588 |
vxor(VR5, VR5, VR5); |
|
4589 |
vxor(VR6, VR6, VR6); |
|
4590 |
vxor(VR7, VR7, VR7); |
|
4591 |
||
4592 |
lvx(const1, constantsPos); |
|
4593 |
||
4594 |
/* |
|
4595 |
* If we are looping back to consume more data we use the values |
|
4596 |
* already in VR16-v23. |
|
4597 |
*/ |
|
4598 |
cmpdi(CCR0, rLoaded, 1); |
|
4599 |
beq(CCR0, L_3); |
|
4600 |
{ |
|
4601 |
||
4602 |
// First warm up pass |
|
4603 |
lvx(VR16, buf); |
|
4604 |
lvx(VR17, off16, buf); |
|
4605 |
lvx(VR18, off32, buf); |
|
4606 |
lvx(VR19, off48, buf); |
|
4607 |
lvx(VR20, off64, buf); |
|
4608 |
lvx(VR21, off80, buf); |
|
4609 |
lvx(VR22, off96, buf); |
|
4610 |
lvx(VR23, off112, buf); |
|
4611 |
addi(buf, buf, 8*16); |
|
4612 |
||
4613 |
// xor in initial value |
|
4614 |
vxor(VR16, VR16, VR8); |
|
4615 |
} |
|
4616 |
||
4617 |
BIND(L_3); |
|
4618 |
bdz(L_first_warm_up_done); |
|
4619 |
||
4620 |
addi(constantsPos, constantsPos, 16); |
|
4621 |
lvx(const2, constantsPos); |
|
4622 |
||
4623 |
// Second warm up pass |
|
4624 |
vpmsumd(VR8, VR16, const1); |
|
4625 |
lvx(VR16, buf); |
|
4626 |
||
4627 |
vpmsumd(VR9, VR17, const1); |
|
4628 |
lvx(VR17, off16, buf); |
|
4629 |
||
4630 |
vpmsumd(VR10, VR18, const1); |
|
4631 |
lvx(VR18, off32, buf); |
|
4632 |
||
4633 |
vpmsumd(VR11, VR19, const1); |
|
4634 |
lvx(VR19, off48, buf); |
|
4635 |
||
4636 |
vpmsumd(VR12, VR20, const1); |
|
4637 |
lvx(VR20, off64, buf); |
|
4638 |
||
4639 |
vpmsumd(VR13, VR21, const1); |
|
4640 |
lvx(VR21, off80, buf); |
|
4641 |
||
4642 |
vpmsumd(VR14, VR22, const1); |
|
4643 |
lvx(VR22, off96, buf); |
|
4644 |
||
4645 |
vpmsumd(VR15, VR23, const1); |
|
4646 |
lvx(VR23, off112, buf); |
|
4647 |
||
4648 |
addi(buf, buf, 8 * 16); |
|
4649 |
||
4650 |
bdz(L_first_cool_down); |
|
4651 |
||
4652 |
/* |
|
4653 |
* main loop. We modulo schedule it such that it takes three iterations |
|
4654 |
* to complete - first iteration load, second iteration vpmsum, third |
|
4655 |
* iteration xor. |
|
4656 |
*/ |
|
4657 |
{ |
|
4658 |
BIND(L_4); |
|
4659 |
lvx(const1, constantsPos); addi(constantsPos, constantsPos, 16); |
|
4660 |
||
4661 |
vxor(VR0, VR0, VR8); |
|
4662 |
vpmsumd(VR8, VR16, const2); |
|
4663 |
lvx(VR16, buf); |
|
4664 |
||
4665 |
vxor(VR1, VR1, VR9); |
|
4666 |
vpmsumd(VR9, VR17, const2); |
|
4667 |
lvx(VR17, off16, buf); |
|
4668 |
||
4669 |
vxor(VR2, VR2, VR10); |
|
4670 |
vpmsumd(VR10, VR18, const2); |
|
4671 |
lvx(VR18, off32, buf); |
|
4672 |
||
4673 |
vxor(VR3, VR3, VR11); |
|
4674 |
vpmsumd(VR11, VR19, const2); |
|
4675 |
lvx(VR19, off48, buf); |
|
4676 |
lvx(const2, constantsPos); |
|
4677 |
||
4678 |
vxor(VR4, VR4, VR12); |
|
4679 |
vpmsumd(VR12, VR20, const1); |
|
4680 |
lvx(VR20, off64, buf); |
|
4681 |
||
4682 |
vxor(VR5, VR5, VR13); |
|
4683 |
vpmsumd(VR13, VR21, const1); |
|
4684 |
lvx(VR21, off80, buf); |
|
4685 |
||
4686 |
vxor(VR6, VR6, VR14); |
|
4687 |
vpmsumd(VR14, VR22, const1); |
|
4688 |
lvx(VR22, off96, buf); |
|
4689 |
||
4690 |
vxor(VR7, VR7, VR15); |
|
4691 |
vpmsumd(VR15, VR23, const1); |
|
4692 |
lvx(VR23, off112, buf); |
|
4693 |
||
4694 |
addi(buf, buf, 8 * 16); |
|
4695 |
||
4696 |
bdnz(L_4); |
|
4697 |
} |
|
4698 |
||
4699 |
BIND(L_first_cool_down); |
|
4700 |
||
4701 |
// First cool down pass |
|
4702 |
lvx(const1, constantsPos); |
|
4703 |
addi(constantsPos, constantsPos, 16); |
|
4704 |
||
4705 |
vxor(VR0, VR0, VR8); |
|
4706 |
vpmsumd(VR8, VR16, const1); |
|
4707 |
||
4708 |
vxor(VR1, VR1, VR9); |
|
4709 |
vpmsumd(VR9, VR17, const1); |
|
4710 |
||
4711 |
vxor(VR2, VR2, VR10); |
|
4712 |
vpmsumd(VR10, VR18, const1); |
|
4713 |
||
4714 |
vxor(VR3, VR3, VR11); |
|
4715 |
vpmsumd(VR11, VR19, const1); |
|
4716 |
||
4717 |
vxor(VR4, VR4, VR12); |
|
4718 |
vpmsumd(VR12, VR20, const1); |
|
4719 |
||
4720 |
vxor(VR5, VR5, VR13); |
|
4721 |
vpmsumd(VR13, VR21, const1); |
|
4722 |
||
4723 |
vxor(VR6, VR6, VR14); |
|
4724 |
vpmsumd(VR14, VR22, const1); |
|
4725 |
||
4726 |
vxor(VR7, VR7, VR15); |
|
4727 |
vpmsumd(VR15, VR23, const1); |
|
4728 |
||
4729 |
BIND(L_second_cool_down); |
|
4730 |
// Second cool down pass |
|
4731 |
vxor(VR0, VR0, VR8); |
|
4732 |
vxor(VR1, VR1, VR9); |
|
4733 |
vxor(VR2, VR2, VR10); |
|
4734 |
vxor(VR3, VR3, VR11); |
|
4735 |
vxor(VR4, VR4, VR12); |
|
4736 |
vxor(VR5, VR5, VR13); |
|
4737 |
vxor(VR6, VR6, VR14); |
|
4738 |
vxor(VR7, VR7, VR15); |
|
4739 |
||
4740 |
/* |
|
4741 |
* vpmsumd produces a 96 bit result in the least significant bits |
|
4742 |
* of the register. Since we are bit reflected we have to shift it |
|
4743 |
* left 32 bits so it occupies the least significant bits in the |
|
4744 |
* bit reflected domain. |
|
4745 |
*/ |
|
4746 |
vsldoi(VR0, VR0, zeroes, 4); |
|
4747 |
vsldoi(VR1, VR1, zeroes, 4); |
|
4748 |
vsldoi(VR2, VR2, zeroes, 4); |
|
4749 |
vsldoi(VR3, VR3, zeroes, 4); |
|
4750 |
vsldoi(VR4, VR4, zeroes, 4); |
|
4751 |
vsldoi(VR5, VR5, zeroes, 4); |
|
4752 |
vsldoi(VR6, VR6, zeroes, 4); |
|
4753 |
vsldoi(VR7, VR7, zeroes, 4); |
|
4754 |
||
4755 |
// xor with last 1024 bits |
|
4756 |
lvx(VR8, buf); |
|
4757 |
lvx(VR9, off16, buf); |
|
4758 |
lvx(VR10, off32, buf); |
|
4759 |
lvx(VR11, off48, buf); |
|
4760 |
lvx(VR12, off64, buf); |
|
4761 |
lvx(VR13, off80, buf); |
|
4762 |
lvx(VR14, off96, buf); |
|
4763 |
lvx(VR15, off112, buf); |
|
4764 |
addi(buf, buf, 8 * 16); |
|
4765 |
||
4766 |
vxor(VR16, VR0, VR8); |
|
4767 |
vxor(VR17, VR1, VR9); |
|
4768 |
vxor(VR18, VR2, VR10); |
|
4769 |
vxor(VR19, VR3, VR11); |
|
4770 |
vxor(VR20, VR4, VR12); |
|
4771 |
vxor(VR21, VR5, VR13); |
|
4772 |
vxor(VR22, VR6, VR14); |
|
4773 |
vxor(VR23, VR7, VR15); |
|
4774 |
||
4775 |
li(rLoaded, 1); |
|
4776 |
cmpdi(CCR0, rIdx, 0); |
|
4777 |
addi(rIdx, rIdx, 128); |
|
4778 |
bne(CCR0, L_1); |
|
4779 |
} |
|
4780 |
||
4781 |
// Work out how many bytes we have left |
|
4782 |
andi_(len, len, 127); |
|
4783 |
||
4784 |
// Calculate where in the constant table we need to start |
|
4785 |
subfic(rTmp1, len, 128); |
|
4786 |
add(constantsPos, constantsPos, rTmp1); |
|
4787 |
||
4788 |
// How many 16 byte chunks are in the tail |
|
4789 |
srdi(rIdx, len, 4); |
|
4790 |
mtctr(rIdx); |
|
4791 |
||
4792 |
/* |
|
4793 |
* Reduce the previously calculated 1024 bits to 64 bits, shifting |
|
4794 |
* 32 bits to include the trailing 32 bits of zeros |
|
4795 |
*/ |
|
4796 |
lvx(VR0, constantsPos); |
|
4797 |
lvx(VR1, off16, constantsPos); |
|
4798 |
lvx(VR2, off32, constantsPos); |
|
4799 |
lvx(VR3, off48, constantsPos); |
|
4800 |
lvx(VR4, off64, constantsPos); |
|
4801 |
lvx(VR5, off80, constantsPos); |
|
4802 |
lvx(VR6, off96, constantsPos); |
|
4803 |
lvx(VR7, off112, constantsPos); |
|
4804 |
addi(constantsPos, constantsPos, 8 * 16); |
|
4805 |
||
4806 |
vpmsumw(VR0, VR16, VR0); |
|
4807 |
vpmsumw(VR1, VR17, VR1); |
|
4808 |
vpmsumw(VR2, VR18, VR2); |
|
4809 |
vpmsumw(VR3, VR19, VR3); |
|
4810 |
vpmsumw(VR4, VR20, VR4); |
|
4811 |
vpmsumw(VR5, VR21, VR5); |
|
4812 |
vpmsumw(VR6, VR22, VR6); |
|
4813 |
vpmsumw(VR7, VR23, VR7); |
|
4814 |
||
4815 |
// Now reduce the tail (0 - 112 bytes) |
|
4816 |
cmpdi(CCR0, rIdx, 0); |
|
4817 |
beq(CCR0, L_XOR); |
|
4818 |
||
4819 |
lvx(VR16, buf); addi(buf, buf, 16); |
|
4820 |
lvx(VR17, constantsPos); |
|
4821 |
vpmsumw(VR16, VR16, VR17); |
|
4822 |
vxor(VR0, VR0, VR16); |
|
4823 |
beq(CCR0, L_XOR); |
|
4824 |
||
4825 |
lvx(VR16, buf); addi(buf, buf, 16); |
|
4826 |
lvx(VR17, off16, constantsPos); |
|
4827 |
vpmsumw(VR16, VR16, VR17); |
|
4828 |
vxor(VR0, VR0, VR16); |
|
4829 |
beq(CCR0, L_XOR); |
|
4830 |
||
4831 |
lvx(VR16, buf); addi(buf, buf, 16); |
|
4832 |
lvx(VR17, off32, constantsPos); |
|
4833 |
vpmsumw(VR16, VR16, VR17); |
|
4834 |
vxor(VR0, VR0, VR16); |
|
4835 |
beq(CCR0, L_XOR); |
|
4836 |
||
4837 |
lvx(VR16, buf); addi(buf, buf, 16); |
|
4838 |
lvx(VR17, off48,constantsPos); |
|
4839 |
vpmsumw(VR16, VR16, VR17); |
|
4840 |
vxor(VR0, VR0, VR16); |
|
4841 |
beq(CCR0, L_XOR); |
|
4842 |
||
4843 |
lvx(VR16, buf); addi(buf, buf, 16); |
|
4844 |
lvx(VR17, off64, constantsPos); |
|
4845 |
vpmsumw(VR16, VR16, VR17); |
|
4846 |
vxor(VR0, VR0, VR16); |
|
4847 |
beq(CCR0, L_XOR); |
|
4848 |
||
4849 |
lvx(VR16, buf); addi(buf, buf, 16); |
|
4850 |
lvx(VR17, off80, constantsPos); |
|
4851 |
vpmsumw(VR16, VR16, VR17); |
|
4852 |
vxor(VR0, VR0, VR16); |
|
4853 |
beq(CCR0, L_XOR); |
|
4854 |
||
4855 |
lvx(VR16, buf); addi(buf, buf, 16); |
|
4856 |
lvx(VR17, off96, constantsPos); |
|
4857 |
vpmsumw(VR16, VR16, VR17); |
|
4858 |
vxor(VR0, VR0, VR16); |
|
4859 |
||
4860 |
// Now xor all the parallel chunks together |
|
4861 |
BIND(L_XOR); |
|
4862 |
vxor(VR0, VR0, VR1); |
|
4863 |
vxor(VR2, VR2, VR3); |
|
4864 |
vxor(VR4, VR4, VR5); |
|
4865 |
vxor(VR6, VR6, VR7); |
|
4866 |
||
4867 |
vxor(VR0, VR0, VR2); |
|
4868 |
vxor(VR4, VR4, VR6); |
|
4869 |
||
4870 |
vxor(VR0, VR0, VR4); |
|
4871 |
||
4872 |
b(L_barrett_reduction); |
|
4873 |
||
4874 |
BIND(L_first_warm_up_done); |
|
4875 |
lvx(const1, constantsPos); |
|
4876 |
addi(constantsPos, constantsPos, 16); |
|
4877 |
vpmsumd(VR8, VR16, const1); |
|
4878 |
vpmsumd(VR9, VR17, const1); |
|
4879 |
vpmsumd(VR10, VR18, const1); |
|
4880 |
vpmsumd(VR11, VR19, const1); |
|
4881 |
vpmsumd(VR12, VR20, const1); |
|
4882 |
vpmsumd(VR13, VR21, const1); |
|
4883 |
vpmsumd(VR14, VR22, const1); |
|
4884 |
vpmsumd(VR15, VR23, const1); |
|
4885 |
b(L_second_cool_down); |
|
4886 |
||
4887 |
BIND(L_barrett_reduction); |
|
4888 |
||
4889 |
lvx(const1, barretConstants); |
|
4890 |
addi(barretConstants, barretConstants, 16); |
|
4891 |
lvx(const2, barretConstants); |
|
4892 |
||
4893 |
vsldoi(VR1, VR0, VR0, -8); |
|
4894 |
vxor(VR0, VR0, VR1); // xor two 64 bit results together |
|
4895 |
||
4896 |
// shift left one bit |
|
4897 |
vspltisb(VR1, 1); |
|
4898 |
vsl(VR0, VR0, VR1); |
|
4899 |
||
4900 |
vand(VR0, VR0, mask_64bit); |
|
4901 |
||
4902 |
/* |
|
4903 |
* The reflected version of Barrett reduction. Instead of bit |
|
4904 |
* reflecting our data (which is expensive to do), we bit reflect our |
|
4905 |
* constants and our algorithm, which means the intermediate data in |
|
4906 |
* our vector registers goes from 0-63 instead of 63-0. We can reflect |
|
4907 |
* the algorithm because we don't carry in mod 2 arithmetic. |
|
4908 |
*/ |
|
4909 |
vand(VR1, VR0, mask_32bit); // bottom 32 bits of a |
|
4910 |
vpmsumd(VR1, VR1, const1); // ma |
|
4911 |
vand(VR1, VR1, mask_32bit); // bottom 32bits of ma |
|
4912 |
vpmsumd(VR1, VR1, const2); // qn */ |
|
4913 |
vxor(VR0, VR0, VR1); // a - qn, subtraction is xor in GF(2) |
|
4914 |
||
4915 |
/* |
|
4916 |
* Since we are bit reflected, the result (ie the low 32 bits) is in |
|
4917 |
* the high 32 bits. We just need to shift it left 4 bytes |
|
4918 |
* V0 [ 0 1 X 3 ] |
|
4919 |
* V0 [ 0 X 2 3 ] |
|
4920 |
*/ |
|
4921 |
vsldoi(VR0, VR0, zeroes, 4); // shift result into top 64 bits of |
|
4922 |
||
4923 |
// Get it into r3 |
|
4924 |
mfvrd(crc, VR0); |
|
4925 |
||
4926 |
BIND(L_end); |
|
4927 |
||
4928 |
offsetInt = 0; |
|
4929 |
// Restore non-volatile Vector registers (frameless). |
|
4930 |
offsetInt -= 16; li(offset, -16); lvx(VR20, offset, R1_SP); |
|
4931 |
offsetInt -= 16; addi(offset, offset, -16); lvx(VR21, offset, R1_SP); |
|
4932 |
offsetInt -= 16; addi(offset, offset, -16); lvx(VR22, offset, R1_SP); |
|
4933 |
offsetInt -= 16; addi(offset, offset, -16); lvx(VR23, offset, R1_SP); |
|
4934 |
offsetInt -= 16; addi(offset, offset, -16); lvx(VR24, offset, R1_SP); |
|
4935 |
offsetInt -= 16; addi(offset, offset, -16); lvx(VR25, offset, R1_SP); |
|
4936 |
offsetInt -= 16; addi(offset, offset, -16); lvx(VR26, offset, R1_SP); |
|
4937 |
offsetInt -= 16; addi(offset, offset, -16); lvx(VR27, offset, R1_SP); |
|
4938 |
offsetInt -= 16; addi(offset, offset, -16); lvx(VR28, offset, R1_SP); |
|
4939 |
offsetInt -= 8; ld(R22, offsetInt, R1_SP); |
|
4940 |
offsetInt -= 8; ld(R23, offsetInt, R1_SP); |
|
4941 |
offsetInt -= 8; ld(R24, offsetInt, R1_SP); |
|
4942 |
offsetInt -= 8; ld(R25, offsetInt, R1_SP); |
|
4943 |
offsetInt -= 8; ld(R26, offsetInt, R1_SP); |
|
4944 |
offsetInt -= 8; ld(R27, offsetInt, R1_SP); |
|
4945 |
offsetInt -= 8; ld(R28, offsetInt, R1_SP); |
|
4946 |
offsetInt -= 8; ld(R29, offsetInt, R1_SP); |
|
4947 |
offsetInt -= 8; ld(R30, offsetInt, R1_SP); |
|
4948 |
offsetInt -= 8; ld(R31, offsetInt, R1_SP); |
|
4949 |
} |
|
4950 |
||
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4951 |
void MacroAssembler::kernel_crc32_singleByte(Register crc, Register buf, Register len, Register table, Register tmp, bool invertCRC) { |
31861 | 4952 |
assert_different_registers(crc, buf, /* len, not used!! */ table, tmp); |
4953 |
||
4954 |
BLOCK_COMMENT("kernel_crc32_singleByte:"); |
|
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4955 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4956 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4957 |
} |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4958 |
|
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4959 |
lbz(tmp, 0, buf); // Byte from buffer, zero-extended. |
31861 | 4960 |
update_byte_crc32(crc, tmp, table); |
4961 |
||
46317
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4962 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4963 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4964 |
} |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4965 |
} |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4966 |
|
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4967 |
void MacroAssembler::kernel_crc32_singleByteReg(Register crc, Register val, Register table, bool invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4968 |
assert_different_registers(crc, val, table); |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4969 |
|
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4970 |
BLOCK_COMMENT("kernel_crc32_singleByteReg:"); |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4971 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4972 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4973 |
} |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4974 |
|
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4975 |
update_byte_crc32(crc, val, table); |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4976 |
|
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4977 |
if (invertCRC) { |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4978 |
nand(crc, crc, crc); // 1s complement of crc |
5f88747fe29e
8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents:
43428
diff
changeset
|
4979 |
} |
31861 | 4980 |
} |
4981 |
||
31773 | 4982 |
// dest_lo += src1 + src2 |
4983 |
// dest_hi += carry1 + carry2 |
|
4984 |
void MacroAssembler::add2_with_carry(Register dest_hi, |
|
4985 |
Register dest_lo, |
|
4986 |
Register src1, Register src2) { |
|
4987 |
li(R0, 0); |
|
4988 |
addc(dest_lo, dest_lo, src1); |
|
4989 |
adde(dest_hi, dest_hi, R0); |
|
4990 |
addc(dest_lo, dest_lo, src2); |
|
4991 |
adde(dest_hi, dest_hi, R0); |
|
4992 |
} |
|
4993 |
||
4994 |
// Multiply 64 bit by 64 bit first loop. |
|
4995 |
void MacroAssembler::multiply_64_x_64_loop(Register x, Register xstart, |
|
4996 |
Register x_xstart, |
|
4997 |
Register y, Register y_idx, |
|
4998 |
Register z, |
|
4999 |
Register carry, |
|
5000 |
Register product_high, Register product, |
|
5001 |
Register idx, Register kdx, |
|
5002 |
Register tmp) { |
|
5003 |
// jlong carry, x[], y[], z[]; |
|
5004 |
// for (int idx=ystart, kdx=ystart+1+xstart; idx >= 0; idx--, kdx--) { |
|
5005 |
// huge_128 product = y[idx] * x[xstart] + carry; |
|
5006 |
// z[kdx] = (jlong)product; |
|
5007 |
// carry = (jlong)(product >>> 64); |
|
5008 |
// } |
|
5009 |
// z[xstart] = carry; |
|
5010 |
||
5011 |
Label L_first_loop, L_first_loop_exit; |
|
5012 |
Label L_one_x, L_one_y, L_multiply; |
|
5013 |
||
5014 |
addic_(xstart, xstart, -1); |
|
5015 |
blt(CCR0, L_one_x); // Special case: length of x is 1. |
|
5016 |
||
5017 |
// Load next two integers of x. |
|
5018 |
sldi(tmp, xstart, LogBytesPerInt); |
|
5019 |
ldx(x_xstart, x, tmp); |
|
5020 |
#ifdef VM_LITTLE_ENDIAN |
|
5021 |
rldicl(x_xstart, x_xstart, 32, 0); |
|
5022 |
#endif |
|
5023 |
||
5024 |
align(32, 16); |
|
5025 |
bind(L_first_loop); |
|
5026 |
||
5027 |
cmpdi(CCR0, idx, 1); |
|
5028 |
blt(CCR0, L_first_loop_exit); |
|
5029 |
addi(idx, idx, -2); |
|
5030 |
beq(CCR0, L_one_y); |
|
5031 |
||
5032 |
// Load next two integers of y. |
|
5033 |
sldi(tmp, idx, LogBytesPerInt); |
|
5034 |
ldx(y_idx, y, tmp); |
|
5035 |
#ifdef VM_LITTLE_ENDIAN |
|
5036 |
rldicl(y_idx, y_idx, 32, 0); |
|
5037 |
#endif |
|
5038 |
||
5039 |
||
5040 |
bind(L_multiply); |
|
5041 |
multiply64(product_high, product, x_xstart, y_idx); |
|
5042 |
||
5043 |
li(tmp, 0); |
|
5044 |
addc(product, product, carry); // Add carry to result. |
|
5045 |
adde(product_high, product_high, tmp); // Add carry of the last addition. |
|
5046 |
addi(kdx, kdx, -2); |
|
5047 |
||
5048 |
// Store result. |
|
5049 |
#ifdef VM_LITTLE_ENDIAN |
|
5050 |
rldicl(product, product, 32, 0); |
|
5051 |
#endif |
|
5052 |
sldi(tmp, kdx, LogBytesPerInt); |
|
5053 |
stdx(product, z, tmp); |
|
5054 |
mr_if_needed(carry, product_high); |
|
5055 |
b(L_first_loop); |
|
5056 |
||
5057 |
||
5058 |
bind(L_one_y); // Load one 32 bit portion of y as (0,value). |
|
5059 |
||
5060 |
lwz(y_idx, 0, y); |
|
5061 |
b(L_multiply); |
|
5062 |
||
5063 |
||
31861 | 5064 |
bind(L_one_x); // Load one 32 bit portion of x as (0,value). |
31773 | 5065 |
|
5066 |
lwz(x_xstart, 0, x); |
|
5067 |
b(L_first_loop); |
|
5068 |
||
5069 |
bind(L_first_loop_exit); |
|
5070 |
} |
|
5071 |
||
5072 |
// Multiply 64 bit by 64 bit and add 128 bit. |
|
5073 |
void MacroAssembler::multiply_add_128_x_128(Register x_xstart, Register y, |
|
5074 |
Register z, Register yz_idx, |
|
5075 |
Register idx, Register carry, |
|
5076 |
Register product_high, Register product, |
|
5077 |
Register tmp, int offset) { |
|
5078 |
||
5079 |
// huge_128 product = (y[idx] * x_xstart) + z[kdx] + carry; |
|
5080 |
// z[kdx] = (jlong)product; |
|
5081 |
||
5082 |
sldi(tmp, idx, LogBytesPerInt); |
|
31861 | 5083 |
if (offset) { |
31773 | 5084 |
addi(tmp, tmp, offset); |
5085 |
} |
|
5086 |
ldx(yz_idx, y, tmp); |
|
5087 |
#ifdef VM_LITTLE_ENDIAN |
|
5088 |
rldicl(yz_idx, yz_idx, 32, 0); |
|
5089 |
#endif |
|
5090 |
||
5091 |
multiply64(product_high, product, x_xstart, yz_idx); |
|
5092 |
ldx(yz_idx, z, tmp); |
|
5093 |
#ifdef VM_LITTLE_ENDIAN |
|
5094 |
rldicl(yz_idx, yz_idx, 32, 0); |
|
5095 |
#endif |
|
5096 |
||
5097 |
add2_with_carry(product_high, product, carry, yz_idx); |
|
5098 |
||
5099 |
sldi(tmp, idx, LogBytesPerInt); |
|
31861 | 5100 |
if (offset) { |
31773 | 5101 |
addi(tmp, tmp, offset); |
5102 |
} |
|
5103 |
#ifdef VM_LITTLE_ENDIAN |
|
5104 |
rldicl(product, product, 32, 0); |
|
5105 |
#endif |
|
5106 |
stdx(product, z, tmp); |
|
5107 |
} |
|
5108 |
||
5109 |
// Multiply 128 bit by 128 bit. Unrolled inner loop. |
|
5110 |
void MacroAssembler::multiply_128_x_128_loop(Register x_xstart, |
|
5111 |
Register y, Register z, |
|
5112 |
Register yz_idx, Register idx, Register carry, |
|
5113 |
Register product_high, Register product, |
|
5114 |
Register carry2, Register tmp) { |
|
5115 |
||
5116 |
// jlong carry, x[], y[], z[]; |
|
5117 |
// int kdx = ystart+1; |
|
5118 |
// for (int idx=ystart-2; idx >= 0; idx -= 2) { // Third loop |
|
5119 |
// huge_128 product = (y[idx+1] * x_xstart) + z[kdx+idx+1] + carry; |
|
5120 |
// z[kdx+idx+1] = (jlong)product; |
|
5121 |
// jlong carry2 = (jlong)(product >>> 64); |
|
5122 |
// product = (y[idx] * x_xstart) + z[kdx+idx] + carry2; |
|
5123 |
// z[kdx+idx] = (jlong)product; |
|
5124 |
// carry = (jlong)(product >>> 64); |
|
5125 |
// } |
|
5126 |
// idx += 2; |
|
5127 |
// if (idx > 0) { |
|
5128 |
// product = (y[idx] * x_xstart) + z[kdx+idx] + carry; |
|
5129 |
// z[kdx+idx] = (jlong)product; |
|
5130 |
// carry = (jlong)(product >>> 64); |
|
5131 |
// } |
|
5132 |
||
5133 |
Label L_third_loop, L_third_loop_exit, L_post_third_loop_done; |
|
5134 |
const Register jdx = R0; |
|
5135 |
||
5136 |
// Scale the index. |
|
5137 |
srdi_(jdx, idx, 2); |
|
5138 |
beq(CCR0, L_third_loop_exit); |
|
5139 |
mtctr(jdx); |
|
5140 |
||
5141 |
align(32, 16); |
|
5142 |
bind(L_third_loop); |
|
5143 |
||
5144 |
addi(idx, idx, -4); |
|
5145 |
||
5146 |
multiply_add_128_x_128(x_xstart, y, z, yz_idx, idx, carry, product_high, product, tmp, 8); |
|
5147 |
mr_if_needed(carry2, product_high); |
|
5148 |
||
5149 |
multiply_add_128_x_128(x_xstart, y, z, yz_idx, idx, carry2, product_high, product, tmp, 0); |
|
5150 |
mr_if_needed(carry, product_high); |
|
5151 |
bdnz(L_third_loop); |
|
5152 |
||
5153 |
bind(L_third_loop_exit); // Handle any left-over operand parts. |
|
5154 |
||
5155 |
andi_(idx, idx, 0x3); |
|
5156 |
beq(CCR0, L_post_third_loop_done); |
|
5157 |
||
5158 |
Label L_check_1; |
|
5159 |
||
5160 |
addic_(idx, idx, -2); |
|
5161 |
blt(CCR0, L_check_1); |
|
5162 |
||
5163 |
multiply_add_128_x_128(x_xstart, y, z, yz_idx, idx, carry, product_high, product, tmp, 0); |
|
5164 |
mr_if_needed(carry, product_high); |
|
5165 |
||
5166 |
bind(L_check_1); |
|
5167 |
||
5168 |
addi(idx, idx, 0x2); |
|
35085 | 5169 |
andi_(idx, idx, 0x1); |
31773 | 5170 |
addic_(idx, idx, -1); |
5171 |
blt(CCR0, L_post_third_loop_done); |
|
5172 |
||
5173 |
sldi(tmp, idx, LogBytesPerInt); |
|
5174 |
lwzx(yz_idx, y, tmp); |
|
5175 |
multiply64(product_high, product, x_xstart, yz_idx); |
|
5176 |
lwzx(yz_idx, z, tmp); |
|
5177 |
||
5178 |
add2_with_carry(product_high, product, yz_idx, carry); |
|
5179 |
||
5180 |
sldi(tmp, idx, LogBytesPerInt); |
|
5181 |
stwx(product, z, tmp); |
|
5182 |
srdi(product, product, 32); |
|
5183 |
||
5184 |
sldi(product_high, product_high, 32); |
|
5185 |
orr(product, product, product_high); |
|
5186 |
mr_if_needed(carry, product); |
|
5187 |
||
5188 |
bind(L_post_third_loop_done); |
|
5189 |
} // multiply_128_x_128_loop |
|
5190 |
||
5191 |
void MacroAssembler::multiply_to_len(Register x, Register xlen, |
|
5192 |
Register y, Register ylen, |
|
5193 |
Register z, Register zlen, |
|
5194 |
Register tmp1, Register tmp2, |
|
5195 |
Register tmp3, Register tmp4, |
|
5196 |
Register tmp5, Register tmp6, |
|
5197 |
Register tmp7, Register tmp8, |
|
5198 |
Register tmp9, Register tmp10, |
|
5199 |
Register tmp11, Register tmp12, |
|
5200 |
Register tmp13) { |
|
5201 |
||
5202 |
ShortBranchVerifier sbv(this); |
|
5203 |
||
5204 |
assert_different_registers(x, xlen, y, ylen, z, zlen, |
|
5205 |
tmp1, tmp2, tmp3, tmp4, tmp5, tmp6); |
|
5206 |
assert_different_registers(x, xlen, y, ylen, z, zlen, |
|
5207 |
tmp1, tmp2, tmp3, tmp4, tmp5, tmp7); |
|
5208 |
assert_different_registers(x, xlen, y, ylen, z, zlen, |
|
5209 |
tmp1, tmp2, tmp3, tmp4, tmp5, tmp8); |
|
5210 |
||
5211 |
const Register idx = tmp1; |
|
5212 |
const Register kdx = tmp2; |
|
5213 |
const Register xstart = tmp3; |
|
5214 |
||
5215 |
const Register y_idx = tmp4; |
|
5216 |
const Register carry = tmp5; |
|
5217 |
const Register product = tmp6; |
|
5218 |
const Register product_high = tmp7; |
|
5219 |
const Register x_xstart = tmp8; |
|
5220 |
const Register tmp = tmp9; |
|
5221 |
||
5222 |
// First Loop. |
|
5223 |
// |
|
5224 |
// final static long LONG_MASK = 0xffffffffL; |
|
5225 |
// int xstart = xlen - 1; |
|
5226 |
// int ystart = ylen - 1; |
|
5227 |
// long carry = 0; |
|
5228 |
// for (int idx=ystart, kdx=ystart+1+xstart; idx >= 0; idx-, kdx--) { |
|
5229 |
// long product = (y[idx] & LONG_MASK) * (x[xstart] & LONG_MASK) + carry; |
|
5230 |
// z[kdx] = (int)product; |
|
5231 |
// carry = product >>> 32; |
|
5232 |
// } |
|
5233 |
// z[xstart] = (int)carry; |
|
5234 |
||
5235 |
mr_if_needed(idx, ylen); // idx = ylen |
|
5236 |
mr_if_needed(kdx, zlen); // kdx = xlen + ylen |
|
5237 |
li(carry, 0); // carry = 0 |
|
5238 |
||
5239 |
Label L_done; |
|
5240 |
||
5241 |
addic_(xstart, xlen, -1); |
|
5242 |
blt(CCR0, L_done); |
|
5243 |
||
5244 |
multiply_64_x_64_loop(x, xstart, x_xstart, y, y_idx, z, |
|
5245 |
carry, product_high, product, idx, kdx, tmp); |
|
5246 |
||
5247 |
Label L_second_loop; |
|
5248 |
||
5249 |
cmpdi(CCR0, kdx, 0); |
|
5250 |
beq(CCR0, L_second_loop); |
|
5251 |
||
5252 |
Label L_carry; |
|
5253 |
||
5254 |
addic_(kdx, kdx, -1); |
|
5255 |
beq(CCR0, L_carry); |
|
5256 |
||
5257 |
// Store lower 32 bits of carry. |
|
5258 |
sldi(tmp, kdx, LogBytesPerInt); |
|
5259 |
stwx(carry, z, tmp); |
|
5260 |
srdi(carry, carry, 32); |
|
5261 |
addi(kdx, kdx, -1); |
|
5262 |
||
5263 |
||
5264 |
bind(L_carry); |
|
5265 |
||
5266 |
// Store upper 32 bits of carry. |
|
5267 |
sldi(tmp, kdx, LogBytesPerInt); |
|
5268 |
stwx(carry, z, tmp); |
|
5269 |
||
5270 |
// Second and third (nested) loops. |
|
5271 |
// |
|
5272 |
// for (int i = xstart-1; i >= 0; i--) { // Second loop |
|
5273 |
// carry = 0; |
|
5274 |
// for (int jdx=ystart, k=ystart+1+i; jdx >= 0; jdx--, k--) { // Third loop |
|
5275 |
// long product = (y[jdx] & LONG_MASK) * (x[i] & LONG_MASK) + |
|
5276 |
// (z[k] & LONG_MASK) + carry; |
|
5277 |
// z[k] = (int)product; |
|
5278 |
// carry = product >>> 32; |
|
5279 |
// } |
|
5280 |
// z[i] = (int)carry; |
|
5281 |
// } |
|
5282 |
// |
|
5283 |
// i = xlen, j = tmp1, k = tmp2, carry = tmp5, x[i] = rdx |
|
5284 |
||
5285 |
bind(L_second_loop); |
|
5286 |
||
5287 |
li(carry, 0); // carry = 0; |
|
5288 |
||
5289 |
addic_(xstart, xstart, -1); // i = xstart-1; |
|
5290 |
blt(CCR0, L_done); |
|
5291 |
||
5292 |
Register zsave = tmp10; |
|
5293 |
||
5294 |
mr(zsave, z); |
|
5295 |
||
5296 |
||
5297 |
Label L_last_x; |
|
5298 |
||
5299 |
sldi(tmp, xstart, LogBytesPerInt); |
|
5300 |
add(z, z, tmp); // z = z + k - j |
|
5301 |
addi(z, z, 4); |
|
5302 |
addic_(xstart, xstart, -1); // i = xstart-1; |
|
5303 |
blt(CCR0, L_last_x); |
|
5304 |
||
5305 |
sldi(tmp, xstart, LogBytesPerInt); |
|
5306 |
ldx(x_xstart, x, tmp); |
|
5307 |
#ifdef VM_LITTLE_ENDIAN |
|
5308 |
rldicl(x_xstart, x_xstart, 32, 0); |
|
5309 |
#endif |
|
5310 |
||
5311 |
||
5312 |
Label L_third_loop_prologue; |
|
5313 |
||
5314 |
bind(L_third_loop_prologue); |
|
5315 |
||
5316 |
Register xsave = tmp11; |
|
5317 |
Register xlensave = tmp12; |
|
5318 |
Register ylensave = tmp13; |
|
5319 |
||
5320 |
mr(xsave, x); |
|
5321 |
mr(xlensave, xstart); |
|
5322 |
mr(ylensave, ylen); |
|
5323 |
||
5324 |
||
5325 |
multiply_128_x_128_loop(x_xstart, y, z, y_idx, ylen, |
|
5326 |
carry, product_high, product, x, tmp); |
|
5327 |
||
5328 |
mr(z, zsave); |
|
5329 |
mr(x, xsave); |
|
5330 |
mr(xlen, xlensave); // This is the decrement of the loop counter! |
|
5331 |
mr(ylen, ylensave); |
|
5332 |
||
5333 |
addi(tmp3, xlen, 1); |
|
5334 |
sldi(tmp, tmp3, LogBytesPerInt); |
|
5335 |
stwx(carry, z, tmp); |
|
5336 |
addic_(tmp3, tmp3, -1); |
|
5337 |
blt(CCR0, L_done); |
|
5338 |
||
5339 |
srdi(carry, carry, 32); |
|
5340 |
sldi(tmp, tmp3, LogBytesPerInt); |
|
5341 |
stwx(carry, z, tmp); |
|
5342 |
b(L_second_loop); |
|
5343 |
||
5344 |
// Next infrequent code is moved outside loops. |
|
5345 |
bind(L_last_x); |
|
5346 |
||
5347 |
lwz(x_xstart, 0, x); |
|
5348 |
b(L_third_loop_prologue); |
|
5349 |
||
5350 |
bind(L_done); |
|
5351 |
} // multiply_to_len |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5352 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5353 |
void MacroAssembler::asm_assert(bool check_equal, const char *msg, int id) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5354 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5355 |
Label ok; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5356 |
if (check_equal) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5357 |
beq(CCR0, ok); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5358 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5359 |
bne(CCR0, ok); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5360 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5361 |
stop(msg, id); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5362 |
bind(ok); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5363 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5364 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5365 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5366 |
void MacroAssembler::asm_assert_mems_zero(bool check_equal, int size, int mem_offset, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5367 |
Register mem_base, const char* msg, int id) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5368 |
#ifdef ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5369 |
switch (size) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5370 |
case 4: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5371 |
lwz(R0, mem_offset, mem_base); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5372 |
cmpwi(CCR0, R0, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5373 |
break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5374 |
case 8: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5375 |
ld(R0, mem_offset, mem_base); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5376 |
cmpdi(CCR0, R0, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5377 |
break; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5378 |
default: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5379 |
ShouldNotReachHere(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5380 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5381 |
asm_assert(check_equal, msg, id); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5382 |
#endif // ASSERT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5383 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5384 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5385 |
void MacroAssembler::verify_thread() { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5386 |
if (VerifyThread) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5387 |
unimplemented("'VerifyThread' currently not implemented on PPC"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5388 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5389 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5390 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5391 |
// READ: oop. KILL: R0. Volatile floats perhaps. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5392 |
void MacroAssembler::verify_oop(Register oop, const char* msg) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5393 |
if (!VerifyOops) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5394 |
return; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5395 |
} |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5396 |
|
22861 | 5397 |
address/* FunctionDescriptor** */fd = StubRoutines::verify_oop_subroutine_entry_address(); |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5398 |
const Register tmp = R11; // Will be preserved. |
35085 | 5399 |
const int nbytes_save = MacroAssembler::num_volatile_regs * 8; |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5400 |
save_volatile_gprs(R1_SP, -nbytes_save); // except R0 |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5401 |
|
35085 | 5402 |
mr_if_needed(R4_ARG2, oop); |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5403 |
save_LR_CR(tmp); // save in old frame |
23211 | 5404 |
push_frame_reg_args(nbytes_save, tmp); |
5405 |
// load FunctionDescriptor** / entry_address * |
|
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5406 |
load_const_optimized(tmp, fd, R0); |
23211 | 5407 |
// load FunctionDescriptor* / entry_address |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5408 |
ld(tmp, 0, tmp); |
35085 | 5409 |
load_const_optimized(R3_ARG1, (address)msg, R0); |
5410 |
// Call destination for its side effect. |
|
5411 |
call_c(tmp); |
|
5412 |
||
5413 |
pop_frame(); |
|
5414 |
restore_LR_CR(tmp); |
|
5415 |
restore_volatile_gprs(R1_SP, -nbytes_save); // except R0 |
|
5416 |
} |
|
5417 |
||
5418 |
void MacroAssembler::verify_oop_addr(RegisterOrConstant offs, Register base, const char* msg) { |
|
5419 |
if (!VerifyOops) { |
|
5420 |
return; |
|
5421 |
} |
|
5422 |
||
5423 |
address/* FunctionDescriptor** */fd = StubRoutines::verify_oop_subroutine_entry_address(); |
|
5424 |
const Register tmp = R11; // Will be preserved. |
|
5425 |
const int nbytes_save = MacroAssembler::num_volatile_regs * 8; |
|
5426 |
save_volatile_gprs(R1_SP, -nbytes_save); // except R0 |
|
5427 |
||
5428 |
ld(R4_ARG2, offs, base); |
|
5429 |
save_LR_CR(tmp); // save in old frame |
|
5430 |
push_frame_reg_args(nbytes_save, tmp); |
|
5431 |
// load FunctionDescriptor** / entry_address * |
|
5432 |
load_const_optimized(tmp, fd, R0); |
|
5433 |
// load FunctionDescriptor* / entry_address |
|
5434 |
ld(tmp, 0, tmp); |
|
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5435 |
load_const_optimized(R3_ARG1, (address)msg, R0); |
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5436 |
// Call destination for its side effect. |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5437 |
call_c(tmp); |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5438 |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5439 |
pop_frame(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5440 |
restore_LR_CR(tmp); |
28187
fc19df82d6ee
8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents:
27012
diff
changeset
|
5441 |
restore_volatile_gprs(R1_SP, -nbytes_save); // except R0 |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5442 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5443 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5444 |
const char* stop_types[] = { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5445 |
"stop", |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5446 |
"untested", |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5447 |
"unimplemented", |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5448 |
"shouldnotreachhere" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5449 |
}; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5450 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5451 |
static void stop_on_request(int tp, const char* msg) { |
25374
d7fb2af5d53c
8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents:
23492
diff
changeset
|
5452 |
tty->print("PPC assembly code requires stop: (%s) %s\n", stop_types[tp%/*stop_end*/4], msg); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32596
diff
changeset
|
5453 |
guarantee(false, "PPC assembly code requires stop: %s", msg); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5454 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5455 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5456 |
// Call a C-function that prints output. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5457 |
void MacroAssembler::stop(int type, const char* msg, int id) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5458 |
#ifndef PRODUCT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5459 |
block_comment(err_msg("stop: %s %s {", stop_types[type%stop_end], msg)); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5460 |
#else |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5461 |
block_comment("stop {"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5462 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5463 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5464 |
// setup arguments |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5465 |
load_const_optimized(R3_ARG1, type); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5466 |
load_const_optimized(R4_ARG2, (void *)msg, /*tmp=*/R0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5467 |
call_VM_leaf(CAST_FROM_FN_PTR(address, stop_on_request), R3_ARG1, R4_ARG2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5468 |
illtrap(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5469 |
emit_int32(id); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5470 |
block_comment("} stop;"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5471 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5472 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5473 |
#ifndef PRODUCT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5474 |
// Write pattern 0x0101010101010101 in memory region [low-before, high+after]. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5475 |
// Val, addr are temp registers. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5476 |
// If low == addr, addr is killed. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5477 |
// High is preserved. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5478 |
void MacroAssembler::zap_from_to(Register low, int before, Register high, int after, Register val, Register addr) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5479 |
if (!ZapMemory) return; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5480 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5481 |
assert_different_registers(low, val); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5482 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5483 |
BLOCK_COMMENT("zap memory region {"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5484 |
load_const_optimized(val, 0x0101010101010101); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5485 |
int size = before + after; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5486 |
if (low == high && size < 5 && size > 0) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5487 |
int offset = -before*BytesPerWord; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5488 |
for (int i = 0; i < size; ++i) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5489 |
std(val, offset, low); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5490 |
offset += (1*BytesPerWord); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5491 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5492 |
} else { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5493 |
addi(addr, low, -before*BytesPerWord); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5494 |
assert_different_registers(high, val); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5495 |
if (after) addi(high, high, after * BytesPerWord); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5496 |
Label loop; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5497 |
bind(loop); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5498 |
std(val, 0, addr); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5499 |
addi(addr, addr, 8); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5500 |
cmpd(CCR6, addr, high); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5501 |
ble(CCR6, loop); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5502 |
if (after) addi(high, high, -after * BytesPerWord); // Correct back to old value. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5503 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5504 |
BLOCK_COMMENT("} zap memory region"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5505 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5506 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5507 |
#endif // !PRODUCT |
23221 | 5508 |
|
5509 |
SkipIfEqualZero::SkipIfEqualZero(MacroAssembler* masm, Register temp, const bool* flag_addr) : _masm(masm), _label() { |
|
5510 |
int simm16_offset = masm->load_const_optimized(temp, (address)flag_addr, R0, true); |
|
5511 |
assert(sizeof(bool) == 1, "PowerPC ABI"); |
|
5512 |
masm->lbz(temp, simm16_offset, temp); |
|
5513 |
masm->cmpwi(CCR0, temp, 0); |
|
5514 |
masm->beq(CCR0, _label); |
|
5515 |
} |
|
5516 |
||
5517 |
SkipIfEqualZero::~SkipIfEqualZero() { |
|
5518 |
_masm->bind(_label); |
|
5519 |
} |